About the source code of this protocol

/*
The data type ID in the node ID may be wrong, but it is because of the error that successfully avoided the conflict with the correct data type ID
*/

#define CAN_ID2_OUT ((u32)0x1109216)

//Pack the payload to be sent
void CAN_CustomerCode_TX(void)
{
static uint32_t tickstart_CAN = 0;
static uint32_t ticksotp_CAN = 0;
if(tickstart_CAN == 0)
{
tickstart_CAN = HAL_GetTick();
}

ticksotp_CAN = HAL_GetTick();
if(ticksotp_CAN<tickstart_CAN)//
{
	ticksotp_CAN=0xffffffff-tickstart_CAN+ticksotp_CAN;
}
else
	ticksotp_CAN=ticksotp_CAN-tickstart_CAN;

if((ticksotp_CAN>250)&&(CAN_TX_Falg == 0))
{
	tickstart_CAN = 0;
	ticksotp_CAN = 0;
}
else
{
	return;
}	
//Battery manufacturer code
CAN_CustomerCode.gBatCode[0]= BMS_config.CustomerCode.gBatCode[0];
CAN_CustomerCode.gBatCode[1]= BMS_config.CustomerCode.gBatCode[1];      
    //Battery model code
CAN_CustomerCode.gBatCodeNumber[0]=BMS_config.CustomerCode.gBatPack[0]; 
CAN_CustomerCode.gBatCodeNumber[1]=BMS_config.CustomerCode.gBatPack[1];        	
    //Total voltage 1mV
CAN_CustomerCode.gVoltSum = BMS_config.BMS_Read.gVoltSum*100;    
    //Current current value 		
CAN_CustomerCode.gCurrent = BMS_config.BMS_Read.gCurrent*10;  
     //Average temperature    				
CAN_CustomerCode.gTemAvg = BMS_config.BMS_Read.gTemAvg; 
    //Battery pack SOC         				
CAN_CustomerCode.gSOC = BMS_config.Pack_RW_config.gSOC;    
    //Number of cycles                  	
CAN_CustomerCode.gsCycleCnt= BMS_config.Pack_RW_config.gsCycleCnt;  
    //Battery pack SOH            
CAN_CustomerCode.gSOH= BMS_config.Pack_RW_config.gSOH;                 			
memcpy(&CAN_CustomerCode.g_Volt_call,&BMSVoltTemperature.g_Volt_call,
		sizeof(CAN_CustomerCode.g_Volt_call));  
   //Design capacity of battery pack
CAN_CustomerCode.gSetPackCapacity = BMS_config.Pack_RW_config.gSetPackCapacity*10;   
   //Remaining capacity
CAN_CustomerCode.gSurpulsPackCapacity = BMS_config.Pack_RW_config.gSurpulsPackCapacity*10;  
////////////Need to fill in the real fault code////////////////
CAN_CustomerCode.gAlarm[0] = (gBitChgLowTemAlm|gBitChgLowTemAlmPrt|gBitDchgLowTemAlm | gBitDchgLowTemAlmPrt)|\
((gBitChgHighTemAlm | gBitChgHighTemAlmPrt|gBitDchgHighTemAlm | gBitDchgHighTemAlmPrt)<<1) |\
((gBitChgOverCurrentAlm|gBitChgOverCurrentAlmPrt<<2)) |\
((gBitDchgOverCurrentAlm|gBitDchgOverCurrentAlmPrt)<<3) |\
((gBitVoltDiff1MaxAlm) | (gBitVoltDiff1MaxAlmPrt) | (gBitVoltDiff2MaxAlm) |(gBitVoltDiff2MaxAlmPrt)<<6) |\
((gBitOverVoltAlm | gBitOverVoltAlmPrt)<<7) |\
((gBitUnderVoltAlm | gBitUnderVoltAlmPrt)<<8) |\
(gBitChgShortCircuit<<9) | (gBitDchgShortCircuit<<10) | (gBitSOClow<<11) |(gBit_Chg_Error<<12);
CAN_CustomerCode.gAlarm[1] = 0;

/////////////////////////	
memcpy(&CAN_CustomerCode.gXUHAO,&BMS_config.CustomerCode.gBatCodeNumber,
		sizeof(CAN_CustomerCode.gXUHAO)); 							
CCITT_CRC16Init((u8 *)(&CAN_CustomerCode.gBatCode),(sizeof(CAN_CustomerCode)-2)); 
CAN_CustomerCode.CRC16 = CCITT_CRC16;


//Put the payload to be sent into the sending array		
memcpy(CAN_Tx_payload,&CAN_CustomerCode,sizeof(CAN_CustomerCode));  

CAN_T_LEN_SUM = sizeof(CAN_CustomerCode);
gCAN_flag = 1;	

CAN_Tx_Flag = 1;

CAN_Node_Id =CAN_ID2_OUT;		//Load the 29-bit ID of the data packet	

}
//250ms send a complete frame once, 1ms send a packet (<=8byte)
u8 CAN_TX_BcmuMsgHandle(void)
{
static CanTxMsg TxMessage;
static u8 can_pack = 0;
static u8 can_send_cnt = 0;
u8 temp_i = 0;
if(CAN_T_LEN_SUM < 240)
{
if(CAN_Tx_Flag == 1)
{
for(temp_i = 0;temp_i < 7;)
{
TxMessage.Data[temp_i] = CAN_T[can_send_cnt++];
temp_i++;
if(can_send_cnt >= CAN_T_LEN_SUM)//发送到了最后一个 字节
break;
}
if(can_send_cnt >= CAN_T_LEN_SUM)
TxMessage.Data[temp_i] = 0x40 | can_pack | ((can_pack%2) << 5);
else
{
TxMessage.Data[temp_i] = can_pack|((can_pack%2) << 5);
}

		if(can_pack == 0)						///第一包数据处理
		{
			if(can_send_cnt >= CAN_T_LEN_SUM)
				TxMessage.Data[temp_i] = 0xc0;//装载尾字节
			else
				TxMessage.Data[temp_i] = 0x80;//装载尾字节
		}	

		TxMessage.DLC = temp_i+1;
		TxMessage.IDE = CAN_ID_EXT;			

		TxMessage.ExtId = CAN_Node_Id;
		CAN_Transmit(CAN, &TxMessage);	
		can_pack++;
		if(can_send_cnt >= CAN_T_LEN_SUM)     //Data transmission complete flag
		{
			can_pack = 0;
			can_send_cnt = 0;
			CAN_T_LEN_SUM = 0;
			CAN_Tx_Flag = 0;
			/*If the UAVCAN transmission is over, clear the UAVCAN transmission setting*/
			if(gCAN_flag)
				gCAN_flag = 0;
		}

	}
}
return 1;

}
//Check function
void CCITT_CRC16Init(uint8_t const * bytes, uint16_t len)
{
uint16_t j;
uint8_t i=0;
CCITT_CRC16 =CRC_CCITT_INIT;
while (len–)
{
CCITT_CRC16 ^= ((uint16_t)bytes[i++] << 8);
for (j = 0; j < 8; j++)
{
CCITT_CRC16=(CCITT_CRC16 & 0x8000U)?((CCITT_CRC16 << 1) ^ CRC_CCITT_POLY):(CCITT_CRC16 << 1);
}
}
}