Hello,
I am Victor Rosello, i am trying to send a command to a base station
using the serial port and transmit this message using the radio.
After some test I realize that if I have SerailActiveMessageComponentC
and ActiveMessageComponentC running at the same time using the
SplicControlC.start() the base station does not get the serial port
messages. I am using a telosb-like mote.
To reproduce the failure I modified the TestSerial application. as follows.
I don`t know how to dela with this problem, to use the
ActiveMessageComponentC to use radio communications and
SerailActiveMessageComponentC to use the serial port at the same time.
-- TestSerialC.nc with
module TestSerialC {
uses {
interface SplitControl as Control;
interface SplitControl as RadioControl; // Added interface
interface Leds;
interface Boot;
interface Receive;
interface AMSend;
interface Timer<TMilli> as MilliTimer;
interface Packet;
}
}
implementation {
message_t packet;
bool locked = FALSE;
uint16_t counter = 0;
event void Boot.booted() {
call Control.start();
}
event void MilliTimer.fired() {
counter++;
if (locked) {
return;
}
else {
test_serial_msg_t* rcm = (test_serial_msg_t*)call
Packet.getPayload(&packet, sizeof(test_serial_msg_t));
if (rcm == NULL) {return;}
if (call Packet.maxPayloadLength() < sizeof(test_serial_msg_t)) {
return;
}
rcm->counter = counter;
if (call AMSend.send(AM_BROADCAST_ADDR, &packet,
sizeof(test_serial_msg_t)) == SUCCESS) {
locked = TRUE;
}
}
}
event message_t* Receive.receive(message_t* bufPtr,
void* payload, uint8_t len) {
if (len != sizeof(test_serial_msg_t)) {return bufPtr;}
else {
test_serial_msg_t* rcm = (test_serial_msg_t*)payload;
if (rcm->counter & 0x1) {
call Leds.led0On();
}
else {
call Leds.led0Off();
}
if (rcm->counter & 0x2) {
call Leds.led1On();
}
else {
call Leds.led1Off();
}
if (rcm->counter & 0x4) {
call Leds.led2On();
}
else {
call Leds.led2Off();
}
return bufPtr;
}
}
event void AMSend.sendDone(message_t* bufPtr, error_t error) {
if (&packet == bufPtr) {
locked = FALSE;
}
}
event void Control.startDone(error_t err) {
if (err == SUCCESS) {
call MilliTimer.startPeriodic(1000);
call RadioControl.start(); // Added start call
}
}
event void Control.stopDone(error_t err) {}
event void RadioControl.stopDone(error_t err) {} // Added events
event void RadioControl.startDone(error_t err) {} // Added events
}
-- TestSerialApp.nc with ActiveMessageC component
#include "TestSerial.h"
configuration TestSerialAppC {}
implementation {
components TestSerialC as App, LedsC, MainC;
components SerialActiveMessageC as AM;
components ActiveMessageC as RadioAM; // Added component
components new TimerMilliC();
App.Boot -> MainC.Boot;
App.Control -> AM;
App.RadioControl -> RadioAM; // Added link
App.Receive -> AM.Receive[AM_TEST_SERIAL_MSG];
App.AMSend -> AM.AMSend[AM_TEST_SERIAL_MSG];
App.Leds -> LedsC;
App.MilliTimer -> TimerMilliC;
App.Packet -> AM;
}
_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help