Hi people,
I wrote an application that allows to display data on the PC.
The application also works wit the SerialForwarder but there is a problem. I
can send over the serial port like shown in the tutorials by changing the
ActiveMessageC component to SerialActiveMessageC, etc.
Since I did that I cannot receive any data from the Receive.reveive event.
I posted the code below.
AM_MEASURINGDATAPACKET is defined in Global.h. Like I wrote when i implement a
timer that periodically sends a measuringDataPacket to the serial port it gets
displayed but the receiving of messages does not work any longer. Do I have to
use a second SplitControl interface and wire it to a new ActiveMessageC? I
tried that to but I had no look with the receiving. Any suggestions?
BlinkToRadioAppC:
#include <Timer.h>
#include "BlinkToRadio.h"
#include "Global.h"
configuration BlinkToRadioAppC {
}
implementation {
components MainC;
components LedsC;
components BlinkToRadioC as App;
components SerialActiveMessageC;
//Serial
components new SerialAMSenderC(AM_MEASURINGDATAPACKET);
components new AMReceiverC(AM_MEASURINGDATAPACKET);
App.Boot -> MainC;
App.Leds -> LedsC;
App.Timer0 -> Timer0;
App.SerialPacket -> SerialAMSenderC;
App.SerialControl -> SerialActiveMessageC;
App.SerialSend -> SerialAMSenderC;
App.Receive -> AMReveiver;
BlinkToRadioC:
#include <Timer.h>
#include "BlinkToRadio.h"
#include "Global.h"
module BlinkToRadioC {
uses interface Boot;
uses interface Leds;
uses interface Packet;
uses interface AMPacket as SerialPacket;
uses interface AMSend as SerialSend;
//Radio
uses interface AMPacket;
uses interface AMSend;
uses interface Receive;
//Start Radio
uses interface SplitControl as AMControl; //Is wired with SerialActiveMessageC
//Start Serial
uses interface SplitControl as SerialControl; //Is wired with ActiveMessageC
}
implementation {
uint16_t counter;
message_t pkt;
bool busy = FALSE;
event void Boot.booted() {
call SerialControl.start(); //start serial
}
event void SerialControl.startDone(error_t err) {
if (err == SUCCESS) {
}
else {
call SerialControl.start();
}
}
event void SerialControl.stopDone(error_t err) {
}
event void AMControl.startDone(error_t err) {
if (err == SUCCESS) {
// call Timer0.startPeriodic(TIMER_PERIOD_MILLI);
}
else {
call AMControl.start();
}
}
event void AMControl.stopDone(error_t err) {
}
event void SerialSend.sendDone(message_t* msg, error_t err) {
if (&pkt == msg) {
busy = FALSE;
}
}
event void AMSend.sendDone(message_t* msg, error_t err) {
if (&pkt == msg) {
busy = FALSE;
}
}
event message_t* Receive.receive(message_t* msg, void* payload, uint8_t len){
measuringData_t *pData;
if (len == sizeof(measuringData_t) && !busy) {
measuringData_t* receivedData = (measuringData_t*)payload;
pData=call SerialSend.getPayload(&pkt, sizeof(measuringData_t));
*pData=*receivedData;
if (call SerialSend.send(0,
&pkt, sizeof(measuringData_t)) == SUCCESS) {
busy = TRUE;
}
}
return msg;
}
}
--
Psssst! Schon vom neuen GMX MultiMessenger gehört? Der kann`s mit allen:
http://www.gmx.net/de/go/multimessenger01
_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help