Hello,

I have a problem in sending message from PC to a mica2 mote. I use a mote
with the basestation application at serial port of PC. I use the following
JAVA code (changed from the net.tinyos.tools.send) to send the message "00
FF FF 00 00 04 00 06 02 02" to the mote. However, the mote cannot receive
the last two bytes information "02 02", instead, it always reads the payload
field data as "00 00". If anyone has encounter the same problem or find any
mistakes in my code, please tell me what is the possible problem. Thank you
very much!

The JAVA code to send messages to the mote:

        String[] data = {"00","FF","FF","00","00","04","00","06","02","02"};
        System.out.println("Start");
        try {

            String source = "ser...@com4:mica2";
            PacketSource com = BuildSource.makePacketSource(source);
            com.open(PrintStreamMessenger.err);
            byte[] packet;
            for (int i = 0; i < data.length; i++)
                packet[i] = (byte)Integer.parseInt(data[i], 16);

            if(com.writePacket(packet) == true)
            {
                System.out.println("Successfully send packet");
            } else {
                System.out.println("Failing to sens packet");
            }

        } catch (IOException e) {
            System.out.println("Error: " + e);
        }

The message structure in mote application is:

typedef nx_struct TempMsg {
  nx_uint16_t data;
} TempMsg;

and I use the code

event message_t* Receive.receive(message_t* msg, void* payload, uint8_t
len){

    if (len == sizeof(TempMsg)) {

        TempMsg* recpkt = (TempMsg*)payload;
        mlen = call Packet.payloadLength(msg);
        mdata = recpkt->data;
        pkt = msg;

        call Timer1.startOneShot(500);    // send back the payload field
data
    }

    return msg;
  }

in the mote application to receive the message.
_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

Reply via email to