programming assignment 2 cse535: mobile computing (fall 2010)

Post on 04-Jan-2016

223 Views

Category:

Documents

2 Downloads

Preview:

Click to see full reader

TRANSCRIPT

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.

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

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

Overall System ArchitectureOverall System Architecture

TelosB(BaseStation)

PC(Java App)

TelosB(Sensing)

Id = 1

TelosB(Sensing)

Id = 2

USB

EXAMPLE: see TestSerial.java under $TOSROOT/apps/tests/TestSerial

EXAMPLE: $TOSROOT/apps/BaseStation

EXAMPLE: $TOSROOT/apps/OscilloscopeSampler.zip in google group

Zigbee

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,

};

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(……)

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;

Getting multiple packets for one Getting multiple packets for one requestrequest

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) { ... }

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

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.

top related