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,
|
async def connect_pipe(pin: asyncio.StreamReader, pout: asyncio.StreamWriter,
|
||||||
ctrl: bool = False) -> None:
|
ctrl: bool = False) -> None:
|
||||||
esc: bool = False
|
|
||||||
while not pin.at_eof():
|
while not pin.at_eof():
|
||||||
c: bytes = await pin.read(1)
|
c: bytes = await pin.read(1)
|
||||||
if len(c) == 0:
|
if len(c) == 0:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if esc:
|
c = keycodes.process(c)
|
||||||
esc = False
|
if len(c) == 0:
|
||||||
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
|
|
||||||
continue
|
continue
|
||||||
|
|
||||||
pout.write(c)
|
pout.write(c)
|
||||||
|
|
Loading…
Reference in New Issue