Hi Urs,
thanks for your reply, I checked my code and commented the conditions out and
set all LEDs instead of one. My module still doesn't call the receive event
handler if I send a packet.
I can't match all bytes of the frame with its function (3 and 7 are missing).
The frame I try to receive with my module:
1 2 3 4 5 6 7 8 9 10 1
Hex: 7E 45 00 FF FF 00 00 02 00 89 00 48 2D FD 7E
1 Framing Byte
2 Framer-level dispatch (Type of the frame) 45 = Data no ACK
3 ??
4 Destination addr. 2 byte (broadcast)
5 Source addr. 2 byte
6 Length (byte Payload)
7 ??
8 AM_ID
9 Payload 2 byte
10 CRC 2 byte
If I compare my frame with the TEP113 3.6 Packet Format, there is a difference.
____________________________________________
| | | | | | | |
| | | | | | | |
|_|_|_|_|_______________________________|__|_|
F P S D Payload CR F
F = Framing byte, denoting start of packet: HdlcTranslateC
P = Protocol byte: SerialP
S = Sequence number byte: SerialP
D = Packet format dispatch byte: SerialDispatcherC
Payload = Data payload (stored in SerialDispatcherC): SerialDispatcherC
CR = Two-byte CRC over S to end of Payload: SerialP
F = Framing byte denoting end of packet: HdlcTranslateC
Can you check my frame and explain to me the missing bytes and the relation
between TEP113?
Do you have an idea how to figure out what's my receiving problem?
Cheers,
Mario
-----Ursprüngliche Nachricht-----
Von: Urs Hunkeler [mailto:[email protected]]
Gesendet: Sonntag, 17. Oktober 2010 08:38
An: Mario Riesner; [email protected]
Betreff: Re: [Tinyos-help] unable to receive UART frame
Hi Mario,
The AM ID is the Active Message ID, which is similar to a port number in
TCP or UDP. You can have multiple services or protocols running on a
mote (with multiple Receive interfaces) and this ID indicates which part
of the code should receive the message. A match is necessary.
I am not sure whether the serial code also matches the node ID. In any
case it is good programming practice to also properly set the node ID of
the receiving node, even if the node is directly connected to the
computer. A simple solution would be to set it to the broadcast address
(0xFFFF).
In your code a few lines later in the Receive event handler you check a
condition and turn led0 off again if the condition is not met. If you
expect led0 to light up, make sure you do not accidentally turn it off
again.
Cheers,
Urs
On 10/14/10 4:05 PM, Mario Riesner wrote:
> Hi all,
>
> Im new with TinyOS and I need to send data (instructions) to TinyOS over
> UART.
> Im using SerialAMSenderC and the event message_t* Receive.receive () is not
> called if I send a TinyOS frame to the module. Its the TestSerial example
> and I try to get it running on a Meshbean platform. Send frames to a PC is
> already possible. Does anyone know a solution? Thats a frame I tried to
> receive: 7E 45 00 FF FF 00 00 02 00 89 00 48 2D FD 7E
> What is the am_id (in my case 0x89)? Is there a match necessary?
>
> Thank you very much!
>
>
> //TestSerialApp.nc
> #include "TestSerial.h"
>
> configuration TestSerialAppC {}
> implementation {
> components TestSerialC as App, LedsC, MainC;
> components SerialActiveMessageC as AM;
> components new TimerMilliC();
>
> App.Boot -> MainC.Boot;
> App.Control -> AM;
> 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;
> }
>
>
> // TestSerialC.nc
> #include "Timer.h"
> #include "TestSerial.h"
>
> module TestSerialC {
> uses {
> interface SplitControl as Control;
> 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) {
> call Leds.led0On(); // test is event triggered?
> 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);
> }
> }
> event void Control.stopDone(error_t err) {}
> }
>
>
> //TestSerial.h
> #ifndef TEST_SERIAL_H
> #define TEST_SERIAL_H
>
> typedef nx_struct test_serial_msg {
> nx_uint16_t counter;
> } test_serial_msg_t;
>
> enum {
> AM_TEST_SERIAL_MSG = 0x89,
> };
>
> #endif
_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help