diff --git a/tools/jt808_e2e_smoke.py b/tools/jt808_e2e_smoke.py index d0eab050..f15f02b8 100755 --- a/tools/jt808_e2e_smoke.py +++ b/tools/jt808_e2e_smoke.py @@ -123,11 +123,13 @@ def parse_event_time(value: str) -> dt.datetime: return parsed -def send_frame(host: str, port: int, frame: bytes, timeout: float, read_response: bool) -> bytes: +def send_frame(host: str, port: int, frame: bytes, timeout: float, read_response: bool, linger_ms: int = 0) -> bytes: with socket.create_connection((host, port), timeout=timeout) as sock: sock.settimeout(timeout) sock.sendall(frame) if not read_response: + if linger_ms > 0: + time.sleep(linger_ms / 1000) return b"" try: return sock.recv(1024) @@ -147,13 +149,20 @@ def send_register(host: str, port: int, phone: str, serial: int, timeout: float) ) -def send_location(host: str, port: int, phone: str, serial: int, event_time: dt.datetime, timeout: float) -> bytes: +def send_location(host: str, + port: int, + phone: str, + serial: int, + event_time: dt.datetime, + timeout: float, + linger_ms: int) -> bytes: return send_frame( host, port, build_frame(0x0200, phone, serial, build_location_body(event_time, serial)), timeout, False, + linger_ms, ) @@ -313,6 +322,7 @@ def run(args: argparse.Namespace) -> dict[str, Any]: serial, event_time + dt.timedelta(seconds=frame_index), args.tcp_timeout, + args.linger_ms, ) sent += 1 if args.rate > 0: