[Tinyos-help] Tmote sky serial comunication

muflacek at centrum.cz muflacek at centrum.cz
Mon Jan 1 07:55:19 PST 2007


Hello, 
 
Pleas I need a help with the serial communication. I have a Tmote sky and
I also have some GPS board. I need to comunicate with these two devices over
the serial line and I am not very successfull. My TinyOs version is
Boomerang 2.0.4.
I need to send a special packet [ NMEA message - for example
$PSRF100,9600,8,1,0*0C(CRLF) ] from the Tmote, so I send it as an array of
bytes with HPLUSARTControl interface like this:


event void ResourceSend.granted(uint8_t rh) 
  {  
    Uint8_t i;
    //-- Make any necessary UART changes
      //call UartControl.disableSPI();
      //call UartControl.enableUART();
    call UartControl.enableUART();
      //call UartControl.disableUARTRx();
    call UartControl.setModeUART();
    call UartControl.setClockSource(SSEL_SMCLK);
    call UartControl.setClockRate(UBR_SMCLK_38400, UMCTL_SMCLK_38400);
    call UartControl.disableRxIntr();
    call UartControl.enableTxIntr();

  //-- Send data 

    for (i = 0; i < sizeof(setUart)-1; i++) // setUart = array of chars of the NMEA message
    {
        call UartControl.tx( setUart[i] );  // message transmission
        while ( !(call UartControl.isTxEmpty()) ) ;
    };
  
//-- Release the resource
      ....
  

The problem is that I need to send 20 characters, but sometimes I send 5
chars, sometimes 10 chars, sometimes 12 and so on. 
But when I make a short delay after sending each byte, it works quite
fine. But It's not very effective. I also tried to work with event TxDone() from
HPLUSARTFeedback, but it's the same problem. Pleas can you give me some advice
how to send serial data?
I am also not very shure how to recive bytes. How do I know, when a byte is
comming? What if another byte comes before I read the previous one? 

 Thanks a lot for any help.
Bye, Jan



More information about the Tinyos-help mailing list