problems with openct/ctapi


[ Follow Ups ] [ BasicCard User Forum ]

Posted by daniele (212.227.35.114) on December 01, 2005 at 13:22:48:

Hi,

I have implemented a simple command on the card:

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 100
Put #1, , One
Next I
data$ = Str$( Len( #1 ) ) + ":" + data$
Close #1
End Command

A file is created which is filled with 1's. In the Terminal, calling this command on the card (not the emulator) works fine. After some seconds the file has been created.

When writing the Eeprom to the card and calling the command from Linux with the ctapi of MUSCLE I'm getting a transmission error.

When writing the Eeprom to the card and calling the command from the Terminal and after that calling the command from Linux it works.

I have not tested this example with OpenCT but I get transmission errors with OpenCT in similar situations as well. It seems that if a command takes more than some seconds to be executed I get these problems.

I'm using the T1 protocol.

Are there any known problems with OpenCT or ctapi in combination with the basic card?

Here are parts of the C source of my Linux program:


unsigned char dad = 0; /* ICC1 = 0x0 */
unsigned char sad = HOST; /* CT = 0x1 */
unsigned short lenc = 4;
unsigned char cmd[ 255 ];
unsigned short lenr = 255;
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 with card failed\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 with card failed\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 );
cmd[ 8 ] = 255; /* Le */
if( CT_data( 1, &dad, &sad, lenc, cmd, &lenr, rec ) != OK ) {
fprintf( stderr, "communication with card failed\n" );
exit( 1 );
}

Thanks a lot,
Daniel


Follow Ups:


[ Follow Ups ] [ BasicCard User Forum ]