38 lines
919 B
C
38 lines
919 B
C
|
|
|
|||
|
|
#ifndef JT808_UTIL_H_
|
|||
|
|
#define JT808_UTIL_H_
|
|||
|
|
|
|||
|
|
#include <stdio.h>
|
|||
|
|
#include <stdlib.h>
|
|||
|
|
#include <stdint.h>
|
|||
|
|
#include <stddef.h>
|
|||
|
|
#include <string.h>
|
|||
|
|
// #include <vector>
|
|||
|
|
|
|||
|
|
// 双字节大小端交换
|
|||
|
|
uint16_t Swap16(uint16_t val16);
|
|||
|
|
// 四字节大小端交换
|
|||
|
|
uint32_t Swap32(uint32_t val32);
|
|||
|
|
// 异或校验
|
|||
|
|
uint8_t BCC_Check(const uint8_t *src, uint32_t len);
|
|||
|
|
|
|||
|
|
|
|||
|
|
// 十进制转BCD码
|
|||
|
|
uint8_t DecToBcd(uint8_t Dec);
|
|||
|
|
|
|||
|
|
// BCD码转十进制
|
|||
|
|
uint8_t BcdToDec(uint8_t Bcd);
|
|||
|
|
|
|||
|
|
// 原始字符串转BCD码 //奇数位时,首位BCD码前面补0
|
|||
|
|
uint8_t *rawStrToBcd(uint8_t *bcd, const uint8_t *str, uint16_t str_len);
|
|||
|
|
|
|||
|
|
// BCD转字符串,自动去掉bcd码前导零
|
|||
|
|
// bcdlen 为bcd码字节数
|
|||
|
|
uint8_t *BcdToStr(uint8_t *str, const uint8_t *bcd, int bcd_len);
|
|||
|
|
|
|||
|
|
// 原始BCD数据转字符串
|
|||
|
|
// strlen 为原始BCD数据字节数
|
|||
|
|
uint8_t *rawBcdToStr(uint8_t *str, const uint8_t *bcd, int bcd_len);
|
|||
|
|
|
|||
|
|
#endif // JT808_UTIL_H_
|