修改了upack方法 将方法单独放置到IRIS_Method.c/.h 将数据和方法分离
This commit is contained in:
@ -28,7 +28,7 @@ int32_t IRIS_Protocol_Pack(uint8_t Command,uint16_t LenthofIn, uint8_t *BufferIn
|
|||||||
{
|
{
|
||||||
memcpy(&PackData[5],BufferIn,LenthofIn);
|
memcpy(&PackData[5],BufferIn,LenthofIn);
|
||||||
}
|
}
|
||||||
uint16_t CRC = IRIS_calcCRC(PackData, LenthofIn+5);
|
uint16_t CRC = IRIS_calcCRC(PackData+3, LenthofIn+5);
|
||||||
PackData[LenthofIn+5] = CRC & 0xFF;
|
PackData[LenthofIn+5] = CRC & 0xFF;
|
||||||
PackData[LenthofIn+6] = (CRC >> 8) & 0xFF;
|
PackData[LenthofIn+6] = (CRC >> 8) & 0xFF;
|
||||||
return LenthofIn+7;
|
return LenthofIn+7;
|
||||||
@ -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, LenthofOut+5);
|
uint16_t CRC = IRIS_calcCRC(PackData+3, LenthofOut+5);
|
||||||
if(CRC != (PackData[LenthofOut+6] + (PackData[LenthofOut+5] << 8)))
|
if(CRC != (PackData[LenthofOut+6] + (PackData[LenthofOut+5] << 8)))
|
||||||
{
|
{
|
||||||
return ERROR_CRC;
|
return ERROR_CRC;
|
||||||
@ -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, LenthofOut+5);
|
uint16_t CRC = IRIS_calcCRC(PackData+3, LenthofOut+5);
|
||||||
if(CRC != (PackData[LenthofOut+6] + (PackData[LenthofOut+5] << 8)))
|
if(CRC != (PackData[LenthofOut+6] + (PackData[LenthofOut+5] << 8)))
|
||||||
{
|
{
|
||||||
return ERROR_CRC;
|
return ERROR_CRC;
|
||||||
@ -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, LenthofOut+5);
|
uint16_t CRC = IRIS_calcCRC(PackData+3, LenthofOut+5);
|
||||||
if(CRC != (PackData[LenthofOut+6] + (PackData[LenthofOut+5] << 8)))
|
if(CRC != (PackData[LenthofOut+6] + (PackData[LenthofOut+5] << 8)))
|
||||||
{
|
{
|
||||||
return ERROR_CRC;
|
return ERROR_CRC;
|
||||||
|
Reference in New Issue
Block a user