laforge has uploaded this change for review. ( https://gerrit.osmocom.org/c/pysim/+/41742?usp=email )
Change subject: some more use of PaddedBcdAdapter ......................................................................
some more use of PaddedBcdAdapter
There are more files where trailing digits are indicated using 'f' and should be stripped during decode, including EF.MSISDN and EF.VGCS
Change-Id: I4571482da924a3d645caa297108279d182448d21 --- M pySim/ts_31_102.py M pySim/ts_51_011.py 2 files changed, 9 insertions(+), 9 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/42/41742/1
diff --git a/pySim/ts_31_102.py b/pySim/ts_31_102.py index 3ae178c..a93f1e8 100644 --- a/pySim/ts_31_102.py +++ b/pySim/ts_31_102.py @@ -596,7 +596,7 @@ self._construct = Struct('alpha_id'/Bytes(this._.total_len-28), 'len_of_bcd_contents'/Int8ub, 'ton_npi'/Int8ub, - 'call_number'/BcdAdapter(Bytes(10)), + 'call_number'/PaddedBcdAdapter(Rpad(Bytes(10))), 'cap_cfg2_record_id'/Int8ub, 'ext5_record_id'/Int8ub, 'date_and_time'/BcdAdapter(Bytes(7)), @@ -612,7 +612,7 @@ self._construct = Struct('alpha_id'/Bytes(this._.total_len-27), 'len_of_bcd_contents'/Int8ub, 'ton_npi'/Int8ub, - 'call_number'/BcdAdapter(Bytes(10)), + 'call_number'/PaddedBcdAdapter(Rpad(Bytes(10))), 'cap_cfg2_record_id'/Int8ub, 'ext5_record_id'/Int8ub, 'date_and_time'/BcdAdapter(Bytes(7)), @@ -1118,7 +1118,7 @@ # responsibility of home network operator but BCD coding shall be used. If a network # operator decides to assign less than 4 digits to Routing Indicator, the remaining digits # shall be coded as "1111" to fill the 4 digits coding of Routing Indicator - self._construct = Struct('routing_indicator'/Rpad(BcdAdapter(Bytes(2)), 'f', 2), + self._construct = Struct('routing_indicator'/PaddedBcdAdapter(Rpad(Bytes(2))), 'rfu'/Bytes(2))
# TS 31.102 Section 4.4.11.13 (Rel 16) diff --git a/pySim/ts_51_011.py b/pySim/ts_51_011.py index d37715f..70c38b1 100644 --- a/pySim/ts_51_011.py +++ b/pySim/ts_51_011.py @@ -152,7 +152,7 @@ self._construct = Struct('alpha_id'/COptional(GsmOrUcs2Adapter(Rpad(Bytes(this._.total_len-14)))), 'len_of_bcd'/Int8ub, 'ton_npi'/TonNpi, - 'dialing_nr'/ExtendedBcdAdapter(BcdAdapter(Rpad(Bytes(10)))), + 'dialing_nr'/ExtendedBcdAdapter(PaddedBcdAdapter(Rpad(Bytes(10)))), 'cap_conf_id'/Int8ub, ext_name/Int8ub)
@@ -193,11 +193,11 @@ ( 'ffffffffffffffffffffffffffffffffffffffff04b12143f5ffffffffffffffffff', {"alpha_id": "", "len_of_bcd": 4, "ton_npi": {"ext": True, "type_of_number": "network_specific", "numbering_plan_id": "isdn_e164"}, - "dialing_nr": "12345f"}), + "dialing_nr": "12345"}), ( '456967656e65205275666e756d6d6572ffffffff0891947172199181f3ffffffffff', {"alpha_id": "Eigene Rufnummer", "len_of_bcd": 8, "ton_npi": {"ext": True, "type_of_number": "international", "numbering_plan_id": "isdn_e164"}, - "dialing_nr": "4917279119183f"}), + "dialing_nr": "4917279119183"}), ]
# Ensure deprecated representations still work @@ -215,7 +215,7 @@ self._construct = Struct('alpha_id'/COptional(GsmOrUcs2Adapter(Rpad(Bytes(this._.total_len-14)))), 'len_of_bcd'/Int8ub, 'ton_npi'/TonNpi, - 'dialing_nr'/ExtendedBcdAdapter(BcdAdapter(Rpad(Bytes(10)))), + 'dialing_nr'/ExtendedBcdAdapter(PaddedBcdAdapter(Rpad(Bytes(10)))), Padding(2, pattern=b'\xff'))
# Maintain compatibility with deprecated representations @@ -661,12 +661,12 @@ # TS 51.011 Section 10.3.20 / 10.3.22 class EF_VGCS(TransRecEF): _test_de_encode = [ - ( "92f9ffff", "299fffff" ), + ( "92f9ffff", "299" ), ] def __init__(self, fid='6fb1', sfid=None, name='EF.VGCS', size=(4, 200), rec_len=4, desc='Voice Group Call Service', **kwargs): super().__init__(fid, sfid=sfid, name=name, desc=desc, size=size, rec_len=rec_len, **kwargs) - self._construct = BcdAdapter(Bytes(4)) + self._construct = PaddedBcdAdapter(Rpad(Bytes(4)))
# TS 51.011 Section 10.3.21 / 10.3.23 class EF_VGCSS(TransparentEF):