DbgMuxPeer: get away from using construct's parse_stream()
This commit is contained in:
parent
45548e0a3e
commit
e71875aa12
11
peer.py
11
peer.py
|
@ -19,7 +19,7 @@
|
||||||
import logging as log
|
import logging as log
|
||||||
|
|
||||||
from typing import Any
|
from typing import Any
|
||||||
from construct import Container, Int16ul
|
from construct import Const, Container, Int16ul
|
||||||
|
|
||||||
from transport import Transport
|
from transport import Transport
|
||||||
from proto import DbgMuxFrame
|
from proto import DbgMuxFrame
|
||||||
|
@ -64,7 +64,14 @@ class DbgMuxPeer:
|
||||||
self.tx_count += 1
|
self.tx_count += 1
|
||||||
|
|
||||||
def recv(self) -> Container:
|
def recv(self) -> Container:
|
||||||
c = DbgMuxFrame.Frame.parse_stream(self.io)
|
frame: bytes = b''
|
||||||
|
frame += self.io.read(2) # Magic
|
||||||
|
Const(b'\x42\x42').parse(frame[:2])
|
||||||
|
frame += self.io.read(2) # Length
|
||||||
|
length: int = Int16ul.parse(frame[2:])
|
||||||
|
frame += self.io.read(length) # Rest
|
||||||
|
|
||||||
|
c = DbgMuxFrame.Frame.parse(frame)
|
||||||
|
|
||||||
log.debug('Rx frame (Ns=%03u, Nr=%03u, fcs=0x%04x) %s %s',
|
log.debug('Rx frame (Ns=%03u, Nr=%03u, fcs=0x%04x) %s %s',
|
||||||
c['TxCount'], c['RxCount'], c['FCS'],
|
c['TxCount'], c['RxCount'], c['FCS'],
|
||||||
|
|
Loading…
Reference in New Issue