Closed hglassdyb closed 6 months ago
@hglassdyb Thanks for this! I am working on a fix now. If you'd like to unblock your work, you can modify smp/header.py in your venv to contain the definition for your custom group:
class GroupId(IntEnum):
OS_MANAGEMENT = 0
IMAGE_MANAGEMENT = 1
STATISTICS_MANAGEMENT = 2
SETTINGS_MANAGEMENT = 3
LOG_MANAGEMENT = 4
RUNTIME_TESTS = 5
SPLIT_IMAGE_MANAGEMENT = 6
TEST_CRASH = 7
FILE_MANAGEMENT = 8
SHELL_MANAGEMENT = 9
ZEPHYR = 63
_APPLICATIION_CUSTOM_MIN = 64
INTERCREATE = 64
MY_GROUP = 65
The fix will allow inheritance the way you've defined it.
@hglassdyb This should be fixed in 0.3.4, test it out at your convenience, thanks!
Thanks, now it works for _GROUP_ID > 64
:+1:
However I didn't manage to use the _GROUP_ID=64
along with _COMMAND_ID=0
or _COMMAND_ID>=2
:
class DeviceRequest(smp.message.ReadRequest):
_GROUP_ID=64
_COMMAND_ID=0
It gives this error:
Traceback (most recent call last):
File "/home/test_smpclient.py", line 64, in <module>
req = DeviceRequest()
^^^^^^^^^^^^^^^
File "/home/.venv/lib/python3.11/site-packages/pydantic/main.py", line 176, in __init__
self.__pydantic_validator__.validate_python(data, self_instance=self)
pydantic_core._pydantic_core.ValidationError: 1 validation error for DeviceRequest
Value error, Command ID 0 is not valid for Group ID 64 (_APPLICATIION_CUSTOM_MIN) [type=value_error, input_value={}, input_type=dict]
For further information visit https://errors.pydantic.dev/2.7/v/value_error
Good point! I need to move 64 out of the GroupId enum, it's attempting to validate the CommandIds.
@unique
class GroupId(IntEnum):
OS_MANAGEMENT = 0
IMAGE_MANAGEMENT = 1
STATISTICS_MANAGEMENT = 2
SETTINGS_MANAGEMENT = 3
LOG_MANAGEMENT = 4
RUNTIME_TESTS = 5
SPLIT_IMAGE_MANAGEMENT = 6
TEST_CRASH = 7
FILE_MANAGEMENT = 8
SHELL_MANAGEMENT = 9
ZEPHYR = 63
class CustomGroupId(IntEnum):
INTERCREATE = 64
Hi,
I was trying to use this library (along with
smpclient
) to test some application specific management groups. However it gave some errors when defining custom requests.Is there a way around this? Or am I doing something wrong?