lc calculation

git-svn-id: svn+ssh://localhost/home/henryk/svn/cyberflex-shell/trunk@24 f711b948-2313-0410-aaa9-d29f33439f0b
This commit is contained in:
henryk 2005-09-30 03:03:54 +00:00
parent 28021747f4
commit b89286679b
1 changed files with 4 additions and 3 deletions

View File

@ -124,7 +124,6 @@ class APDU(list):
if len(self) < 4:
self.extend([0] * (4-len(self)))
print self
le = None
for (kw, arg) in kwargs.items():
if kw == "cla":
@ -146,13 +145,15 @@ class APDU(list):
else:
raise TypeError, "Got an unexpected keyword argument '%s'" % kw
print self
if le is not None:
if len(self) > self.OFFSET_CONTENT:
raise TypeError, "le can't be set when there is data to send"
else:
self[self.OFFSET_LE:self.OFFSET_LE+1] = (le,)
if self[self.OFFSET_LC] == None:
self[self.OFFSET_LC] = len(self)-self.OFFSET_CONTENT
for i in range(len(self)):
t = type(self[i])
if t == str:
@ -240,6 +241,6 @@ if __name__ == "__main__":
#response = sys.stdin.read()
#parse_status(_unformat_hexdump(response)[:-2])
print APDU((1,2,3), lc=42, cla=0x23, le=4)
print APDU((1,2,3), cla=0x23, content="hallo", lc=None)