P1sec / pycrate

A Python library to ease the development of encoders and decoders for various protocols and file formats; contains ASN.1 and CSN.1 compilers.
GNU Lesser General Public License v2.1
381 stars 132 forks source link

fix: TS24008 Networkname from dict #190

Closed edhinard closed 2 years ago

edhinard commented 2 years ago

Trying to create a NAS5G/FGMMConfigurationUpdateCommand payload, an exception was raised. I think the problem is in TS24008_IE.py.

Let's take an example:

import pycrate_mobile.TS24008_IE

hex = '10004f00700065006e003500470053'

n1 = pycrate_mobile.TS24008_IE.NetworkName()
n1.from_bytes(bytes.fromhex(hex))
val = n1.get_val_d()
print(val)

n2 = pycrate_mobile.TS24008_IE.NetworkName()
n2.set_val(val)
assert n2.to_bytes().hex() == hex

val equals to {'Ext': 0, 'Coding': 1, 'AddCountryInitials': 0, 'SpareBits': 0, 'Name': b'\x00O\x00p\x00e\x00n\x005\x00G\x00S'} and the line n2.set_val(val) raises the exception:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.8/dist-packages/pycrate_mobile/TS24008_IE.py", line 925, in set_val
    Name = dict(vals['Name'])
TypeError: cannot convert dictionary update sequence element #0 to a sequence

The current request fix this.

edhinard commented 2 years ago

sorry wrong commit - Closing request and reopening...