-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
UDT tag reading #21
Comments
I use a compatLogix, and the latest version of libplctag4j |
UDTs are read like any other tag type. When you read an entire UDT, you get the whole thing as a blob of bytes. You can also read each field individually. name="myUDTTag" -> gets the entire tag. You can use the tag_rw2 tool from the C project to experiment with this. If you read an entire UDT at once, it is very fast, but you will need to determine the offsets within the bytes of each field. For instance, if you have a UDT, myUDTTag, with 3 DINTs, A, B, and C, you can read and extract them like this: Tag tag = new Tag("...name=myUDTTag"...); tag.read(1000) // you should check the status here int fieldAValue = tag.getInt32(0); There are many different packing rules for UDTs that Rockwell imposes. If you have boolean values in a UDT, they are packed into hidden byte values that are stored at the start of the UDT or before the boolean field. Each bit is allocated from one of the bits in the hidden field. Most fields are padded to their nearest power-of-two size. For instance if you have a UDT with a SINT (one byte) followed by a DINT (4 bytes), the UDT will be a total of 8 bytes. The SINT field will be at the beginning, then there will be 3 bytes of padding and then the DINT field. Let me know if you still have questions! |
Thank you very much, it works, I understand that string data type tags are 88 bytes? I seemed to read. |
an example of how you can read or write a UDT tag with libplctag4j, thanks
The text was updated successfully, but these errors were encountered: