Download presentation
Presentation is loading. Please wait.
Published byAlison Terry Modified over 9 years ago
1
Programming Assignment 2 CSE535: Mobile Computing (Fall 2010)
2
Environmental Setup IssuesEnvironmental Setup Issues Go to your home directory. Open.bash_profile or.bashrc Add necessary environmental variables Ex) export TOSROOT=“/opt/tinyos-2.x” Important! You need to add the current directory (.) into CLASSPATH Check these variables using “echo” command. ex) echo $TOSROOT Run “tos-check-env” to check all other environments.
3
Multiple JRE installation IssuesMultiple JRE installation Issues Check the location of Java library tos-locate-jre --jni Copy toscomm.dll and getenv.dll from \lib\tinyos into the directory you found using tos-locate-jre --jni
4
Compile and Install a codeCompile and Install a code make telosb Compile an application make telosb install.(node id) bsl,(Comport) Ex) make telosb install.5 bsl,/dev/ttyUSB0 Type “motelist “ to check the com port number
5
Overall System ArchitectureOverall System Architecture TelosB (BaseStation) PC (Java App) TelosB (Sensing) Id = 1 TelosB (Sensing) Id = 2 USBUSB EXAMPLE: see TestSerial.java under $TOSROOT/apps/tests/TestSerial EXAMPLE: $TOSROOT/apps/BaseStation EXAMPLE: $TOSROOT/apps/Oscilloscope Sampler.zip in google group Zigbee
6
Header fileHeader file typedef nx_struct SenseMsg { nx_uint16_t sourceMoteID; // Queried mote id nx_uint16_t datatype; // Data type = temperature, humidity, // or light nx_uint16_t data; // Sensingdata } SenseMsg; enum { AM_SENSEMSG = 100, };
7
AM (Active Message) formatAM (Active Message) format Destination address (2 bytes) Link source address (2 bytes) Message length (1 byte) Group ID (1 byte) Active Message handler type (1 byte) Payload (up to 28 bytes): Use SenseMsg structure Call AMSend.getPayload(……)
8
AM_SENSEMSG = 100AM_SENSEMSG = 100 In configuration file (~AppC.nc) components new AMSenderC(AM_SENSEMSG); components new AMReceiverC(AM_SENSEMSG); In java file (~Msg.java) /** The Active Message type associated with this message. */ public static final int AM_TYPE = 100;
9
Getting multiple packets for one request You might get multiple packets after sending one request Check the sender id and data type whether they match with the request you sent. Check whether there are other telosb motes with the same ID. Check whether you create multiple listeners. public TestSerial(MoteIF moteIF) { this.moteIF = moteIF; this.moteIF.registerListener(new TestSerialMsg(), this); } // Invoked when a message arrives public void messageReceived(int toaddr, Message msg) {... }
10
Creating multiple listenersCreating multiple listeners MoteIF mif = new MoteIF(phoenix); TestSerial serial = new TestSerial(mif); While (!quit) { …….. serial.sendPackets(); …….. } MoteIF mif = new MoteIF(phoenix); While (!quit) { TestSerial serial = new TestSerial(mif); ……… serial.sendPackets(); ……… } Create listener
11
Tips for using TestSerial.javaTips for using TestSerial.java Change the header file (TestSerial.h) Type “make telosb” Makefile includes TestSerialMsg.java: mig java -target=null $(CFLAGS) -java- classname=TestSerialMsg TestSerial.h test_serial_msg -o $@ Check TestSerialMsg.java You will see set_sourceMoteID(), get_sourceMoteID() etc.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.