How do I send serial Hex/binary data
Hi,
I'm writing a script to communicate with a serial device.
Using data=somedata in the XAP serial schema works as expected and I see "somedata" received on the serial port but I need to send hex/binary data.
The XAP protocol suggests that ! in place of = would allow hexadecimal data to be sent so I've tried using data!0AB123F for example but this appears to get removed from the XAP message (or isn't displayed by the XFX message viewer) and no serial data is generated.
Is hex serial data not supported or am I missing something?
Paul
I've added support for HEX in the data key for the xap-serial component this will be in the next release (build 307). The sytnax will be like this
Serial.Send { port=/dev/ttyUSB0 data=\x7b\x42\x72\x65\x74\x74\x7d }
Brett
I knew that would happen - there is no workaround I'd need to modify the internals to store the LENGTH of the data transmission instead of using the NUL terminator on the string. *sigh*
UPDATE: I've just fixed the code I've uploaded BETA 306.2 for you to try out this will handle a NULL plus it has the HEX support that I mentioned in my earlier post. Much easier than dealing with Octal.
Grab the beta and let me know how that goes for you.
# /etc_ro_fs/update-dev hah-beta.dbzoo.com
Brett
Er yeah I screwed up a couple of things. Fixed in 306.3 unless of course you are enjoying octal so much.
Brett
Paul 306.3 is now available - that should get you out of your octal funk.
I had to re-read the xAP specification as I'd not run into the (!) character in this usage.
http://www.xapautomation.org/index.php?title=Protocol_definition#Message...
Wow what do you know this is part of the specification. Well unfortunately the xaplib library that I wrote doesn't know how to do this. As this is a quite a low level change I'd need to rework a few bits to enable this and make sure I don't break EVERYTHING in the process.
What you can do thou is use OCTAL just like you would in a C string to send binary data.
data=\027\177 etc.. this I've have coded for.
Unfortunately it does not have the HEX encoding but adding handling for \xFF and \x1B would not be too hard to do. Certainly easier then putting in (!) exclamation mark support. I'll add this too.
update: http://www.dbzoo.com/livebox/xap_serial?&#output_messages
I amended the wiki page to document this.
Brett