ME221 Sample Code README -------------------------------------------------------------------------- Instructions: -------------------------------------------------------------------------- Folder Locations: 1. First unzip all 3 folders 2. Place ME221Base and ME221Mobile in /opt/tinyos-1.x/apps 3. Place me221 in /opt/tinyos-1.x/tools/java/net/tinyos ME221Base is used to program the mote attached to the base station ME221Mobile is used to program the mote which has sensors attached to it me221 is the code to create a Java GUI To run it: 1. Program the base station and sensor motes using ME221Base and ME221Mobile, respectively. 2. Open another cygwin window (you should have two open) 3. Attach the base station mote to the computer, and attach sensors to the sensor mote. 4. In the first window, type "motelist". This gives the COM port # of the mote. 5. In the same window, type "java net.tinyos.sf.SerialForwarder -comm serial@COM:telos", where COM# refers to the COM port number. A small java window should pop up. This is the serial forwarder window. 6. In the second window, type "cd /opt/tinyos-1.x/tools/java/net/tinyos/me221" 7. Type "make clean", then type "make". This compiles the Java code, and generates the ToCompMsg.java and FromCompMsg.java files (as well as some class files). 8. Type "cd ..", then type "java net.tinyos.me221.me221". The Java GUI should now pop up, displaying your values. -------------------------------------------------------------------------- Files that should NOT be modified: -------------------------------------------------------------------------- -In ME221Mobile -ADC0.h, ADC0C.nc, ADC0M.nc -ADC1.h, ADC1C.nc, ADC1M.nc -ADC2.h, ADC2C.nc, ADC2M.nc -ADC3.h, ADC3C.nc, ADC3M.nc -ADC4.h, ADC4C.nc, ADC4M.nc -ADC5.h, ADC5C.nc, ADC5M.nc -ADC6.h, ADC6C.nc, ADC6M.nc -ADC7.h, ADC7C.nc, ADC7M.nc -In me221 -Makefile -------------------------------------------------------------------------- Files that can be modified: -------------------------------------------------------------------------- -In ME221Mobile -MakeFile -Line 5: Value of DEFAULT_LOCAL_GROUP should be group # -MsgDefinition.h -This file defines what variables each message holds. ToCompMsg is the name of the message that is sent from the sensor mote to the base station. FromCompMsg is the name of the message that is sent from the base station to the sensor mote (if necessary). Data fields can be added or subtracted as necessary. Please note, the data is read in words, so each field must fit within a 16 bit block. For example, if the message consists of three integers, one uint16_t, one uint8_t and another uint16_t, then a valid order to list the fields is 16, 16, 8. You will get bad data if the order is 8, 16, 16 or 16, 8, 16. A file with the same name can also be found in ME221Base. THESE FILES MUST BE THE SAME. -ME221Sample.nc -Timers can be added/subtracted as necessary (be sure to make the corresponding change in ME221SampleM.nc). -ME221SampleM.nc -Lines 60-62: Timer periods can be adjusted as necessary (remember times are in ms). -Lines 138-141: If MsgDefinition.h is changed, the corresponding changes should be made here -Please read the comments for further explanation of parts -In ME221Base -MakeFile -Line 5: Value of DEFAULT_LOCAL_GROUP should be group # -MsgDefinition.h -This file defines what variables each message holds. ToCompMsg is the name of the message that is sent from the sensor mote to the base station. FromCompMsg is the name of the message that is sent from the base station to the sensor mote (if necessary). Data fields can be added or subtracted as necessary. Please note, the data is read in words, so each field must fit within a 16 bit block. For example, if the message consists of three integers, one uint16_t, one uint8_t and another uint16_t, then a valid order to list the fields is 16, 16, 8. You will get bad data if the order is 8, 16, 16 or 16, 8, 16. A file with the same name can also be found in ME221Mobile. THESE FILES MUST BE THE SAME. -ME221Sample.nc -Timers can be added/subtracted as necessary (be sure to make the corresponding change in ME221SampleM.nc). -ME221SampleM.nc -Lines 52: Timer periods can be adjusted as necessary (remember times are in ms). The timer on this line determines how often a message is sent from the mote through the serial port to the computer. -Lines 159-162, 174-177: If MsgDefinition.h is changed, the corresponding changes should be made here -Please read the comments for further explanation of parts -In me221 -me221.java -For information on classes in Java, please view the API at http://java.sun.com/j2se/1.4.2/docs/api/ -May need to import other packages at beginning of file depending on how you wish to implement the GUI. -Line 63: This is the beginning of the paint component, where the graphics can be instantiated and displayed. Please refer to the API for more details. -Line 69: I've put in a simple statement that displays the values obtained from the message the mote sent. This can be adjusted as necessary. -Line 83: This is the function where the Java receives the mote message and can then process the data. If MsgDefinition.h changes, the corresponding change must be made here as well. The function calls to obtain the data can also be found in ToCompMsg.java and FromCompMsg.java (which is generated when you type "make" in the command line).