fix(core): SerialConsole.read устойчив к 'readiness to read but no data' на RPi/USB-serial
pyserial на Raspberry Pi временами кидает SerialException (readiness but no data) на простоях порта — читаем как пустоту и продолжаем, а не роняем WS-консоль.
This commit is contained in:
+10
-5
@@ -158,13 +158,18 @@ async def ws_console(ws: WebSocket):
|
||||
await ws.send_bytes(("\r\nATXPI console ready. driver=%s\r\n" % DRIVER).encode())
|
||||
|
||||
async def reader():
|
||||
try:
|
||||
while True:
|
||||
while True:
|
||||
try:
|
||||
data = await asyncio.to_thread(console.read, 0.25)
|
||||
if data:
|
||||
except Exception as e:
|
||||
log.warning("console.read error: %s", e)
|
||||
break
|
||||
if data:
|
||||
try:
|
||||
await ws.send_bytes(data)
|
||||
except Exception:
|
||||
pass
|
||||
except Exception as e:
|
||||
log.warning("ws handle_console send error: %s", e)
|
||||
break
|
||||
|
||||
read_task = asyncio.create_task(reader())
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user