ottowayi / pycomm3

A Python Ethernet/IP library for communicating with Allen-Bradley PLCs.
MIT License
397 stars 88 forks source link

Mismatch Datatype in UDT returns "Unable to create a writable value" error #273

Closed Colt-H closed 1 year ago

Colt-H commented 1 year ago

Not sure how this should be handled, but it might be useful to add a little more descriptive error message.

I have a UDT that has 3 members: an array of 200 strings, an array of 200 DINTS, and another array of 200 DINTS. Upon trying to write to these values, I was inadvertently trying to write numbers as strings to the DINT arrays. Pycomm caught the error (line 1514 in Logix_Driver.py), however there's no hint as to what caused the exception. It looks like this may be a generic catch-all for trying to encode values, but I'm not 100% sure why this is the exception I was getting.

ottowayi commented 1 year ago

You're right that's a generic catch all message, the root cause is somewhere in the stack trace and I agree it's frustrating trying to find it. I'm currently working on a new implementation of all of the data types that are better about this and should give a much better indication on what was incorrect. Unfortunately, I don't have a timeline on when that will be done and don't really plan on modifying the existing code since that would take significant refactoring to just be replaced anyway. Thanks for reporting this though.