Close

Serial Protocols...

A project log for ramanPi - Raman Spectrometer

The open source 3D Printable Raman Spectrometer using a RaspberryPi and easy to find off the shelf components..

flcfl@C@ 07/15/2014 at 00:250 Comments

So, I'm looking into different ways to implement the serial communication protocols between the control board, interface board / (imaging board), and the raspberryPi..  

I looked for open source solutions and didn't find much for framing data, etc. over serial..  I found a protocol called COBS (Consistent Overhead Byte Stuffing).. But I don't know how well that will translate to my needs..  It does have libraries for Python and C, which is good.. I won't eliminate it just yet, but I'm leaning toward some info I found at Eli Bendersky's website   http://eli.thegreenplace.net/2009/08/12/framing-in-serial-communications/ which covers a lot of good details on framing and flag bytes with byte stuffing..  

Each board will have specific functions (obviously) and a set of commands it will understand..  So, for instance...the control board can receive a command to open the cuvette tray..  We'll say that the user decideds to open the cuvette tray from the manual interface using the keypad and touch panel..on the device.  The interface board would accept the command from the user, transmit that request to the raspberryPi via rs232 and the raspberryPi will determine the system state, etc.. and issue the appropriate commands to the other modules in the system.. One of those commands might be to ask the controlBoard what the current state of the laser is.. So the raspberryPi would send a sentence to the controlBoard requesting that information...  The control board would in turn respond with an acknowledgment, and so on..  

I could get really wordy here, but basically it looks like using escape characters as flags on the beginning and ending are good ways to frame the data..  Then you form the packet... 

You want something like:

        [start]  [command]  [arg1]  [arg2]  [end]

What you would end up with is something like:

        [wait]  [start]  [command]  [esc]  [arg1]  [esc]  [arg2]  [end]

Like I said, I'm starting...to look into this.. I'd love to hear if anyone has any suggestions..

I'll be trying some experiments here very soon..as well as coming up with a list of commands for each board.

Discussions