In this project I am reading the Symbol Table of a Beckhoff Twincat based PLC. Work in progress!
If you run this, the state machine in MAIN will run through the following states:
Message 08-Sep-20 16:47:26 193 ms | 'PlcTask' (351): PLC: 0: 6681: RS_WAIT_FOR_START => RS_READ_SYMBOL_UPLOAD_INFO
Message 08-Sep-20 16:47:26 195 ms | 'PlcTask' (351): PLC: 1: 6683: RS_READ_SYMBOL_UPLOAD_INFO => RS_READ_SYMBOL_UPLOAD
Message 08-Sep-20 16:47:26 197 ms | 'PlcTask' (351): PLC: 2: 6685: RS_READ_SYMBOL_UPLOAD => RS_PROCESS_SYMBOL_UPLOAD
Message 08-Sep-20 16:47:26 378 ms | 'PlcTask' (351): PLC: 183: 6866: RS_PROCESS_SYMBOL_UPLOAD => RS_READ_SYMBOL_UPLOAD_INFO2
Message 08-Sep-20 16:47:26 380 ms | 'PlcTask' (351): PLC: 184: 6868: RS_READ_SYMBOL_UPLOAD_INFO2 => RS_READ_DATA_TYPE_UPLOAD
Message 08-Sep-20 16:47:26 382 ms | 'PlcTask' (351): PLC: 185: 6870: RS_READ_DATA_TYPE_UPLOAD => RS_PROCESS_DATA_UPLOAD
Message 08-Sep-20 16:47:26 440 ms | 'PlcTask' (351): PLC: 392: 6928: RS_PROCESS_DATA_UPLOAD => RS_DONE
If successfull it will end in the state RS_DONE.
In the state RS_PROCESS_SYMBOL_UPLOAD it will print all variables used and their type. For example, here are two pointers shown that point to the type AdsSymbolEntry:
Message 08-Sep-20 16:47:26 356 ms | 'PlcTask' (351): PLC: 161: 6844: MAIN.pAdsSymbolEntry POINTER TO AdsSymbolEntry
Message 08-Sep-20 16:47:26 361 ms | 'PlcTask' (351): PLC: 166: 6849: MAIN.pSubAdsSymbolEntry POINTER TO AdsSymbolEntry
In the RS_PROCESS_DATA_UPLOAD state it will print all the types that exist in the project. For example, the type AdsSymbolEntry, which contains 9 subitems:
Message 08-Sep-20 16:47:26 387 ms | 'PlcTask' (351): PLC: 237: 6875: AdsSymbolEntry
Message 08-Sep-20 16:47:26 387 ms | 'PlcTask' (351): PLC: 238: 6875: Amount of Subitems: 9
Message 08-Sep-20 16:47:26 387 ms | 'PlcTask' (351): PLC: 239: 6875: entryLength UDINT length of complete symbol entry
Message 08-Sep-20 16:47:26 387 ms | 'PlcTask' (351): PLC: 240: 6875: iGroup UDINT indexGroup of symbol: input, output etc.
Message 08-Sep-20 16:47:26 387 ms | 'PlcTask' (351): PLC: 241: 6875: iOffs UDINT indexOffset of symbol
Message 08-Sep-20 16:47:26 387 ms | 'PlcTask' (351): PLC: 242: 6875: size UDINT size of symbol ( in bytes, 0 = bit )
Message 08-Sep-20 16:47:26 387 ms | 'PlcTask' (351): PLC: 243: 6875: dataType UDINT adsDataType of symbol
Message 08-Sep-20 16:47:26 387 ms | 'PlcTask' (351): PLC: 244: 6875: flags UDINT see above
Message 08-Sep-20 16:47:26 387 ms | 'PlcTask' (351): PLC: 245: 6875: nameLength UINT length of symbol name (excl. \0)
Message 08-Sep-20 16:47:26 387 ms | 'PlcTask' (351): PLC: 246: 6875: typeLength UINT length of type name (excl. \0)
Message 08-Sep-20 16:47:26 387 ms | 'PlcTask' (351): PLC: 247: 6875: commentLength UINT length of comment (excl. \0)