The 'Len' field of UPSISublist is not encoded when using 'to_bytes'
The issue may be reproduced using the following test
def test_upsi_sublist_from_obj_to_bytes(self):
upsi_sublist_obj = UPSISublist(val={
'PLMN': '27201',
'Cont': [
1,
2
]
})
show(upsi_sublist_obj)
upsi_sublist_bytes = upsi_sublist_obj.to_bytes()
print(upsi_sublist_obj.hex())
expected_upsi_sublist_bytes = b'\x00\x07\x72\xf2\x10\x00\x01\x00\x02'
assert upsi_sublist_bytes == expected_upsi_sublist_bytes
There is no 'init' method associated with the UPSISublist class.
|
class UPSISublist(Envelope): |
I've done some experimenting and the addition of the following code, resolves the issue.
def __init__(self, *args, **kwargs):
Envelope.__init__(self, *args, **kwargs)
self[0].set_valauto(lambda: 3 + self[2].get_len())
self[2].set_blauto(lambda: (self[0].get_val()-3) << 3)
I'm happy to assist with testing.
Thanks.