Hi,

Please do not apply the patch by Jim Rees, but instead the one at the
bottom of this message. It fixes a problem parssing ATR when interface
byte TD1 (the one that determines the protocol) is not pressent in the
ATR, better than hardwiring T=0 (maybe someday when I find time or if
somebody of you help me we will have a T=1 implementation ;-)

The patch may work on all platforms because ATR parsing is not a platform
specific operation (like for instance I/O), but a simple calculation based
on ATR byte array.

Jim, Towitoko_ResetCard() goes through the loop three times cause driver
doesn't know if the card inserted  has "active low reset" or "active high
reset" so it tries both posibilities, and sometimes card does not
respond to the first reset so it performs reset three times (your card for
instance has "active low reset" and doesn't respond on firts reset
operation, but on second).

Also I see you are not using latest version of driver. The bug setting
port speed with "newtio.c_cflag = B9600" is already fixed. Please get
latest from ftp://apolonio.atos-ods.es/pub/musclecard . Version 0.97.6
includes both ATR bugfixes and /dev/ttyS* serial port changes.

Thanks,
Carlos

On Fri, 26 Feb 1999, Jim Rees wrote:

> I've got the Towitoko reader working on OpenBSD now.  I'm using Payflex P1
> cards and there seem to be some problems in the ctapi library.
>
> Reset takes a long time, because Towitoko_ResetCard() goes through the loop
> three times.  I don't know why.  Then atr parsing fails, and ATR_Protocol()
> returns 0xf.  Again, I don't know why.  For now I've hardwired T=0 in  the
> driver.
>                                       
> Sending Active Low Reset 
> Sending Active High Reset 
> Sending Active Low Reset 
> ATR: 3B 23 0 35 11 80 
> 
> Here are the changes I ended up making to serial.c (this is against
> towitoko-0.97).  I believe these are correct, but it would be nice if
> someone would verify that this still works on a linux system.

The patch applies doing

cd ctapi-towitoko-0.97.*
patch atr.c atr.diff 

(I know patches can be better, but I don't know exactly how, maybe some
options to the diff command?)
49c49
<   for(i=0;i<=index;i++) {
---
>   for(i=1;i<=index;i++) {
114d113
<   BYTE T0;
122,123c121,123
<   /* Record T0 */
<   T0 = TDi = atr[pointer=1];
---
>   /* Record T0 and number of historical bytes */
>   TDi = atr[pointer=1];
>   *lhist = TDi & 0x0F;
181c181
<   if(TD==ATR_NOTFOUND)
---
>   if(status==ATR_NOTFOUND)

Reply via email to