laforge submitted this change.

View Change


Approvals: Jenkins Builder: Verified laforge: Looks good to me, approved
pySim-trace: catch StopIteration exception on trace file end

When the trace file end is reaced, pyShark raises a StopIteration
exception. Let's catch this exception and exit gracefully.

Related: OS#6094
Change-Id: I6ab5689b909333531d08bf46e5dfea59b161a79e
---
M pySim-trace.py
1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/pySim-trace.py b/pySim-trace.py
index 8313c27..325fb8c 100755
--- a/pySim-trace.py
+++ b/pySim-trace.py
@@ -100,9 +100,15 @@

def main(self):
"""Main loop of tracer: Iterates over all Apdu received from source."""
+ apdu_counter = 0
while True:
# obtain the next APDU from the source (blocking read)
- apdu = self.source.read()
+ try:
+ apdu = self.source.read()
+ apdu_counter = apdu_counter + 1
+ except StopIteration:
+ print("%i APDUs parsed, stop iteration." % apdu_counter)
+ return 0

if isinstance(apdu, CardReset):
self.rs.reset()

To view, visit change 33962. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I6ab5689b909333531d08bf46e5dfea59b161a79e
Gerrit-Change-Number: 33962
Gerrit-PatchSet: 2
Gerrit-Owner: dexter <pmaier@sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy@sysmocom.de>
Gerrit-Reviewer: laforge <laforge@osmocom.org>
Gerrit-MessageType: merged