4G_module/custom/jt808/inc/jt808_util.h

38 lines
919 B
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#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_