snizami Posted August 23, 2017 Report Share Posted August 23, 2017 Does anyone know how to use this function block; Link to comment Share on other sites More sharing options...
NoamM Posted January 23, 2018 Report Share Posted January 23, 2018 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 More sharing options...
Gabriel Franco Posted January 23, 2018 Report Share Posted January 23, 2018 How are SD filename and type related with SWAP bytes? I understand from the FB name, it can be used to swap bytes from a tag. Link to comment Share on other sites More sharing options...
NoamM Posted January 24, 2018 Report Share Posted January 24, 2018 Gabriel Franco, thanks for noticing, I also think it's unrelated (updated my previous post). It will be fixed. Link to comment Share on other sites More sharing options...
MVP 2023 Joe Tauser Posted February 10 MVP 2023 Report Share Posted February 10 @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 More sharing options...
MVP 2023 Flex727 Posted February 10 MVP 2023 Report Share Posted February 10 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 More sharing options...
Cara Bereck Levy Posted February 15 Report Share Posted February 15 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 More sharing options...
jwh Posted February 29 Report Share Posted February 29 This was very helpful Joe T Same retarded modbus device Here is my solution before and after i read this tread. And i did use a lot more than one hour on swap bytes extended 4 byte buffer to int32 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now