feat(channel): 6通道独立调度+MQueue/DEBUG_Printf重构/冗余清理
通道系统: - 新增Channel_m枚举(CH_NULL/DBG/CH1/CH2/ETH/LORA/CAT1) - Much/Auch/Duch/CuchMask替代旧Comm/DebugChannel - ChannelIsActive宏四重身份检查, ChannelMQ每通道独立队列 - much/auch/duch/cuch命令(互斥检查+USART1 pair冲突) - 各通道任务按ChannelIsActive休眠/活跃 双回调分离: - SvrRegFlag->MuchRegFlag+AuchRegFlag - _NetRevCallBack+pRegFlag实现Much/Auch回调复用 MQ重构: - ChMQ[6]每通道独立队列替代NetSendData_MQ - UploadSend无条件下发Much+Auch双队列 - Cat1/ETH/RS485/Lora各自消费ChMQ 注册流程: - 注册帧绕MQ直接发送(解决FIFO顺序冲突) - NetCommOrgData输入输出buffer分离(解决重叠bug) - Much首次连上必注册, Auch跳过注册直接发送 - ETH_REG_SVR SendRetryCnt首次清零(解决无限重试) - 状态机不再清零注册标志 调试通道: - Debug_Printf->rt_kprintf->rt_hw_console_output全ch路由 - rt_hw_console_output 6通道switch - EthTxMutex保护USART4多线程安全 - ETH接收线程非0x7A帧头->DebugAnalyze(网络debug指令) - EthOverHandler阈值>5->>0(短指令接收) 冗余清理: - 删Cat1UpdateCallback/Cat1SendRegister/ETHSendRegister - 删InfTest/FSInit/SDCardTest死代码 - 删unused includes/macros/variables - 删vcom_Print/buff/ir中间层 - DEBUG_CMD_CNT实际对齐 - 中文标点修正 - 默认: Much=ETH Auch=null Duch=ETH Cuch=LORA
This commit is contained in:
@@ -115,7 +115,7 @@ static void update_on_start(uint8_t* frame, int len, uint8_t* pload, int size)
|
||||
|
||||
boot_para_t cfg = {0};
|
||||
|
||||
cfg.AppFlag = 0;
|
||||
cfg.AppFlag = APP_BOOT_UPGRADE_FLAG;
|
||||
cfg.UpdateFlag = APP_UPDATE_FLAG;
|
||||
cfg.Crc32Check = pReq->AppCrc32;
|
||||
cfg.PackageNum = pReq->PackageNum;
|
||||
@@ -127,6 +127,7 @@ static void update_on_start(uint8_t* frame, int len, uint8_t* pload, int size)
|
||||
|
||||
update_send_cmd(0x01, 1, pReq->PackageNum);
|
||||
|
||||
Ddl_Delay1ms(1000);
|
||||
//重启进入BOOT
|
||||
NVIC_SystemReset();
|
||||
}
|
||||
@@ -302,7 +303,7 @@ void RS485LoopHandler(GateWayPara GateWay, RS485Para RS485Ch, SensorCommPara SCP
|
||||
RS485Ch->CUPara.Para.BatLevel = GateWay->Battery;
|
||||
CommUintLen = CommUintOrgData(GateWay, &RS485Ch->CUPara.Para, &SCPara->SensorData, CommUintData);
|
||||
//AddLog(&CommUintData[2], CommUintLen - 2);
|
||||
CatOneEthSendQueue(CommUintData, CommUintLen);
|
||||
UploadSend(CommUintData, CommUintLen);
|
||||
if(RS485Ch == &GateWay->ConfigPara.Rs485Ch1) {
|
||||
MAIN_DBG_LOG("InCommUint1 Send Meg...\r\n");
|
||||
}
|
||||
@@ -426,7 +427,7 @@ void RS485LoopHandler(GateWayPara GateWay, RS485Para RS485Ch, SensorCommPara SCP
|
||||
MegData[2] = COMM_UNIT_CMD_READ;
|
||||
memcpy(&MegData[3], GateWay->ConfigPara.CommUnitArray[SCPara->SendUnitCommIdx].Mac[0], 6);
|
||||
MegData[9] = GateWay->ConfigPara.CommUnitArray[SCPara->SendUnitCommIdx].CommStatus;
|
||||
CatOneEthSendQueue(MegData, 10); //发送离线消息
|
||||
UploadSend(MegData, 10); //发送离线消息
|
||||
}
|
||||
}
|
||||
SCPara->SendUnitCommIdx++;
|
||||
@@ -469,7 +470,7 @@ void RS485Ch1_Thread_Entry(void *parameter)
|
||||
if(SCPara->RS485Rev_Sem == RT_NULL) {
|
||||
Debug_Printf("RS485Ch1Rev Sem Create Failed!\r\n");
|
||||
}
|
||||
Debug_Printf("RS485Ch1Rev Thread is running!\r\n");
|
||||
Debug_Printf("RS485Ch1Rev Thread is running!\r\n");
|
||||
|
||||
rt_thread_delay(3000);
|
||||
SCPara->InitOverFlag = true;
|
||||
@@ -477,6 +478,18 @@ void RS485Ch1_Thread_Entry(void *parameter)
|
||||
|
||||
update_init(RS485Ch1UartSend);
|
||||
while(1) {
|
||||
if(!ChannelIsActive(GateWay->ConfigPara, CH_RS485_1)
|
||||
&& !GateWay->ConfigPara.Rs485Ch1.UpgradeEnable) {
|
||||
rt_thread_delay(100);
|
||||
continue;
|
||||
}
|
||||
{
|
||||
uint8_t sData[512];
|
||||
if(rt_mq_recv(ChannelMQ(*GateWay, CH_RS485_1), sData, 512, 0) == RT_EOK) {
|
||||
uint16_t len = (sData[0] | (sData[1] << 8)) + 3;
|
||||
RS485Ch1UartSend(sData, len);
|
||||
}
|
||||
}
|
||||
RS485LoopHandler(GateWay, RS485Ch, SCPara);
|
||||
//rt_thread_delay(10);
|
||||
}
|
||||
@@ -533,10 +546,22 @@ void RS485Ch2_Thread_Entry(void *parameter)
|
||||
if(SCPara->RS485Rev_Sem == RT_NULL) {
|
||||
Debug_Printf("RS485Ch2Rev Sem Create Failed!\r\n");
|
||||
}
|
||||
Debug_Printf("RS485Ch2Rev Thread is running!\r\n");
|
||||
Debug_Printf("RS485Ch2Rev Thread is running!\r\n");
|
||||
rt_thread_delay(3000);
|
||||
SCPara->InitOverFlag = true;
|
||||
while(1) {
|
||||
if(!ChannelIsActive(GateWay->ConfigPara, CH_RS485_2)
|
||||
&& !GateWay->ConfigPara.Rs485Ch2.UpgradeEnable) {
|
||||
rt_thread_delay(100);
|
||||
continue;
|
||||
}
|
||||
{
|
||||
uint8_t sData[512];
|
||||
if(rt_mq_recv(ChannelMQ(*GateWay, CH_RS485_2), sData, 512, 0) == RT_EOK) {
|
||||
uint16_t len = (sData[0] | (sData[1] << 8)) + 3;
|
||||
RS485Ch2UartSend(sData, len);
|
||||
}
|
||||
}
|
||||
RS485LoopHandler(GateWay, RS485Ch, SCPara);
|
||||
//rt_thread_delay(10);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user