A serial-to-network proxy for relaying data between a serial port and a TCP/IP socket connection. Allows an Arduino (or other sensor) to connect to SensorMonkey. Serves Flash Socket Policy files inline on the specified port.
Built for Processing.
Clone the repo using Git or download the source code as a zip or tarball.
Open the file SensorMonkeySerialNet.pde with Processing and click Run.
You can edit the following global variables in the sketch to suit your needs:
port
The TCP/IP port on which to listen for incoming network connections (default is 20000)pollingFreq
The polling frequency (in Hz) of the sketch (default is 50)baudRate
The baud rate to use for serial communication (default is 9600)policyFile
The Flash Socket Policy file to serve inlinewaitTime
Time (in milliseconds) to wait after a new client connects before continuing to transfer data from the serial port to the open TCP/IP socket connection(s) (default is 1000)
Important! The sketch will attempt to open the first serial port in the list of serial ports
so change the array index to match your sensor if needed (see setup()
function).
- You should only attempt to connect a single client to the server at any one time. Otherwise, the Flash Socket Policy file will be sent to all currently connected clients every time a new one connects.
- When connecting and disconnecting a client, the server may generate a
java.net.SocketException: Broken pipe
or ajava.net.SocketException: Software caused connection abort: socket write error
error. These can be safely ignored. - There are known issues with Processing and Bluetooth virtual serial ports when running under Windows. If you're on a Windows machine, download and install Bloom instead of running this sketch (whether you're using Bluetooth or not). Your sanity will thank you for it!
- When terminating the sketch, use the Stop button on the Processing IDE rather than the Close button on the sketch's display window.
- If you get a "WARNING: RXTX Version mismatch" error when running the sketch you can (in my experience) usually safely ignore it. However, if you want to update the serial library to avoid the error in the future, please see the threads in the Processing forums.
- If you're having trouble getting the sketch to run on Linux, the cause may be a bug in Processing that denies communication to the serial port because of the name it uses in the /dev/ folder. Please see the final post in this thread that describes how to solve this issue.
- Visit SensorMonkey on the Web
- Google Group for discussion
- Follow sensormonkey on Twitter for updates
- Visit SensorMonkey on Facebook
- SensorMonkey on GitHub