Skip to content

Commit e0b0b24

Browse files
authored
Merge branch 'master' into feature/physical-value-rounding
2 parents 801a7e6 + c6b3acd commit e0b0b24

File tree

5 files changed

+17
-4
lines changed

5 files changed

+17
-4
lines changed

CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
## [0.26.0] - 2025-01-27
11+
1012
### Changed
1113

14+
- Empty signal encoders are now allowed
15+
- Signals can now be associated with multiple frames, accessible under `signal.frames`
1216
- Physical values are now rounded to the nearest integer, rather than down
1317

1418
### Migration guide for 0.26.0
1519

20+
- Newly written should be using `signal.frames` to determine the owners of a signal, for
21+
compatibility reasons `signal.frame` is still set, but only when a signal is associated with one
22+
frame
1623
- Physical values might be rounded the wrong way depending on the user's intention. This type of
1724
rounding should generally work better in values ranging from `0-X`, for example `49.9` is no longer
1825
rounded down to `49`. If this is undesired the user can in most cases offset the input by `0.5` and

ldfparser/grammars/ldf.lark

+1-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ signal_group: ldf_identifier ":" ldf_integer "{" (ldf_identifier "," ldf_integer
110110

111111
// LIN 2.1 Specification, section 9.2.6.1
112112
signal_encoding_types: "Signal_encoding_types" "{" (signal_encoding_type+) "}"
113-
signal_encoding_type: ldf_identifier "{" (signal_encoding_logical_value | signal_encoding_physical_value | signal_encoding_bcd_value | signal_encoding_ascii_value)+ "}"
113+
signal_encoding_type: ldf_identifier "{" (signal_encoding_logical_value | signal_encoding_physical_value | signal_encoding_bcd_value | signal_encoding_ascii_value)* "}"
114114
signal_encoding_logical_value: "logical_value" "," ldf_integer ("," signal_encoding_text_value)? ";"
115115
signal_encoding_physical_value: "physical_value" "," ldf_integer "," ldf_integer "," ldf_float "," ldf_float ("," signal_encoding_text_value)? ";"
116116
signal_encoding_bcd_value: "bcd_value" ";"

ldfparser/parser.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,11 @@ def _populate_ldf_frames(json: dict, ldf: LDF):
129129
ldf._unconditional_frames[frame['name']] = frame_obj
130130

131131
for (_, signal) in signals.items():
132-
signal.frame = frame_obj
132+
if len(signal.frames) == 0:
133+
signal.frame = frame_obj # signal has only appeared in one frame
134+
elif len(signal.frames) >= 1:
135+
signal.frame = None # signal is in multiple frames
136+
signal.frames.append(frame_obj)
133137

134138
def _populate_ldf_event_triggered_frames(json: dict, ldf: LDF):
135139
if "event_triggered_frames" not in json:

ldfparser/signal.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ def __init__(self, name: str, width: int, init_value: Union[int, List[int]]):
3131
self.publisher: 'LinNode' = None
3232
self.subscribers: List['LinNode'] = []
3333
self.encoding_type: 'LinSignalEncodingType' = None
34-
self.frame: 'LinUnconditionalFrame' = None
34+
self.frame: 'LinUnconditionalFrame' = None # for compatibility reasons this is set
35+
# when the signal is added to only one frame
36+
self.frames: List['LinUnconditionalFrame'] = []
3537

3638
def __eq__(self, o: object) -> bool:
3739
if isinstance(o, LinSignal):

setup.cfg

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
[metadata]
2-
version = 0.25.0
2+
version = 0.26.0

0 commit comments

Comments
 (0)