Changeset 69


Ignore:
Timestamp:
05/05/09 06:30:51 (12 years ago)
Author:
rorothetroll
Message:

csctapi/io_serial.c : update of the mac os x serial IO. Works on SECA at 3.58 and 6MHz, not on viaccess.
As I rewrote my own code (looking at the existing one) I think this is most probably a timing issue.
The initial problem on OS X are the IO_Serial_WaitToWrite and IO_Serial_WaitToRead function that always
return a timeout as I have to set the port in O_NDELAY for it to work on OS X, O_SYNC doesn't work.
I might try to fix these routine instead and see how it goes but I'm affraid that without the sync mode this
is not going to work as expected.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/csctapi/io_serial.c

    r68 r69  
    696696   nByte=0;
    697697   length= size * (_in_echo_read ? (1+io_serial_need_dummy_char) : 1);
    698 #ifdef DEBUG_IO
    699     printf("size = %d\n", size);
    700     printf("length = %d\n", length);
    701     printf("timeout = %d\n", timeout);
     698
     699    if((io->com!=RTYP_SCI) && (io->wr>0))
     700    {
     701        BYTE buf[256];
     702        int n = io->wr;
     703        io->wr = 0;
     704   
     705        if(!IO_Serial_Read_MacOSX (io, timeout, n, buf))
     706        {
     707            return FALSE;
     708        }
     709    }
     710
     711#ifdef DEBUG_IO
     712   printf ("IO: IO_Serial_Read_MacOSX\n");
     713    printf ("IO: Receiving %d byte(s): ",size);
     714    fflush (stdout);
    702715#endif
    703716   while(TRUE)
     
    710723         if(m_timeout==timeout)
    711724         {
     725#ifdef DEBUG_IO
     726            printf ("TIMEOUT\n");
     727            fflush (stdout);
     728#endif
    712729            tcflush (io->fd, TCIFLUSH);
    713730            return FALSE;
     
    718735         m_timeout=0;
    719736#ifdef DEBUG_IO
    720          printf("value read : %c\n",c);
    721          fflush (stdout);
     737            printf ("%02X ", c);
     738            fflush (stdout);
    722739#endif
    723740         data[_in_echo_read ? totalRead/(1+io_serial_need_dummy_char) : totalRead] = c;
    724741         totalRead+=nByte;
    725 #ifdef DEBUG_IO
    726          printf("value totalRead : %d\n",totalRead);
    727 
    728 #endif
    729742         if(length == totalRead)
    730743            break;
     
    732745   }
    733746   
     747   _in_echo_read = 0;
     748
     749#ifdef DEBUG_IO
     750   printf ("\n");
     751   fflush (stdout);
    734752   printf("exiting IO_Serial_Read_MacOSX [true]\n" );
     753#endif
    735754   return TRUE;
    736755}
     
    747766   int i_w;
    748767   unsigned count, to_send;
     768
     769#ifdef DEBUG_IO
     770    unsigned i;
     771    printf ("IO: IO_Serial_Write_MacOSX\n");
     772    printf ("IO: Sending %d byte(s) : ",size);
     773    fflush (stdout);
     774#endif
    749775   
    750776   m_delay=0;
     
    770796      {
    771797         tcflush (io->fd, TCIFLUSH);
     798         if(io->com!=RTYP_SCI)
     799            io->wr += nByte;
     800
     801#ifdef DEBUG_IO
     802         printf ("ERROR\n");
    772803         printf("exiting IO_Serial_Write_MacOSX [false]\n" );
     804         fflush (stdout);
     805#endif
    773806         return FALSE;
    774807      }
    775808      if(delay)
    776809         usleep(delay*1000L);
     810
     811      if(io->com!=RTYP_SCI)
     812         io->wr += to_send;
     813
     814#ifdef DEBUG_IO
     815      for (i=0; i<(1+io_serial_need_dummy_char)*to_send; i++)
     816         printf ("%02 X ", data_w[count + i]);
     817      fflush (stdout);
     818#endif
    777819     
    778820   }
    779821
     822#ifdef DEBUG_IO
     823    printf ("\n");
     824    fflush (stdout);
     825#endif
    780826    return TRUE;
    781827}
     828
    782829
    783830
Note: See TracChangeset for help on using the changeset viewer.