From 26b5baf657036cf1a443ccd7943a4d29845caafa Mon Sep 17 00:00:00 2001 From: Jan Pochyla Date: Wed, 6 Sep 2017 15:43:37 +0200 Subject: [PATCH] apps/fido_u2f: fix worfklow api, optimize --- src/apps/fido_u2f/__init__.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/apps/fido_u2f/__init__.py b/src/apps/fido_u2f/__init__.py index b7da0c7e86..614bcc7fc5 100644 --- a/src/apps/fido_u2f/__init__.py +++ b/src/apps/fido_u2f/__init__.py @@ -229,8 +229,9 @@ class Cmd: async def read_cmd(iface: io.HID) -> Cmd: desc_init = frame_init() desc_cont = frame_cont() + read = loop.select(iface.iface_num()) - buf, = await loop.select(iface.iface_num()) + buf = await read # log.debug(__name__, 'read init %s', buf) ifrm = overlay_struct(buf, desc_init) @@ -252,7 +253,7 @@ async def read_cmd(iface: io.HID) -> Cmd: data = data[:bcnt] while datalen < bcnt: - buf, = await loop.select(iface.iface_num()) + buf = await read # log.debug(__name__, 'read cont %s', buf) cfrm = overlay_struct(buf, desc_cont) @@ -444,10 +445,12 @@ class ConfirmState: def fork(self) -> None: self.deadline_ms = utime.ticks_ms() + _CONFIRM_STATE_TIMEOUT_MS self.task = self.confirm() - workflow.start(self.task) + workflow.onstart(self.task) + loop.schedule_task(self.task) def kill(self) -> None: if self.task is not None: + workflow.onclose(self.task) self.task.close() async def confirm(self) -> None: