[Tinyos-2-commits] CVS: tinyos-2.x/tos/chips/atm128/spi Atm128SpiP.nc, 1.5, 1.6

Phil Levis scipio at users.sourceforge.net
Wed Feb 28 09:34:02 PST 2007


Update of /cvsroot/tinyos/tinyos-2.x/tos/chips/atm128/spi
In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv16349

Modified Files:
	Atm128SpiP.nc 
Log Message:
Fix zero-length send bug: just post a task.


Index: Atm128SpiP.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/chips/atm128/spi/Atm128SpiP.nc,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** Atm128SpiP.nc	25 Jan 2007 19:12:23 -0000	1.5
--- Atm128SpiP.nc	28 Feb 2007 17:33:59 -0000	1.6
***************
*** 204,207 ****
--- 204,224 ----
    }
  
+ 
+   task void zeroTask() {
+      uint8_t* rx;
+      uint8_t* tx;
+      uint16_t  myLen;
+      atomic {
+        rx = rxBuffer;
+        tx = txBuffer;
+        myLen = len;
+        rxBuffer = NULL;
+        txBuffer = NULL;
+        len = 0;
+        pos = 0;
+        signal SpiPacket.sendDone(tx, rx, myLen, SUCCESS);
+      }
+   }
+ 
    /**
     * Send bufLen bytes in <tt>writeBuf</tt> and receive bufLen bytes
***************
*** 213,219 ****
     * This command only sets up the state variables and clears the SPI:
     * <tt>sendNextPart()</tt> does the real work.
!    *
     */
!   
    
    async command error_t SpiPacket.send(uint8_t* writeBuf, 
--- 230,240 ----
     * This command only sets up the state variables and clears the SPI:
     * <tt>sendNextPart()</tt> does the real work.
!    * 
!    * If there's a send of zero bytes, short-circuit and just post
!    * a task to signal the sendDone. This generally occurs due to an
!    * error in the caler, but signaling an event will hopefully let
!    * it recover better than returning FAIL.
     */
! 
    
    async command error_t SpiPacket.send(uint8_t* writeBuf, 
***************
*** 227,234 ****
        pos = 0;
      }
!     
!     discard = call Spi.read();
!     
!     return sendNextPart();
    }
  
--- 248,259 ----
        pos = 0;
      }
!     if (bufLen > 0) {
!       discard = call Spi.read();
!       return sendNextPart();
!     }
!     else {
!       post zeroTask();
!       return SUCCESS;
!     }
    }
  



More information about the Tinyos-2-commits mailing list