favalex / modbus-cli

Command line tool to access Modbus devices
Mozilla Public License 2.0
175 stars 33 forks source link

enumerations break on spaces #23

Open smee opened 1 year ago

smee commented 1 year ago

Shouldn't https://github.com/favalex/modbus-cli/blob/c889b6d5f463d4f4de3cc4dfc43924f23076cf41/modbus_cli/definitions.py#L58 be splitlines? split will split on any whitespace, so this enumeration will not work:

:example 0=ok 1=not ok

Error message:

Traceback (most recent call last): File "/home/pi/.local/bin/modbus", line 110, in main() File "/home/pi/.local/bin/modbus", line 101, in main definitions.parse(args.registers + os.environ.get('MODBUS_DEFINITIONS', '').split(':')) File "/home/pi/.local/lib/python3.9/site-packages/modbus_cli/definitions.py", line 25, in parse self.parse_line(accumulated_line) File "/home/pi/.local/lib/python3.9/site-packages/modbus_cli/definitions.py", line 40, in parse_line name, values = self.parse_presenter(line) File "/home/pi/.local/lib/python3.9/site-packages/modbus_cli/definitions.py", line 63, in parse_presenter value, symbol = definition.split('=') ValueError: not enough values to unpack (expected 2, got 1)

favalex commented 1 year ago

Spaces in enum identifiers are not supported, you can use something like 1=not_ok or 1=ko instead.