From 60951b0c17c5c04e75824d671fe415f84d6b3bb8 Mon Sep 17 00:00:00 2001 From: Matan Perelman Date: Thu, 1 Jun 2023 17:39:04 +0300 Subject: [PATCH] utils: Remove format_xplmn leading zeros in MNC Change-Id: I803edafbd892c2b32b884d0b39fed61967a3d68b --- pySim/utils.py | 9 ++++----- pysim-testdata/sysmoISIM-SJA2.ok | 2 +- pysim-testdata/sysmoUSIM-SJS1.ok | 8 ++++---- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/pySim/utils.py b/pySim/utils.py index 537014f0..c6362fab 100644 --- a/pySim/utils.py +++ b/pySim/utils.py @@ -594,8 +594,8 @@ def dec_xplmn(threehexbytes: Hexstr) -> dict: plmn_chars = 6 # first three bytes (six ascii hex chars) plmn_str = threehexbytes[:plmn_chars] - res['mcc'] = dec_mcc_from_plmn(plmn_str) - res['mnc'] = dec_mnc_from_plmn(plmn_str) + res['mcc'] = dec_mcc_from_plmn_str(plmn_str) + res['mnc'] = dec_mnc_from_plmn_str(plmn_str) return res @@ -603,11 +603,10 @@ def format_xplmn(hexstr: Hexstr) -> str: s = "" for rec_data in hexstr_to_Nbytearr(hexstr, 3): rec_info = dec_xplmn(rec_data) - if rec_info['mcc'] == 0xFFF and rec_info['mnc'] == 0xFFF: + if not rec_info['mcc'] and not rec_info['mnc']: rec_str = "unused" else: - rec_str = "MCC: %03d MNC: %03d" % ( - rec_info['mcc'], rec_info['mnc']) + rec_str = "MCC: %s MNC: %s" % (rec_info['mcc'], rec_info['mnc']) s += "\t%s # %s\n" % (rec_data, rec_str) return s diff --git a/pysim-testdata/sysmoISIM-SJA2.ok b/pysim-testdata/sysmoISIM-SJA2.ok index f9476df9..45acd795 100644 --- a/pysim-testdata/sysmoISIM-SJA2.ok +++ b/pysim-testdata/sysmoISIM-SJA2.ok @@ -103,7 +103,7 @@ SIM Service Table: ff33ffff3f003f0f300cf0c3f00000 Service 59 - MMS User Connectivity Parameters EHPLMN: - 00f110 # MCC: 001 MNC: 001 + 00f110 # MCC: 001 MNC: 01 ffffff # unused ffffff # unused ffffff # unused diff --git a/pysim-testdata/sysmoUSIM-SJS1.ok b/pysim-testdata/sysmoUSIM-SJS1.ok index b4277f45..b793cc0e 100644 --- a/pysim-testdata/sysmoUSIM-SJS1.ok +++ b/pysim-testdata/sysmoUSIM-SJS1.ok @@ -105,10 +105,10 @@ SIM Service Table: ff3fffff3f003f1ff00c00c0f00000 Service 59 - MMS User Connectivity Parameters FPLMN: - 62f201 # MCC: 262 MNC: 010 - 62f202 # MCC: 262 MNC: 020 - 62f203 # MCC: 262 MNC: 030 - 62f207 # MCC: 262 MNC: 070 + 62f201 # MCC: 262 MNC: 10 + 62f202 # MCC: 262 MNC: 20 + 62f203 # MCC: 262 MNC: 30 + 62f207 # MCC: 262 MNC: 70 USIM Service Table: 9e6b1dfc67f6580000 Service 2 - Fixed Dialling Numbers (FDN)