当前位置:网站首页>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
边栏推荐
- 苹果放大招!这件事干的太漂亮了……
- SSH服务器拒绝密码,再试一次;PermitRootLogin yes无效问题
- mysql截取_mysql截取字符串的方法[通俗易懂]
- mysql cdc能把能把op字段拿出来吗
- C [byte array] and [hexadecimal string] mutual conversion - codeplus series
- Daily mathematics serial 55: February 24
- What a high commission! The new programmer's partner plan is coming. Everyone can participate!
- Change password of MySQL version 5.7 and 8.0
- Module 9: design e-commerce seckill system
- 云原生到底是什么?它会是未来发展的趋势吗?
猜你喜欢

谁还在买“三只松鼠”们

IDEA运行报错Command line is too long. Shorten command line for...

scratch大鱼吃小鱼 电子学会图形化编程scratch等级考试二级真题和答案解析2022年6月

If you meet a female driver and drive didi as an amateur, you can earn 500 a day!

A quietly rising domestic software, low-key and powerful!

It is interesting to understand MMAP in this way!

This is the best flash popular science article I have ever seen!

Finally, someone made it clear what DRAM and NAND flash are

TC8:UDP_ USER_ INTERFACE_ 01-08

零基础入门测试该学什么?最全整理,照着学就对了
随机推荐
IDEA运行报错Command line is too long. Shorten command line for...
Finally, someone made it clear what DRAM and NAND flash are
Programmers want to go to state-owned enterprises? The technology is backward and the salary is low. I can't find a job after lying flat for several years
Module 9: design e-commerce seckill system
零基础入行软件测试必看,10年测试老鸟的良心建议(共15条)
php 实现抽奖功能
京东与腾讯续签三年战略合作协议;起薪涨至26万元!韩国三星SK争相加薪留住半导体人才;Firefox 102 发布|极客头条...
建议收藏 | 在openGauss上遇到慢SQL该怎么办?
Postgraduate entrance examination vocabulary 2023 sharing (1)
架构实战营 模块九:设计电商秒杀系统
Floyd repeat
7-Zip boycotted? The callers have committed "three crimes": pseudo open source, unsafe, and the author is from Russia!
PHP 字符串与二进制相互转换
CSDN's one-stop cloud service is open for internal testing, and new and old users are sincerely invited to grab the fresh
C one line code calculates the MD5 value of the file - codeplus series
编写自己的who命令
Tryhackme Christmas challenge 2021 advance of cyber 3-day1-idor vulnerability, insecure access control vulnerability
微信表情符号写入判决书,你发的OK、炸弹都可能成为“呈堂证供”
About database: how to avoid deadlock in gbase 8s
JD and Tencent renewed the three-year strategic cooperation agreement; The starting salary rose to 260000 yuan! Samsung sk of South Korea competes for salary increase to retain semiconductor talents;