[Tinyos-help] Problem with UartDetectC
Ole Bischoff
s01item2 at item.uni-bremen.de
Thu Dec 21 05:31:50 PST 2006
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 );
}
}
--------------------------------------------------------------------------------------------------------------------------------
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.millennium.berkeley.edu/pipermail/tinyos-help/attachments/20061221/6cafd224/attachment.html
More information about the Tinyos-help
mailing list