Change in pysim[master]: Fixed MCC and MCC representation in the output of pySim-read

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

herlesupreeth gerrit-no-reply at lists.osmocom.org
Mon Jan 20 12:17:59 UTC 2020


herlesupreeth has uploaded this change for review. ( https://gerrit.osmocom.org/c/pysim/+/16944 )


Change subject: Fixed MCC and MCC representation in the output of pySim-read
......................................................................

Fixed MCC and MCC representation in the output of pySim-read

Change-Id: Ie699c0a38d5ae90e4d6109e4574ce860e4044096
---
M pySim/utils.py
1 file changed, 18 insertions(+), 9 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/44/16944/1

diff --git a/pySim/utils.py b/pySim/utils.py
index 65f10c5..3b6c0bc 100644
--- a/pySim/utils.py
+++ b/pySim/utils.py
@@ -124,9 +124,13 @@
 	digit3 = ia[1] & 0x0F		# 2nd byte, LSB
 	if digit3 == 0xF and digit2 == 0xF and digit1 == 0xF:
 		return 0xFFF # 4095
-	mcc = digit1 * 100
-	mcc += digit2 * 10
-	mcc += digit3
+	mcc = 0
+	if digit1 != 0XF:
+		mcc += digit1 * 100
+	if digit2 != 0XF:
+		mcc += digit2 * 10
+	if digit3 != 0XF:
+		mcc += digit3
 	return mcc
 
 def dec_mnc_from_plmn(plmn):
@@ -139,12 +143,17 @@
 	mnc = 0
 	# signifies two digit MNC
 	if digit3 == 0xF:
-		mnc += digit1 * 10
-		mnc += digit2
+		if digit1 != 0XF:
+			mnc += digit1 * 10
+		if digit2 != 0XF:
+			mnc += digit2
 	else:
-		mnc += digit1 * 100
-		mnc += digit2 * 10
-		mnc += digit3
+		if digit1 != 0XF:
+			mnc += digit1 * 100
+		if digit2 != 0XF:
+			mnc += digit2 * 10
+		if digit3 != 0XF:
+			mnc += digit3
 	return mnc
 
 def dec_act(twohexbytes):
@@ -182,7 +191,7 @@
 		if rec_info['mcc'] == 0xFFF and rec_info['mnc'] == 0xFFF:
 			rec_str = "unused"
 		else:
-			rec_str = "MCC: %3s MNC: %3s AcT: %s" % (rec_info['mcc'], rec_info['mnc'], ", ".join(rec_info['act']))
+			rec_str = "MCC: %03d MNC: %03d AcT: %s" % (rec_info['mcc'], rec_info['mnc'], ", ".join(rec_info['act']))
 		s += "\t%s # %s\n" % (rec_data, rec_str)
 	return s
 

-- 
To view, visit https://gerrit.osmocom.org/c/pysim/+/16944
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: Ie699c0a38d5ae90e4d6109e4574ce860e4044096
Gerrit-Change-Number: 16944
Gerrit-PatchSet: 1
Gerrit-Owner: herlesupreeth <herlesupreeth at gmail.com>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20200120/f4c7f936/attachment.htm>


More information about the gerrit-log mailing list