MEMORY_COPY doesn't copy the data correctly

Hello,
I’m using MEMORY_COPY to copy 2 different strings into an array that is used by a ModBus TCP block (MB_TCP_FC16) to write the registers of a ModBus slave (an RUT240 Router) that make up the contents of an SMS. However when sending the text, the message is empty. The code is used like so:
image.png

OUT := MEMORY_COPY(SMS1 (* SRC *), 0 (* SRC_OFF *), DataToSend (* DST *), 21 (* DST_OFF *), LenSMS1 (* CNT *));
OUT2 := MEMORY_COPY(SMS2 (* SRC *), 0 (* SRC_OFF *), DataToSend (* DST *), LenSMS1+1 (* DST_OFF *), LenSMS2 (* CNT *));
Test SMS input:
'TESTSMS123'

Received SMS (empty): In the ‚WATCHES‘ bar I can see that some of the words have empty values (00):
image.pngWhich means that there is a way to flip them (like using SWAP for example) but I can’t see how to do that without having to do it for every character for both strings. I guess my question is if there is a way to swap or rotate the words so that I receive the correct text. Thanks in advance.

Hi Ricardo,
maybe the ‚Endian‘ functions are useful in your case?
image.png
Cheers
DivisionByZero

You might also be able to use the STRING_TO_BUF function block, which (a) will automatically strip the header bytes off the STRING variable, and (b) can be used to control the byte order using the BUF_FORMAT input parameter.