JoelBender / bacpypes

BACpypes provides a BACnet application layer and network layer written in Python for daemons, scripting, and graphical interfaces.
MIT License
302 stars 129 forks source link

Potential Error in _parse_wp_args #500

Open Kabilan001 opened 1 year ago

Kabilan001 commented 1 year ago

Firstly, I'm a big fan of your work.

I have an object named "limitEnable" with a current value of [0,0]. I would like to change it to [1,1] using the command:

bacnet.write("200.0.0.29 analogInput 3 limitEnable [1,1]")

However, I'm encountering the error "ValueError: invalid literal for int() with base 10: '-'." I've checked the code base and the function _parse_wp_args, but I'm still getting the same error. Could you please assist me with this?

JoelBender commented 1 year ago

This is a BAC0 issue, so you're actually a fan of his work :-).

The basic reason is that the particular "sub-language" in that write command doesn't support that syntax for a bit string. It's possible to extend _validate_value_vs_datatype(); if the datatype is a subclass of Enumerated then something like value = [int(x) for x in value.split(",")] then maybe a assert all(x in (0,1) for z in value) to make sure they are just bits. Your write() call becomes bacnet.write("... 1,1").

Not tested! :smile: