(Serial) messaging library for Teensy and .NET/Mono, with Teensy benchmarks
Hi,
A few months ago I wanted my Arduino to communicate with a C# application in order to log some data. I had expected to find a messaging library without any issue. However I could only find one library that came close: It implemented
- Both sending and receiving benchmarks
- sending multiple arguments per command command
- Trigger specific callback functions on received commands
But it was still lacking in some aspects. I updated the library so that:
- It can send all data-primitives (char arrays, floats, ints, longs, bytes) instead of just strings.
- It can wait for an acknowledge command after sending
- It has the ability to escape data. Special characters that would otherwise be interpreted as field separators or command separators are can be escaped and are made harmless.
- It has the ability to send binary data. Using escaping, basic data-types can be send over in binary form, for efficiency and accuracy
However, most work went into writing an implementation of the library from scratch in C# that runs both on .NET and Mono. In the time after the initial release I improved the library to work both at low speeds (i.e. a physical serial port) and high speeds (i.e. a virtual port running at full USB speed) by implementing my own serial port communication, that adapts dynamically to transfer tates. This means that it will hopefully run quite fast on a Teensy 3.
I quickly tried it out on a Teensy 3 of a friend, and at first glance it seems to work smoothly. Unfortunately I had little time to play with it (I was amazed at how small it is!) and was not yet able to do any benchmarks.
So I would like to ask everybody who is interested to try out the library with the Teensy and let me know how it works. Maybe somebody would even run some speed benchmarks?
In the latest version I also added an hopefully useful sample of a PC controlled, Arduino based thermostat. It uses a K-type thermocouple and a MAX31855 / Max6675 breakout board to measure temperature, a Solid State Relay to turn a heater on and off, and a PID controller implementation to steer the temperature optimally (no overshoots) to the goal temperature. My personal aim is to update our Gaggia Classic espresso machine with temperature stabilization, but this is sample set up to be generic enough that you can use it for anything: brewing beer, controlling a clay oven, etc.
Anyway, my rather expansive posts on the library on the Arduino forum can be found here:
forum.arduino.cc/index.php?topic=186928
And a even more detailed explanation can be found on my blog, together with a bunch of examples:
http://thijs.elenbaas.net/2013/09/arduino-to-pc-messaging/
and
http://thijs.elenbaas.net/2013/11/arduino-to-pc-messaging-more-devices-protocols-speeds/
You can download the library here:
http://thijs.elenbaas.net/downloads/?did=9
Or at the Github repository:
https://github.com/thijse/Arduino-Libraries/tree/master/CmdMessenger
If anybody want to try the library, please let me know what your experiences are.
Cheers, Thijs
Hi,
A few months ago I wanted my Arduino to communicate with a C# application in order to log some data. I had expected to find a messaging library without any issue. However I could only find one library that came close: It implemented
- Both sending and receiving benchmarks
- sending multiple arguments per command command
- Trigger specific callback functions on received commands
But it was still lacking in some aspects. I updated the library so that:
- It can send all data-primitives (char arrays, floats, ints, longs, bytes) instead of just strings.
- It can wait for an acknowledge command after sending
- It has the ability to escape data. Special characters that would otherwise be interpreted as field separators or command separators are can be escaped and are made harmless.
- It has the ability to send binary data. Using escaping, basic data-types can be send over in binary form, for efficiency and accuracy
However, most work went into writing an implementation of the library from scratch in C# that runs both on .NET and Mono. In the time after the initial release I improved the library to work both at low speeds (i.e. a physical serial port) and high speeds (i.e. a virtual port running at full USB speed) by implementing my own serial port communication, that adapts dynamically to transfer tates. This means that it will hopefully run quite fast on a Teensy 3.
I quickly tried it out on a Teensy 3 of a friend, and at first glance it seems to work smoothly. Unfortunately I had little time to play with it (I was amazed at how small it is!) and was not yet able to do any benchmarks.
So I would like to ask everybody who is interested to try out the library with the Teensy and let me know how it works. Maybe somebody would even run some speed benchmarks?
In the latest version I also added an hopefully useful sample of a PC controlled, Arduino based thermostat. It uses a K-type thermocouple and a MAX31855 / Max6675 breakout board to measure temperature, a Solid State Relay to turn a heater on and off, and a PID controller implementation to steer the temperature optimally (no overshoots) to the goal temperature. My personal aim is to update our Gaggia Classic espresso machine with temperature stabilization, but this is sample set up to be generic enough that you can use it for anything: brewing beer, controlling a clay oven, etc.
Anyway, my rather expansive posts on the library on the Arduino forum can be found here:
forum.arduino.cc/index.php?topic=186928
And a even more detailed explanation can be found on my blog, together with a bunch of examples:
http://thijs.elenbaas.net/2013/09/arduino-to-pc-messaging/
and
http://thijs.elenbaas.net/2013/11/arduino-to-pc-messaging-more-devices-protocols-speeds/
You can download the library here:
http://thijs.elenbaas.net/downloads/?did=9
Or at the Github repository:
https://github.com/thijse/Arduino-Libraries/tree/master/CmdMessenger
If anybody want to try the library, please let me know what your experiences are.
Cheers, Thijs
Last edited: