Hi,

I have trouble sending msg from laptop (using c++) code to tmote.  All the
code is at the bottom. I have no problem reading the data from the serial
but sending it back dooesn't seam to work. Anyone knows why? Thanks.

Indy

CODE :nesC and tinyOS

configuration TimeSync
{
}

implementation
{
 components Main, TimeSyncM,
    TimerC,
    GenericComm as Comm,
    UARTComm,
    LedsC;

 Main.StdControl -> TimeSyncM.StdControl;
...
 Main.StdControl -> UARTComm;

...
 TimeSyncM.SubControl -> Comm;
 TimeSyncM.ReceiveMsg -> Comm.ReceiveMsg[AM_INTMSG];
 TimeSyncM.CommControl -> Comm;
 TimeSyncM.Leds -> LedsC;
 TimeSyncM.UCommControl -> UARTComm;
 TimeSyncM.UReceive -> UARTComm.ReceiveMsg[AM_URECEIVEMSG];
 TimeSyncM.USend -> UARTComm.SendMsg[AM_USENDMSG];
}


AND The Module:
#define BASE_STATION


module TimeSyncM
{
 provides
 {
   interface StdControl;
 }
 uses
 {
    interface StdControl as SubControl;
    interface StdControl as CommControl;

    interface SendMsg as Send;
    interface ReceiveMsg as ReceiveMsg;
...
    interface StdControl as UCommControl;
   interface SendMsg as USend;
   interface ReceiveMsg as UReceive;
 }
}

implementation
{
 ...

 /**
  * Signalled when the reset message counter AM is received.
  * @return The free TOS_MsgPtr.
  */
 event TOS_MsgPtr UReceive.receive(TOS_MsgPtr m)
 {
   call Leds.greenToggle();

   return m;
 }


 /**
  * Signalled when the previous packet has been sent.
  * @return Always returns SUCCESS.
  */
 event result_t USend.sendDone(TOS_MsgPtr sent, result_t success)
 {
   return SUCCESS;
 }
}


CODE C++

main
{
.....
   struct TOS_Msg msgOUT;
   char output_buffer[sizeof(msgOUT)];
   char data[10] = {'h', 'e', 'l', 'l', 'o'};

   msgOUT.addr = 0xffff;
   msgOUT.type = 0x42;       //no return type
   msgOUT.group = 0x7d;
   msgOUT.length = (uint8_t) 5;
   memcpy(msgOUT.data, data, 5);
   msgOUT.crc = calc((uint8_t *) &msgOUT, 5+5);

   memset(output_buffer, 0, TOS_PACKET_LENGTH);
   memcpy(output_buffer, &msgOUT, sizeof(msgOUT));

   write(fd, pData, sizeof(msgOUT));
}
_______________________________________________
Tinyos-help mailing list
Tinyos-help@Millennium.Berkeley.EDU
https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

Reply via email to