From 9a4d20fe7afbde36b7b5770e37fa9f95d84e3e9c Mon Sep 17 00:00:00 2001 From: Markus Kuhn <78373870+schwabix-1311@users.noreply.github.com> Date: Sun, 26 Mar 2023 21:09:40 +0200 Subject: [PATCH 1/2] Issue #9 Add a delay to finalize handler --- tc420/__main__.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tc420/__main__.py b/tc420/__main__.py index abb9e62..9c7a1aa 100644 --- a/tc420/__main__.py +++ b/tc420/__main__.py @@ -19,6 +19,7 @@ from random import random, randint from datetime import datetime from typing import Callable, Tuple +from time import sleep import click import usb.core @@ -290,6 +291,7 @@ def finalize(ctx: Context, _): Finalize command chain """ if ctx.obj.mode_stop_neded: + sleep(0.01) # Close mode commands print("Finalizing modes...", end=" ", flush=True) check_result(ctx.obj.dev.mode_stop()) From 90b4982baae7266a2a47652093986bf02f9d7ef6 Mon Sep 17 00:00:00 2001 From: Markus Kuhn <78373870+schwabix-1311@users.noreply.github.com> Date: Sun, 26 Mar 2023 21:11:55 +0200 Subject: [PATCH 2/2] Update tc420.py --- tc420/tc420.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tc420/tc420.py b/tc420/tc420.py index 9207d78..8deda04 100644 --- a/tc420/tc420.py +++ b/tc420/tc420.py @@ -19,6 +19,7 @@ from datetime import datetime, time from struct import pack, unpack from time import time as timestamp +from time import sleep import sys from threading import Thread @@ -327,6 +328,9 @@ def send(self, packet: TC420Packet, check=True) -> bool: # It seems in case of error they just repeat the sent package from pos 2. res = res_pkt.data_len == 1 and res_pkt.data == self.OK + # give time for processing even though it returned success, issue #9 + sleep(0.01) + return res def time_sync(self, date: datetime = None) -> bool: