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/.
laforge gerrit-no-reply at lists.osmocom.orglaforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/26204 ) Change subject: pySim-shell: export command: guess number of records when not specified ...................................................................... pySim-shell: export command: guess number of records when not specified The select response of an UICC will always return the number of records of a file. However, older SIM will not include the number of records in the select response. In those cases, simply guess the number of records by reading until the first invalid record is hit. Change-Id: Ib480797d881b9ec607ec6a86b73d452449f8cf87 Related: OS#5274 --- M pySim-shell.py 1 file changed, 22 insertions(+), 4 deletions(-) Approvals: Jenkins Builder: Verified laforge: Looks good to me, approved fixeria: Looks good to me, but someone else must approve diff --git a/pySim-shell.py b/pySim-shell.py index 0519ec4..8e8a1a6 100755 --- a/pySim-shell.py +++ b/pySim-shell.py @@ -517,10 +517,28 @@ result = self._cmd.rs.read_binary() self._cmd.poutput("update_binary " + str(result[0])) elif structure == 'cyclic' or structure == 'linear_fixed': - num_of_rec = fd['num_of_rec'] - for r in range(1, num_of_rec + 1): - result = self._cmd.rs.read_record(r) - self._cmd.poutput("update_record %d %s" % (r, str(result[0]))) + # Use number of records specified in select response + if 'num_of_rec' in fd: + num_of_rec = fd['num_of_rec'] + for r in range(1, num_of_rec + 1): + result = self._cmd.rs.read_record(r) + self._cmd.poutput("update_record %d %s" % (r, str(result[0]))) + # When the select response does not return the number of records, read until we hit the + # first record that cannot be read. + else: + r = 1 + while True: + try: + result = self._cmd.rs.read_record(r) + except SwMatchError as e: + # We are past the last valid record - stop + if e.sw_actual == "9402": + break + # Some other problem occurred + else: + raise e + self._cmd.poutput("update_record %d %s" % (r, str(result[0]))) + r = r + 1 elif structure == 'ber_tlv': tags = self._cmd.rs.retrieve_tags() for t in tags: -- To view, visit https://gerrit.osmocom.org/c/pysim/+/26204 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: pysim Gerrit-Branch: master Gerrit-Change-Id: Ib480797d881b9ec607ec6a86b73d452449f8cf87 Gerrit-Change-Number: 26204 Gerrit-PatchSet: 6 Gerrit-Owner: dexter <pmaier at sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria <vyanitskiy at sysmocom.de> Gerrit-Reviewer: laforge <laforge at osmocom.org> Gerrit-MessageType: merged -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20211122/4fb91a45/attachment.htm>