Change in pysim[master]: cards.py: added read_sst_raw and read_sst methods

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/.

guilly@gmail.com gerrit-no-reply at lists.osmocom.org
Wed Apr 15 15:21:45 UTC 2020


guilly at gmail.com has uploaded this change for review. ( https://gerrit.osmocom.org/c/pysim/+/17827 )


Change subject: cards.py: added read_sst_raw and read_sst methods
......................................................................

cards.py: added read_sst_raw and read_sst methods

read_sst generates a an array of strings of the form
service N: service name
it simply calls read_sst_raw and parses it

read_sst_raw generates a string consisting of an array of
bits, ordered from 1 to N

Change-Id: I4e85b3e6c25ede4ad4c3c46db83f8314864a036f
---
M pySim/cards.py
1 file changed, 25 insertions(+), 0 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/27/17827/1

diff --git a/pySim/cards.py b/pySim/cards.py
index d27092d..d155e9f 100644
--- a/pySim/cards.py
+++ b/pySim/cards.py
@@ -226,6 +226,31 @@
 		except Exception as e:
 			print("Can't read AIDs from SIM -- %s" % (str(e),))
 
+	def read_sst_raw(self):
+		try:
+			(res, sw) = self._scc.read_binary(EF['SST'])
+			if sw == '9000':
+				return (res, sw)
+			else:
+				return (None, sw)
+		except Exception as e:
+			print("Can't read AIDs from SIM -- %s" % (str(e),))
+
+	def read_sst(self):
+		(res, sw) = self.read_sst_raw()
+		if sw == '9000':
+			res_mapped = []
+			supported_services=''
+			for i in range(len(res)/2):
+				bitmask ='{0:08b}'.format(int(res[2*i:2*i+2],16))
+				supported_services += bitmask[::-1]
+
+			res_mapped = [ "Service #{0:03d} - {1}".format(i,service) 
+							for i, service in EF_SST_map.items() if supported_services[i] == '1']
+			return (res_mapped, sw)
+		else:
+			return (None, sw)
+
 
 class _MagicSimBase(Card):
 	"""

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

Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I4e85b3e6c25ede4ad4c3c46db83f8314864a036f
Gerrit-Change-Number: 17827
Gerrit-PatchSet: 1
Gerrit-Owner: guilly at gmail.com <guilly at gmail.com>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20200415/68fc27d2/attachment.htm>


More information about the gerrit-log mailing list