libplctag / libplctag.NET

A .NET wrapper for libplctag.
https://libplctag.github.io/
Mozilla Public License 2.0
194 stars 50 forks source link

Array of UDT #366

Closed arcimus closed 3 months ago

arcimus commented 4 months ago

Hello, I'm attempting to list and read tags in ControlLogix software written by an equipment manufacturer. I am able to list tags and UDTs using your sample code, but I'm not sure how to enumerate arrays of UDTs.

Here's an example set of tags retrieved using a 3rd party tool: ArrayofUDT

Using libplctag.NET, I can determine that "B0501_COM262_Node2:I.Slot" is a UDT, and can retrieve the UDT definition that contains ".Fault" and ".Data" DINTs. However, I'm not sure how to determine that "B0501_COM262_Node2:I.Slot" is an array of UDTs.

B0501_COM262_Node2:I.Slot: Type: 44080 Offset: 4 Metadata: 7 NumFields: 2 Size: 60

The 7 value for Metadata sticks out, but after searching around, I'm not sure what Metadata is used for.

timyhac commented 4 months ago

There is some information about the meaning of the UDT info structure in the source code here - you are onto something!

arcimus commented 3 months ago

Hello and thanks for your reply. In the source code you mentioned, I see:

     * N x field info entries
     *     uint16_t field_metadata - array element count or bit field number
     *     uint16_t field_type
     *     uint32_t field_offset

So, the 7 returned in the libplctag.NET Metadata field could be an array element count or bit field number. How can I use libplctag.NET to determine if it's the former or the latter?

timyhac commented 3 months ago

I believe that it refers to a bit field number when it is a BOOL type.

arcimus commented 3 months ago

Hi and thanks. The print_element_type function here helped me identify tag types.