modify bugs
This commit is contained in:
parent
8703533f5f
commit
80d84f927f
@ -256,7 +256,7 @@ int Uart::ZigbeeTest() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Uart::WriteToUart(const char *strSend, int pLen) {
|
void Uart::WriteToUart(const char *strSend, int pLen) {
|
||||||
if (!bUpdate)
|
//if (!bUpdate)
|
||||||
{
|
{
|
||||||
printf( "\nWrite To Uart Start: %s\n",GetCurrentTime().c_str());
|
printf( "\nWrite To Uart Start: %s\n",GetCurrentTime().c_str());
|
||||||
for (int i = 0; i < pLen; i++) {
|
for (int i = 0; i < pLen; i++) {
|
||||||
@ -265,7 +265,8 @@ void Uart::WriteToUart(const char *strSend, int pLen) {
|
|||||||
printf( "\nWrite To Uart End.\n");
|
printf( "\nWrite To Uart End.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
write_data(fd, (char *)strSend, pLen);
|
int iRet = write_data(fd, (char *)strSend, pLen);
|
||||||
|
printf( "WriteToUart iRet = %d, pLen = %d\n", iRet, pLen);
|
||||||
}
|
}
|
||||||
|
|
||||||
int Uart::ReadFromUart() {
|
int Uart::ReadFromUart() {
|
||||||
@ -288,7 +289,10 @@ int Uart::ReadFromAlarm(){
|
|||||||
zlog_info(zct, "==========ReadFromAlarm========len = %d", len);
|
zlog_info(zct, "==========ReadFromAlarm========len = %d", len);
|
||||||
if (len > 0)
|
if (len > 0)
|
||||||
{
|
{
|
||||||
if(buffer[5] == 0x02 && buffer[6] == 0x00){
|
for (int i = 0; i < len; i++) {
|
||||||
|
printf( "%02x ", buffer[i] & 0xff);
|
||||||
|
}
|
||||||
|
if(buffer[5] == 0x02 && buffer[6] == 0x01){
|
||||||
return 0 ;
|
return 0 ;
|
||||||
}else{
|
}else{
|
||||||
return 1 ;
|
return 1 ;
|
||||||
|
|||||||
@ -136,7 +136,7 @@ void Uart::WriteChanl2Zigbee(unsigned char pad) {
|
|||||||
GlobalConfig::Zigbee_G.Chan = pad1;
|
GlobalConfig::Zigbee_G.Chan = pad1;
|
||||||
modify_info(tmp, (char *)&GlobalConfig::Zigbee_G);
|
modify_info(tmp, (char *)&GlobalConfig::Zigbee_G);
|
||||||
|
|
||||||
//resetZigbee();
|
resetZigbee();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Uart::WritePanId2Zigbee(unsigned short pad) {
|
void Uart::WritePanId2Zigbee(unsigned short pad) {
|
||||||
@ -147,7 +147,7 @@ void Uart::WritePanId2Zigbee(unsigned short pad) {
|
|||||||
GlobalConfig::Zigbee_G.PanID = pad1;
|
GlobalConfig::Zigbee_G.PanID = pad1;
|
||||||
modify_info(tmp, (char *)&GlobalConfig::Zigbee_G);
|
modify_info(tmp, (char *)&GlobalConfig::Zigbee_G);
|
||||||
|
|
||||||
//resetZigbee();
|
resetZigbee();
|
||||||
}
|
}
|
||||||
void Uart::WriteSpeed2Zigbee() {
|
void Uart::WriteSpeed2Zigbee() {
|
||||||
GlobalConfig::Zigbee_G.Serial_Rate = 0x07;
|
GlobalConfig::Zigbee_G.Serial_Rate = 0x07;
|
||||||
@ -156,7 +156,7 @@ void Uart::WriteSpeed2Zigbee() {
|
|||||||
unsigned short tmp;
|
unsigned short tmp;
|
||||||
tmp = GlobalConfig::Zigbee_G.MyAddr;
|
tmp = GlobalConfig::Zigbee_G.MyAddr;
|
||||||
modify_info(tmp, (char *)&GlobalConfig::Zigbee_G);
|
modify_info(tmp, (char *)&GlobalConfig::Zigbee_G);
|
||||||
//resetZigbee();
|
resetZigbee();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Uart::WriteTranTimeout2Zigbee(unsigned char Time) {
|
void Uart::WriteTranTimeout2Zigbee(unsigned char Time) {
|
||||||
@ -168,7 +168,7 @@ void Uart::WriteTranTimeout2Zigbee(unsigned char Time) {
|
|||||||
GlobalConfig::Zigbee_G.TranTimeout = Time;
|
GlobalConfig::Zigbee_G.TranTimeout = Time;
|
||||||
modify_info(tmp, (char *)&GlobalConfig::Zigbee_G);
|
modify_info(tmp, (char *)&GlobalConfig::Zigbee_G);
|
||||||
|
|
||||||
//resetZigbee();
|
resetZigbee();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Uart::WriteShortAddr2Zigbee(unsigned short pad) {
|
void Uart::WriteShortAddr2Zigbee(unsigned short pad) {
|
||||||
@ -179,7 +179,7 @@ void Uart::WriteShortAddr2Zigbee(unsigned short pad) {
|
|||||||
GlobalConfig::Zigbee_G.MyAddr = pad1;
|
GlobalConfig::Zigbee_G.MyAddr = pad1;
|
||||||
modify_info(tmp, (char *)&GlobalConfig::Zigbee_G);
|
modify_info(tmp, (char *)&GlobalConfig::Zigbee_G);
|
||||||
|
|
||||||
//resetZigbee();
|
resetZigbee();
|
||||||
sleep(1);
|
sleep(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -198,7 +198,7 @@ void Uart::WriteShortAddr_DistAddr2Zigbee(unsigned short pad, unsigned char *pDe
|
|||||||
GlobalConfig::ZigbeeInfo_G.MyAddr = "9999";
|
GlobalConfig::ZigbeeInfo_G.MyAddr = "9999";
|
||||||
modify_info(tmp, (char *)&GlobalConfig::Zigbee_G);
|
modify_info(tmp, (char *)&GlobalConfig::Zigbee_G);
|
||||||
|
|
||||||
//resetZigbee();
|
resetZigbee();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Uart::getGPIOStatus()
|
void Uart::getGPIOStatus()
|
||||||
|
|||||||
@ -161,13 +161,13 @@ int Uart::DealDataNodeFeature(const char *pData, int flag) {
|
|||||||
char logInfo[100] = {0x00};
|
char logInfo[100] = {0x00};
|
||||||
sprintf(logInfo, "ShortAddr = %s,localtimestamp = %s,staticData = %d, data = %d", strShortAddr.c_str(), localtimestamp, count, count2);
|
sprintf(logInfo, "ShortAddr = %s,localtimestamp = %s,staticData = %d, data = %d", strShortAddr.c_str(), localtimestamp, count, count2);
|
||||||
zlog_info(zct, logInfo);
|
zlog_info(zct, logInfo);
|
||||||
std::vector<uint8_t>& data_vec = map_send_data[u_short_addr];
|
// std::vector<uint8_t>& data_vec = map_send_data[u_short_addr];
|
||||||
const uint8_t* send_data = data_vec.data();
|
// const uint8_t* send_data = data_vec.data();
|
||||||
WriteToUart((const char*)send_data, 100);
|
// WriteToUart((const char*)send_data, 100);
|
||||||
mssleep(50000);
|
// mssleep(50000);
|
||||||
WriteToUart((const char*)send_data, 100);
|
// WriteToUart((const char*)send_data, 100);
|
||||||
mssleep(50000);
|
// mssleep(50000);
|
||||||
WriteToUart((const char*)send_data, 100);
|
// WriteToUart((const char*)send_data, 100);
|
||||||
}
|
}
|
||||||
memset(whereCon, 0x00, sizeof(whereCon));
|
memset(whereCon, 0x00, sizeof(whereCon));
|
||||||
sprintf(szTableNameData, "t_data_%s", strMeasurementID.c_str());
|
sprintf(szTableNameData, "t_data_%s", strMeasurementID.c_str());
|
||||||
|
|||||||
@ -140,7 +140,7 @@ void Uart::UpdateWirelessNode(uint16_t shortAdd) {
|
|||||||
// zlog_warn(zct,"This block contains incompressible data.out_len = %lu,thisSize = %lu",out_len,thisSize);
|
// zlog_warn(zct,"This block contains incompressible data.out_len = %lu,thisSize = %lu",out_len,thisSize);
|
||||||
// memcpy(fw_senddata,buffer,thisSize);
|
// memcpy(fw_senddata,buffer,thisSize);
|
||||||
// }
|
// }
|
||||||
memcpy(fw_senddata,buffer,thisSize);
|
// memcpy(fw_senddata,buffer,thisSize);
|
||||||
unsigned char Data[100] = {0x00};
|
unsigned char Data[100] = {0x00};
|
||||||
unsigned char size[4] = {0x00};
|
unsigned char size[4] = {0x00};
|
||||||
zlog_info(zct, "thisSize = %d", (int)thisSize);
|
zlog_info(zct, "thisSize = %d", (int)thisSize);
|
||||||
@ -170,16 +170,17 @@ void Uart::UpdateWirelessNode(uint16_t shortAdd) {
|
|||||||
Data[99] = tmp;
|
Data[99] = tmp;
|
||||||
sleep(1);
|
sleep(1);
|
||||||
WriteToUart((const char*)Data, 100);
|
WriteToUart((const char*)Data, 100);
|
||||||
int iRet = CheckZigbeeACK();
|
// int iRet = CheckZigbeeACK();
|
||||||
if (iRet == 0) {
|
// if (iRet == 0) {
|
||||||
zlog_info(zct, "Packge ACK send success,shortAddr = %02x%02x", UINT16_HIGH(shortAdd), UINT16_LOW(shortAdd));
|
// zlog_info(zct, "Packge ACK send success,shortAddr = %02x%02x", UINT16_HIGH(shortAdd), UINT16_LOW(shortAdd));
|
||||||
} else {
|
// } else {
|
||||||
zlog_warn(zct, "Packge ACK send failed,shortAddr = %02x%02x", UINT16_HIGH(shortAdd), UINT16_LOW(shortAdd));
|
// zlog_warn(zct, "Packge ACK send failed,shortAddr = %02x%02x", UINT16_HIGH(shortAdd), UINT16_LOW(shortAdd));
|
||||||
}
|
// }
|
||||||
mssleep(50000);
|
mssleep(50000);
|
||||||
int Count = thisSize / 92;
|
int Count = thisSize / 92;
|
||||||
int lastSize = thisSize % 92;
|
int lastSize = thisSize % 92;
|
||||||
unsigned char UpdateData[100] = {0x00};
|
unsigned char UpdateData[100] = {0x00};
|
||||||
|
unsigned char command[11] = {0xA5,0x5A,0xA5,0x02,0x02,0x02,0x02,0x00,0x00,0x00,0xAC};
|
||||||
//帧头[3byte] 节点地址[2byte] 数据类型[1byte] 序号[1byte] 数据包[92byte] CRC校验[1byte]
|
//帧头[3byte] 节点地址[2byte] 数据类型[1byte] 序号[1byte] 数据包[92byte] CRC校验[1byte]
|
||||||
zlog_warn(zbt, "Start Upgrade!!! file Size = %d,fileName = %s,Count = %d,lastSize = %d,shortAddr = %02x%02x", (int)thisSize,DataNodeUpdateFile.c_str(),Count,lastSize,UINT16_HIGH(shortAdd), UINT16_LOW(shortAdd));
|
zlog_warn(zbt, "Start Upgrade!!! file Size = %d,fileName = %s,Count = %d,lastSize = %d,shortAddr = %02x%02x", (int)thisSize,DataNodeUpdateFile.c_str(),Count,lastSize,UINT16_HIGH(shortAdd), UINT16_LOW(shortAdd));
|
||||||
tmp = 0x00;
|
tmp = 0x00;
|
||||||
@ -192,14 +193,16 @@ void Uart::UpdateWirelessNode(uint16_t shortAdd) {
|
|||||||
UpdateData[4]=UINT16_LOW(shortAdd);
|
UpdateData[4]=UINT16_LOW(shortAdd);
|
||||||
UpdateData[5]=0x10;
|
UpdateData[5]=0x10;
|
||||||
UpdateData[6]=0xff & j;
|
UpdateData[6]=0xff & j;
|
||||||
memcpy(&UpdateData[7],fw_senddata + 92 * j,92);
|
memcpy(&UpdateData[7],buffer + 92 * j,92);
|
||||||
tmp = 0x00;
|
tmp = 0x00;
|
||||||
for(int k = 0; k < 99;k++){
|
for(int k = 0; k < 99;k++){
|
||||||
tmp +=UpdateData[k];
|
tmp +=UpdateData[k];
|
||||||
}
|
}
|
||||||
UpdateData[99] = tmp;
|
UpdateData[99] = tmp;
|
||||||
WriteToUart((const char*)UpdateData,100);
|
WriteToUart((const char*)UpdateData,100);
|
||||||
mssleep(1000);
|
mssleep(100000);
|
||||||
|
WriteToUart((const char*)command,11);
|
||||||
|
mssleep(100000);
|
||||||
if (ReadFromAlarm() == 0) {
|
if (ReadFromAlarm() == 0) {
|
||||||
zlog_info(zct, "Packge %d ACK send success,shortAddr = %02x%02x", j, UINT16_HIGH(shortAdd), UINT16_LOW(shortAdd));
|
zlog_info(zct, "Packge %d ACK send success,shortAddr = %02x%02x", j, UINT16_HIGH(shortAdd), UINT16_LOW(shortAdd));
|
||||||
} else {
|
} else {
|
||||||
@ -222,14 +225,16 @@ void Uart::UpdateWirelessNode(uint16_t shortAdd) {
|
|||||||
UpdateData[4] = UINT16_LOW(shortAdd);
|
UpdateData[4] = UINT16_LOW(shortAdd);
|
||||||
UpdateData[5] = 0x10;
|
UpdateData[5] = 0x10;
|
||||||
UpdateData[6] = 0xff & Count;
|
UpdateData[6] = 0xff & Count;
|
||||||
memcpy(&UpdateData[7], fw_senddata + 92 * Count, lastSize);
|
memcpy(&UpdateData[7], buffer + 92 * Count, lastSize);
|
||||||
tmp = 0x00;
|
tmp = 0x00;
|
||||||
for (int k = 0; k < 99; k++) {
|
for (int k = 0; k < 99; k++) {
|
||||||
tmp += UpdateData[k];
|
tmp += UpdateData[k];
|
||||||
}
|
}
|
||||||
UpdateData[99] = tmp;
|
UpdateData[99] = tmp;
|
||||||
WriteToUart((const char*)UpdateData, 100);
|
WriteToUart((const char*)UpdateData, 100);
|
||||||
mssleep(1000);
|
mssleep(100000);
|
||||||
|
getGPIOStatus();
|
||||||
|
mssleep(100000);
|
||||||
if (ReadFromAlarm() == 0) {
|
if (ReadFromAlarm() == 0) {
|
||||||
zlog_info(zct, "ACK send success,shortAddr = %02x%02x", UINT16_HIGH(shortAdd), UINT16_LOW(shortAdd));
|
zlog_info(zct, "ACK send success,shortAddr = %02x%02x", UINT16_HIGH(shortAdd), UINT16_LOW(shortAdd));
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user