Jump to content

Swap Bytes Extended


snizami

Recommended Posts

  • 4 months later...

Hi snizami,
Use "Swap bytes extended"  to copy bytes in a tag from one location to another. Paramters:

        A - Source tag (INT16/UINT16/INT32/UINT32/REAL/BUFFER).
        B - Source byte index.
        C - Destination  byte index.
        D - Length to swap.
        E - Swap type (AB_BA/ABCD_DCBA/ABCD_CDBA). 

Link to comment
Share on other sites

  • 6 years later...
  • MVP 2023

@NoamM, @Cara Bereck Levy

 

<rant>

Daresay, there's an error in the Help on this block.  And on the floating tooltip, too. 😪

The "Modbus" device I am reading data from is retarded and has the byte order backwards on regular old integers.  I need to read a block of four holding registers and swap the bytes so the numbers make sense.  My input block is an array of 4 UINT 16s.

I just spent an hour trying to figure out why the output array contained all 0s.  The Help on the Swap Bytes Extended block states Parameter "D" is "Sets the number of bytes to be swapped". 

I know what a byte is.  So like a good little data type rule follower I set parameter D to 8.  Four UINT 16s is 8 bytes.

The correct and working answer is actually 4 for this application.   It's not the number of bytes, it's the number of array elements.  NoamM alludes to this in his above post when he says D is "size", but that's not specific enough.

So once again, people, the correct word for Parameter D is "Elements".

 

</rant>

Joe T.

Link to comment
Share on other sites

  • MVP 2023
7 hours ago, Joe Tauser said:

The "Modbus" device I am reading data from is retarded

Now, now, now, Mr. Tauser. We simply must replace that word with "intellectual disability".

https://www.federalregister.gov/documents/2013/08/01/2013-18552/change-in-terminology-mental-retardation-to-intellectual-disability

Your "Modbus" device is intellectually disabled. Now isn't that better?

🙊

😂

Link to comment
Share on other sites

On 2/10/2024 at 7:20 AM, Joe Tauser said:

@NoamM, @Cara Bereck Levy

The correct and working answer is actually 4 for this application.   It's not the number of bytes, it's the number of array elements.  NoamM alludes to this in his above post when he says D is "size", but that's not specific enough.

So once again, people, the correct word for Parameter D is "Elements".

@Joe Tauser

I fixed that in the Help (you'll see it next release) and had the software guys fix the tooltip--apologies, and thanks for tagging me directly!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...