当前位置:网站首页>CRC 校验
CRC 校验
2022-07-01 10:11:00 【@无聊人】
1. 概述:
该demo主要实现CRC校验
引用CRC库的地址为:https://github.com/whik/crc-lib-c
2. 测试:
/* demo_crc.c crc demo : CRC 校验 引用 crcLib.h crcLib.c github 地址 : https://github.com/whik/crc-lib-c */
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include "crcLib.h"
int main(int argc, char *argv[]) {
char str[16] = "Hello World!";
printf("crc4_itu\t \"%s\" = 0x%0X\n", str, crc4_itu((uint8_t *)str, (uint16_t)(strlen(str))));
printf("crc5_epc\t \"%s\" = 0x%0X\n", str, crc5_epc((uint8_t *)str, (uint16_t)(strlen(str))));
printf("crc5_itu\t \"%s\" = 0x%0X\n", str, crc5_itu((uint8_t *)str, (uint16_t)(strlen(str))));
printf("crc5_usb\t \"%s\" = 0x%0X\n", str, crc5_usb((uint8_t *)str, (uint16_t)(strlen(str))));
printf("crc6_itu\t \"%s\" = 0x%0X\n", str, crc6_itu((uint8_t *)str, (uint16_t)(strlen(str))));
printf("crc7_mmc\t \"%s\" = 0x%0X\n", str, crc7_mmc((uint8_t *)str, (uint16_t)(strlen(str))));
printf("crc8\t\t \"%s\" = 0x%0X\n", str, crc8((uint8_t *)str, (uint16_t)(strlen(str))));
printf("crc8_itu\t \"%s\" = 0x%0X\n", str, crc8_itu((uint8_t *)str, (uint16_t)(strlen(str))));
printf("crc8_rohc\t \"%s\" = 0x%0X\n", str, crc8_rohc((uint8_t *)str, (uint16_t)(strlen(str))));
printf("crc8_maxim\t \"%s\" = 0x%0X\n", str, crc8_maxim((uint8_t *)str, (uint16_t)(strlen(str))));
printf("crc16_ibm\t \"%s\" = 0x%0X\n", str, crc16_ibm((uint8_t *)str, (uint16_t)(strlen(str))));
printf("crc16_maxim\t \"%s\" = 0x%0X\n", str, crc16_maxim((uint8_t *)str, (uint16_t)(strlen(str))));
printf("crc16_usb\t \"%s\" = 0x%0X\n", str, crc16_usb((uint8_t *)str, (uint16_t)(strlen(str))));
printf("crc16_modbus\t \"%s\" = 0x%0X\n", str, crc16_modbus((uint8_t *)str, (uint16_t)(strlen(str))));
printf("crc16_ccitt\t \"%s\" = 0x%0X\n", str, crc16_ccitt((uint8_t *)str, (uint16_t)(strlen(str))));
printf("crc16_ccitt_false\t \"%s\" = 0x%0X\n", str, crc16_ccitt_false((uint8_t *)str, (uint16_t)(strlen(str))));
printf("crc16_x25\t \"%s\" = 0x%0X\n", str, crc16_x25((uint8_t *)str, (uint16_t)(strlen(str))));
printf("crc16_xmodem\t \"%s\" = 0x%0X\n", str, crc16_xmodem((uint8_t *)str, (uint16_t)(strlen(str))));
printf("crc16_dnp\t \"%s\" = 0x%0X\n", str, crc16_dnp((uint8_t *)str, (uint16_t)(strlen(str))));
printf("crc32\t\t \"%s\" = 0x%0X\n", str, crc32((uint8_t *)str, (uint16_t)(strlen(str))));
printf("crc32_mpeg_2\t \"%s\" = 0x%0X\n", str, crc32_mpeg_2((uint8_t *)str, (uint16_t)(strlen(str))));
return 0;
}
#Makefile
CC := gcc
AR := ar
all:
$(CC) -c crcLib.c -o crcLib.o -Wall -Werror
$(AR) cr libcrcLib.a crcLib.o
#-L 指定库的路径 -l 指定需连接的库名
#-Wl,-Bstatic指示跟在后面的-lxxx选项链接的都是静态库
#-Wl,-Bdynamic指示跟在后面的-lxxx选项链接的都是动态库
$(CC) demo_crc.c -o demo_crc -lm -L. -Wl,-Bstatic -lcrcLib -Wl,-Bdynamic -Wall -Werror
clean:
rm demo_crc *.o *.a
边栏推荐
- 程序员都想去国企?技术落后薪资低,躺平几年出来都找不到工作...
- 442. 数组中重复的数据
- IDEA运行报错Command line is too long. Shorten command line for...
- CSDN's one-stop cloud service is open for internal testing, and new and old users are sincerely invited to grab the fresh
- The latest masterpiece of Alibaba, which took 182 days to produce 1015 pages of distributed full stack manual, is so delicious
- venv: venv 的目录结构
- BSN长话短说之十:如何保证NFT的安全
- sql语句修改字段类型「建议收藏」
- What is cloud primordial? Will it be the trend of future development?
- Ubuntu系统安装与配置MySQL
猜你喜欢

直播管理项目

The latest masterpiece of Alibaba, which took 182 days to produce 1015 pages of distributed full stack manual, is so delicious

架构实战营 模块九:设计电商秒杀系统

建议收藏 | 在openGauss上遇到慢SQL该怎么办?

Kotlin 协程调度切换线程是时候解开真相了

预制菜迎来“黄金时代”,谁能领跑下一个万亿市场

Tearful eyes, it's not easy to change jobs. Three rounds of interviews, four hours of soul torture

Sleeping second brother...

新数据库时代,不要只学 Oracle、MySQL

Venv: directory structure of venv
随机推荐
106. 从中序与后序遍历序列构造二叉树
Dotnet console uses microsoft Maui. Getting started with graphics and skia
新一代云原生数据库的设计与实践
STM32 inverter power supply design scheme, based on STM32F103 controller [easy to understand]
Daily mathematics serial 55: February 24
What if the win11 account is locked and unable to log in? Win11 account is locked and unable to log in
[dark horse morning post] Yu Minhong said he never looked at the stock price of New Oriental; Hengchi 5 will start pre-sale in July; Naixue virtual stock or suspected of illegal fund-raising; From Jul
leetcode:111. 二叉树的最小深度
TC8:UDP_USER_INTERFACE_01-08
Thread Basics
《天天数学》连载55:二月二十四日
【黑马早报】俞敏洪称从来不看新东方股价;恒驰5将于7月开启预售;奈雪虚拟股票或涉嫌非法集资;7月1日起冰墩墩停产...
建议收藏 | 在openGauss上遇到慢SQL该怎么办?
Today in history: the semiconductor war in the late 1990s; Von Neumann published the first draft; CBS acquires CNET
Japanese professor sues Intel FPGA and SOC products for infringing a design patent
Common penetration tools -goby
预制菜迎来“黄金时代”,谁能领跑下一个万亿市场
CentOS configures discuz prompt, please check whether the MySQL module is loaded correctly
在中金证券上做基金定投安全吗?
Introduction to expressions and operators in C language