forked from public/pysim
transport/serial: fix for Python 3
Change-Id: I21e5a7ad4f623ed30681dce1ff819679b8714c5b
This commit is contained in:
@@ -184,7 +184,7 @@ class SerialSimLink(LinkBase):
|
|||||||
def _send_apdu_raw(self, pdu):
|
def _send_apdu_raw(self, pdu):
|
||||||
|
|
||||||
pdu = h2b(pdu)
|
pdu = h2b(pdu)
|
||||||
data_len = ord(pdu[4]) # P3
|
data_len = pdu[4] # P3
|
||||||
|
|
||||||
# Send first CLASS,INS,P1,P2,P3
|
# Send first CLASS,INS,P1,P2,P3
|
||||||
self._tx_string(pdu[0:5])
|
self._tx_string(pdu[0:5])
|
||||||
@@ -195,7 +195,7 @@ class SerialSimLink(LinkBase):
|
|||||||
# - SW1: The card can apparently proceed ...
|
# - SW1: The card can apparently proceed ...
|
||||||
while True:
|
while True:
|
||||||
b = self._rx_byte()
|
b = self._rx_byte()
|
||||||
if b == pdu[1]:
|
if ord(b) == pdu[1]:
|
||||||
break
|
break
|
||||||
elif b != '\x60':
|
elif b != '\x60':
|
||||||
# Ok, it 'could' be SW1
|
# Ok, it 'could' be SW1
|
||||||
@@ -215,7 +215,7 @@ class SerialSimLink(LinkBase):
|
|||||||
# length = [P3 - tx_data (=len(pdu)-len(hdr)) + 2 (SW1//2) ]
|
# length = [P3 - tx_data (=len(pdu)-len(hdr)) + 2 (SW1//2) ]
|
||||||
to_recv = data_len - len(pdu) + 5 + 2
|
to_recv = data_len - len(pdu) + 5 + 2
|
||||||
|
|
||||||
data = ''
|
data = bytes(0)
|
||||||
while (len(data) < to_recv):
|
while (len(data) < to_recv):
|
||||||
b = self._rx_byte()
|
b = self._rx_byte()
|
||||||
if (to_recv == 2) and (b == '\x60'): # Ignore NIL if we have no RX data (hack ?)
|
if (to_recv == 2) and (b == '\x60'): # Ignore NIL if we have no RX data (hack ?)
|
||||||
|
|||||||
Reference in New Issue
Block a user