In Older CPU (not arm and AS3)
I have been able to read the value in a REAL array directly.
Now I have to save it in an Array of data type UINT.
Then convert this to REAL as below.
Can I convert this variable on a another way than this? (this works to)
Modbus transfers data in “Big Endian”, so the most significant byte first and “older CPU” (motorola) used the same, so you could directly use that data on variables. Intel CPUs use “Little Endian” and thus the data is swapped from the viewpoint of a variable.
You can use the TARGETInfo (AS6) TARGETInfo (AS4) function block in the BRSystem library. This has an output that will tell you if your processor is Little or Big Endian.
There is also functions in in the AsIecCon library called N_TO_H and H_TO_N which convert between Host and Network format. (Conversion from Host to TCP/IP Network, Conversion from TCP/IP Network to Host). I believe these function blocks check something internally and automatically change so you don’t need to check endian-ness before using them. I.e. on a big endian processor, the functions don’t do any byte changing, just assign the input value to the output.
There are also functions in AsIecCon for just swapping bytes, useful if need to create specific data blobs/files of a specific endianess. Swapping Data Types.