[Tinyos-2-commits] CVS: tinyos-2.x/support/sdk/c serialsource.c, 1.3, 1.4

David Gay idgay at users.sourceforge.net
Thu Jul 5 09:02:52 PDT 2007


Update of /cvsroot/tinyos/tinyos-2.x/support/sdk/c
In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv16088

Modified Files:
	serialsource.c 
Log Message:
read of ack in write_packet should behave as if source was non-blocking


Index: serialsource.c
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/support/sdk/c/serialsource.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** serialsource.c	6 Jun 2007 16:17:42 -0000	1.3
--- serialsource.c	5 Jul 2007 16:02:50 -0000	1.4
***************
*** 193,208 ****
  }
  
! /* Work around buggy usb serial driver (returns 0 when no data is
!    available, independent of the blocking/non-blocking mode).
!    Mac OS X seems to like to do this too (at least with a Keyspan 49WG)
! */
! static int buggyread(serial_source src, void *buffer, int n)
  {
    fd_set fds;
    int cnt;
  
!   if (src->non_blocking)
      {
        cnt = read(src->fd, buffer, n);
        if (cnt == 0)
  	{
--- 193,209 ----
  }
  
! static int serial_read(serial_source src, int non_blocking, void *buffer, int n)
  {
    fd_set fds;
    int cnt;
  
!   if (non_blocking)
      {
        cnt = read(src->fd, buffer, n);
+ 
+       /* Work around buggy usb serial driver (returns 0 when no data
+ 	 is available). Mac OS X seems to like to do this too (at
+ 	 least with a Keyspan 49WG).
+       */
        if (cnt == 0)
  	{
***************
*** 470,476 ****
  }
  
! static int read_byte(serial_source src)
! /* Returns: next byte (>= 0), or -1 if no data available and the source
!      is non-blocking.
  */
  {
--- 471,476 ----
  }
  
! static int read_byte(serial_source src, int non_blocking)
! /* Returns: next byte (>= 0), or -1 if no data available and non-blocking is true.
  */
  {
***************
*** 479,485 ****
        for (;;)
  	{
! 	  int n = buggyread(src, src->recv.buffer, sizeof src->recv.buffer);
  
! 	  if (n == 0) /* Can't occur because of buggyread bug workaround */
  	    {
  	      message(src, msg_closed);
--- 479,485 ----
        for (;;)
  	{
! 	  int n = serial_read(src, non_blocking, src->recv.buffer, sizeof src->recv.buffer);
  
! 	  if (n == 0) /* Can't occur because of serial_read bug workaround */
  	    {
  	      message(src, msg_closed);
***************
*** 510,514 ****
  			       const uint8_t *packet, int count);
  
! static void read_and_process(serial_source src)
  /* Effects: reads and processes up to one packet.
  */
--- 510,514 ----
  			       const uint8_t *packet, int count);
  
! static void read_and_process(serial_source src, int non_blocking)
  /* Effects: reads and processes up to one packet.
  */
***************
*** 518,522 ****
    for (;;)
      {
!       int byte = read_byte(src);
  
        if (byte < 0)
--- 518,522 ----
    for (;;)
      {
!       int byte = read_byte(src, non_blocking);
  
        if (byte < 0)
***************
*** 632,636 ****
        struct packet_list *entry;
  
!       read_and_process(src);
        entry = pop_protocol_packet(src, P_PACKET_NO_ACK);
        if (entry)
--- 632,636 ----
        struct packet_list *entry;
  
!       read_and_process(src, src->non_blocking);
        entry = pop_protocol_packet(src, P_PACKET_NO_ACK);
        if (entry)
***************
*** 764,768 ****
        struct packet_list *entry;
        
!       read_and_process(src);
        entry = pop_protocol_packet(src, P_ACK);
        if (entry)
--- 764,768 ----
        struct packet_list *entry;
        
!       read_and_process(src, TRUE);
        entry = pop_protocol_packet(src, P_ACK);
        if (entry)



More information about the Tinyos-2-commits mailing list