Hello
I have to connect to a device using Modbus TCP protocol
I should to change the Byte order when I read a 32 bit register ( float and long) in according with Intel-formatted data.
The driver can only reverse the word order in a 32 bit register but not the byte order
Has anyone did this with ignition?
Thank you very much
Andrea
Does the entire byte order need to be reversed?
If so:
[code]import struct
i = 2864434397
s= struct.unpack("<I",struct.pack(">I",i))[0]
print i, hex(i)
print s, hex(s)
[/code]

For another technique, you can flip things around using some Java types:
def int32BE_to_float32LE(i):
from java.lang import Float, Integer
return Float.intBitsToFloat(Integer.reverseBytes(i))
Hi
Thank you very much to everybody
…two great solutions!!!
Andrea