Home

Tuscarora Framework is now Open Source  

Tuscarora is a framework for developing highly scalable and portable Network Patterns (NP) and applications. The Framework serves as the narrow waist of the system, decoupling the Application Layer and the Network Patterns from the underlying radio and hardware platform, enabling portability, scalability and extensibility. Tuscarora was partly funded by DARPA.

The source has been released on GitHub at https://github.com/Samraksh/Tuscarora/. Learn More.

 

 

About Samraksh  

 

 Wireless Sensor Network Expertise We are experts in low-power, reliable wireless sensor networks (WSN) with world-class experience and deep, innovative research into the hardware, software and algorithmic issues they present. We design, manufacture and sell inexpensive high-performance, low-power, scalable and easy-to-program components and systems.

WSN-Enabling Products Besides the eMote .NOW and the BumbleBee highlighted below,  we also provide a range of other sensors and supporting items. Complete network solutions can be deployed using these components.

 

Download zip archive

Key Ideas

  • Serial communication to PC.

Description

This app note is an extension of the On-Off Switch app note, which contains information about how to set up the switch. This app note illustrates how to use serial communication between an eMote .NOW and a PC.

There are two programs. One is a WinForm client app that runs on a PC under Windows. The other is an eMote .NOW server app. When running, the client and the mote communicate via a serial port. When the mote switch is closed or opened, that information is sent to the PC, which displays it in a window. The PC can send messages to the mote instructing it to enable or disable sending of switch information.

Complexity Level

Introductory. There is some complexity involving understanding how serial communication works.

Compatibility

eMote.NOW 1.0, eMote version 4.3.1.12 and Visual Studio 2012.

Setup

Please refer to the On-Off Switch app note for setting up the switch.

Getting Started

Open two instances of Visual Studio. In the first, open the mote app. In the second, open the PC app. 

Connect your mote to the PC with a USB cable. Due to limitations in the drivers, only COM1 through COM8 are supported, so you may have to change the COM port assigned to your mote. You can do this as follows.

device manager

If a COM port in the range of COM1 - COM8 is not already specified, double-click to open the property window and choose Port Settings => Advanced and select port number.

port settings

In the mote program find the constant named "commPort" and change it to the right value. Also change the project's .NET Micro Framework properties to specify the same com port.

Running the Programs

First, deploy the mote program and get it running. In Visual Studio, choose Build => Deploy Solution. The mote program and Visual Studio both use the same com port: Visual Studio to deploy the app and the program to communicate with the PC. Both can't use the same com port at the same time. When you begin deployment and you see Visual Studio indicating that it is beginning to deploy, press the reset button on the .NOW. If that doesn't work, you may have to unplug the .NOW and plug it back in again. For this same reason, you can't use the Visual Studio debugger while running the mote program. When the mote program starts, you'll see "Hola" displayed on the LCD panel. After this, opening and closing the switch should show 0 and 1 in the 2nd cell of the LCD panel.

Next, run the PC program in debug mode (press F5 in Visual Studio). You'll see an dropdown box to let you choose a serial port. Choose the same one as the mote is using and click to enable serial. Open and close the switch on the mote and you should see messages appearing that indicate switch status. Then you can click to disable the mote switch. This will cause the mote to send a message that the switch is disabled. Until you click to enable the mote switch, nothing will be transmitted from the mote.

Discussion

You will see comments in the code that document each part. Both the PC and the mote programs are entirely event-driven with no busy-wait loops.

The PC client program is fairly straightforward. When serial data arrives, it is buffered. The method to handle serial data is not called until the buffer is full. Hence the buffer size is set to 1 so that each byte that comes through is handled immediately.

The mote program consists of a Main method with three classes that provide abstractions tailored to our needs.

  • InputSwitch sets up a thread that responds to switch events. A callback method "SwitchCallback" is used in the main program to process debounced switch values.
  • DebounceTimer is used by InputSwitch to provide a simple interface for switch debouncing.
  • SerialComm sets up a thread that listens for incoming serial events from the PC and sends text strings to the PC. A callback method "SerialCallback" is used in the main program to process received text.

Suggestions

If you made changes to the On-Off Switch app note, incorporate those changes into this one.

Try using two switches and have each send different status messages. Note that if you do this, you'll probably want to modify the constructor for InputSwitch to include arguments for the on and off messages.