tck_hal_crc.c
来自「一个免费的SMART CARD OS系统。」· C语言 代码 · 共 84 行
C
84 行
/* ============================================================================ Project Name : jayaCard TCK Module Name : proto/tck/hal/crc/tck_hal_crc.c Version : $Id: tck_hal_crc.c,v 1.5 2004/01/11 09:56:35 dgil Exp $ Description: HAL CRC The Original Code is jayaCard TCK code. The Initial Developer of the Original Code is Gilles Dumortier. Portions created by the Initial Developer are Copyright (C) 2002-2004 the Initial Developer. All Rights Reserved. Contributor(s): Permission is granted to any individual to use, copy, or redistribute this software so long as all of the original files are included unmodified, that it is not sold for profit, and that this copyright notice is retained. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. History Rev Description 062103 dgil wrote it from scratch ============================================================================*/#include "precomp.h"/* ============================================================================ main() ========================================================================= */int main(void){ jbyte i; jbyte b1[12] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C }; jbyte b2[12] = { 0x01, 0x00, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C }; jbyte crclo; jbyte crchi; printf("Start of hal::crc\n"); tcl_type = TCL_TYPEA; printf("\nTest 1\n"); HAL_CRC_INIT(); printf("b1-crc-0 : 0x%.2X%.2X\n",HAL_CRC_LO(),HAL_CRC_HI()); for (i=0; i<sizeof(b1); i++) { HAL_CRC_COMPUTE(b1[i]); } printf("b1-crc-1 : 0x%.2X%.2X\n",HAL_CRC_LO(),HAL_CRC_HI()); printf("\nTest 2\n"); HAL_CRC_INIT(); printf("b2-crc-0 : 0x%.2X%.2X\n",HAL_CRC_LO(),HAL_CRC_HI()); for (i=0; i<sizeof(b2); i++) { HAL_CRC_COMPUTE(b2[i]); } crclo = HAL_CRC_LO(); crchi = HAL_CRC_HI(); printf("b2-crc-1 : 0x%.2X%.2X\n",crclo,crchi); HAL_CRC_COMPUTE(crclo); HAL_CRC_COMPUTE(crchi); printf("b2-crc-2 : 0x%.2X%.2X\n",HAL_CRC_LO(),HAL_CRC_HI()); printf("\nTest 3\n"); HAL_CRC_INIT(); printf("b3-crc-0 : 0x%.2X%.2X\n",HAL_CRC_LO(),HAL_CRC_HI()); for (i=0; i<sizeof(b2); i++) { HAL_CRC_COMPUTE(b2[i]); } crclo = HAL_CRC_LO(); crchi = HAL_CRC_HI(); printf("b3-crc-1 : 0x%.2X%.2X\n",crclo,crchi); HAL_CRC_INIT(); printf("b3-crc-2 : 0x%.2X%.2X\n",HAL_CRC_LO(),HAL_CRC_HI()); for (i=0; i<4; i++) { HAL_CRC_COMPUTE(b1[i]); } HAL_CRC_COMPUTE(crclo); HAL_CRC_COMPUTE(crchi); for (i=0; i<4; i++) { HAL_CRC_COMPUTE(b2[i]); } printf("b3-crc-3 : 0x%.2X%.2X\n",HAL_CRC_LO(),HAL_CRC_HI()); printf("\nEnd of hal::crc\n"); return 0;}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?