diff --git a/canopen_monitor/__init__.py b/canopen_monitor/__init__.py index f01bd89..c75868d 100755 --- a/canopen_monitor/__init__.py +++ b/canopen_monitor/__init__.py @@ -2,7 +2,7 @@ MAJOR = 4 MINOR = 0 -PATCH = 1 +PATCH = 2 APP_NAME = 'canopen-monitor' APP_DESCRIPTION = 'An NCurses-based TUI application for tracking activity' \ diff --git a/canopen_monitor/parse/eds.py b/canopen_monitor/parse/eds.py index 7f7fd4e..1ca117f 100644 --- a/canopen_monitor/parse/eds.py +++ b/canopen_monitor/parse/eds.py @@ -194,10 +194,12 @@ def __len__(self) -> int: def convert_value(value: str) -> Union[int, str]: # Turn number-like objects into numbers if (value != ''): - if (all(c in string.hexdigits for c in value)): - return int(value, 16) - elif (all(c in string.digits for c in value)): + if value.startswith("0x") and all(c in string.hexdigits for c in value): + return int(value[2:], 16) + if (all(c in string.digits for c in value)): return int(value, 10) + elif (all(c in string.hexdigits for c in value)): + return int(value, 16) else: return value diff --git a/tests/spec_eds_parser.py b/tests/spec_eds_parser.py index 9573dc6..1a1b237 100644 --- a/tests/spec_eds_parser.py +++ b/tests/spec_eds_parser.py @@ -102,7 +102,7 @@ def test_get_node_id(self): """ DCF Parsing set node id attribute """ - self.assertEqual(0x10, + self.assertEqual(10, self.eds.node_id, "Error parsing node id") @@ -163,7 +163,7 @@ def test_invalid_subindex_when_no_subindices(self): class TestExtendedPDODefinition(unittest.TestCase): def setUp(self): # node id defined in file - self.node_id = 0x10 + self.node_id = 10 with patch('builtins.open', mock_open(read_data=TEST_DCF)) as _: with patch('os.listdir') as mocked_listdir: mocked_listdir.return_value = ["battery.dcf"]