Thanks Xiaoyang  for the help and suggestions.

Will go through the mentioned documentations and try "*byte-by-byte" *
handling.

Regards
Jobish john



On Mon, Jan 1, 2018 at 9:18 PM, Xiaoyang Zhong <xiaoz...@umail.iu.edu>
wrote:

> The idea is to use "*async event void UartStream.receivedByte(uint8_t
> data)*" to process the stream *"byte-by-byte"*, instead of calling the 
> "*UartSream.receive(buf,
> len)"* function. The later would return only when exactly "len" bytes are
> received, and it would hold the resource.
>
> Processing the uart stream byte by byte is actually how the serial library
> handles the received packets, since the packet length usually varies.
> Please read the code in */tos/lib/serial* carefully, especially the
> implementations in SerialDispatcherP, HdlcTranslateC, and SerialP.
>
> You should also configure the serial port to the same baud rate as the
> sensor. An example uartstream with configuration is provided here:
> http://tinyos-help.10906.n7.nabble.com/any-working-example-of-UartStream-
> receive-td4750.html.
>
> Also, the following link using the Decagon MPS-2 sensor with telosb, as
> your reference, especially part 2: https://zhongcs.wordpress.
> com/2015/02/15/decagon-mps-2-water-potential-sensor-with-telosb-mote/.
>
>
>
>
>
> On Mon, Jan 1, 2018 at 9:23 AM, Jobish John <jobishjohn.m...@gmail.com>
> wrote:
>
>> Hi,
>>
>> I am using telosb mote and UartStream interface in nesc to receive data
>> from a sensor (Tinyos 2.1.2). Once UartStream.receive() is initiated and
>> due to some reasons if the data is not received, the mote will keep on
>> waiting for the data and is not able to receive or transmit any packets
>> after that.
>>
>> I have tried to implement a timeout, based on a timer and resource
>> interface as shown below. But it could not solve the issue.
>>
>> uses interface Resource as Resource_uart_TIVAC;
>> uses interface UartStream as uart_TIVAC;
>> -----------
>> -----------
>> event void Resource_uart_TIVAC.granted()
>> {
>>         if ((call uart_TIVAC.receive(refbuf, 4))== SUCCESS)
>>             call uarttimeout_timer.startOneShot(1024);
>> }
>>   ------------
>>   event void uarttimeout_timer.fired()
>>   {
>>         if(call Resource_uart_TIVAC.release()!= SUCCESS)
>>         {
>>             printf("uart not released\n");
>>             printfflush();
>>         }
>>     }
>> --------------
>> components new Msp430Uart0C() as uart_sensor;
>>
>> The uart is not getting released and telosb radio is not able to transmit
>> or receive any packets after that. Please suggest a way to handle this.
>>
>> Thanks for your valuable time.
>>
>> Regards
>> Wishing you a happy new year 2018..
>> Jobish John
>>
>> _______________________________________________
>> Tinyos-help mailing list
>> Tinyos-help@millennium.berkeley.edu
>> https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
>>
>
>
_______________________________________________
Tinyos-help mailing list
Tinyos-help@millennium.berkeley.edu
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

Reply via email to