Oscilloscope parsing in TELOSB-serial communication

Source: Internet
Author: User

This example of oscilloscope includes a PC and a serial port to send messages, it is worth studying.

The general idea is that the sensor node collects data, sends one packet to another base node for each 10 data acquisition, and then the base node forwards the data to the PC side. The PC side has a Java program that collects data and displays it. So run this example to two nodes, a burning oscilloscope, a burning base node, also need a PC, connect the base node, run Java program. However, before running the Java program, start the Serialforward tool so that the PC and the base node can communicate. The specific command is not described in detail.

In this example, I find it interesting that the Java program.




Can see mainly including the above several files

node is the processing of the nodes, data is the integration of all, graph is drawing, Windows is on the system processing, Oscilloscope.java is the most

Important function, which contains the method of starting function run, data receiving and sending. In this file, there are changes to the data acquisition frequency time, there is a messagereceived method, this method can receive the serial port information from the node.

/* Broadcast a VERSION+INTERVAL message. */
void Sendinterval () {
Oscilloscopemsg omsg = new Oscilloscopemsg ();

Omsg.set_version (version);
Omsg.set_interval (interval);
try {
Mote.send (MOTEIF.TOS_BCAST_ADDR, omsg);
}
catch (IOException e) {
Window.error ("Cannot send message to Mote");
}
}

This is the Sendinterval method, this method has a mote.send call, is to send PC information to the serial port method. mote.send (moteif.tos_bcast_addr, omsg); is to send the OMSG class to the serial port. The uart.receive in base will receive this method to emit

The message. If you want to do serial communication, you can focus on messagereceive this method and Mote.send this method, the other can be removed.

Here you have to say Oscilloscope.h this header file, which defines the structure of oscilloscope_t, Run make in a Java file to see that there is a Oscilloscopemsg.java file, which is the Java class of the structure of the header file definition, and through the method inside, you can control the Oscilloscope object. If we need to modify an object for data transmission, we need to modify that header file, of course, it is necessary to modify the corresponding Phthon. I use this example for data communication when the head file and Python have also been handled to avoid unnecessary errors.

The above is the approximate analysis of this example.


Oscilloscope parsing in TELOSB-serial communication

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.