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.

*** serial.c-   Wed Dec  2 14:52:59 1998
--- serial.c    Fri Feb 26 13:16:36 1999
***************
*** 211,220 ****
    switch (baud) {
  
    case 9600:                                               /* Baudrate 9600          
*/
!     newtio.c_cflag = B9600;
      break;
    case 19200:                                              /* Baudrate 19200         
*/
!     newtio.c_cflag = B19200;
      break;
    default:
      close(handle);
--- 211,222 ----
    switch (baud) {
  
    case 9600:                                               /* Baudrate 9600          
*/
!     cfsetispeed(&newtio, B9600);
!     cfsetospeed(&newtio, B9600);
      break;
    case 19200:                                              /* Baudrate 19200         
*/
!     cfsetispeed(&newtio, B19200);
!     cfsetospeed(&newtio, B19200);
      break;
    default:
      close(handle);
***************
*** 273,292 ****
          newtio.c_cflag |= CSTOPB;
        #endif
        newtio.c_cflag |= CREAD|HUPCL|CLOCAL;
!       newtio.c_iflag &= ~(IGNPAR|PARMRK|INLCR|IGNCR|ICRNL);
        newtio.c_iflag |= BRKINT;  
!       newtio.c_lflag &= ~(ICANON|ECHO|ISTRIP);
        newtio.c_oflag  = 0;  
        newtio.c_lflag  = 0;
        
        newtio.c_cc[VMIN]  = 1;
        newtio.c_cc[VTIME] = 0;
        
-       if (tcflush(handle, TCIFLUSH) < 0) {             /* Flush the serial port      
      */
-         close(handle);
-         return FALSE;
-       }
-       
        if (tcsetattr(handle, TCSANOW, &newtio) < 0) {   /* Set the parameters         
       */
          close(handle);
          return FALSE;
--- 275,289 ----
          newtio.c_cflag |= CSTOPB;
        #endif
        newtio.c_cflag |= CREAD|HUPCL|CLOCAL;
!       newtio.c_iflag &= ~(IGNPAR|PARMRK|INLCR|IGNCR|ICRNL|ISTRIP);
        newtio.c_iflag |= BRKINT;
!       newtio.c_lflag &= ~(ICANON|ECHO);
        newtio.c_oflag  = 0;  
        newtio.c_lflag  = 0;
  
        newtio.c_cc[VMIN]  = 1;
        newtio.c_cc[VTIME] = 0;
        
        if (tcsetattr(handle, TCSANOW, &newtio) < 0) {   /* Set the parameters         
       */
          close(handle);
          return FALSE;
***************
*** 303,308 ****
--- 300,310 ----
    select (handle+1, &rfds, NULL, NULL, &tv);
  
  /* END OF WORKAROUND */
+ 
+       if (tcflush(handle, TCIFLUSH) < 0) {             /* Flush the serial port      
+      */
+         close(handle);
+         return FALSE;
+       }
  
        ioport.handle = handle;                           /* Record the handle         
        */
        ioport.baud   = baud;                             /* Record the baudrate       
        */
***************************************************************
Linux Smart Card Developers - M.U.S.C.L.E.
(Movement for the Use of Smart Cards in a Linux Environment)
http://www.linuxnet.com/smartcard/index.html
***************************************************************

Reply via email to