File tree 3 files changed +29
-1
lines changed
3 files changed +29
-1
lines changed Original file line number Diff line number Diff line change @@ -1671,6 +1671,17 @@ def compress(self):
1671
1671
gap_found = True
1672
1672
break
1673
1673
1674
+ def multiplex_signals (self ):
1675
+ """Assign multiplexer to signals. When a multiplexor is in the frame."""
1676
+ multiplexor = self .get_multiplexer
1677
+ if multiplexor is None :
1678
+ return
1679
+
1680
+ for signal in self .signals :
1681
+ if signal .is_multiplexer or (signal .muxer_for_signal is not None ):
1682
+ continue
1683
+ signal .muxer_for_signal = multiplexor .name
1684
+ signal .mux_val = signal .multiplex
1674
1685
1675
1686
def __str__ (self ): # type: () -> str
1676
1687
"""Represent the frame by its name only."""
Original file line number Diff line number Diff line change @@ -599,9 +599,11 @@ def add_frame_by_id(new_frame): # type: (canmatrix.Frame) -> None
599
599
multiplex = temp .group (2 ) # type: str
600
600
601
601
is_complex_multiplexed = False
602
+ is_multiplexer = False
602
603
603
604
if multiplex == 'M' :
604
605
multiplex = 'Multiplexor'
606
+ is_multiplexer = True
605
607
elif multiplex .endswith ('M' ):
606
608
is_complex_multiplexed = True
607
609
multiplex = multiplex [:- 1 ]
@@ -632,7 +634,7 @@ def add_frame_by_id(new_frame): # type: (canmatrix.Frame) -> None
632
634
** extras
633
635
)
634
636
635
- if is_complex_multiplexed :
637
+ if is_complex_multiplexed or is_multiplexer :
636
638
temp_signal .is_multiplexer = True
637
639
temp_signal .multiplex = 'Multiplexor'
638
640
@@ -989,6 +991,7 @@ def add_frame_by_id(new_frame): # type: (canmatrix.Frame) -> None
989
991
990
992
db .enum_attribs_to_values ()
991
993
for frame in db .frames :
994
+ frame .multiplex_signals ()
992
995
if "_FD" in frame .attributes .get ("VFrameFormat" , "" ):
993
996
frame .is_fd = True
994
997
if "J1939PG" in frame .attributes .get ("VFrameFormat" , "" ):
Original file line number Diff line number Diff line change @@ -339,6 +339,20 @@ def test_j1939_frametype():
339
339
matrix = canmatrix .formats .dbc .load (dbc , dbcImportEncoding = "utf8" )
340
340
assert matrix .frames [0 ].is_j1939 == False
341
341
342
+ def test_multiplex_frame ():
343
+ dbc = io .BytesIO (textwrap .dedent (u'''\
344
+ BU_: someOtherEcu
345
+
346
+ BO_ 123 someFrame: 8 someOtherEcu
347
+ SG_ someSignal m2 : 8|8@1+ (1,0) [0|9] "" CCL_TEST
348
+ SG_ someOtherSignal m1 : 8|8@0+ (1,0) [0|9] "" CCL_TEST
349
+ SG_ someMultiplexor M : 0|8@1+ (1,0) [0|2] "" CCL_TEST
350
+ ''' ).encode ('utf-8' ))
351
+ matrix = canmatrix .formats .dbc .load (dbc , dbcImportEncoding = "utf8" )
352
+ assert matrix .frames [0 ].is_multiplexed
353
+
354
+ assert matrix .frames [0 ].signal_by_name ("someSignal" ).muxer_for_signal == "someMultiplexor"
355
+
342
356
343
357
def test_attributes_with_spaces_before_semicolumn ():
344
358
dbc = io .BytesIO (textwrap .dedent (u'''\
You can’t perform that action at this time.
0 commit comments