refactor
This commit is contained in:
parent
655e6a9c8a
commit
18e161e7d8
|
@ -158,23 +158,13 @@ async def megacom(tty: str, baud: int, mode: str) -> None:
|
|||
|
||||
async def connect_pipe(pin: asyncio.StreamReader, pout: asyncio.StreamWriter,
|
||||
ctrl: bool = False) -> None:
|
||||
esc: bool = False
|
||||
while not pin.at_eof():
|
||||
c: bytes = await pin.read(1)
|
||||
if len(c) == 0:
|
||||
continue
|
||||
|
||||
if esc:
|
||||
esc = False
|
||||
if c == b"\x01":
|
||||
pout.write(b"\x01")
|
||||
await pout.drain()
|
||||
elif c == b"q":
|
||||
keycodes.exit_flag.set()
|
||||
break
|
||||
|
||||
if c == b"\x01" and ctrl:
|
||||
esc = True
|
||||
c = keycodes.process(c)
|
||||
if len(c) == 0:
|
||||
continue
|
||||
|
||||
pout.write(c)
|
||||
|
|
Loading…
Reference in New Issue