Forum > General

PLCString reverse letters

(1/1)

Mossie:
I'm using a PLCString tag, read the string into HMIEdit.
What I get is "HP" and it should be "PH"
    Values: 50 48 07 08 ff ff ff ff 27 75
As per serial logger it does come correct, but PLCString and HMIEdit is reversing the string?
Anything I'm missing?
Somebody please can assist?
Thanks so much.

Handoko:
Hello Mossie,
Welcome to the forum.

I'm not sure, but maybe that has something to do with endianness:
https://en.wikipedia.org/wiki/Endianness

Mossie:
Hi Thx Handoko.
Any idea as to how I can address this in Lazarus? Thx.
The raw value is correct, If I use a PLCTagnumber, its correct,
so I cannot see that it is an Indianess as you suggest.
Once I use the PLCString tag it is swapped? thus. Am I
missing something here?

Handoko:
Endianess in use is determined by the hardware/platform. If your case is endian issue, maybe there information can help:


--- Quote ---With the correct TagType, you should set the properties SwapBytes, SwapWords to match the Endian of your controller. You will have to make trial and error to find out the correct setup of SwapBytes/SwapWords properties. I can’t help you in this with more accurate information.
--- End quote ---
Source: https://www.pascalscada.com/2016/11/22/expressions-on-all-properties-of-base-tags/

FPC has these functions for endian conversion:
SwapEndian, BEtoN (big endian to current endian), LEtoN (little endian to current endian), NtoBE (current endian to big endian) and NtoLE (current endian to little endian).
Source: https://wiki.lazarus.freepascal.org/Multiplatform_Programming_Guide#Endianess

Mossie:
Thx Handoko,
Just what I needed. Be Blessed Man!!!!!!

Navigation

[0] Message Index

Go to full version