Beginner, Binary Protocol Setup


Recommended Posts

Hello, I'm a LabWindows guy, so excuse my newbishness. 

 

I've been tasked with porting over a binary protocol for a custom piece of hardware.  This hardware is fully defined in its protocol, which is binary, not ASCII.

 

I have working hardware at my disposal which responds predictably in a port monitor environment (I prefer RealTerm).  The simplest test command/response on this hardware is a ping command: send 0x1, receive back 0x1.  This protocol doesn't always use a CRC (I know, I know, but I didn't write it!).

 

Ok, so in the DF world, I've been reading about custom serial devices and protocols.  I've created one and am playing with the Monitor tab to at least verify this basic ping test.  I have the basic display options set (all chars as ASCII, codes in hex, Tx/Rx times), but am floundering.  I can't get an Rx back from my Tx, because it's refusing to send anything beyond ASCII.  I need to be binary only. I've tried guessing at the format, like "\x01" etc. but every character is parsed as ASCII.  See screenshot. 

 

You'll notice in this screenshot that there are a few Rx lines.  This is from the hardware at power up, so I know that DF is "seeing" it.  Just can't get a valid Tx formatted.

post-9451-0-36436000-1402937500_thumb.pn

Link to comment
Share on other sites

This is mostly just you trying to use RealTerm syntax in DAQFactory.  If you want to send 0x01 to the device, just type: 

 

\x01 

 

in the output string, not '1'

 

So, if you wanted to send out the hex values 1, 3A and 5E in one swoop, you'd do:

 

\x01\x3A\x5E

 

Now once you got to scripting, its usually easiest to do:

 

device.myDevice.write(chra({0x01, 0x3A, 0x5E}))

 

There are other ways to build up the strings, but its usually best to create an array holding your values, then use chra() to convert it into a single string.

 

I also recommend doing the script in a sequence.  Don't mess with custom protocols until you've tested it in sequences.  Then its pretty easy to port over to a custom, reusable protocol.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.