pjkundert / cpppo

Communications Protocol Python Parser and Originator -- EtherNet/IP CIP
https://hardconsulting.com/products/6-cpppo-enip-api
Other
334 stars 109 forks source link

Fix boolean writing #13

Closed johanfforsberg closed 8 years ago

johanfforsberg commented 8 years ago

Writing boolean tags is broken so that whatever value specified, it will always be interpreted as True. This fix allows "0" or "false" to write false, and any other number or "true" to write true. Not sure what should be allowed exactly.

pjkundert commented 8 years ago

Thanks! Fixed; rolled version 3.9.2

rikirolly commented 4 years ago

I am trying to write a BOOL tag on Omron NX1P2 PLC. When I read the tag declared as BOOL on the PLC I get an INT list of 2 elements with the first element representing the corresponding BOOL value. I cannot write the tag instead and this is my trial: via = proxy( shelf[identifier].ip_address )
with via: value = True params = via.parameter_substitution('mytag = (BOOL)' + str(value)) tag_value, = via.write(params, checking=True)

any suggestion? Thanks a lot

GraninDB commented 3 years ago

Hello! try to replace

class BOOL( TYPE ):
    tag_type                    = 0x00c1
    struct_format               = 'B'

with

class BOOL( TYPE ):
    tag_type                    = 0x00c1
    struct_format               = '<H'

in parser.py i was able to write BOOL from ONRON NJ series