Temperature reading application: Difference between revisions
| Line 18: | Line 18: | ||
Extract the TReadSerial.zip file. Here, you will find a C++ class called <code>CSerialCom</code> that can be used for retreiving the data. | Extract the TReadSerial.zip file. Here, you will find a C++ class called <code>CSerialCom</code> that can be used for retreiving the data. | ||
<br>Opens the connection to a serial device | <br><br>Opens the connection to a serial device | ||
with i.e "/dev/USB0" (Linux) | with i.e "/dev/USB0" (Linux) | ||
<br><code>int openDevice(const char* pDevice) | <br><code>int openDevice(const char* pDevice)</code> | ||
Closes the connection to the serial device | Closes the connection to the serial device | ||
Revision as of 13:15, 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);
The method <opendevice(const char* pDevice) opens the connection to the tmote device by for example "/dev/USB0" in unix/linux environment. There after the data can be read by calling