Created
November 24, 2022 12:49
-
-
Save cuu/455b04cc5af6a9a626c204ea8fdfb5de to your computer and use it in GitHub Desktop.
24c_read.c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "comPro.h" | |
#include <stdio.h> | |
#include <string.h> | |
int main(int argc,char* argv[]) | |
{ | |
int icdev,st,number; | |
char szVer[128]; | |
int iNode = 0; | |
char szNode[128]; | |
unsigned char cardSt; | |
//usb port ... | |
do | |
{ | |
sprintf(szNode, "/dev/usb/hiddev%d", iNode); | |
iNode++; | |
if((icdev=lc_init_ex(2,szNode,115200))== -1) | |
{ | |
printf("lc_init ERR %d\n",icdev); | |
return 0; | |
} | |
else | |
{ | |
st = lc_iccGetCardState(icdev, 0, &cardSt); | |
if(cardSt ==0) | |
{ | |
printf("No card found,Please Insert...."); | |
break; | |
} | |
if(st == 0) | |
{ | |
printf(" Found card %d\n",icdev); | |
lc_iccSelCardType(icdev, SLOT_ICC_MSR, 1); | |
break; | |
} | |
} | |
}while(icdev != -1); | |
unsigned char rData[1024]; | |
memset(rData,0,1024);; | |
int readLen = 6; | |
st = lc_icc_ReadMem(icdev,SLOT_ICC_MSR,0, readLen, rData); | |
if(st ==0 ){ | |
printf("read 24c card OK\n"); | |
for(int i=0;i<readLen;i++) { | |
printf("%02x ",rData[i]); | |
} | |
printf("\n"); | |
}else{ | |
printf("read 24c card failed %d\n",st); | |
} | |
lc_exit(icdev); | |
return 0; | |
} | |
//gcc -fPIC -o 24c_read -g 24c_read.c ./x64/libcomPro.so |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment