diff --git a/CHANGELOG.md b/CHANGELOG.md index deeb350..43e8699 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [0.25.0] - 2024-04-28 + +### Changed + +- Signals overlapping error message now includes relevant information + ## [0.24.0] - 2024-02-22 ### Changed diff --git a/ldfparser/frame.py b/ldfparser/frame.py index ef3419f..f1b5b68 100644 --- a/ldfparser/frame.py +++ b/ldfparser/frame.py @@ -53,10 +53,11 @@ def __init__(self, frame_id: int, name: str, length: int, signals: Dict[int, 'Li self.publisher = None self.length = length self.signal_map = sorted(signals.items(), key=lambda x: x[0]) - self._packer = LinUnconditionalFrame._frame_pattern(self.length, self.signal_map, pad_with_zero) + self._packer = LinUnconditionalFrame._frame_pattern(self.name, self.length, self.signal_map, pad_with_zero) @staticmethod def _frame_pattern( + frame_name: str, frame_size: int, signals: List[Tuple[int, 'LinSignal']], pad_with_zero: bool = True, @@ -89,21 +90,23 @@ def _frame_pattern( pattern = "<" frame_bits = frame_size * 8 frame_offset = 0 + prev_signal = None padding_value = "p" if pad_with_zero else "P" for (offset, signal) in signals: if offset < frame_offset: - raise ValueError(f"{signal} is overlapping ") + raise ValueError(f"{frame_name}: {signal.name} at bit {offset} is overlapping {prev_signal.name}") if offset != frame_offset: padding = offset - frame_offset pattern += f"{padding_value}{padding}" frame_offset += padding if frame_offset + signal.width > frame_bits: - raise ValueError(f"{signal} with offset {offset} spans outside frame!") + raise ValueError(f"{frame_name}: {signal.name} at bit {offset} spans outside frame!") if signal.is_array(): pattern += "u8" * int(signal.width / 8) else: pattern += f"u{signal.width}" frame_offset += signal.width + prev_signal = signal if frame_offset < frame_bits: pattern += f"{padding_value}{frame_bits - frame_offset}" return bitstruct.compile(pattern) diff --git a/setup.cfg b/setup.cfg index 352d405..288e330 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,2 +1,2 @@ [metadata] -version = 0.24.0 +version = 0.25.0