refactor(DebugCmd): 统一结构体成员CUData为CUPara
1. 修正所有RS485通道配置结构体的成员命名错误,将CUData改为CUPara 2. 新增bsp头文件引用,补充ETHStop、ETHReset相关调用 3. 调整通信切换时的服务器注册标志重置与外设复位逻辑
This commit is contained in:
+33
-30
@@ -1,4 +1,5 @@
|
|||||||
#include "main.h"
|
#include "main.h"
|
||||||
|
#include "bsp.h"
|
||||||
#include "CatOneTask.h"
|
#include "CatOneTask.h"
|
||||||
#include "RS485Task.h"
|
#include "RS485Task.h"
|
||||||
#include "Public.h"
|
#include "Public.h"
|
||||||
@@ -301,9 +302,9 @@ void DebugCmdRS485Ctrl(int argc, char *argv[])
|
|||||||
if(idx == 1) {
|
if(idx == 1) {
|
||||||
GateWay->ConfigPara.Rs485Ch1.CommUnitEnable = true;
|
GateWay->ConfigPara.Rs485Ch1.CommUnitEnable = true;
|
||||||
GateWay->ConfigPara.Rs485Ch1.QuerySensorFlag = true;
|
GateWay->ConfigPara.Rs485Ch1.QuerySensorFlag = true;
|
||||||
GateWay->ConfigPara.Rs485Ch1.CUData.Para.SensorN = 0;
|
GateWay->ConfigPara.Rs485Ch1.CUPara.Para.SensorN = 0;
|
||||||
memset(GateWay->ConfigPara.Rs485Ch1.CUData.Para.SensorType, 0x00, SENSOR_NUM_MAX * 2);
|
memset(GateWay->ConfigPara.Rs485Ch1.CUPara.Para.SensorType, 0x00, SENSOR_NUM_MAX * 2);
|
||||||
GateWay->ConfigPara.Rs485Ch1.CUData.Para.CommStatus = true;
|
GateWay->ConfigPara.Rs485Ch1.CUPara.Para.CommStatus = true;
|
||||||
RS485Ch1_Config(9600);
|
RS485Ch1_Config(9600);
|
||||||
GateWay->ConfigPara.Rs485Ch1.BaudRate = 9600;
|
GateWay->ConfigPara.Rs485Ch1.BaudRate = 9600;
|
||||||
SComm1Para.SensorCnt = 0;
|
SComm1Para.SensorCnt = 0;
|
||||||
@@ -311,9 +312,9 @@ void DebugCmdRS485Ctrl(int argc, char *argv[])
|
|||||||
else if(idx == 2) {
|
else if(idx == 2) {
|
||||||
GateWay->ConfigPara.Rs485Ch2.CommUnitEnable = true;
|
GateWay->ConfigPara.Rs485Ch2.CommUnitEnable = true;
|
||||||
GateWay->ConfigPara.Rs485Ch2.QuerySensorFlag = true;
|
GateWay->ConfigPara.Rs485Ch2.QuerySensorFlag = true;
|
||||||
GateWay->ConfigPara.Rs485Ch2.CUData.Para.SensorN = 0;
|
GateWay->ConfigPara.Rs485Ch2.CUPara.Para.SensorN = 0;
|
||||||
memset(GateWay->ConfigPara.Rs485Ch2.CUData.Para.SensorType, 0x00, SENSOR_NUM_MAX * 2);
|
memset(GateWay->ConfigPara.Rs485Ch2.CUPara.Para.SensorType, 0x00, SENSOR_NUM_MAX * 2);
|
||||||
GateWay->ConfigPara.Rs485Ch2.CUData.Para.CommStatus = true;
|
GateWay->ConfigPara.Rs485Ch2.CUPara.Para.CommStatus = true;
|
||||||
RS485Ch2_Config(9600);
|
RS485Ch2_Config(9600);
|
||||||
GateWay->ConfigPara.Rs485Ch2.BaudRate = 9600;
|
GateWay->ConfigPara.Rs485Ch2.BaudRate = 9600;
|
||||||
SComm2Para.SensorCnt = 0;
|
SComm2Para.SensorCnt = 0;
|
||||||
@@ -323,11 +324,11 @@ void DebugCmdRS485Ctrl(int argc, char *argv[])
|
|||||||
else if(strstr(argv[3], "off") != NULL){
|
else if(strstr(argv[3], "off") != NULL){
|
||||||
if(idx == 1) {
|
if(idx == 1) {
|
||||||
GateWay->ConfigPara.Rs485Ch1.CommUnitEnable = false;
|
GateWay->ConfigPara.Rs485Ch1.CommUnitEnable = false;
|
||||||
GateWay->ConfigPara.Rs485Ch1.CUData.Para.CommStatus = false;
|
GateWay->ConfigPara.Rs485Ch1.CUPara.Para.CommStatus = false;
|
||||||
}
|
}
|
||||||
else if(idx == 2) {
|
else if(idx == 2) {
|
||||||
GateWay->ConfigPara.Rs485Ch2.CommUnitEnable = false;
|
GateWay->ConfigPara.Rs485Ch2.CommUnitEnable = false;
|
||||||
GateWay->ConfigPara.Rs485Ch2.CUData.Para.CommStatus = false;
|
GateWay->ConfigPara.Rs485Ch2.CUPara.Para.CommStatus = false;
|
||||||
}
|
}
|
||||||
DBG_LOG("RS485Ch%d Disable!\r\n", idx);
|
DBG_LOG("RS485Ch%d Disable!\r\n", idx);
|
||||||
}
|
}
|
||||||
@@ -475,10 +476,10 @@ void DebugCmdLsCommUnit(int argc, char *argv[])
|
|||||||
if(GateWay->ConfigPara.Rs485Ch1.CommUnitEnable == true) {
|
if(GateWay->ConfigPara.Rs485Ch1.CommUnitEnable == true) {
|
||||||
DBG_LOG("DevType: 8001\r\n");
|
DBG_LOG("DevType: 8001\r\n");
|
||||||
DBG_LOG("DevMac: 01-80-02-00-00-01\r\n");
|
DBG_LOG("DevMac: 01-80-02-00-00-01\r\n");
|
||||||
DBG_LOG("SensorNum: %d\r\n", GateWay->ConfigPara.Rs485Ch1.CUData.Para.SensorN);
|
DBG_LOG("SensorNum: %d\r\n", GateWay->ConfigPara.Rs485Ch1.CUPara.Para.SensorN);
|
||||||
DBG_LOG("SensorType: ");
|
DBG_LOG("SensorType: ");
|
||||||
for(int i = 0; i < GateWay->ConfigPara.Rs485Ch1.CUData.Para.SensorN; i++) {
|
for(int i = 0; i < GateWay->ConfigPara.Rs485Ch1.CUPara.Para.SensorN; i++) {
|
||||||
DBG_LOG("%04X ", GateWay->ConfigPara.Rs485Ch1.CUData.Para.SensorType[i]);
|
DBG_LOG("%04X ", GateWay->ConfigPara.Rs485Ch1.CUPara.Para.SensorType[i]);
|
||||||
}
|
}
|
||||||
DBG_LOG("\r\n\r\n");
|
DBG_LOG("\r\n\r\n");
|
||||||
}
|
}
|
||||||
@@ -486,10 +487,10 @@ void DebugCmdLsCommUnit(int argc, char *argv[])
|
|||||||
if(GateWay->ConfigPara.Rs485Ch2.CommUnitEnable == true) {
|
if(GateWay->ConfigPara.Rs485Ch2.CommUnitEnable == true) {
|
||||||
DBG_LOG("DevType: 8002\r\n");
|
DBG_LOG("DevType: 8002\r\n");
|
||||||
DBG_LOG("DevMac: 01-80-02-00-00-02\r\n");
|
DBG_LOG("DevMac: 01-80-02-00-00-02\r\n");
|
||||||
DBG_LOG("SensorNum: %d\r\n", GateWay->ConfigPara.Rs485Ch2.CUData.Para.SensorN);
|
DBG_LOG("SensorNum: %d\r\n", GateWay->ConfigPara.Rs485Ch2.CUPara.Para.SensorN);
|
||||||
DBG_LOG("SensorType: ");
|
DBG_LOG("SensorType: ");
|
||||||
for(int i = 0; i < GateWay->ConfigPara.Rs485Ch2.CUData.Para.SensorN; i++) {
|
for(int i = 0; i < GateWay->ConfigPara.Rs485Ch2.CUPara.Para.SensorN; i++) {
|
||||||
DBG_LOG("%04X ", GateWay->ConfigPara.Rs485Ch2.CUData.Para.SensorType[i]);
|
DBG_LOG("%04X ", GateWay->ConfigPara.Rs485Ch2.CUPara.Para.SensorType[i]);
|
||||||
}
|
}
|
||||||
DBG_LOG("\r\n\r\n");
|
DBG_LOG("\r\n\r\n");
|
||||||
}
|
}
|
||||||
@@ -678,7 +679,9 @@ void DebugCmdSetComm(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(strcmp(argv[1], "cat1") == 0) {
|
if(strcmp(argv[1], "cat1") == 0) {
|
||||||
|
GateWay->SvrRegFlag = false;
|
||||||
GateWay->ConfigPara.Comm = CATONE_COMM;
|
GateWay->ConfigPara.Comm = CATONE_COMM;
|
||||||
|
ETHStop();
|
||||||
CAT1_ON();
|
CAT1_ON();
|
||||||
CatOneReset();
|
CatOneReset();
|
||||||
DBG_LOG("Set the communication method to Cat1.\r\n");
|
DBG_LOG("Set the communication method to Cat1.\r\n");
|
||||||
@@ -692,12 +695,12 @@ void DebugCmdSetComm(int argc, char *argv[])
|
|||||||
rt_thread_delay(3000);
|
rt_thread_delay(3000);
|
||||||
CAT1_PWR_KEY_SET();
|
CAT1_PWR_KEY_SET();
|
||||||
}
|
}
|
||||||
|
GateWay->SvrRegFlag = false;
|
||||||
GateWay->ConfigPara.Comm = ETH_COMM;
|
GateWay->ConfigPara.Comm = ETH_COMM;
|
||||||
ETH_ON();
|
ETH_ON();
|
||||||
|
ETHReset();
|
||||||
WritePara((uint8_t *)&GateWay->ConfigPara, sizeof(GWConfigPara_t));
|
WritePara((uint8_t *)&GateWay->ConfigPara, sizeof(GWConfigPara_t));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************************
|
/*****************************************************************************************
|
||||||
@@ -1051,15 +1054,15 @@ void DebugCmdQuerySensor(int argc, char *argv[])
|
|||||||
if(GateWay->ConfigPara.Rs485Ch1.Enable == true && GateWay->ConfigPara.Rs485Ch1.CommUnitEnable == true) {
|
if(GateWay->ConfigPara.Rs485Ch1.Enable == true && GateWay->ConfigPara.Rs485Ch1.CommUnitEnable == true) {
|
||||||
DBG_LOG("Query Rs485Ch1...\r\n");
|
DBG_LOG("Query Rs485Ch1...\r\n");
|
||||||
GateWay->ConfigPara.Rs485Ch1.QuerySensorFlag = true;
|
GateWay->ConfigPara.Rs485Ch1.QuerySensorFlag = true;
|
||||||
GateWay->ConfigPara.Rs485Ch1.CUData.Para.SensorN = 0;
|
GateWay->ConfigPara.Rs485Ch1.CUPara.Para.SensorN = 0;
|
||||||
memset(GateWay->ConfigPara.Rs485Ch1.CUData.Para.SensorType, 0x00, sizeof(GateWay->ConfigPara.Rs485Ch1.CUData.Para.SensorType));
|
memset(GateWay->ConfigPara.Rs485Ch1.CUPara.Para.SensorType, 0x00, sizeof(GateWay->ConfigPara.Rs485Ch1.CUPara.Para.SensorType));
|
||||||
SComm1Para.SensorCnt = 0;
|
SComm1Para.SensorCnt = 0;
|
||||||
}
|
}
|
||||||
if(GateWay->ConfigPara.Rs485Ch2.Enable == true && GateWay->ConfigPara.Rs485Ch2.CommUnitEnable == true) {
|
if(GateWay->ConfigPara.Rs485Ch2.Enable == true && GateWay->ConfigPara.Rs485Ch2.CommUnitEnable == true) {
|
||||||
DBG_LOG("Query Rs485Ch2...\r\n");
|
DBG_LOG("Query Rs485Ch2...\r\n");
|
||||||
GateWay->ConfigPara.Rs485Ch2.QuerySensorFlag = true;
|
GateWay->ConfigPara.Rs485Ch2.QuerySensorFlag = true;
|
||||||
GateWay->ConfigPara.Rs485Ch2.CUData.Para.SensorN = 0;
|
GateWay->ConfigPara.Rs485Ch2.CUPara.Para.SensorN = 0;
|
||||||
memset(GateWay->ConfigPara.Rs485Ch2.CUData.Para.SensorType, 0x00, sizeof(GateWay->ConfigPara.Rs485Ch2.CUData.Para.SensorType));
|
memset(GateWay->ConfigPara.Rs485Ch2.CUPara.Para.SensorType, 0x00, sizeof(GateWay->ConfigPara.Rs485Ch2.CUPara.Para.SensorType));
|
||||||
SComm2Para.SensorCnt = 0;
|
SComm2Para.SensorCnt = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1252,17 +1255,17 @@ static void DebugCmdGetPara(int argc, char *argv[])
|
|||||||
DBG_LOG("Svr Port: %d\r\n", GateWay->ConfigPara.SvrPort);
|
DBG_LOG("Svr Port: %d\r\n", GateWay->ConfigPara.SvrPort);
|
||||||
DBG_LOG("Register Status: %d\r\n", GateWay->SvrRegFlag);
|
DBG_LOG("Register Status: %d\r\n", GateWay->SvrRegFlag);
|
||||||
DBG_LOG("RS485Ch1 Mac: %02X-%02X-%02X-%02X-%02X-%02X\r\n",
|
DBG_LOG("RS485Ch1 Mac: %02X-%02X-%02X-%02X-%02X-%02X\r\n",
|
||||||
GateWay->ConfigPara.Rs485Ch1.CUData.Para.Mac[0][0],GateWay->ConfigPara.Rs485Ch1.CUData.Para.Mac[0][1],
|
GateWay->ConfigPara.Rs485Ch1.CUPara.Para.Mac[0][0],GateWay->ConfigPara.Rs485Ch1.CUPara.Para.Mac[0][1],
|
||||||
GateWay->ConfigPara.Rs485Ch1.CUData.Para.Mac[0][2],GateWay->ConfigPara.Rs485Ch1.CUData.Para.Mac[0][3],
|
GateWay->ConfigPara.Rs485Ch1.CUPara.Para.Mac[0][2],GateWay->ConfigPara.Rs485Ch1.CUPara.Para.Mac[0][3],
|
||||||
GateWay->ConfigPara.Rs485Ch1.CUData.Para.Mac[0][4],GateWay->ConfigPara.Rs485Ch1.CUData.Para.Mac[0][5]);
|
GateWay->ConfigPara.Rs485Ch1.CUPara.Para.Mac[0][4],GateWay->ConfigPara.Rs485Ch1.CUPara.Para.Mac[0][5]);
|
||||||
DBG_LOG("RS485Ch1: %s, ", (GateWay->ConfigPara.Rs485Ch1.Enable == true) ? "Enable" : "Disable");
|
DBG_LOG("RS485Ch1: %s, ", (GateWay->ConfigPara.Rs485Ch1.Enable == true) ? "Enable" : "Disable");
|
||||||
DBG_LOG("InCommUnit %s, ", (GateWay->ConfigPara.Rs485Ch1.CommUnitEnable == true) ? "Enable" : "Disable");
|
DBG_LOG("InCommUnit %s, ", (GateWay->ConfigPara.Rs485Ch1.CommUnitEnable == true) ? "Enable" : "Disable");
|
||||||
DBG_LOG("Vout %s, ", (GateWay->ConfigPara.Rs485Ch1.Power == true) ? "Enable" : "Disable");
|
DBG_LOG("Vout %s, ", (GateWay->ConfigPara.Rs485Ch1.Power == true) ? "Enable" : "Disable");
|
||||||
DBG_LOG("Baudrate %d\r\n", GateWay->ConfigPara.Rs485Ch1.BaudRate);
|
DBG_LOG("Baudrate %d\r\n", GateWay->ConfigPara.Rs485Ch1.BaudRate);
|
||||||
DBG_LOG("RS485Ch2 Mac: %02X-%02X-%02X-%02X-%02X-%02X\r\n",
|
DBG_LOG("RS485Ch2 Mac: %02X-%02X-%02X-%02X-%02X-%02X\r\n",
|
||||||
GateWay->ConfigPara.Rs485Ch2.CUData.Para.Mac[0][0],GateWay->ConfigPara.Rs485Ch2.CUData.Para.Mac[0][1],
|
GateWay->ConfigPara.Rs485Ch2.CUPara.Para.Mac[0][0],GateWay->ConfigPara.Rs485Ch2.CUPara.Para.Mac[0][1],
|
||||||
GateWay->ConfigPara.Rs485Ch2.CUData.Para.Mac[0][2],GateWay->ConfigPara.Rs485Ch2.CUData.Para.Mac[0][3],
|
GateWay->ConfigPara.Rs485Ch2.CUPara.Para.Mac[0][2],GateWay->ConfigPara.Rs485Ch2.CUPara.Para.Mac[0][3],
|
||||||
GateWay->ConfigPara.Rs485Ch2.CUData.Para.Mac[0][4],GateWay->ConfigPara.Rs485Ch2.CUData.Para.Mac[0][5]);
|
GateWay->ConfigPara.Rs485Ch2.CUPara.Para.Mac[0][4],GateWay->ConfigPara.Rs485Ch2.CUPara.Para.Mac[0][5]);
|
||||||
DBG_LOG("RS485Ch2: %s, ", (GateWay->ConfigPara.Rs485Ch2.Enable == true) ? "Enable" : "Disable");
|
DBG_LOG("RS485Ch2: %s, ", (GateWay->ConfigPara.Rs485Ch2.Enable == true) ? "Enable" : "Disable");
|
||||||
DBG_LOG("InCommUnit %s, ", (GateWay->ConfigPara.Rs485Ch2.CommUnitEnable == true) ? "Enable" : "Disable");
|
DBG_LOG("InCommUnit %s, ", (GateWay->ConfigPara.Rs485Ch2.CommUnitEnable == true) ? "Enable" : "Disable");
|
||||||
DBG_LOG("Vout %s, ", (GateWay->ConfigPara.Rs485Ch2.Power == true) ? "Enable" : "Disable");
|
DBG_LOG("Vout %s, ", (GateWay->ConfigPara.Rs485Ch2.Power == true) ? "Enable" : "Disable");
|
||||||
@@ -1359,7 +1362,7 @@ static void DebugCmdCali(int argc, char *argv[])
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(memcmp(mac, GateWay->ConfigPara.Rs485Ch1.CUData.Para.Mac[0], 6) == 0) {
|
if(memcmp(mac, GateWay->ConfigPara.Rs485Ch1.CUPara.Para.Mac[0], 6) == 0) {
|
||||||
if(!GateWay->ConfigPara.Rs485Ch1.Enable || !GateWay->ConfigPara.Rs485Ch1.CommUnitEnable) {
|
if(!GateWay->ConfigPara.Rs485Ch1.Enable || !GateWay->ConfigPara.Rs485Ch1.CommUnitEnable) {
|
||||||
DBG_LOG("Internal communication unit 1 is turned off!\r\n");
|
DBG_LOG("Internal communication unit 1 is turned off!\r\n");
|
||||||
return;
|
return;
|
||||||
@@ -1369,7 +1372,7 @@ static void DebugCmdCali(int argc, char *argv[])
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(memcmp(mac, GateWay->ConfigPara.Rs485Ch2.CUData.Para.Mac[0], 6) == 0) {
|
if(memcmp(mac, GateWay->ConfigPara.Rs485Ch2.CUPara.Para.Mac[0], 6) == 0) {
|
||||||
if(!GateWay->ConfigPara.Rs485Ch2.Enable || !GateWay->ConfigPara.Rs485Ch2.CommUnitEnable) {
|
if(!GateWay->ConfigPara.Rs485Ch2.Enable || !GateWay->ConfigPara.Rs485Ch2.CommUnitEnable) {
|
||||||
DBG_LOG("Internal communication unit 2 is turned off!\r\n");
|
DBG_LOG("Internal communication unit 2 is turned off!\r\n");
|
||||||
return;
|
return;
|
||||||
@@ -1458,7 +1461,7 @@ static void DebugLaserConfig(int argc, char *argv[])
|
|||||||
|
|
||||||
if(strcmp(argv[2], "on") == 0 || strcmp(argv[2], "off") == 0)
|
if(strcmp(argv[2], "on") == 0 || strcmp(argv[2], "off") == 0)
|
||||||
{
|
{
|
||||||
if(memcmp(mac, GateWay->ConfigPara.Rs485Ch1.CUData.Para.Mac[0], 6) == 0) {
|
if(memcmp(mac, GateWay->ConfigPara.Rs485Ch1.CUPara.Para.Mac[0], 6) == 0) {
|
||||||
if(!GateWay->ConfigPara.Rs485Ch1.Enable || !GateWay->ConfigPara.Rs485Ch1.CommUnitEnable) {
|
if(!GateWay->ConfigPara.Rs485Ch1.Enable || !GateWay->ConfigPara.Rs485Ch1.CommUnitEnable) {
|
||||||
DBG_LOG("Internal communication unit 1 is turned off!\r\n");
|
DBG_LOG("Internal communication unit 1 is turned off!\r\n");
|
||||||
return;
|
return;
|
||||||
@@ -1468,7 +1471,7 @@ static void DebugLaserConfig(int argc, char *argv[])
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(memcmp(mac, GateWay->ConfigPara.Rs485Ch2.CUData.Para.Mac[0], 6) == 0) {
|
if(memcmp(mac, GateWay->ConfigPara.Rs485Ch2.CUPara.Para.Mac[0], 6) == 0) {
|
||||||
if(!GateWay->ConfigPara.Rs485Ch2.Enable || !GateWay->ConfigPara.Rs485Ch2.CommUnitEnable) {
|
if(!GateWay->ConfigPara.Rs485Ch2.Enable || !GateWay->ConfigPara.Rs485Ch2.CommUnitEnable) {
|
||||||
DBG_LOG("Internal communication unit 2 is turned off!\r\n");
|
DBG_LOG("Internal communication unit 2 is turned off!\r\n");
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user