fix:修改UDP通讯中,取电变化上报机制
1、问题点:当RCU网络状态异常的情况下,网络还处于协商状态下,还未进入正常通讯环节时,取电变化不会进行判断。这会导致取电变化上报与实际产生取电状态时间点对不上。 2、将BLV_C1F_Module代码上传至Gitea,之前代码修改记录请查看 .\BasicCode\Readme.txt
This commit is contained in:
454
BasicCode/Drive/CHECK/check_fun.c
Normal file
454
BasicCode/Drive/CHECK/check_fun.c
Normal file
@@ -0,0 +1,454 @@
|
||||
#include "includes.h"
|
||||
|
||||
|
||||
/**
|
||||
* @name <20><><EFBFBD>ֽ<EFBFBD>CRCУ<43><D0A3>
|
||||
* @param
|
||||
aStr <20><>ҪУ<D2AA><D0A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ
|
||||
len <20><><EFBFBD><EFBFBD><EFBFBD>ܳ<EFBFBD><DCB3><EFBFBD>
|
||||
* @retval <20><>
|
||||
* @brief <20><>
|
||||
*/
|
||||
void NetCRC16(uint8_t *aStr ,uint16_t len)
|
||||
{
|
||||
uint16_t alen = len-2; //CRC16
|
||||
uint16_t xda , xdapoly ;
|
||||
uint16_t i,j, xdabit ;
|
||||
xda = 0xFFFF ;
|
||||
xdapoly = 0xA001 ; // (X**16 + X**15 + X**2 + 1)
|
||||
for(i=0;i<alen;i++)
|
||||
{
|
||||
xda ^= aStr[i] ;
|
||||
for(j=0;j<8;j++)
|
||||
{
|
||||
xdabit = (uint8_t )(xda & 0x01) ;
|
||||
xda >>= 1 ;
|
||||
if( xdabit ) xda ^= xdapoly ;
|
||||
}
|
||||
}
|
||||
aStr[alen] = (uint8_t)(xda & 0xFF) ;
|
||||
aStr[alen+1] = (uint8_t)(xda>>8) ;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* Function Name : SRAM_CRC16
|
||||
* Description : CRCУ<43><D0A3> - <20><>ȡSRAM<41><4D><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* Input :
|
||||
|
||||
len : <20><><EFBFBD>ݵij<DDB5><C4B3><EFBFBD> -- Flash<73>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD>У<EFBFBD><D0A3>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>512Byte
|
||||
* Return : <20><><EFBFBD>ݵ<EFBFBD>У<EFBFBD><D0A3>ֵ
|
||||
*******************************************************************************/
|
||||
uint16_t SRAM_CRC16(uint32_t addr,uint16_t len)
|
||||
{
|
||||
uint16_t xda , xdapoly ;
|
||||
uint16_t i, j, xdabit ;
|
||||
xda = 0xFFFF ;
|
||||
xdapoly = 0xA001 ; // (X**16 + X**15 + X**2 + 1)
|
||||
for (i = 0; i < len; i++)
|
||||
{
|
||||
xda ^= SRAM_Read_Byte(addr+i) ;
|
||||
for (j = 0; j < 8; j++)
|
||||
{
|
||||
xdabit = (unsigned char)(xda & 0x01) ;
|
||||
xda >>= 1 ;
|
||||
if ( xdabit ) xda ^= xdapoly ;
|
||||
}
|
||||
}
|
||||
return xda;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* Function Name : NetCRC16_2
|
||||
* Description : CRCУ<43><D0A3> - <20><>ȡSRAM<41><4D><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* Input :
|
||||
aStr : <20><>ҪУ<D2AA><D0A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ
|
||||
len : <20><><EFBFBD>ݵij<DDB5><C4B3><EFBFBD> -- Flash<73>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD>У<EFBFBD><D0A3>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>512Byte
|
||||
* Return : <20><><EFBFBD>ݵ<EFBFBD>У<EFBFBD><D0A3>ֵ
|
||||
*******************************************************************************/
|
||||
uint16_t NetCRC16_2(uint8_t *aStr ,uint16_t len)
|
||||
{
|
||||
uint16_t xda , xdapoly ;
|
||||
uint16_t i,j, xdabit ;
|
||||
xda = 0xFFFF ;
|
||||
xdapoly = 0xA001 ; // (X**16 + X**15 + X**2 + 1)
|
||||
for(i=0;i<len;i++)
|
||||
{
|
||||
xda ^= aStr[i] ;
|
||||
for(j=0;j<8;j++)
|
||||
{
|
||||
xdabit = (uint8_t )(xda & 0x01) ;
|
||||
xda >>= 1 ;
|
||||
if( xdabit ) xda ^= xdapoly ;
|
||||
}
|
||||
}
|
||||
return xda;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* Function Name : NetCRC16_Data
|
||||
* Description : CRCУ<43><D0A3> - CRC<52>ڼ<EFBFBD><DABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* Input :
|
||||
aStr : <20><>ҪУ<D2AA><D0A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ
|
||||
len : <20><><EFBFBD>ݵij<DDB5><C4B3><EFBFBD> -- Flash<73>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD>У<EFBFBD><D0A3>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>512Byte
|
||||
crc_id <09><>CRC<52><43><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD><D0B5>±<EFBFBD>λ<EFBFBD>ã<EFBFBD><C3A3>͵<EFBFBD>ַ<EFBFBD><D6B7>ǰ
|
||||
* Return : <20><><EFBFBD>ݵ<EFBFBD>У<EFBFBD><D0A3>ֵ
|
||||
*******************************************************************************/
|
||||
uint16_t NetCRC16_Data(uint8_t *aStr ,uint16_t len,uint16_t crc_id)
|
||||
{
|
||||
uint16_t xda , xdapoly ;
|
||||
uint16_t i,j, xdabit ;
|
||||
xda = 0xFFFF ;
|
||||
xdapoly = 0xA001 ; // (X**16 + X**15 + X**2 + 1)
|
||||
for(i=0;i<len;i++)
|
||||
{
|
||||
if((i == crc_id) || (i == (crc_id + 1)))
|
||||
{
|
||||
xda ^= 0x00;
|
||||
}else {
|
||||
xda ^= aStr[i];
|
||||
}
|
||||
|
||||
for(j=0;j<8;j++)
|
||||
{
|
||||
xdabit = (uint8_t )(xda & 0x01) ;
|
||||
xda >>= 1 ;
|
||||
if( xdabit ) xda ^= xdapoly ;
|
||||
}
|
||||
}
|
||||
|
||||
return xda;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* Function Name : <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>flash<73><68><EFBFBD><EFBFBD><EFBFBD>ݼ<EFBFBD><DDBC><EFBFBD>CRC
|
||||
* Description : CRCУ<43><D0A3> - <20><>ȡSRAM<41><4D><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* Input :
|
||||
aStr : <20><>ҪУ<D2AA><D0A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ
|
||||
len : <20><><EFBFBD>ݵij<DDB5><C4B3><EFBFBD> -- Flash<73>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD>У<EFBFBD><D0A3>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>512Byte
|
||||
* Return : <20><><EFBFBD>ݵ<EFBFBD>У<EFBFBD><D0A3>ֵ
|
||||
*******************************************************************************/
|
||||
//uint16_t FlashData_NetCRC16(uint32_t FlashAddr ,uint8_t* aStr ,uint16_t len)
|
||||
//{
|
||||
// uint16_t xda , xdapoly;
|
||||
// uint16_t i,j, xdabit ;
|
||||
// xda = 0xFFFF ;
|
||||
// xdapoly = 0xA001 ; // (X**16 + X**15 + X**2 + 1)
|
||||
// for(i=0;i<len;i++)
|
||||
// {
|
||||
// if((len %512) == 0)
|
||||
// {
|
||||
// WDT_Feed();
|
||||
// Flash_Read(aStr, 512, FlashAddr);
|
||||
// FlashAddr += 512;
|
||||
// }
|
||||
//
|
||||
// xda ^= aStr[i%512];
|
||||
// for(j=0;j<8;j++)
|
||||
// {
|
||||
// xdabit = (uint8_t )(xda & 0x01) ;
|
||||
// xda >>= 1 ;
|
||||
// if( xdabit ) xda ^= xdapoly ;
|
||||
// }
|
||||
// }
|
||||
// return xda;
|
||||
//}
|
||||
|
||||
/*******************************************************************************
|
||||
* Function Name : <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>flash<73><68><EFBFBD><EFBFBD><EFBFBD>ݼ<EFBFBD><DDBC><EFBFBD>CRC
|
||||
* Description : CRCУ<43><D0A3> - <20><>ȡSRAM<41><4D><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* Input :
|
||||
aStr : <20><>ҪУ<D2AA><D0A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ
|
||||
len : <20><><EFBFBD>ݵij<DDB5><C4B3><EFBFBD> -- Flash<73>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD>У<EFBFBD><D0A3>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>512Byte
|
||||
* Return : <20><><EFBFBD>ݵ<EFBFBD>У<EFBFBD><D0A3>ֵ
|
||||
*******************************************************************************/
|
||||
uint16_t FlashData_NetCRC16(uint32_t FlashAddr, uint16_t len)
|
||||
{
|
||||
uint16_t xda , xdapoly;
|
||||
uint16_t i,j, xdabit ;
|
||||
uint8_t Fdata =0;
|
||||
xda = 0xFFFF ;
|
||||
xdapoly = 0xA001 ; // (X**16 + X**15 + X**2 + 1)
|
||||
for(i=0;i<len;i++)
|
||||
{
|
||||
Flash_Read(&Fdata, 1, FlashAddr++);
|
||||
xda ^= Fdata;
|
||||
for(j=0;j<8;j++)
|
||||
{
|
||||
xdabit = (uint8_t )(xda & 0x01) ;
|
||||
xda >>= 1 ;
|
||||
if( xdabit ) xda ^= xdapoly ;
|
||||
}
|
||||
}
|
||||
return xda;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* Function Name : UDP_Data_Pack_CRC16
|
||||
* Description : UDP<44><50><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Э<EFBFBD><D0AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>CRCУ<43>麯<EFBFBD><E9BAAF> -
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>CRCУ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Щ<EFBFBD><EFBFBD>ͬ<EFBFBD><EFBFBD>CRC<EFBFBD>ڰ<EFBFBD>ͷ<EFBFBD>ڲ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>У<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD>CRCֵĬ<EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȷ<EFBFBD><EFBFBD>CRC16<EFBFBD><EFBFBD>ֵ
|
||||
* Input :
|
||||
aStr : <20><>ҪУ<D2AA><D0A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ
|
||||
len : <20><><EFBFBD>ݵij<DDB5><C4B3><EFBFBD>
|
||||
* Return : None
|
||||
*******************************************************************************/
|
||||
uint16_t UDP_Data_Pack_CRC16(uint8_t *aStr ,uint16_t len)
|
||||
{
|
||||
uint16_t alen = len; //CRC16
|
||||
uint16_t xda , xdapoly ;
|
||||
uint16_t i,j, xdabit ;
|
||||
xda = 0xFFFF ;
|
||||
xdapoly = 0xA001 ; // (X**16 + X**15 + X**2 + 1)
|
||||
for(i=0;i<alen;i++)
|
||||
{
|
||||
xda ^= aStr[i];
|
||||
|
||||
for(j=0;j<8;j++)
|
||||
{
|
||||
xdabit = (uint8_t )(xda & 0x01) ;
|
||||
xda >>= 1 ;
|
||||
if( xdabit ) xda ^= xdapoly ;
|
||||
}
|
||||
}
|
||||
return xda;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* Function Name : Dev_CheckSum
|
||||
* Description : <20><>У<EFBFBD><D0A3>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݴ<EFBFBD>SRAM<41>ж<EFBFBD>ȡ
|
||||
*******************************************************************************/
|
||||
uint8_t Dev_CheckSum(uint32_t addr,uint16_t len)
|
||||
{
|
||||
uint8_t data_sum = 0;
|
||||
uint8_t check_temp_buff[SRAM_Device_List_Size] = {0};
|
||||
|
||||
SRAM_Read_Buff(check_temp_buff,len,addr);
|
||||
|
||||
for(uint16_t i = 0;i<len;i++)
|
||||
{
|
||||
data_sum += check_temp_buff[i];
|
||||
}
|
||||
return ~data_sum;
|
||||
}
|
||||
|
||||
/**@name <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>У<EFBFBD><D0A3>ȡ<EFBFBD><C8A1>
|
||||
*@para
|
||||
* Data1 <20><><EFBFBD>ݰ<EFBFBD>1
|
||||
* Data1Len <20><><EFBFBD>ݰ<EFBFBD>1<EFBFBD>ij<EFBFBD><C4B3><EFBFBD>
|
||||
* Data2 <20><><EFBFBD>ݰ<EFBFBD>2
|
||||
* Data2Len <20><><EFBFBD>ݰ<EFBFBD>2<EFBFBD>ij<EFBFBD><C4B3><EFBFBD>
|
||||
*@ret data_sum
|
||||
*/
|
||||
uint8_t DoubleData_CheckSum(uint8_t *Data1, uint16_t Data1Len, uint8_t *Data2, uint16_t Data2Len)
|
||||
{
|
||||
uint8_t data_sum = 0;
|
||||
uint16_t i;
|
||||
|
||||
for(i = 0; i < Data1Len;i++)
|
||||
{
|
||||
data_sum += Data1[i];
|
||||
}
|
||||
|
||||
for(i = 0; i < Data2Len; i++)
|
||||
{
|
||||
data_sum += Data2[i];
|
||||
}
|
||||
|
||||
return ~data_sum;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* Function Name : CheckSum
|
||||
* Description : <20><>У<EFBFBD><D0A3>ȡ<EFBFBD><C8A1>
|
||||
*******************************************************************************/
|
||||
uint8_t CheckSum(uint8_t *data,uint16_t len)
|
||||
{
|
||||
uint8_t data_sum = 0;
|
||||
|
||||
for(uint16_t i = 0;i<len;i++)
|
||||
{
|
||||
data_sum += data[i];
|
||||
}
|
||||
return ~data_sum;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* Function Name : CheckSum_Overlook_Check
|
||||
* Description : <20><>У<EFBFBD><D0A3>ȡ<EFBFBD><C8A1>,<2C><><EFBFBD><EFBFBD>У<EFBFBD><D0A3><EFBFBD>ֱ<EFBFBD><D6B1><EFBFBD>
|
||||
* input: data: <20><><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8>
|
||||
len <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܳ<EFBFBD><DCB3><EFBFBD>
|
||||
check_id: У<><D0A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>±<EFBFBD>
|
||||
*******************************************************************************/
|
||||
uint8_t CheckSum_Overlook_Check(uint8_t *data, uint16_t len, uint16_t check_id)
|
||||
{
|
||||
uint8_t data_sum = 0;
|
||||
|
||||
for(uint16_t i = 0;i<len;i++)
|
||||
{
|
||||
if(check_id != i) data_sum += data[i];
|
||||
}
|
||||
return ~data_sum;
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
* Function Name : SOR_CRC
|
||||
* Description : <20><>У<EFBFBD>飬<EFBFBD><E9A3AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݴ<EFBFBD>SRAM<41>ж<EFBFBD>ȡ
|
||||
*******************************************************************************/
|
||||
uint8_t SOR_SRAM_CRC(uint32_t Dataaddr, uint8_t DataLen)
|
||||
{
|
||||
uint8_t i;
|
||||
uint8_t sor_data = 0;
|
||||
|
||||
for(i = 0; i < DataLen; i++)
|
||||
{
|
||||
sor_data += SRAM_Read_Byte(Dataaddr+i);;
|
||||
}
|
||||
return sor_data;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* Function Name : SOR_CRC
|
||||
* Description : <20><>У<EFBFBD><D0A3>
|
||||
*******************************************************************************/
|
||||
uint8_t SOR_CRC(uint8_t *Data, uint8_t DataLen)
|
||||
{
|
||||
uint8_t i;
|
||||
uint8_t sor_data = 0;
|
||||
|
||||
for(i = 0; i < DataLen; i++)//i<><69><EFBFBD><EFBFBD>Ϊ0 <20><>Ҳ<EFBFBD><D2B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>1
|
||||
{
|
||||
sor_data = sor_data+Data[i];
|
||||
}
|
||||
return sor_data;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* Function Name : Device_Data_Check
|
||||
* Description : <20>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>У<EFBFBD><D0A3>
|
||||
*******************************************************************************/
|
||||
uint8_t Device_Data_Check(uint32_t sram_addr)
|
||||
{
|
||||
uint16_t data_len = SRAM_Read_Word(sram_addr + Dev_DataLen);
|
||||
uint8_t data_sum = 0;
|
||||
if(data_len > SRAM_Device_List_Size) return 1;
|
||||
|
||||
uint8_t check_temp_buff[SRAM_Device_List_Size] = {0};
|
||||
|
||||
SRAM_Read_Buff(check_temp_buff,data_len,sram_addr);
|
||||
|
||||
for(uint16_t i = 0;i<data_len;i++)
|
||||
{
|
||||
data_sum += check_temp_buff[i];
|
||||
}
|
||||
return ~data_sum;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
* Function Name : CheckSum_Overlook_Check
|
||||
* Description : <20><>У<EFBFBD><D0A3>ȡ<EFBFBD><C8A1>,<2C><><EFBFBD><EFBFBD>У<EFBFBD><D0A3><EFBFBD>ֱ<EFBFBD><D6B1><EFBFBD>
|
||||
* input: data: <20><><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8>
|
||||
len <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܳ<EFBFBD><DCB3><EFBFBD>
|
||||
check_id: У<><D0A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>±<EFBFBD>
|
||||
*******************************************************************************/
|
||||
uint8_t SRAM_CheckSum_Overlook_Check(uint32_t addr, uint16_t len, uint16_t check_id)
|
||||
{
|
||||
uint8_t data_sum = 0;
|
||||
|
||||
for(uint16_t i = 0;i<len;i++)
|
||||
{
|
||||
if(check_id != i) data_sum += SRAM_Read_Byte(addr+i) ;
|
||||
}
|
||||
return ~data_sum;
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------*/
|
||||
/*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>CRC_168 */
|
||||
/*<2A><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
/*<2A><><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5>У<EFBFBD><D0A3>ֵ */
|
||||
/*-----------------------------------------------------------*/
|
||||
uint8_t CRC_168(uint8_t * data_buf, uint16_t datalen)
|
||||
{
|
||||
uint8_t CRC_Val = 0;
|
||||
uint8_t i=0;
|
||||
uint32_t sum = 0;
|
||||
|
||||
while(datalen--)
|
||||
{
|
||||
sum += data_buf[i];
|
||||
i++;
|
||||
}
|
||||
CRC_Val = sum%168;
|
||||
return CRC_Val;
|
||||
}
|
||||
|
||||
/**
|
||||
*@name NetCRC8 һ<><D2BB><EFBFBD>ֽ<EFBFBD><D6BD><EFBFBD><EFBFBD><EFBFBD>У<EFBFBD><D0A3>
|
||||
*@para
|
||||
* aStr <20><>ҪУ<D2AA><D0A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* len <20><><EFBFBD><EFBFBD><EFBFBD>ܳ<EFBFBD><DCB3><EFBFBD>
|
||||
*@Ret <20><>
|
||||
*@attention <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĩβ<C4A9><CEB2><EFBFBD><EFBFBD>У<EFBFBD><D0A3>ֵ
|
||||
*/
|
||||
void NetCRC8( uint8_t *aStr ,uint16_t len)
|
||||
{
|
||||
uint8_t i;
|
||||
uint8_t xda;
|
||||
// u8 sum = 0;
|
||||
xda = 0x00;
|
||||
for(i = 0; i < len-1; i++)
|
||||
{
|
||||
// xda ^= aStr[i];
|
||||
// sum += xda;
|
||||
xda = xda ^ aStr[i];
|
||||
|
||||
}
|
||||
|
||||
aStr[len-1] = xda;
|
||||
}
|
||||
/**
|
||||
*@name GetCRC8 һ<><D2BB><EFBFBD>ֽ<EFBFBD><D6BD><EFBFBD><EFBFBD><EFBFBD>У<EFBFBD><D0A3>
|
||||
*@para
|
||||
* aStr <20><>ҪУ<D2AA><D0A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* len <20><><EFBFBD><EFBFBD><EFBFBD>ܳ<EFBFBD><DCB3><EFBFBD>
|
||||
*@Ret <20><><EFBFBD><EFBFBD>У<EFBFBD><D0A3>ֵ
|
||||
*@attention <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>м<EFBFBD><D0BC><EFBFBD>
|
||||
*/
|
||||
uint8_t GetCRC8(uint8_t *aStr, uint16_t len)
|
||||
{
|
||||
uint8_t i;
|
||||
uint8_t xda;
|
||||
// u8 sum = 0;
|
||||
xda = 0x00;
|
||||
for(i = 0; i < len; i++)
|
||||
{
|
||||
// xda ^= aStr[i];
|
||||
// sum += xda;
|
||||
xda = xda ^ aStr[i];
|
||||
|
||||
}
|
||||
|
||||
return xda;
|
||||
}
|
||||
|
||||
|
||||
/**@name BLV SN<53>ŵõ<C5B5><C3B5><EFBFBD><EFBFBD><EFBFBD>
|
||||
*@para
|
||||
* SnValue Sn<53><6E>ǰֵ
|
||||
* SnMin Sn<53><6E><EFBFBD><EFBFBD>Сֵ
|
||||
* SnMax Sn<53><6E><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
|
||||
*/
|
||||
uint8_t BLV_SN_Get(uint8_t *SnValue, uint8_t SnMin, uint8_t SnMax)
|
||||
{
|
||||
if((*SnValue < SnMax)&&(*SnValue >= SnMin)) //Sn<53><6E>
|
||||
{
|
||||
(*SnValue)++;
|
||||
}
|
||||
else
|
||||
{
|
||||
*SnValue = SnMin;
|
||||
}
|
||||
return *SnValue;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user