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()) 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: