Compare commits

...

2 Commits

Author SHA1 Message Date
Vadim Yanitskiy 2990cc14b8 SEDbgMuxApp: use non-zero default serial port read timeout 5 months ago
Vadim Yanitskiy f9759d1024 Transport: mark abstract methods with @abc.abstractmethod 5 months ago
  1. 6
      peer.py
  2. 4
      sedbgmux.py
  3. 4
      transport.py

@ -18,7 +18,7 @@
import logging as log
from typing import Any
from typing import Any, Optional
from construct import Const, Container, Int16ul
from transport import Transport
@ -63,9 +63,11 @@ class DbgMuxPeer:
if msg_type != DbgMuxFrame.MsgType.Ack:
self.tx_count += 1
def recv(self) -> Container:
def recv(self) -> Optional[Container]:
frame: bytes = b''
frame += self.io.read(2) # Magic
if frame == b'':
return None
Const(b'\x42\x42').parse(frame[:2])
frame += self.io.read(2) # Length
length: int = Int16ul.parse(frame[2:])

@ -169,8 +169,8 @@ group.add_argument('-p', '--serial-port', metavar='PORT', type=str, default='/de
help='Serial port path (default %(default)s)')
group.add_argument('--serial-baudrate', metavar='BAUDRATE', type=int, default=115200,
help='Serial port speed (default %(default)s)')
group.add_argument('--serial-timeout', metavar='TIMEOUT', type=int,
help='Serial port timeout')
group.add_argument('--serial-timeout', metavar='TIMEOUT', type=float, default=0.5,
help='Serial port read timeout (default %(default)s)')
log.basicConfig(
format='[%(levelname)s] %(filename)s:%(lineno)d %(message)s', level=log.INFO)

@ -30,15 +30,19 @@ class TransportIOError(Exception):
class Transport(abc.ABC):
''' Abstract transport layer for DebugMux '''
@abc.abstractmethod
def connect(self, opts: dict) -> None:
''' Establish connection to the target and enter DebugMux mode '''
@abc.abstractmethod
def disconnect(self) -> None:
''' Escape DebugMux mode and terminate connection with the target '''
@abc.abstractmethod
def write(self, data: bytes) -> int:
''' Write the given data bytes '''
@abc.abstractmethod
def read(self, length: int = 0) -> bytes:
''' Read the given number of bytes '''

Loading…
Cancel
Save