1 Star 0 Fork 1

qingsonggege / openwrt_mt7688_ctest

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
crc24_test.c 1.99 KB
一键复制 编辑 原始数据 按行查看 历史
Midas 提交于 2017-06-14 17:16 . add cc1101_tx.c and cc1101_rx.c
/*-------------------------------------------------------------------
Test program for ADSB-CRC.H
midaszhou@qq.com
-------------------------------------------------------------------*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h> //-strlen()
#include <stdint.h> //uint32_t
#include "adsb_crc.h"
#include "cstring.h" //strmid()
/*=====================================================================
MAIN
=====================================================================*/
void main(int argc, char* argv[])
{
//------------ test code -----------
char str_HEX_CODE[32]=""; //4*8=32 > 28
strcpy(str_HEX_CODE,"8D40621D58C382D690C8AC2863A7"); //--28 chars for str_HEX code
//strcpy(str_HEX_CODE,"8D40621D58C386435CC412692AD6");
//strcpy(str_HEX_CODE,"8D4840D6202CC371C32CE0576098");
int i,j,k;
char str_Temp[8];
//int n_div=4;
uint32_t crc32_GP=0xFFFA0480;//0x04C11DB7; // CRC Generator Polynomial alread inlucdes the highest first bit, while standard CRC usually omitted.
char str_ICAO24[6+1]=""; //--4*6=24bits
int int_ICAO24;
uint32_t bin32_code[4]; //store full binary ADS-B CODE in 4 groups of 32bit array
uint32_t bin32_divid[4]={0,0,0,0};//dividend = message(88)+crc(24)=112bits
uint32_t bin32_CRC24;
//-------------- convert hex code to bin code in string -----------
printf("ADS-B CODE: ");
for(i=0;i<4;i++)
{
strmid(str_Temp,str_HEX_CODE,8,i*8);
bin32_code[i]=strtoul(str_Temp,NULL,16);
if(i==3)
bin32_code[i]=(bin32_code[i]<<16); //--shift the last 16bits to left
printf("%08x",bin32_code[i]);
}
printf("\n");
//------------------------- CRC calculation -------------------------------
//------- prepare dividend for CRC calculation
bin32_divid[0]=bin32_code[0];
bin32_divid[1]=bin32_code[1];
bin32_divid[2]=bin32_code[2]&0xffffff00;
//printf("CRC24: %06x \n",adsb_crc24(bin32_divid));
printf("88bits CRC24: %06x \n",adsb_crc(bin32_code,88));
printf("112bits CRC24: %06x \n",adsb_crc(bin32_code,112));
} //// end of main()
1
https://gitee.com/qingsonggege/openwrt_mt7688_ctest.git
git@gitee.com:qingsonggege/openwrt_mt7688_ctest.git
qingsonggege
openwrt_mt7688_ctest
openwrt_mt7688_ctest
master

搜索帮助