/* HardCore SoftWare's smart card interface software. (C) 2002, HardCore Software This program is protected under the GNU General Purpose License. You may copy, modify, and redistribute this program by the terms of this license. See the file 'LICENSE' for details. */ #include #include #define P_PORT_ADDR 888 #define UNIX /* Undefine this if compiling in DOS so as to ignore the permission grabbing code */ #define READTO 200 /* Bytes to read to */ #define SC_OFF 0 /* 0 */ #define SC_POWER 1 /* (2^0) */ #define SC_RESET 2 /* (2^1) */ #define SC_CLOCK 4 /* (2^2) */ #define SC_WRITE 8 /* (2^3) */ #define SC_VPP 16 /* (2^4) */ #define SC_IO 64 /* (2^6) */ void parsend(int value) { outb((unsigned char) value, P_PORT_ADDR); } int parget() { return inb(P_PORT_ADDR+1); } int paropen() { #ifdef UNIX return !(ioperm(P_PORT_ADDR, 3, P_PORT_ADDR+1)); #else return 1; #endif } int parclose() { #ifdef UNIX return !(ioperm(P_PORT_ADDR, 3, 0)); #else return 1; #endif } int open_sc() { parsend(SC_OFF); usleep(1000); parsend(SC_POWER); parsend(SC_POWER | SC_RESET); parsend(SC_POWER | SC_RESET | SC_CLOCK); parsend(SC_POWER | SC_RESET); parsend(SC_POWER); usleep(10); return 1; } int close_sc() { parsend(SC_OFF); return 1; } void paraddrinc() { parsend(SC_POWER | SC_CLOCK); parsend(SC_POWER); return; } int dump_sc(int *buf, int bytes) { int i, currbit; for (i=0; i=1; currbit--) { buf[i] += ((parget() & 8)/8) * pow(2,currbit-1); paraddrinc(); } } buf[0]-=128; /* HACK - you may not have to do this with your parport */ return 1; } int pow(int i, int j) { int tally=1; while(j>0) { tally*=i; j--; } return tally; } float amount_on_sc(int *tp) { int tpi=0; tpi=(tp[51]<<16) + (tp[52]<<8) + tp[53]; return tpi/4000.0; } int main() { int tp[READTO]; int i; memset(tp, 0, sizeof(tp)); if (!paropen()) { printf("HardCore SoftWare smart card software\n Sorry, you need to be r00ted.\n"); exit(-1); } open_sc(); dump_sc(tp, READTO); printf("HardCore Software Laundry Card Reader\n"); printf(" HEX DEC\n"); for (i=0; i