Thanks for trying to help,
this is the task sendSerialMessage:
task void sendSerialMessage(){
if (locked) {
post sendSerialMessage();
return;
}
else {
test_serial_msg_t* rcm = (test_serial_msg_t*)call
PacketSerial.getPayload(&packet_one, NULL);
if (call PacketSerial.maxPayloadLength() < sizeof(test_serial_msg_t))
{
return;
}
rcm -> counter = counter_val; //counter_val is a uint16_t global
variable. Has the value received inReceive.receive(message_t* bufPtr, void*
payload, uint8_t len).
if (call SerialAMSend.send(0xffff, &packet_one,
sizeof(test_serial_msg_t)) == SUCCESS) {
locked = TRUE;
}
}
}
These is how I wire the componentes:
configuration RadioCountToLedsAppC { }
implementation {
components MainC, RadioCountToLedsC as App, LedsC;
components new AMSenderC(AM_RADIO_COUNT_MSG);
components new AMReceiverC(AM_RADIO_COUNT_MSG);
components new TimerMilliC();
components ActiveMessageC;
components SerialActiveMessageC; //----- SERIAL TEST
components new SerialAMSenderC(AM_TEST_SERIAL_MSG);//----- SERIAL TEST
App.SerialAMSend -> SerialAMSenderC.AMSend; //----- SERIAL TEST
App.SerialControl -> SerialActiveMessageC; //----- SERIAL TEST
App.PacketSerial -> SerialAMSenderC; //----- SERIAL TEST
App.Boot -> MainC.Boot;
App.Receive -> AMReceiverC;
App.AMSend -> AMSenderC;
App.RadioControl -> ActiveMessageC;
App.Leds -> LedsC;
App.MilliTimer -> TimerMilliC;
App.Packet -> AMSenderC;
}
----
module RadioCountToLedsC {
uses {
interface Leds;
interface Boot;
interface Receive;
interface AMSend;
interface Timer<TMilli> as MilliTimer;
interface SplitControl as RadioControl;
interface Packet;
//------ Test Serial
interface SplitControl as SerialControl;
interface Packet as PacketSerial;
interface AMSend as SerialAMSend;
//interface Receive as SerialReceive;
}
}
-------------------
Function where Send is done:
event void MilliTimer.fired() {
counter++;
if (locked) {
return;
}
else {
radio_count_msg_t* rcm = (radio_count_msg_t*)call
Packet.getPayload(&packet, NULL);
if (call Packet.maxPayloadLength() < sizeof(radio_count_msg_t)) {
return;
}
rcm->counter = counter;
if (call AMSend.send(AM_BROADCAST_ADDR, &packet,
sizeof(radio_count_msg_t)) == SUCCESS) {
locked = TRUE;
}
}
}
-------------------
Receive function that post the task sendSerialMessage():
event message_t* Receive.receive(message_t* bufPtr,
void* payload, uint8_t len) {
radio_count_msg_t* rcm = NULL;
rcm = (radio_count_msg_t*) payload;
counter_val = rcm -> counter; //counter_val is a uint16_t global
variable
post sendSerialMessage();
}
On Mon, Nov 9, 2009 at 8:42 PM, Razvan Musaloiu-E. <[email protected]>wrote:
> Hi!
>
>
> On Mon, 9 Nov 2009, Ricardo . wrote:
>
> Hello everyone ,
>>
>> I'm having some difficulty in debug my application. My question is if the
>> component ActiveMessageC can be used with the component
>> SerialActiveMessageC, without interfere with each other?
>>
>> In my application when the event AMSend.sendDone (message_to * BufPtr,
>> error_t error) is signal I try to print the value of the sent message, and
>> I
>> get a constant value that does not match the value sent.
>>
>> This is the piece of code used to obtain the value sent:
>>
>>
>> AMSend.sendDone event void (* message_to BufPtr, error_t error) {
>> radio_count_msg_t * rcm = NULL;
>>
>> if (& packet == BufPtr) {
>> rcm = (radio_count_msg_t *) call Packet.getPayload (BufPtr, NULL);
>> counter_val = rcm -> counter;
>> locked = FALSE;
>> post sendSerialMessage ();
>> }
>> }
>>
>>
> Could you please also show us the sendSerialMessage task?
>
>
> In this example, counter_val is the value that will be sent by
>> SerialAMSend.send (AM_BROADCAST_ADDR, & packet_one, sizeof
>> (test_serial_msg_t)).
>>
>> Can I use both without running the risk of coming into conflict?
>>
>
> Yes, you should be able to use simultaneously but you need to be careful
> that the message_t you pass to .send is locked until the .sendDone is
> signaled.
>
I believe that I had careful with this...
Please, if you need anything else let me know.
> --
> Razvan ME
>
--
Ricardo
_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help