
/******************************************************************
*  Copyright (C) 2023 - 2023 OneChip, Inc. All rights reserved.
* File name: van_com_algorithm.h
* Author: fanyidong 	 Date:2024.1.21
* Description:		常用算法定义
* Others:
* History:
        1. Date:
                 Author:
                 Modification:

*****************************************************************/

#ifndef VAN_COM_ALGORITHM_H
#define VAN_COM_ALGORITHM_H


#include "communication.h"
#define VAN_COM_HEADER_FALG 0x55AA
#define VAN_COM_TAIL_FALG 0x5AA5
#define VAN_CFG_NONE 0


#define SIZEOF_MSG_ST 8

#define SIZEOF_MSG_MODBUS 8


#define combine_cmdMessage(msg,header,typeer,cmder,tailer)  {\
	msg.head = header; \
	msg.type = typeer; \
	msg.cmd = cmder; \
}



unsigned int checkSum(const unsigned char *pInBuffer, unsigned int  uLen);
int DecodeNew(CmdMessage* pMessage, unsigned char *pdata, const unsigned char *pInBuffer, unsigned int *pheader,unsigned int  ulast,unsigned int maxlen);
int DecodeModbud_RTU(unsigned char *pdata,const unsigned char *pInBuffer, unsigned int *pheader, unsigned int ulast, unsigned int maxlen);

#endif

