aboutsummaryrefslogtreecommitdiffstats
path: root/cards
diff options
context:
space:
mode:
authorhploetz <hploetz@f711b948-2313-0410-aaa9-d29f33439f0b>2006-07-21 18:22:40 +0000
committerhploetz <hploetz@f711b948-2313-0410-aaa9-d29f33439f0b>2006-07-21 18:22:40 +0000
commit74f51895ad388e7bbc62ac2b069a46f029919f1d (patch)
treedf42e5a9c4d770c2323e5bc9bed8c12fa222b518 /cards
parentcad6f9cbd1b52888b5803c2cb41d4b23702c4efe (diff)
parse_tlv now takes offset arguments
git-svn-id: svn+ssh://localhost/home/henryk/svn/cyberflex-shell/trunk@104 f711b948-2313-0410-aaa9-d29f33439f0b
Diffstat (limited to 'cards')
-rw-r--r--cards/generic_card.py15
1 files changed, 12 insertions, 3 deletions
diff --git a/cards/generic_card.py b/cards/generic_card.py
index 3b4d6ea..35c2e85 100644
--- a/cards/generic_card.py
+++ b/cards/generic_card.py
@@ -61,9 +61,18 @@ class Card:
"""Reset the card."""
self.card.reconnect(init=pycsc.SCARD_RESET_CARD)
- def cmd_parsetlv(self):
- "Decode the TLV data in the last response"
- print TLV_utils.decode(self.last_result.data, tags=self.TLV_OBJECTS)
+ def cmd_parsetlv(self, start = None, end = None):
+ "Decode the TLV data in the last response, start and end are optional"
+ lastlen = len(self.last_result.data)
+ if start is not None:
+ start = (lastlen + (int(start,0) % lastlen) ) % lastlen
+ else:
+ start = 0
+ if end is not None:
+ end = (lastlen + (int(end,0) % lastlen) ) % lastlen
+ else:
+ end = lastlen
+ print TLV_utils.decode(self.last_result.data[start:end], tags=self.TLV_OBJECTS)
COMMANDS = {
"reset": cmd_reset,