[Tinyos-help] Problem with UartDetectC
Ole Bischoff
s01item2 at item.uni-bremen.de
Thu Dec 21 08:43:14 PST 2006
Perfect,
I only changed UartDetectC to UartPresenceC and now the whole
app works just fine.
Thanks a lot, Joe.
Regards,
OLE
----- Original Message -----
From: "Joe Polastre" <joe at polastre.com>
To: "Ole Bischoff" <s01item2 at item.uni-bremen.de>
Cc: "TinyOs Help List" <tinyos-help at millennium.berkeley.edu>
Sent: Thursday, December 21, 2006 5:04 PM
Subject: Re: [Tinyos-help] Problem with UartDetectC
> UartDetectC is a connection based protocol, which means the PC must
> send messages to the mote and establish a connection for the
> isConnected() function to return true.
>
> I believe that you are looking for UartPresenceC, which tells you if
> the mote is connected to the PC but does not guarantee that the PC can
> actually communicate with the mote.
>
> Please see the documentation in /opt/moteiv/doc/nesdoc for more
> information
>
> -Joe
>
> On 12/21/06, Ole Bischoff <s01item2 at item.uni-bremen.de> wrote:
>>
>>
>>
>>
>> Hi,
>>
>> I tried to detect, whether a mote is connected to a PC or not. Therefor
>> I used the component UartDetectC and the interface Detect, which offers
>> the command isConnected() to determinine if a mote is connected to the
>> UART as well as the events connected() and disconnect() to signal if the
>> mote has been connected/disconnected.
>>
>> For that, I wrote a test program PCLink with the following function (code
>> at
>> bottom):
>> - every 100ms the connection status of the mote will be read
>> (isConnected())
>> and signaled with the blue LED (connection => LED on, no connection
>> =>
>> LED off).
>> - if the mote has been connected to a PC (connected()) => the green LED
>> will
>> glow for one second.
>>
>> - if the mote has been disconnected to a PC (disconnected()) => the red
>> LED will glow for one second.
>>
>> Running this programm always signals the disconnected() event, wheter a
>> mote
>> has been connected or disconnected. The connected() event never appeared
>> and
>> the command isConnected() always returns FALSE (no connection).
>> I also tried the app while running the java tool Listen in a cygwin
>> shell,
>> no difference.
>>
>> If someone has a hint, fix or comment please let me know. Note, that I'm
>> able to send
>> data over the UART. My intention is to use this detection to nominate
>> every
>> mote as
>> another basestation in a multi-hop network, if it is connected to a PC.
>>
>> The Tmote Sky is connected directly to the PC (no USB-hub or extension
>> cable) and
>> I'm using Boomerang 2.0.4, a Tmote Sky and Windows XP.
>>
>>
>> Best regards,
>> Ole Bischoff
>>
>>
>>
>> ------ PCLink.nc
>> ------------------------------------------------------------------------------------------------------
>> configuration PCLink {
>> }
>> implementation {
>> components Main;
>> components PCLinkM as Impl
>> , UartDetectC
>> , LedsC
>> , TimerC;
>>
>> Main.StdControl -> TimerC;
>> Main.StdControl -> Impl;
>>
>> Impl.Timer1 -> TimerC.Timer[unique("Timer")];
>> Impl.Timer2 -> TimerC.Timer[unique("Timer")];
>> Impl.Leds -> LedsC;
>> Impl.Detect -> UartDetectC;
>> }
>>
>> ------ PCLinkM.nc
>> -----------------------------------------------------------------------------------------------------
>> module PCLinkM {
>> provides {
>> interface StdControl;
>> }
>> uses {
>> interface Timer as Timer1;
>> interface Timer as Timer2;
>> interface Leds;
>> interface Detect;
>> }
>> }
>> implementation {
>>
>> /************************* STD CONTROL **********************/
>> command result_t StdControl.init() {
>> return SUCCESS;
>> }
>>
>> command result_t StdControl.start() {
>> call Timer2.start( TIMER_REPEAT, 100 );
>>
>> return SUCCESS;
>> }
>>
>> command result_t StdControl.stop() {
>> call Timer1.stop();
>> call Timer2.stop();
>>
>> return SUCCESS;
>> }
>>
>> /************************* TIMER ****************************/
>> event result_t Timer1.fired() {
>> call Leds.greenOff();
>> call Leds.redOff();
>>
>> return SUCCESS;
>> }
>>
>> event result_t Timer2.fired() {
>> if ( call Detect.isConnected() )
>> call Leds.yellowOn();
>> else
>> call Leds.yellowOff();
>>
>> return SUCCESS;
>> }
>>
>> /************************* DETECT ***************************/
>> event void Detect.connected() {
>> call Leds.greenOn();
>> call Timer1.start( TIMER_REPEAT, 1024 );
>> }
>>
>> event void Detect.disconnected() {
>> call Leds.redOn();
>> call Timer1.start( TIMER_REPEAT, 1024 );
>> }
>>
>> }
>> --------------------------------------------------------------------------------------------------------------------------------
>> _______________________________________________
>> Tinyos-help mailing list
>> Tinyos-help at Millennium.Berkeley.EDU
>> https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.millennium.berkeley.edu/pipermail/tinyos-help/attachments/20061221/108d05ed/attachment.htm
More information about the Tinyos-help
mailing list