Browse Source

解决接受PIS数据校验不通过的问题

lishengyin 3 years ago
parent
commit
f332b16ffa

+ 4 - 4
modules/dataType/include/PIDSClientResultMsg.h

@@ -52,11 +52,11 @@ public:
             data[19+i] = (this->data[id].Num & 0xFF00) >> 8;
             id++;
         }
-        
+
         int16_t crc = Crc16::GetCRC16(data, 9, length);
-        data[45] = (crc & 0x00FF);
-        data[46] = (crc & 0xFF00) >> 8; 
-        
+        data[45] = (crc & 0xFF00) >> 8;
+        data[46] = (crc & 0x00FF);
+         
         // 数据尾
         data[47] = PIDS_DATA_END;
     }

+ 4 - 3
modules/dataType/include/PIDSServerResultMsg.h

@@ -38,7 +38,7 @@ public:
     int32_t Deserialization(uint8_t *data, int length)
     {
         // 检查数据头尾
-        if(data[0] != PIDS_DATA_HEAD || data[length] != PIDS_DATA_END) {
+        if(data[0] != PIDS_DATA_HEAD || data[length-1] != PIDS_DATA_END) {
             ErrorL << "Incorrect data head and tail";
             return ERR;
         }
@@ -47,10 +47,11 @@ public:
 
         // 检查数据校验位
         int16_t crc = Crc16::GetCRC16(data, 9, DataLength);
-        if((data[length-2] != (crc & 0xFF00)) >> 8 || (data[length-1] != crc & 0x00FF)){
+
+        if(data[length-3] != ((crc & 0xFF00) >> 8) || data[length-2] != (crc & 0x00FF)){
             ErrorL << "Incorrect data check digit";
         }
-        
+
         // 数据校验通过提取数据
         this->CurrentSite = data[9];
         this->NextSite = data[10];

+ 1 - 1
modules/userApp/src/user_app.cpp

@@ -345,7 +345,7 @@ namespace MIVA
         // 等级1 - 4
         uint8_t grade = 1;
 
-
+        
         return grade;
     }