1 / 11

Programming Assignment 2

Programming Assignment 2. CSE535: Mobile Computing (Fall 2010). Environmental Setup Issues. Go to your home directory. Open .bash_profile or .bashrc Add necessary environmental variables Ex) export TOSROOT=“/opt/tinyos-2.x”

willem
Download Presentation

Programming Assignment 2

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Programming Assignment 2 CSE535: Mobile Computing (Fall 2010)

  2. Environmental 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 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 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 Architecture PC (Java App) TelosB (Sensing) Id = 1 USB Zigbee TelosB (BaseStation) TelosB (Sensing) Id = 2 EXAMPLE: see TestSerial.java under $TOSROOT/apps/tests/TestSerial EXAMPLE: $TOSROOT/apps/Oscilloscope Sampler.zip in google group EXAMPLE: $TOSROOT/apps/BaseStation

  6. Header 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) 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 = 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 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.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.

More Related