Hi,

I'm using towitoko-2.0.7 ctapi to execute commands on a BasicCard
(4.5D Rev C, basiccard.com) using T1.

On the BasicCard I have the following command with CLA=0x80 and
INS=0xaa which simply creates a file and fills it with 1's. After
that the length of the file and the input data is returned.

Command &H80 &HAA TestCmd( data$ )
   Private One As Byte = 1
   Private I As Long = 0
   Open "123" For Binary As #1
   For I = 1 To 300
       Put #1, , One
   Next I
   data$ = Str$( Len( #1 ) ) + ":" + data$
   Close #1
End Command


To execute the command on the card I do the following CT_data calls:

unsigned char dad;
unsigned char sad;
unsigned short lenc;
unsigned char cmd[ 255 ];
unsigned short lenr;
unsigned char rec[ 255 ];

CT_init( 1, PORT_COM1 )

/* reset CT */
dad = CT;
sad = HOST;
lenc = 4;
lenr = 255;
cmd[ 0 ] = 0x20; /* CLA */
cmd[ 1 ] = 0x11; /* INS */
cmd[ 2 ] = 0; /* P1 */
cmd[ 3 ] = 0; /* P2 */
if( CT_data( 1, &dad, &sad, lenc, cmd, &lenr, rec ) != OK ) {
   fprintf( stderr, "communication error\n" );
   exit( 1 );
}


/* reset ICC return ATR */
dad = CT;
sad = HOST;
lenc = 6;
lenr = 255;
cmd[ 0 ] = 0x20;
cmd[ 1 ] = 0x11;
cmd[ 2 ] = 1;
cmd[ 3 ] = 1; /* P2 return ATR */
cmd[ 4 ] = 0;
cmd[ 5 ] = 0;
if( CT_data( 1, &dad, &sad, lenc, cmd, &lenr, rec ) != OK ) {
   fprintf( stderr, "communication error\n" );
   exit( 1 );
}

/* call command */
dad = 0;
sad = HOST;
lenc = 9;
lenr = 255;
cmd[ 0 ] = 0x80;
cmd[ 1 ] = 0xaa;
cmd[ 2 ] = 0; /* P1 */
cmd[ 3 ] = 0; /* P2 */
cmd[ 4 ] = 3; /* Lc */
memcpy( &cmd[ 5 ], "ABC", 3 );  /* send some data */
cmd[ 8 ] = 255; /* Le */
if( CT_data( 1, &dad, &sad, lenc, cmd, &lenr, rec ) != OK ) {
   fprintf( stderr, "communication error\n" );
   exit( 1 );
}

The last call of CT_data fails with the error code ERR_TRANS.
When removing the for loop on the BasicCard everything works
fine. Maybe because the command returns in less time?

Can anybody help?

Thanks a lot,
Daniel

_______________________________________________
Muscle mailing list
[email protected]
http://lists.drizzle.com/mailman/listinfo/muscle

Reply via email to