⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 debug.c

📁 16为单片机实现调制解调器功能
💻 C
📖 第 1 页 / 共 5 页
字号:
						{//使用DTMF通信
							//不可以工作
						}
						else
						{//使用RS232通信
							//清理 主动报告
							//清理 发送缓冲区
							g_intMark |= CommBuilded_Mark;//通信建立
							g_intMark |= ICanPush_Mark;
							g_chMainPushReport_Stat = 0;//DEFAULT 中会有相关清理
							g_chSendPCBuf_Stat = 0;//DEFAULT 中会有相关清理
						}
						g_intMark &= ~CommDebugUart_Mark;//RS232 用作 通信
					break;
					case 'd':
					case 'D':
						g_intMainDebugProcess_Stat = 220;
					break;
					default:
						g_intMainDebugProcess_Stat = 1;
					break;	
				}
				g_chReceiveDebugChar = 0;
			break;
			case 1://显示版本信息
				{
					unsigned char chM[] = "版本: x.xx(149) x.xx(135)\n\r";	
					chM[6] = Ver_ID0;
					chM[8] = Ver_ID1;
					chM[9] = Ver_ID2;
					
					chM[16] = (g_int135Ver / 1000) % 10 + 48;
					chM[18] = (g_int135Ver / 100) % 10 + 48;
					chM[19] = (g_int135Ver / 10) % 10 + 48;
					
					InsertDebugSendBuf((unsigned char *)chM,sizeof(chM) - 1);
					g_intMainDebugProcess_Stat = 2;	
				}
			break;
			case 2://显示菜单 c_chShow_2
				{
					InsertDebugSendBuf((unsigned char *)c_chShow_2,sizeof(c_chShow_2) - 1);
					g_intMainDebugProcess_Stat = 3;
				}
			break;
			case 3://显示菜单 c_chShow_3
				{
					InsertDebugSendBuf((unsigned char *)c_chShow_3,sizeof(c_chShow_3) - 1);
					g_intMainDebugProcess_Stat = 4;
				}
			break;
			case 4://显示菜单 c_chShow_4
				{
					InsertDebugSendBuf((unsigned char *)c_chShow_4,sizeof(c_chShow_4) - 1);
					g_intMainDebugProcess_Stat = 5;
				}
			break;
			case 5://显示菜单 c_chShow_5
				{
					InsertDebugSendBuf((unsigned char *)c_chShow_5,sizeof(c_chShow_5) - 1);
					g_intMainDebugProcess_Stat = 6;
				}
			break;
			case 6://显示菜单 c_chShow_6
				{
					InsertDebugSendBuf((unsigned char *)c_chShow_6,sizeof(c_chShow_6) - 1);
					g_intMainDebugProcess_Stat = 7;
				}
			break;
			case 7://显示菜单 c_chShow_7
				{
					InsertDebugSendBuf((unsigned char *)c_chShow_7,sizeof(c_chShow_7) - 1);
					g_intMainDebugProcess_Stat = 8;
				}
			break;
			case 8://显示菜单 c_chShow_8
				{
					InsertDebugSendBuf((unsigned char *)c_chShow_8,sizeof(c_chShow_8) - 1);
					g_intMainDebugProcess_Stat = 9;
				}
			break;
			case 9://显示菜单 c_chShow_9
				{
					InsertDebugSendBuf((unsigned char *)c_chShow_9,sizeof(c_chShow_9) - 1);
					g_intMainDebugProcess_Stat = 10;
				}
			break;
			case 10://显示菜单 c_chShow_10
				{
					InsertDebugSendBuf((unsigned char *)c_chShow_10,sizeof(c_chShow_10) - 1);
					g_intMainDebugProcess_Stat = 17;
				}
			break;
			case 17://显示菜单 c_chShow_17
				{
					InsertDebugSendBuf((unsigned char *)c_chShow_17,sizeof(c_chShow_17) - 1);
					g_intMainDebugProcess_Stat = 0;//DEFAULT 中会有相关清理
				}
			break;
			//参数操作//参数操作//参数操作//参数操作//参数操作//参数操作//参数操作//参数操作//参数操作
			case 20://显示菜单
				{
					InsertDebugSendBuf((unsigned char *)c_chShow_Menu10,sizeof(c_chShow_Menu10) - 1);
					g_intMainDebugProcess_Stat = 21;
				}
			break;
			case 21://等待输入 ID 号
				g_intMark |= SendReceiveDebugBuf_Mark;
				if(g_chDebugBuf[g_chDebugTail] == 27)//Esc
				{//Esc
					//返回
					g_intMainDebugProcess_Stat = 2;
				}
				if(g_chDebugTail >= 2)
				{//已经收到了 ID 号
					//记录该号
					g_chID = (g_chDebugBuf[1] - 48) * 10 + (g_chDebugBuf[2] - 48);
					g_intMainDebugProcess_Stat = 22;
				}
			break;
			case 22:////显示菜单
				{
					unsigned char chMenu[] = "ID号:xx\n\r";	
					chMenu[6] = (g_chID / 10) + 48;
					chMenu[7] = (g_chID % 10) + 48;
					g_chDebugTail = 0;
					InsertDebugSendBuf((unsigned char *)chMenu,sizeof(chMenu) - 1);
					g_intMainDebugProcess_Stat = 23;
				}
			break;
			case 23://显示参数信息
				{
					unsigned char chMess[22];
					unsigned char chReturn;
					chReturn = ParamID(g_chID,chMess,99);//写
					if(chReturn)
					{// > 0 成功
						if(chReturn == 98)
						{
							g_intMainDebugProcess_Stat = 24;//返回可能 = 空,必须在 14 中等待一下
							g_chMainDebugProcessTimeout_1s = 0;
						}
						else
						{
							chMess[chReturn] = 10;
							chMess[chReturn + 1] = 13;
							InsertDebugSendBuf((unsigned char *)chMess,chReturn + 2);
							g_intMainDebugProcess_Stat = 25;//返回可能 = 空,必须在 14 中等待一下
						}
					}
					else
					{// = 0 失败
						InsertDebugSendBuf((unsigned char *)c_chShow_Menu13,sizeof(c_chShow_Menu13) - 1);
						g_intMainDebugProcess_Stat = 20;
					}
				}
			break;
			case 24://等待 1-2 s
				//等待 g_chInnerCommSingleChar == 0
				if(g_chInnerCommSingleChar == 0)
				{//表示已经有结果了
					g_intMainDebugProcess_Stat = 25;
				}
				if(g_chMainDebugProcessTimeout_1s > 1)
				{
					g_intMainDebugProcess_Stat = 25;
				}
			break;
			case 25://显示菜单
				{
					InsertDebugSendBuf((unsigned char *)c_chShow_Menu14,sizeof(c_chShow_Menu14) - 1);
					g_intMainDebugProcess_Stat = 26;
				}
			break;
			case 26://等待 输入新的参数,Esc返回
				g_intMark |= SendReceiveDebugBuf_Mark;
				if(g_chDebugBuf[g_chDebugTail] == 27)//Esc
				{//Esc
					//返回
					g_intMainDebugProcess_Stat = 20;
				}
				else if(g_chDebugBuf[g_chDebugTail] == 13)//回车
					{//回车
						//参数
						unsigned char chReturn;
						chReturn = ParamID(g_chID,g_chDebugBuf,g_chDebugTail);
						if(chReturn)
						{
							if(chReturn == 98)
							{
								g_intMainDebugProcess_Stat = 27;//等待 1-2 秒后。。。
								g_chMainDebugProcessTimeout_1s = 0;
							}
							else
							{
								g_intMainDebugProcess_Stat = 22;//显示写入参数信息
							}
							
						}
						else
						{
							InsertDebugSendBuf((unsigned char *)c_chShow_Menu13,sizeof(c_chShow_Menu13) - 1);
							g_intMainDebugProcess_Stat = 20;
						}
					}
					else
					{
						if(g_chDebugBuf[g_chDebugTail] == 10)
						{//使用 超级终端 按 回车后 是 13,使用 TELNET 按 回车后 是 13 10
							g_chDebugTail--;
						}
					}
			break;
			case 27:
				//等待 g_chInnerCommSendTail == 0
				if(g_chInnerCommSendTail == 0)
				{//已经成功了
					g_intMainDebugProcess_Stat = 22;//显示写入参数信息
				}
				if(g_chMainDebugProcessTimeout_1s > 1)
				{
					g_intMainDebugProcess_Stat = 22;//显示写入参数信息
				}
			break;
			case 40://显示菜单---写电子纽扣信息
				{
					InsertDebugSendBuf((unsigned char *)chShow_Pmpt_Door_40,sizeof(chShow_Pmpt_Door_40) - 1);
					g_intMainDebugProcess_Stat = 41;
				}
			break;
			case 41://等待输入 用户  号
				g_intMark |= SendReceiveDebugBuf_Mark;
				if(g_chDebugBuf[g_chDebugTail] == 27)//Esc
				{//Esc
					//返回
					g_intMainDebugProcess_Stat = 2;
				}
				if(g_chDebugTail >= 4)
				{//已经收到了 ID 号
					//记录该号
					unsigned char chI,chM[] = "写电子纽扣号: xxxx\n\r";
					Write_DoorID(&g_chDebugBuf[1]);//固定 四 位
			        for(chI = 0; chI < 4; chI++)
					{
					 	chM[14 + chI] = g_chDebugBuf[1 + chI];
					} 
					g_chDebugTail = 0;
					InsertDebugSendBuf((unsigned char *)chM,sizeof(chM) - 1);
					g_intMainDebugProcess_Stat = 40;
				}
			break;
			case 60://显示菜单-----配置开门人
				{
					InsertDebugSendBuf((unsigned char *)chShow_Pmpt_Door_60,sizeof(chShow_Pmpt_Door_60) - 1);
					g_intMainDebugProcess_Stat = 61;
				}
			break;
			case 61://等待输入 用户序号 及 用户  号
				g_intMark |= SendReceiveDebugBuf_Mark;
				if(g_chDebugBuf[g_chDebugTail] == 27)//Esc
				{//Esc
					//返回
					g_intMainDebugProcess_Stat = 2;
				}
				if(g_chDebugTail >= 7)
				{//已经收到了 ID 号
					//记录该号
					unsigned char chI,chM[] = "xxx :xxxx\n\r";
			     	unsigned char chIndex;
			     	chIndex = (g_chDebugBuf[1] - 48) * 100;
			     	chIndex += (g_chDebugBuf[2] - 48) * 10;
			     	chIndex += (g_chDebugBuf[3] - 48);
			     	if(chIndex < 129)//最大128 1--128
			     	{//                        把 1--128 写到 0--127 中去!
						Write_DoorInfo_AccordingNo(chIndex - 1,&g_chDebugBuf[4]);
					}
			        for(chI = 0; chI < 3; chI++)
					{
					 	chM[chI] = g_chDebugBuf[1 + chI];
					} 
			     	for(chI = 0; chI < 4; chI++)
					{
					 	chM[5 + chI] = *(unsigned char *)(FLASHMEM_Seg_DoorAddr + (chIndex - 1) * 4 + chI);
					} 
					g_chDebugTail = 0;
					InsertDebugSendBuf((unsigned char *)chM,sizeof(chM) - 1);
					g_intMainDebugProcess_Stat = 60;
				}
			break;
			case 80://显示菜单---查询开门人
				{
					InsertDebugSendBuf((unsigned char *)chShow_Pmpt_Door_80,sizeof(chShow_Pmpt_Door_80) - 1);
					g_intMainDebugProcess_Stat = 81;
				}
			break;
			case 81://等待输入 用户  号
				g_intMark |= SendReceiveDebugBuf_Mark;
				if(g_chDebugBuf[g_chDebugTail] == 27)//Esc
				{//Esc
					//返回
					g_intMainDebugProcess_Stat = 2;
				}
				if(g_chDebugTail >= 3)
				{//已经收到了 ID 号
					//记录该号
					unsigned char chI,chM[] = "xxx :xxxx\n\r";
			     	unsigned char chIndex;
			     	chIndex = (g_chDebugBuf[1] - 48) * 100;
			     	chIndex += (g_chDebugBuf[2] - 48) * 10;
			     	chIndex += (g_chDebugBuf[3] - 48);
			     	if(chIndex < 129)//最大128 1--128
			     	{//                       
						for(chI = 0; chI < 3; chI++)
						{
						 	chM[chI] = g_chDebugBuf[1 + chI];
						} 
				     	for(chI = 0; chI < 4; chI++)
						{
						 	chM[5 + chI] = *(unsigned char *)(FLASHMEM_Seg_DoorAddr + (chIndex - 1) * 4 + chI);
						} 
					}
					g_chDebugTail = 0;
					InsertDebugSendBuf((unsigned char *)chM,sizeof(chM) - 1);
					g_intMainDebugProcess_Stat = 80;
				}
			break;
			////////////////////////////////系统区////////////////////////
			//  1---8  工频电流 g_intGP_Current
			case 100://
				{
					unsigned char chM[] = "第1列电流: xxxx固: xxxx\n\r";	
					chM[11] = (g_intGP_Current[0] / 1000) + 48;
					chM[12] = ((g_intGP_Current[0] / 100) % 10) + 48;
					chM[13] = ((g_intGP_Current[0] / 10) % 10) + 48;
					chM[14] = (g_intGP_Current[0] % 10) + 48;
					chM[19] = (g_intGP_FixedCurrent[0] / 1000) + 48;
					chM[20] = ((g_intGP_FixedCurrent[0] / 100) % 10) + 48;
					chM[21] = ((g_intGP_FixedCurrent[0] / 10) % 10) + 48;
					chM[22] = (g_intGP_FixedCurrent[0] % 10) + 48;
					InsertDebugSendBuf((unsigned char *)chM,sizeof(chM) - 1);
					g_intMainDebugProcess_Stat = 101;
				}
			break;
			case 101://
				{
					unsigned char chM[] = "第1列电流: xxxx固: xxxx\n\r";
					chM[11] = (g_intGP_Current[1] / 1000) + 48;
					chM[12] = ((g_intGP_Current[1] / 100) % 10) + 48;
					chM[13] = ((g_intGP_Current[1] / 10) % 10) + 48;
					chM[14] = (g_intGP_Current[1] % 10) + 48;
					chM[19] = (g_intGP_FixedCurrent[1] / 1000) + 48;
					chM[20] = ((g_intGP_FixedCurrent[1] / 100) % 10) + 48;
					chM[21] = ((g_intGP_FixedCurrent[1] / 10) % 10) + 48;
					chM[22] = (g_intGP_FixedCurrent[1] % 10) + 48;
					InsertDebugSendBuf((unsigned char *)chM,sizeof(chM) - 1);
					g_intMainDebugProcess_Stat = 102;
				}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -