Forum > General

PLCString reverse letters


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.

Hello Mossie,
Welcome to the forum.

I'm not sure, but maybe that has something to do with endianness:

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?

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 ---

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).

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


[0] Message Index

Go to full version