I'm writing a piece of software for my project on Wireless Sensor Networks. Right now I'm concerned with injecting various packets into network.
I'm using MIB520 interface board with TinyOS-2.1.2 installed on IRIS mote. I've tried various utilities from sdk/c/sf, as well as tools from net.tinyos.sf.* and net.tinyos.tools.* Java packages.
What I tried so far:
I've been using apps/BaseStation and apps/BaseStation15.4 installed on my mote, alternatively flashing it with apps/test/TestSerial. I have no issues with reading data sent from mote via USB. I can read it just fine using net.tinyos.tools.SerialForwarder or utilities from sdk/c/f or net.tinyos.tools *.
But when it comes to sending data from PC to mote nothing seems to work.I used net.tinyos.tools.Send, serialsend.c, sf.c and sfsend.c. SerialForwarder throws error message after a while, while C utilities throw "no ack" error.
After searching for an answer on TinyOS wiki and SO, I figured it might be an issue with mote sending that "ack" message. I was looking for a way to generate and send legitimate packet to mote as suggested here.
Following article on wiki I found appropriate TEP and used bits listed in it ("7e 40 09 00 be ef 05 7d 5d 06 01 02 03 04 05 7e").
I used Wireshark to sniff USB on which I sent data to mote and I saw same bits sent to mote. My theory is either mote doesn't recognize input I've sent or I use utilities incorrectly. Anyway, this specific event never gets triggered:
event message_t* UartReceive.receive(message_t* bufPtr, void* payload, uint8_t len) {
call Leds.led0On();
return bufPtr;
}
My question is, how do I go about sending data to mote from PC? Perhaps there is some ready to use utility I've overlooked? I've been following instructions in BaseStation15.4 but I'm stuck.
Edit:
From BaseStation/README.txt "BaseStation acknowledges a message arriving over the serial link only if that message was successfully enqueued for delivery to the radio link." That would explain "no ack" in serialsend.c and "write failed" in SerialForwarder.java.
But still, the UartReceive.receive() event never gets triggered, even after clearing its body (in BaseStation) and leaving only LED toggle.
Turns out I made simple mistake of using wrong port for communication.
Here's what I did to run 2 motes: 1. Install BaseStation application on both of them
make iris install,1 mib520,/dev/ttyUSB0
make iris install,2 mib520,/dev/ttyUSB0
With both motes running (including one connected to USB using MIB520) start SerialForwarder
java net.tinyos.sf.SerialForwarder -port 9002 -comm serial@/dev/ttyUSB2:57600
This is where I failed to realise, that serial@/dev/ttyUSB2 isn't always the right interface for communication with motes. It's becouse UART uses 2 USB lines for communication (one for writing to mote, and one for reading data from mote). What I did is I tried few other lines like /ttyUSB1, /ttyUSB3, /ttyUSB4. One of them usually works, no idea how that happens.
Listening to serial@/dev/ttyUSB1:57600
Listening for client connections on port 9002 serial@/dev/ttyUSB1:57600: resynchronising
Now you can use other utilities to send and receive data
java net.tinyos.tools.Send 00 FF FF 00 00 04 22 06 00 02 00 01
java net.tinyos.tools.Listen
Some additional information on my configuration
OS: Linux kali 4.0.0-kali1-amd64 #1 SMP Debian 4.0.4-1+kali2 (2015-06-03) x86_64 GNU/Linux
TinyOS release: 2010-01-20 20:00:48, TinyOs-2.1.2
My env variables (I'm using fish shell)
cat ~/.config/fish/config.fish
# Here we setup the environment variables needed by the tinyos make system
set -Ux "TOSROOT" "/opt/tinyos-release-tinyos-2_1_2"
set -Ux "TOSDIR" "$TOSROOT/tos"
set -Ux "CLASSPATH" "$TOSROOT/support/sdk/java"
set -Ux "MAKERULES" "$TOSROOT/support/make/Makerules"
set -Ux "PYTHONPATH" "$TOSROOT/support/sdk/python"
echo "setting up TinyOS on source path $TOSROOT"
I hope this will save someone's time.