Temperature reading application: Difference between revisions
| Line 65: | Line 65: | ||
CRC: Checksum (ignored) | CRC: Checksum (ignored) | ||
'''''DATA'''''<br> | <br>'''''DATA'''''<br> | ||
The encapsulated data is in the following format: | The encapsulated data is in the following format: | ||
| Line 71: | Line 71: | ||
LOCAL = Base Station | LOCAL = Base Station | ||
REMOTE = Remote Station | <br>REMOTE = Remote Station | ||
'''NOTE!''' | |||
<br>1. The raw stream is in '''Little Endian''' format | |||
<br>2. The following escaped are used for maintaing the framing byte protocol | |||
0x7E -> 0x7D 0x5E | |||
0x/D -> 0x7D 0x5D | |||
Revision as of 13:48, 15 April 2007
This Nesc/TinyOS application is for measuring the temperature with maximum of two sensors. One acts like a Base Station and has to be connected with the USB connection to the computer. The second acts like a Remote Station and transmitts its temperature reading via the radio to the Base Station. At the final stage, the base station transmitts the complete data, both temperature readings, to the computer every second. In this document it is described how to install the Nesc/TinyOS, how to retreive the the data and how to interpret the data.
It is assumed that the installation of TinyOS 1.x and Nesc is installed with the nessecary components.
Installation of the application
Extract the TRead application in the folder /tinyos-1.x/apps/. Then in the folder xxx/tinyos-1.x/apps, install the application by following line:
make telosb && installXXXXXXXX
NOTE!
In the file TReadM.nc, at the top, there is a preprocessor definition #define BASE_STATION.
When installing for the Remote station, comment this line and install as described above. For Base Station, leave it as it is.
Retrieving the data
Extract the TReadSerial.zip file. Here, you will find a C++ class called CSerialCom that can be used for retreiving the data.
Opens the connection to a serial device
with i.e "/dev/USB0" (Linux)
int openDevice(const char* pDevice)
Closes the connection to the serial device
void closeDevice(void)
Settings for the serial device
IN: Only type available: TYPE_TMOTE_SKY
void setOptions(int type)
Retreives the data from the serial port if any available. Max waiting
time for the data retreival is 6s. Where after the return value will be 0.
IN: pData: where the data should be stored. allocated by the caller
Return: Nr of bytes allocated in the pData buffer.
int getData(char* & pData)
Sends the to the serial device NOTE! Doesn't work!
IN: pData: buffer to transmitt
length: number of bytes to send from the buffer
int sendData(uint8_t* pData, int length);
Interpretting the data
The data is retrived in so called raw format as following:
7E: The leading and trailing framing byte 0x7E can be ignored.
TYPE: In this application, 0x42 Which means no acknowledge is required.
NN: Number of bytes of data that is sent in this packet
RESERVED: TMote reservation
DEST. ADDR: Packet destination. In this application: 0xFF 0xFF
MSG TYPE: Not used in this application. Always: 0x01
GRP ID: Group ID. Default set to 0x7E
DATA: NN bytes of data sent. Explained further down
CRC: Checksum (ignored)
DATA
The encapsulated data is in the following format:
LOCAL = Base Station
REMOTE = Remote Station
NOTE!
1. The raw stream is in Little Endian format
2. The following escaped are used for maintaing the framing byte protocol
0x7E -> 0x7D 0x5E 0x/D -> 0x7D 0x5D

