+5 改成+2

This commit is contained in:
xin
2024-05-15 17:38:10 +08:00
parent 2e37bf213e
commit f0c4f0d9f9
2 changed files with 6 additions and 6 deletions

View File

@ -12,7 +12,7 @@
// todo : define your protocol here // todo : define your protocol here
/*-------------------------------------------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------------------------------------------*/

View File

@ -57,7 +57,7 @@ int32_t IRIS_STM32_Protocol_Unpack(uint8_t *PackData, uint16_t LenthofIn, uint8_
{ {
return ERROR_NOT_ENOUGH_DATA; return ERROR_NOT_ENOUGH_DATA;
} }
uint16_t CRC = IRIS_calcCRC(PackData+3, LenthofOut+5); uint16_t CRC = IRIS_calcCRC(PackData+3, LenthofOut+2);
if(CRC != (PackData[LenthofOut+6] + (PackData[LenthofOut+5] << 8))) if(CRC != (PackData[LenthofOut+6] + (PackData[LenthofOut+5] << 8)))
{ {
return ERROR_CRC; return ERROR_CRC;
@ -81,7 +81,7 @@ int32_t IRIS_Protocol_Unpack(uint8_t *PackData, uint16_t LenthofIn, uint8_t Comm
} }
if(PackData[0] != 0x55 || PackData[1] != 0xAA) if(PackData[0] != 0x55 || PackData[1] != 0xAA)
{ {
return ERROR_HEADER return ERROR_HEADER;
} }
if(PackData[2] != Command) if(PackData[2] != Command)
{ {
@ -92,7 +92,7 @@ int32_t IRIS_Protocol_Unpack(uint8_t *PackData, uint16_t LenthofIn, uint8_t Comm
{ {
return ERROR_NOT_ENOUGH_DATA; return ERROR_NOT_ENOUGH_DATA;
} }
uint16_t CRC = IRIS_calcCRC(PackData+3, LenthofOut+5); uint16_t CRC = IRIS_calcCRC(PackData+3, LenthofOut+2);
if(CRC != (PackData[LenthofOut+6] + (PackData[LenthofOut+5] << 8))) if(CRC != (PackData[LenthofOut+6] + (PackData[LenthofOut+5] << 8)))
{ {
return ERROR_CRC; return ERROR_CRC;
@ -111,7 +111,7 @@ int32_t IRIS_Cut_Befor_Header(uint8_t *PackData, uint16_t LenthofIn )
{ {
if( PackData == NULL ) if( PackData == NULL )
{ {
return ERROR_INPUT return ERROR_INPUT;
} }
uint16_t i = 0; uint16_t i = 0;
for(i = 0; i < LenthofIn; i++) for(i = 0; i < LenthofIn; i++)
@ -154,7 +154,7 @@ int32_t IRIS_Check_Data_Valid(uint8_t *PackData, uint16_t LenthofIn)
{ {
return ERROR_NOT_ENOUGH_DATA; return ERROR_NOT_ENOUGH_DATA;
} }
uint16_t CRC = IRIS_calcCRC(PackData+3, LenthofOut+5); uint16_t CRC = IRIS_calcCRC(PackData+3, LenthofOut+2);
if(CRC != (PackData[LenthofOut+6] + (PackData[LenthofOut+5] << 8))) if(CRC != (PackData[LenthofOut+6] + (PackData[LenthofOut+5] << 8)))
{ {
return ERROR_CRC; return ERROR_CRC;