Hi all,

I am trying to send control messages from PC to motes through UART. Since
the program run on PC was written in C#, I could not use the java code
directly. I tried to confirm the package form by modifying the TestSerial
application as follows:

/*TestWriteSerial.h*/
#ifndef TEST_WRITE_SERIAL_H
#define TEST_WRITE_SERIAL_H
typedef nx_struct test_serial_msg {
  nx_uint8_t counter;
} test_serial_msg_t;
enum {
  AM_TEST_SERIAL_MSG = 9,
};
#endif
/*TestWriteSerialAppC.nc*/
#include "TestWriteSerial.h"
configuration TestWriteSerialAppC {}
implementation {
  components TestWriteSerialC as App, LedsC, MainC;
  components SerialActiveMessageC as AM;
  App.Boot -> MainC.Boot;
  App.Control -> AM;
  App.Receive -> AM.Receive[AM_TEST_SERIAL_MSG];
  App.Leds -> LedsC;
}

/*TestWriteSerialC.nc*/
#include "TestWriteSerial.h"
module TestWriteSerialC {
  uses {
    interface SplitControl as Control;
    interface Leds;
    interface Boot;
    interface Receive;
  }
}
implementation {
  event void Boot.booted() {
    call Control.start();
  }

  event message_t* Receive.receive(message_t* bufPtr,
       void* payload, uint8_t len) {
 call Leds.led0On(); //indicate the mote have received a msg form UART
    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 Control.startDone(error_t err) {
    if (err == SUCCESS) {
    }
  }
  event void Control.stopDone(error_t err) {}
}
And then I send a package "00 FF FF 00 00 01 00 09 05" from UART, but
nothing happened, even the red light that indicates having receive a message
from UART did not on at all. I modified the package as the the format of
UART receiving message from mote, that is "7E 45 00 FF FF 00 00 01 00 09 05
DD 1D 7E", the mote still did not work.

I have also tried to find how the java application send the data package,
but what I found in AbstractSource.java is a function that always
return TRUE ( writeSourcePacket(byte[] packet) ). So I did not know what
happened during the sending process.

Anyone has any idea?

Thanks in advance!

Jennifer
_______________________________________________
Tinyos-help mailing list
Tinyos-help@millennium.berkeley.edu
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

Reply via email to