TCP driver hex send problem

Hi.
I have device and I conected to him using Ignition TCP Driver.
This device understend only HEX values.
In Ignition I write script that send HEX values to device.

def fromhex():
	a = '1b02141b03e7'.decode('hex')
        system.tag.write("_IJ600_/4001/Writable", a)

This HEX command 1b02141b03e7 means that the device must return devices status.
Device must reply this code 1B060000140302000000001B03DE
Also I write script to convert devices Tag Wrtitable and Massage to HEX:

def tohex(): readMes = (system.tag.read("_IJ600_/4001/Message")).value readWrit = (system.tag.read("_IJ600_/4001/Writable")).value encodeMes = readMes.encode('hex') encodeWrit = readWrit.encode('hex') system.tag.write("_IJ600_/Mess_hex",encodeMes) system.tag.write("_IJ600_/Writ_hex",encodeWrit)

Problem - when I use my script to send data and conver what I send and what I received, I got this result:
At first sight problem is whit my device, but I cread simple TCP client using Python and using my script send him HEX data. And what I see: 1b02141b033f
Why Ignishion change last two HEX sybols from e7 to 3f I dont understand.
After that I picked the right code for Ignition, it is 1b02141b0337.
When i send it to my simple TCP client I see thes: 1b02141b03e7

Then I send new Hex to my device using Ignition and what I recive: 140302fdfdfdfdfdfdfdfd1b032e

According to the instructions of the device I should get this HEX code 1B060000140302000000001B03DE why Ignition changing some bits I dont understabd.
Please explain why Ignition does it, because when the I used simple TCP client, writing using python, to send commands and receive responses from the device, everything works correctly.
What is the solution of this problem?

The TCP driver is best used for ASCII data wich is good for up to 0x7f. Any characters it does not recognize gets changed to a question mark (0x3f).

I imagine the same sort of thing is happening in reverse on the responses.

Check out this thread. It's relating more to UDP, but should be very similar.

Jordan beat me to it!

He’s right, it’s the same problem as in the other thread - the UDP and TCP driver are for simple text transfers, and the message tag is a string, which is UTF-8 encoded. Only a subset of binary data can survive the conversion from binary -> utf8 -> binary.

What you’re doing looks sufficiently complicated enough that you should just be opening a socket in scripting as well.

[quote=“Kevin.Herron”]Jordan beat me to it!

He’s right…[/quote]

Be sure to tell my wife! :laughing: