Skip to content

Commit 81eac11

Browse files
authored
[WIP] [arxml] add some basic support for flexray and ethernet data (#426)
* [arxml] add some basic support for flexray and ethernet data * extract most of relevant flexray info (#432) * starting rework ARXML * fix dbc for py8 * support for container-pdus with "none" type * fix for container id byteorder * fix for secured-ipdus in container * fix for byteorder big endian header_ids of container-i-pdus * once again header_id * Header_id again * fix for missing compu method * make SOME/IP at least work a bixt #283 * interprete OPAQUE as intel * dbc allow '"' in Values * fix container-pdu without header but with offset * arxml: fix for container-ipdus, containing same pdu multiple times * fix enum support for py2.7
1 parent c6a24f3 commit 81eac11

10 files changed

+180
-54
lines changed

.travis.yml

-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ matrix:
1515
dist: xenial
1616
sudo: true
1717
- python: 3.8
18-
- python: 2.7
19-
env: TOXENV=old_tests
2018
- python: 3.7
2119
dist: xenial
2220
sudo: true

requirements.test.py2.txt

+1
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,4 @@ xlwt==1.3.0
1919
xlrd==1.1.0
2020
click==7.0
2121
lxml==4.5.2
22+
enum34==1.1.10

requirements.tox.txt

+1
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ tox==3.7.0
77
typing==3.6.6; python_version < '3.5'
88
virtualenv==16.4.1
99
click==7.0
10+
enum34==1.1.10; python_version <= '2.7'

requirements.txt

+1
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ future
88
attrs>=18.1.0
99
typing; python_version < '3.5'
1010
pathlib2
11+
enum34; python_version <= '2.7'

src/canmatrix/canmatrix.py

+9
Original file line numberDiff line numberDiff line change
@@ -857,6 +857,8 @@ class Frame(object):
857857
# ('sendType', '_sendType', str, None),
858858

859859
pdus = attr.ib(factory=list) # type: typing.MutableSequence[Pdu]
860+
header_id = attr.ib(default=None) #type: int
861+
# header_id
860862

861863

862864
@property
@@ -1522,6 +1524,12 @@ def update(self): # type: () -> None
15221524
return
15231525
self.definition = 'ENUM "' + '","' .join(self.values) +'"'
15241526

1527+
import enum
1528+
1529+
class matrix_class(enum.Enum):
1530+
CAN = 1
1531+
FLEXRAY = 2
1532+
SOMEIP = 3
15251533

15261534
@attr.s(cmp=False)
15271535
class CanMatrix(object):
@@ -1537,6 +1545,7 @@ class CanMatrix(object):
15371545
value_tables (global defined values)
15381546
"""
15391547

1548+
type = attr.ib(default=matrix_class.CAN) #type: matrix_class
15401549
attributes = attr.ib(factory=dict) # type: typing.MutableMapping[str, typing.Any]
15411550
ecus = attr.ib(factory=list) # type: typing.MutableSequence[Ecu]
15421551
frames = attr.ib(factory=list) # type: typing.MutableSequence[Frame]

src/canmatrix/formats/arxml.py

+131-34
Large diffs are not rendered by default.

src/canmatrix/formats/dbc.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ def dump(in_db, f, **options):
117117
dbc_export_comment_encoding = options.get("dbcExportCommentEncoding", dbc_export_encoding)
118118
compatibility = options.get('compatibility', True)
119119
dbc_unique_signal_names_per_frame = options.get("dbcUniqueSignalNames", compatibility)
120-
ignore_encoding_errors= options.get("ignoreEncodingErrors", "")
120+
ignore_encoding_errors= options.get("ignoreEncodingErrors", "ignore")
121121
write_val_table = options.get("writeValTable", True)
122122

123123
whitespace_replacement = options.get("whitespaceReplacement", '_')
@@ -424,8 +424,11 @@ def dump(in_db, f, **options):
424424
frame.arbitration_id.to_compound_integer() +
425425
output_names[frame][signal]).encode(dbc_export_encoding, ignore_encoding_errors))
426426
for attr_name, val in sorted(signal.values.items(), key=lambda x: int(x[0])):
427+
if '"' in val:
428+
val = val.replace('"', '\\"')
427429
f.write(
428430
(' ' + str(attr_name) + ' "' + val + '"').encode(dbc_export_encoding, ignore_encoding_errors))
431+
429432
f.write(";\n".encode(dbc_export_encoding, ignore_encoding_errors))
430433

431434
# SIG_VALTYPE

src/canmatrix/formats/xls.py

+12-6
Original file line numberDiff line numberDiff line change
@@ -172,16 +172,22 @@ def dump(db, file, **options):
172172
worksheet.col(head_start + 1).width = 5555
173173

174174
frame_hash = {}
175-
logger.debug("Length of db.frames is %d", len(db.frames))
176-
for frame in db.frames:
177-
if frame.is_complex_multiplexed:
178-
logger.error("export complex multiplexers is not supported - ignoring frame %s", frame.name)
179-
continue
180-
frame_hash[int(frame.arbitration_id.id)] = frame
175+
if db.type == canmatrix.matrix_class.CAN:
176+
logger.debug("Length of db.frames is %d", len(db.frames))
177+
for frame in db.frames:
178+
if frame.is_complex_multiplexed:
179+
logger.error("export complex multiplexers is not supported - ignoring frame %s", frame.name)
180+
continue
181+
frame_hash[int(frame.arbitration_id.id)] = frame
182+
else:
183+
frame_hash = {a.name:a for a in db.frames}
184+
181185

182186
# set row to first Frame (row = 0 is header)
183187
row = 1
184188

189+
190+
185191
# iterate over the frames
186192
for idx in sorted(frame_hash.keys()):
187193

src/canmatrix/formats/xls_common.py

+12-5
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,18 @@
3030
def get_frame_info(db, frame):
3131
# type: (canmatrix.CanMatrix, canmatrix.Frame) -> typing.List[str]
3232
ret_array = [] # type: typing.List[str]
33-
# frame-id
34-
if frame.arbitration_id.extended:
35-
ret_array.append("%3Xxh" % frame.arbitration_id.id)
36-
else:
37-
ret_array.append("%3Xh" % frame.arbitration_id.id)
33+
34+
if db.type == canmatrix.matrix_class.CAN:
35+
# frame-id
36+
if frame.arbitration_id.extended:
37+
ret_array.append("%3Xxh" % frame.arbitration_id.id)
38+
else:
39+
ret_array.append("%3Xh" % frame.arbitration_id.id)
40+
elif db.type == canmatrix.matrix_class.FLEXRAY:
41+
ret_array.append("TODO")
42+
elif db.type == canmatrix.matrix_class.SOMEIP:
43+
ret_array.append("%3Xh" % frame.header_id)
44+
3845
# frame-Name
3946
ret_array.append(frame.name)
4047

src/canmatrix/formats/xlsx.py

+9-6
Original file line numberDiff line numberDiff line change
@@ -195,12 +195,15 @@ def dump(db, filename, **options):
195195

196196
write_excel_line(worksheet, 0, 0, row_array, sty_header)
197197

198-
frame_hash = {}
199-
logger.debug("DEBUG: Length of db.frames is %d", len(db.frames))
200-
for frame in db.frames:
201-
if frame.is_complex_multiplexed:
202-
logger.error("Export complex multiplexers is not supported - frame %s might be uncomplete", frame.name)
203-
frame_hash[int(frame.arbitration_id.id)] = frame
198+
if db.type == canmatrix.matrix_class.CAN:
199+
frame_hash = {}
200+
logger.debug("DEBUG: Length of db.frames is %d", len(db.frames))
201+
for frame in db.frames:
202+
if frame.is_complex_multiplexed:
203+
logger.error("Export complex multiplexers is not supported - frame %s might be uncomplete", frame.name)
204+
frame_hash[int(frame.arbitration_id.id)] = frame
205+
else:
206+
frame_hash = {a.name:a for a in db.frames}
204207

205208
# set row to first Frame (row = 0 is header)
206209
row = 1

0 commit comments

Comments
 (0)