Author Topic: Binary data with the serial board  (Read 922 times)

nick

  • Full Member
  • ***
  • Posts: 174
Binary data with the serial board
« on: March 26, 2009, 10:05:02 PM »
I'm trying to connect a weather station to the ioBridge using the serial board.  The weather station produces its output in a binary format.  When I look at the last serial input using the API it is a string of &0's.  Is there any support for non-printable ascii characters?

Thanks,
Nick

jason

  • Administrator
  • Hero Member
  • *****
  • Posts: 502
    • ioBridge.com
Re: Binary data with the serial board
« Reply #1 on: March 27, 2009, 12:16:11 AM »
You may want to check that the correct mode it set for the serial board (inverted vs non-inverted).  I've seen the serial board throw a bunch of nulls (&0) when I have it set wrong.

 
But regarding the binary data (I thought this info was in the wiki, but it looks like I forgot to include it.):

We had to include some special encoding to handle nulls and a few other bytes since since some of the languages the data passes through interprets a null as the end of a string. 

If two serial boards are linked then data is send byte for byte with no encoding.  Binary data will be represented faithfully from board to board.

However, from a serial board to the API (or a widget) the following encoding will occur:

ASCII     character    encoding
-----     ---------    ---------
  0           null               &0
 38            &                &1
 60            <                &2
 62            >                &3

This works in both directions.  Sending a &2 will a < to be sent out the TX line.  Receiving a < on the RX line will cause a &2 to me sent through the API

The rest of the characters (even non-displayable ones) will be sent as they are since they live within the confines of a JSON object.

I know it all sounds kind of screwy but it was the only way to keep the messages chugging through the entire system.




 
Jason Winters
ioBridge Developer

nick

  • Full Member
  • ***
  • Posts: 174
Re: Binary data with the serial board
« Reply #2 on: March 27, 2009, 10:05:28 PM »
Well I'm kind of banging my head against the wall trying to get this to work.  If I plug the weather station into my PC running hyperterminal at 9600-N-8-1, no flow control,  I get a nice stream of ascii garbage, in packets of 5-10 bytes, about one packet every 8 seconds or so.

Hooked up to the iobridge I get an occasional null character, that's it.   Inverted or true seems to make no difference.

I'm hooking signal ground to pin 5 of the DB9 and RX on the iobridge to pin 3 on the DB9, I don't see why any other pins are necessary.  Just to be sure I hooked up Tx to pin 2 and RTS to pin 8 but it didn't make any difference.

The only other serial device I have used with the ioBridge is an arduino.  I can connect the arduino to the iobridge directly and it works fine.  However, to get the arduino to communicate with my PC I have to use a max232 line driver to convert the TTL levels to RS-232.  Is it possible I have to do something similar to use a true RS232 device with the iobridge?

Nick

jason

  • Administrator
  • Hero Member
  • *****
  • Posts: 502
    • ioBridge.com
Re: Binary data with the serial board
« Reply #3 on: March 28, 2009, 12:20:08 AM »
It sounds like you are doing the same troubleshooting steps I would do.

A max232 isn't necessary since the serial board has the option of inverted or non-inverted signals.  If you look closely at the serial board you'll see a few discrete components that perform the same function as a max232.

I'm trying to think of a few reasons that would cause this problem.

Have you been able to get an arduino to receive bytes from the weather station?

I wonder if the weather station needs one of the other lines pulled high or low before it will send data.  I have a serial keyboard that wouldn't send anything until the RTS pin was pulled high.  Other equipment uses the DTR or CTS lines for flow control.  I doubt this is your problem though.

Are you sure you are connecting the the right pins on the DB9?  Sometimes I count from the wrong end and put ground on pin 1 instead of pin 5.

Sorry if these are things you've already checked, I'm just brainstorming.

   
Jason Winters
ioBridge Developer

nick

  • Full Member
  • ***
  • Posts: 174
Re: Binary data with the serial board
« Reply #4 on: November 02, 2009, 11:49:34 PM »
An update here: I found documentation for the weather station and it requires RTS to be high in order to transmit data.  My mistake was attaching RTS to the wrong pin, 8 instead of 7.