Skip to content

Commit fc05078

Browse files
authored
prepare release 0.9.3 (#543)
1 parent dcc785b commit fc05078

15 files changed

Lines changed: 139 additions & 42 deletions

requirements.test.py2.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ tox==3.2.1
1616
typing==3.6.6
1717
virtualenv==16.0.0
1818
xlwt==1.3.0
19-
xlrd==1.1.0
19+
xlrd==1.2.0
2020
click==7.0
21-
lxml==4.5.2
21+
lxml==4.6.2
2222
enum34==1.1.10

requirements.test.py3.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ tox==3.2.1
1616
typing==3.6.6; python_version < '3.5'
1717
virtualenv==16.0.0
1818
xlwt==1.3.0
19-
xlrd==1.1.0
20-
lxml==4.5.2
19+
xlrd==1.2.0
20+
lxml==4.6.2
2121
click==7.0
2222
xlsxwriter==1.2.8
2323
pyaml==20.4.0

requirements.tox.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ typing==3.6.6; python_version < '3.5'
88
virtualenv==16.4.1
99
click==7.0
1010
enum34==1.1.10; python_version <= '2.7'
11+
xlrd==1.2.0

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
click
22
lxml
33
xlwt
4-
xlrd
4+
xlrd==1.2.0
55
xlsxwriter
66
pyyaml
77
future

src/canmatrix/canmatrix.py

Lines changed: 12 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1351,35 +1351,18 @@ def unpack(self, data, report_error=True):
13511351

13521352
return returnDict
13531353

1354-
def _has_sub_multiplexer(self, parent_multiplexer_name):
1354+
def _get_sub_multiplexer(self, parent_multiplexer_name, parent_multiplexer_value):
13551355
"""
1356-
check if any sub-multiplexer in frame
1357-
used for complex-multiplexed frame decoding
1358-
1359-
:param parent_multiplexer_name: string with name of parent multiplexer
1360-
:return: True or False
1361-
"""
1362-
for signal in self.signals:
1363-
if signal.is_multiplexer and signal.muxer_for_signal == parent_multiplexer_name:
1364-
return True
1365-
return False
1366-
1367-
def _get_sub_multiplexer(self, parent_multiplexer_name, parent_multiplexer_value, decoded):
1368-
"""
1369-
get any sub-multiplexer in frame for decoded data
1370-
return multiplexers name and value
1371-
used for complex-multiplexed frame decoding
1356+
get any sub-multiplexer in frame used
1357+
for complex-multiplexed frame decoding
13721358
13731359
:param parent_multiplexer_name: string with name of parent multiplexer
13741360
:param parent_multiplexer_value: raw_value (int) of parent multiplexer
1375-
:param decoded: OrderedDictionary which is returned from canmatrix.Frame.unpack
1376-
:return: muxer_name and muxer_value
1361+
:return: muxer signal or None
13771362
"""
13781363
for signal in self.signals:
13791364
if signal.is_multiplexer and signal.muxer_for_signal == parent_multiplexer_name and signal.multiplexer_value_in_range(parent_multiplexer_value):
1380-
muxer_value = decoded[signal.name].raw_value
1381-
muxer_name = signal.name
1382-
return muxer_name, muxer_value
1365+
return signal
13831366

13841367
def _filter_signals_for_multiplexer(self, multiplexer_name, multiplexer_value):
13851368
"""
@@ -1417,11 +1400,15 @@ def decode(self, data):
14171400
multiplex_name = None
14181401
multiplex_value = None
14191402

1420-
while self._has_sub_multiplexer(multiplex_name):
1421-
multiplex_name, multiplex_value = self._get_sub_multiplexer(multiplex_name, multiplex_value, decoded)
1422-
decoded_values[multiplex_name] = decoded[multiplex_name]
1403+
sub_multiplexer = self._get_sub_multiplexer(multiplex_name, multiplex_value)
1404+
while sub_multiplexer is not None:
1405+
multiplex_name = sub_multiplexer.name
1406+
multiplex_signal = decoded_values[multiplex_name] = decoded[multiplex_name]
1407+
multiplex_value = multiplex_signal.raw_value
14231408
filtered_signals += self._filter_signals_for_multiplexer(multiplex_name, multiplex_value)
14241409

1410+
sub_multiplexer = self._get_sub_multiplexer(multiplex_name, multiplex_value)
1411+
14251412
for signal in filtered_signals:
14261413
decoded_values[signal.name] = decoded[signal.name]
14271414
return decoded_values

src/canmatrix/formats/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
importlib.import_module("canmatrix.formats." + module)
2828
loadedFormats.append(module)
2929
except ImportError:
30-
logger.exception("%s is not supported", module)
30+
logger.warning("%s is not supported", module)
3131

3232
for loadedModule in loadedFormats:
3333
supportedFormats[loadedModule] = []

src/canmatrix/formats/arxml.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1732,6 +1732,7 @@ def decode_ethernet_helper(ea, float_factory):
17321732
pdu_sig_mapping = ea.findall("I-SIGNAL-TO-I-PDU-MAPPING", ipdu)
17331733

17341734
get_signals(pdu_sig_mapping, target_frame, ea, None, float_factory)
1735+
target_frame.update_receiver()
17351736
db.add_frame(target_frame)
17361737
return found_matrixes
17371738

@@ -1750,14 +1751,14 @@ def decode_flexray_helper(ea, float_factory):
17501751
found_matrixes[channel_name] = db
17511752

17521753
frames = ea.findall("FLEXRAY-FRAME-TRIGGERING", pc)
1753-
for frame in frames:
1754+
for frame_element in frames:
17541755
frame_counter += 1
1755-
slot_id = int(ea.get_child(frame, "SLOT-ID").text)
1756-
base_cycle = ea.get_child(frame, "BASE-CYCLE").text
1757-
ipdu_triggerings = ea.get_children(frame, "I-PDU-TRIGGERING")
1758-
frame_repetition_cycle = ea.find_children_by_path(frame, "CYCLE-REPETITION/CYCLE-REPETITION")[0].text
1759-
network_endpoints = pc.findall('.//' + ns + "NETWORK-ENDPOINT")
1760-
frame_size = int(ea.find_children_by_path(frame, "FRAME/FRAME-LENGTH")[0].text)
1756+
slot_id = int(ea.get_child(frame_element, "SLOT-ID").text)
1757+
base_cycle = ea.get_child(frame_element, "BASE-CYCLE").text
1758+
ipdu_triggerings = ea.get_children(frame_element, "I-PDU-TRIGGERING")
1759+
frame_repetition_cycle = ea.find_children_by_path(frame_element, "CYCLE-REPETITION/CYCLE-REPETITION")[0].text
1760+
network_endpoints = pc.findall('.//' + ea.ns + "NETWORK-ENDPOINT")
1761+
frame_size = int(ea.find_children_by_path(frame_element, "FRAME/FRAME-LENGTH")[0].text)
17611762
frame = canmatrix.Frame(size = frame_size, arbitration_id = frame_counter)
17621763
frame.slot_id = slot_id
17631764
frame.base_cycle = base_cycle
@@ -1888,7 +1889,10 @@ def decode_can_helper(ea, float_factory, ignore_cluster_info):
18881889
sig_value_hash[sig.name] = 0
18891890
frame_data = frame.encode(sig_value_hash)
18901891
frame.add_attribute("GenMsgStartValue", "".join(["%02x" % x for x in frame_data]))
1892+
frame.update_receiver()
18911893
found_matrixes[bus_name] = db
1894+
1895+
18921896
return found_matrixes
18931897

18941898
def load(file, **options):

src/canmatrix/formats/dbc.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
from builtins import *
3636

3737
import canmatrix
38-
38+
import canmatrix.utils
3939
logger = logging.getLogger(__name__)
4040

4141

@@ -755,13 +755,15 @@ def add_frame_by_id(new_frame): # type: (canmatrix.Frame) -> None
755755
if temp:
756756
frame_id = temp.group(1)
757757
signal_name = temp.group(2)
758-
temp_list = temp.group(3).split('"')
758+
temp_list = list(canmatrix.utils.escape_aware_split(temp.group(3), '"'))
759+
759760
if frame_id.isnumeric(): # value for Frame
760761
try:
761762
frame = get_frame_by_id(canmatrix.ArbitrationId.from_compound_integer(int(frame_id)))
762763
sg = frame.signal_by_name(signal_name)
763764
for i in range(math.floor(len(temp_list) / 2)):
764765
val = temp_list[i * 2 + 1]
766+
val = val.replace('\\"', '"')
765767
if sg:
766768
sg.add_values(temp_list[i * 2], val)
767769
except:
@@ -930,7 +932,7 @@ def add_frame_by_id(new_frame): # type: (canmatrix.Frame) -> None
930932
ecu.name = ecu.attributes.get("SystemNodeLongSymbol")[1:-1]
931933
ecu.del_attribute("SystemNodeLongSymbol")
932934
for frame in db.frames:
933-
frame.cycle_time = int(frame.attributes.get("GenMsgCycleTime", 0))
935+
frame.cycle_time = int(float(frame.attributes.get("GenMsgCycleTime", 0)))
934936
if frame.attributes.get("SystemMessageLongSymbol", None) is not None:
935937
frame.name = frame.attributes.get("SystemMessageLongSymbol")[1:-1]
936938
frame.del_attribute("SystemMessageLongSymbol")

src/canmatrix/formats/json.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ def dump(db, f, **options):
9393
symbolic_frame = {"name": frame.name,
9494
"id": int(frame.arbitration_id.id),
9595
"is_extended_frame": frame.arbitration_id.extended,
96+
"is_fd": frame.is_fd,
9697
"signals": symbolic_signals}
9798
frame_attributes = {
9899
attr: frame.attribute(attr)
@@ -146,6 +147,7 @@ def dump(db, f, **options):
146147
{"name": frame.name,
147148
"id": int(frame.arbitration_id.id),
148149
"is_extended_frame": frame.arbitration_id.extended,
150+
"is_fd": frame.is_fd,
149151
"signals": symbolic_signals,
150152
"attributes": frame_attributes,
151153
"comment": frame.comment,

src/canmatrix/formats/sym.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,10 @@ class Mode(object):
442442
is_float = False
443443
is_ascii = False
444444
enumeration = None
445-
if index_offset != 1:
445+
446+
if tmp_mux == "Mux":
447+
is_signed = False
448+
elif index_offset != 1 :
446449
is_signed = True
447450
else:
448451
is_signed = False

0 commit comments

Comments
 (0)