mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-04-10 12:25:55 +00:00
DEBUG udp.ping timeout for 0.1s
This commit is contained in:
parent
bf0b939c6f
commit
d06e3637b2
@ -1232,7 +1232,8 @@ class TrezorClientDebugLink(TrezorClient):
|
||||
if open_transport:
|
||||
self.debug.open()
|
||||
# try to open debuglink, see if it works
|
||||
assert self.debug.transport.ping()
|
||||
assert self.debug.transport.ping(), (self.debug.transport, debug_transport)
|
||||
print("OK"*50)
|
||||
except Exception:
|
||||
if not auto_interact:
|
||||
self.debug = NullDebugLink()
|
||||
|
@ -229,8 +229,8 @@ class EmuBleTransport(Transport):
|
||||
try:
|
||||
self.event_socket.sendall(Event.new(EventType.EMULATOR_PING).build())
|
||||
resp = self.read_command()
|
||||
except Exception:
|
||||
pass
|
||||
except Exception as e:
|
||||
print("Ping failed:", e)
|
||||
return (resp is not None) and (resp.command_type == CommandType.EMULATOR_PONG)
|
||||
|
||||
def ble_connected(self) -> None:
|
||||
@ -256,6 +256,7 @@ class EmuBleTransport(Transport):
|
||||
assert self.event_socket is not None
|
||||
try:
|
||||
data = self.event_socket.recv(64)
|
||||
except TimeoutError:
|
||||
except TimeoutError as e:
|
||||
print("Timeout:", e)
|
||||
return None
|
||||
return Command.parse(data)
|
||||
|
@ -27,7 +27,7 @@ from . import Timeout, Transport, TransportException
|
||||
if TYPE_CHECKING:
|
||||
from ..models import TrezorModel
|
||||
|
||||
SOCKET_TIMEOUT = 0.1
|
||||
SOCKET_TIMEOUT = 10
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
@ -99,6 +99,7 @@ class UdpTransport(Transport):
|
||||
self.socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||
self.socket.connect(self.device)
|
||||
self.socket.settimeout(SOCKET_TIMEOUT)
|
||||
LOG.info("timeout: %s", self.socket.gettimeout())
|
||||
|
||||
def close(self) -> None:
|
||||
if self.socket is not None:
|
||||
@ -151,8 +152,11 @@ class UdpTransport(Transport):
|
||||
assert self.socket is not None
|
||||
resp = None
|
||||
try:
|
||||
LOG.info("sending ping")
|
||||
self.socket.sendall(b"PINGPING")
|
||||
resp = self.socket.recv(8)
|
||||
except Exception:
|
||||
pass
|
||||
print("Pong:", resp)
|
||||
except Exception as e:
|
||||
print("Ping failed:", e)
|
||||
LOG.info("ping is over: %s", self.socket.gettimeout())
|
||||
return resp == b"PONGPONG"
|
||||
|
@ -18,7 +18,7 @@ if t.TYPE_CHECKING:
|
||||
P = tx.ParamSpec("P")
|
||||
|
||||
|
||||
udp.SOCKET_TIMEOUT = 0.1
|
||||
udp.SOCKET_TIMEOUT = 1
|
||||
|
||||
|
||||
class NullUI:
|
||||
|
Loading…
Reference in New Issue
Block a user