Skip to content

Commit

Permalink
Fixed bug in ISO7816
Browse files Browse the repository at this point in the history
Added delay after reset and before ISO7816 flush.
  • Loading branch information
kingofpayne committed Jan 29, 2024
1 parent bca3581 commit 5df4f7d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
7 changes: 2 additions & 5 deletions api/scaffold/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -718,9 +718,7 @@ def transmit(self, data: bytes, trigger: bool = False):
else:
buf = data
# Polling on status.ready bit before sending each character.
self.reg_data.write(
buf, poll=self.reg_status, poll_mask=0x01, poll_value=0x01
)
self.reg_data.write(buf, poll=self.reg_status, poll_mask=0x01, poll_value=0x01)
if trigger:
config = self.reg_config.get()
# Enable trigger as soon as previous transmission ends
Expand Down Expand Up @@ -2268,7 +2266,7 @@ def write(self, addr, data, poll=None, poll_mask=0xFF, poll_value=0x00):
remaining = len(data)
while remaining:
chunk_size = min(self.MAX_CHUNK, remaining)
op = self.operation_write(
self.operation_write(
addr, data[offset : offset + chunk_size], poll, poll_mask, poll_value
)
remaining -= chunk_size
Expand Down Expand Up @@ -2640,7 +2638,6 @@ def delay(self, duration: float):
:param cycles: Delay duration in seconds.
"""
cycles = round(duration * self.sys_freq)
print(cycles)
self.bus.operation_delay(cycles)


Expand Down
2 changes: 2 additions & 0 deletions api/scaffold/iso7816.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from . import Scaffold
import requests
import crcmod
from time import sleep


class ProtocolError(Exception):
Expand Down Expand Up @@ -320,6 +321,7 @@ def reset(self) -> bytes:
:raises ProtocolError: if the ATR is not valid.
"""
self.sig_nrst << 0
sleep(0.05)
self.iso7816.flush()
self.sig_nrst << 1
info = parse_atr(ScaffoldISO7816ByteReader(self.iso7816))
Expand Down

0 comments on commit 5df4f7d

Please sign in to comment.