plc4x icon indicating copy to clipboard operation
plc4x copied to clipboard

[Bug]: Invalid tag item type from old Beckhoff

Open RuneRoven opened this issue 1 year ago • 7 comments

What happened?

Run the read example for GO and changed to a single bool which i can read from other clients on the same computer. Using an older PLC with Twincat 2 on port 801.

readRequest, err := connection.GetConnection().ReadRequestBuilder(). AddTagAddress("value-bool", "MAIN.myBool"). Build() if err != nil { panic(err) }

{"level":"debug","connection":"ads.Connection{}","time":"2024-02-25T17:12:04+01:00","message":"created connection, connecting now"} {"level":"trace","time":"2024-02-25T17:12:04+01:00","message":"Connecting"} {"level":"trace","time":"2024-02-25T17:12:04+01:00","message":"connecting"} {"level":"trace","time":"2024-02-25T17:12:04+01:00","message":"Sending request"} {"level":"trace","time":"2024-02-25T17:12:04+01:00","message":"Sending message"} {"level":"trace","time":"2024-02-25T17:12:04+01:00","message":"Reading"} {"level":"debug","tag":"*model.DirectPlcTag","time":"2024-02-25T17:12:04+01:00","message":"Invalid tag item type"} {"level":"info","time":"2024-02-25T17:12:04+01:00","message":"Shutting down driver manager"} {"level":"trace","name":"ads","time":"2024-02-25T17:12:04+01:00","message":"closing driver"} {"level":"trace","name":"tcp","time":"2024-02-25T17:12:04+01:00","message":"closing transport"} {"level":"trace","time":"2024-02-25T17:12:04+01:00","message":"Closing"} panic: runtime error: invalid memory address or nil pointer dereference [signal 0xc0000005 code=0x0 addr=0x28 pc=0x69ea5c]

Version

Latest

Programming Languages

  • [ ] plc4j
  • [X] plc4go
  • [ ] plc4c
  • [ ] plc4net

Protocols

  • [ ] AB-Ethernet
  • [X] ADS /AMS
  • [ ] BACnet/IP
  • [ ] CANopen
  • [ ] DeltaV
  • [ ] DF1
  • [ ] EtherNet/IP
  • [ ] Firmata
  • [ ] KNXnet/IP
  • [ ] Modbus
  • [ ] OPC-UA
  • [ ] S7

RuneRoven avatar Feb 25 '24 16:02 RuneRoven

Would it be possible to test the same on Java?

My reasoning behind this, is that the Java version has been greatly refactored in the past 1,5 years I think the Go version needs some of these updates. It would be good to know, if the Java side works as you expected.

chrisdutz avatar Feb 26 '24 09:02 chrisdutz

It could be possible, i will have to fix a java runtime and complie it.. I have tested communication with the plc using the native go ads lib which worked. I am not sure where the problem lies. maybe i need to clone the source code to add more debugs.. I also found different ways of adding the symbols, where in some examples like the one on the webpage uses AddTagAddress("value-bool", "MAIN.myBool:BOOL") but in the example file for Go it is AddTagAddress("value-bool", "MAIN.myBool").

RuneRoven avatar Feb 26 '24 09:02 RuneRoven

I rewrote most of the connection establishment something round 1,5 years ago so the java version fetches the symbol-table the data-type table and makes it possible to read complex types. I think the Go version still resolves a symbolic adress but possibly can't read UDTs. It's not a technical problem, it's more a problem of simply not having the time and not being to eager to give one of my former employers something they could need and use ;-) (Not talking about Mapped ... they were awesome)

chrisdutz avatar Feb 26 '24 10:02 chrisdutz

I will have another look in the source code to see if i can find the problem. For testing i have a clean plc with a small counter program, so no UDT and only some bool and int

RuneRoven avatar Feb 26 '24 12:02 RuneRoven

I have not yet tested the java version. I have however tried the native go ads library and found some errors there. Since i am using an old PLC it returns a symbol list with for example INT16, which in the native library is not handled, it expects INT which make the connection shut down so in the native lib i have added those types and it works. It maybe is the same problem in your code.

RuneRoven avatar Feb 29 '24 06:02 RuneRoven

Oh yeah. TwinCat2 is really a topic that we haven't really covered much. Mostly because of the lack of having such a device. If you could possibly start a pr for that, I'd be happy to help.

chrisdutz avatar Feb 29 '24 07:02 chrisdutz

I have not had the time to look further into this. I was doing a plugin for benthos to read from ads so I wanted to use the plc4x to have support for more devices, but as for now I ended up with using the go-native-ads library which I had to modify to read TC2.. Most problem was when doing symbol lookup it returned INT16 and UINT16 instead of INT and UINT which caused it to crash. Also for some reason the symbol names need to be in uppercase so I added a conversion in the plugin to change all symbols to uppercase.. I will see if I get the time to look into it again.

RuneRoven avatar Mar 04 '24 15:03 RuneRoven