diff --git a/odxtools/cli/_parser_utils.py b/odxtools/cli/_parser_utils.py index 337d0088..da16db44 100644 --- a/odxtools/cli/_parser_utils.py +++ b/odxtools/cli/_parser_utils.py @@ -5,7 +5,7 @@ def add_pdx_argument(parser): - parser.add_argument("pdx_file", metavar="PDX_FILE", help="path to the .pdx file") + parser.add_argument("pdx_file", nargs="?", metavar="PDX_FILE", help="path to the .pdx file") # parser.add_argument("pdx_files", metavar="PDX_FILES", nargs="+", help="PDX descriptions of all ECUs which shall be analyzed") diff --git a/odxtools/isotp_state_machine.py b/odxtools/isotp_state_machine.py index 43efe3a2..2ae15014 100644 --- a/odxtools/isotp_state_machine.py +++ b/odxtools/isotp_state_machine.py @@ -6,6 +6,7 @@ import sys from enum import IntEnum from typing import AsyncGenerator, Iterable, List, Optional, TextIO, Tuple, Union +from io import TextIOWrapper import bitstruct import can @@ -26,8 +27,9 @@ class IsoTp(IntEnum): class IsoTpStateMachine: can_normal_frame_re = re.compile( - "([a-zA-Z0-9_-]*) *([0-9A-Fa-f ]*) *\\[[0-9]*\\] *([ 0-9A-Fa-f]*)") - can_log_frame_re = re.compile("\\([0-9.]*\\) *([a-zA-Z0-9_-]*) ([0-9A-Fa-f]*)#([0-9A-Fa-f]*)") + "([a-zA-Z0-9_-]*) *([0-9A-Fa-f ]*) *\\[[0-9]+\\] *([ 0-9A-Fa-f]+)") + can_log_frame_re = re.compile("\\([0-9.]*\\) *([a-zA-Z0-9_-]*) ([0-9A-Fa-f]+)#([0-9A-Fa-f]+)") + can_fd_log_frame_re = re.compile("\\([0-9.]*\\) *([a-zA-Z0-9_-]*) ([0-9A-Fa-f]+)##[0-9A-Fa-f]([0-9A-Fa-f]+)") def __init__(self, can_rx_ids: Union[int, List[int]]): if isinstance(can_rx_ids, int): @@ -128,7 +130,7 @@ async def read_telegrams(self, bus: Union[can.Bus, for tmp in self.decode_rx_frame(msg.arbitration_id, msg.data): yield tmp else: - assert isinstance(bus, TextIO) + assert isinstance(bus, (TextIO, TextIOWrapper)) # input is a file while bus: cur_line = bus.readline() @@ -145,7 +147,7 @@ async def read_telegrams(self, bus: Union[can.Bus, for tmp in self.decode_rx_frame(frame_id, frame_data): yield tmp - elif m := self.can_log_frame_re.match(cur_line.strip()): + elif (m := self.can_log_frame_re.match(cur_line.strip())) or (m := self.can_fd_log_frame_re.match(cur_line.strip())): #frame_interface = m.group(2) frame_id = int(m.group(2), 16)