Skip to content

Commit 889c295

Browse files
authored
merge to master for release 0.9 (#429)
* include LICENSE in source distribution (#365) * [arxml]: rx/tx typo fix * annotate and fix codestyle dbc (#369) * Always use Signal.is_little_endian as bool #326 (#371) * Add coding, remove #!python where inappropriate (#370) * annotation cleanup ticket #323 (#372) * Update cli doc (inspired by #361) (#373) * fix: xls is using the wrong number for arbitration id (#377) * add outputformat for Scapy (#378) * fix special char handling in scapy exporter * Dump factor, offset, min, max as float. Load as numeric (#380) * added --jsonNativeTypes as cli option * [arxml]: merge container PDU and Secured PDU support (#384) * [arxml]: support for containers * [arxml]: create signalgroups for containers * [arxml]: support secured pdus (#383) * fix for wrong default ArbitrationId handling (#386) * fix for #381 wrong default ArbitrationId handling * optional ignoring failures durig character encoding #375 (#388) * fix for #238 (j1939 Frame setters might raise TypeError) (#389) * move j1939 (pgn, prio, source) handling direct to arbitration-id class (fixes #238) * [arxml]: #385 // Arxml Container support and ARXML refactoring (#390) * [json] fix multiplex reading issue (#136) * [arxml]: refactoring, DLC for canFD support canmatrix.Frame.fit_dlc now fits to next correct dlc value, DBC export reniced for candb++ (#385) * [arxml]: refactoring and better type handling #368 * [dbc]: fix #242. J1939 and FD Frames in dbc * [xlsx]: fixes #240 (signal init value in excel template) * [xlsx] feature for for #288 (#393) separate lines for values * switch from optparse to click (#236) (#394) * add Basic cli tests (#395) * Annotation cleanup #323 (#396) * Remove cm prefix (#236) (#399) * add muxing support to scapy output; merge PR #398 also (#400) * [try to] Unify imports (#402) unify imports (#236) * [wireshark] dump/export wireshark lua can subdissector (#404) * add cannelloni dissector for wireshark * cycle_time as generic signal and frame attribute (#405) * implement cycle_time as generic signal and frame attribute / remove Gen[Msg/Sig]cycle from attributes #146 * use effective frame cycle time for export use gcd of singnal-cycletimes for calculating effective cycle time * [dbc] Iss407: Signal Comments with space bevore semicolon broken import (#409) * [dbc] fix for issue #407 Signal Comments with space bevore semicolon broken import * make initial value to a native attribute of Signal class (#408) * [dbf] exended ids corrected * [dbc] optional allow multiple singals with same name in frame #411 (#412) * Fix setup.py for console_scripts (#417) * [dbc] Iss413: fix comment reading with whitespaces in front of ; (#416) * fix for iss #414, keeps defines in dbc: this keeps defines from dbc in matrix object, even if native attribute exists. * convert: selective rx/tx ecu extraction issue #421 (#422) * [arxml] can_fd info (potentional fix for #410) (#418) * add baudrate attributes * Auto deploy (#420) * add auto deploy for tags on master
1 parent 2bcf1af commit 889c295

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+17071
-1183
lines changed

Diff for: .travis.yml

+8
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,11 @@ install:
3535
script:
3636
- tox
3737
- tox -e codecov
38+
39+
deploy:
40+
provider: pypi
41+
user: ebroecker
42+
skip_existing: true
43+
on:
44+
tags: true
45+
branch: master

Diff for: MANIFEST.in

+1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
include versioneer.py
22
include canmatrix/_version.py
3+
include LICENSE

Diff for: docs/cli.rst

+55-33
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ Command Line Interface
55
1. **canconvert**:
66

77
converts CAN database formats between all supported formats.
8+
89
Example: "*canconvert* someArSystemdescription.arxml file.dbc"
910

1011
2. **cancompare**:
@@ -17,29 +18,39 @@ Command Line Interface
1718
General
1819
_______
1920

21+
If you properly install canmatrix using *pip,* the setuptools create
22+
two ecxcutables for you: `canconvert` and `cancompare`. You can find these executables
23+
near to your `python(.exe)`
24+
25+
If you aren't able to find the scripts, you can still run it as
26+
2027
::
2128

22-
$ canconvert.py -h
23-
$ canconvert.py --help
29+
$ python -m canmatrix.cli.compare [args]
30+
$ python -m canmatrix.cli.convert [args]
2431

25-
show help message/usage and exits
32+
To show help message/usage call ::
2633

27-
::
34+
$ canconvert -h
35+
$ canconvert --help
2836

29-
$ canconvert.py -v
37+
38+
Another arguments are ::
39+
40+
$ canconvert -v
3041

3142
Output verbosity
3243

3344

3445
::
3546

36-
$ canconvert.py -s
47+
$ canconvert -s
3748

3849
don't print status messages to stdout. (only errors)
3950

4051
::
4152

42-
$ canconvert.py -f FORCE_OUTPUT
53+
$ canconvert -f FORCE_OUTPUT
4354

4455
enforce output format, ignoring output file extension (e.g., -f csv)
4556

@@ -51,19 +62,19 @@ __________________________
5162

5263
::
5364

54-
$ canconvert.py source.dbc target.xlsx
65+
$ canconvert source.dbc target.xlsx
5566

5667
**convert dbc file to dbf:**
5768

5869
::
5970

60-
$ canconvert.py source.dbc target.dbf
71+
$ canconvert source.dbc target.dbf
6172

6273
**convert arxml file to dbc:**
6374

6475
::
6576

66-
$ canconvert.py source.arxml target.dbc
77+
$ canconvert source.arxml target.dbc
6778

6879
Note: in case of ``.arxml`` there can be multiple can databases in.
6980
Thus the target ``target.dbc`` may in this case be called ``BUS-NAME-IN-ARXML_target.dbc``.
@@ -75,15 +86,15 @@ You can even convert to the same format:
7586

7687
::
7788

78-
$ canconvert.py source.dbc target.dbc
89+
$ canconvert source.dbc target.dbc
7990

8091
Multiple charset support:
8192

8293
**convert dbc file to dbc with different charset:**
8394

8495
::
8596

86-
$ canconvert.py --dbcImportEncoding=iso-8859-1 --dbcImportCommentEncoding=cp-1252 --dbcExportEncoding=utf-8 --dbcExportCommentEncoding=utf-8 source.dbc target.dbc
97+
$ canconvert --dbcImportEncoding=iso-8859-1 --dbcImportCommentEncoding=cp-1252 --dbcExportEncoding=utf-8 --dbcExportCommentEncoding=utf-8 source.dbc target.dbc
8798

8899
This converts ``source.dbc`` where units are coded in ``iso-8859-1`` and comments are coded in ``cp-1252`` in a ``target.dbc`` where everything is coded in ``utf-8``.
89100
Similar charset conversions are possible or even mandatory for following formats: dbc, dbf and sym.
@@ -96,31 +107,31 @@ _______________________
96107

97108
::
98109

99-
$ canconvert.py --deleteZeroSignals source.dbc target.dbc
110+
$ canconvert --deleteZeroSignals source.dbc target.dbc
100111

101112
will delete signals with 0 bit length from matrix
102113

103114
**delete unwanted attributes from signals:**
104115

105116
::
106117

107-
$ convert.py --deleteSignalAttributes GenMsgCycleTime,MyAttrib source.dbc target.dbc
118+
$ canconvert --deleteSignalAttributes GenMsgCycleTime,MyAttrib source.dbc target.dbc
108119

109120
will delete the attributes ``GenMsgCycleTime`` and ``MyAttrib`` from all signals in ``source.dbc`` and save the result in ``target.dbc``
110121

111122
**delete unwanted attributes from frames:**
112123

113124
::
114125

115-
$ convert.py --deleteFrameAttributes GenMsgCycleTime,MyAttrib source.dbc target.dbc
126+
$ canconvert --deleteFrameAttributes GenMsgCycleTime,MyAttrib source.dbc target.dbc
116127

117128
will delete the attributes ``GenMsgCycleTime`` and ``MyAttrib`` from all frames in ``source.dbc`` and save the result in ``target.dbc``
118129

119130
**recalculate DLC:**
120131

121132
::
122133

123-
$ canconvert.py --recalcDLC=max source.dbc target.dbc
134+
$ canconvert --recalcDLC=max source.dbc target.dbc
124135

125136
this will recalculate DLC for each frame in ``source.dbc``.
126137
In ``target.dlc`` the same DLC like in ``source.dbc`` will be stored, except the calculated DLC is bigger.
@@ -130,7 +141,7 @@ Than the calculated DLC will be stored.
130141

131142
::
132143

133-
$ canconvert.py --recalcDLC=force source.dbc target.dbc
144+
$ canconvert --recalcDLC=force source.dbc target.dbc
134145

135146
this will recalculate DLC for each frame in ``source.dbc``.
136147
In ``target.dlc`` the calculated DLC will be stored independently from ``source.dbc``.
@@ -139,23 +150,23 @@ In ``target.dlc`` the calculated DLC will be stored independently from ``source.
139150

140151
::
141152

142-
$ canconvert.py --deleteObsoleteDefines source.dbc target.dbc
153+
$ canconvert --deleteObsoleteDefines source.dbc target.dbc
143154

144155
this will remove all defines which no attribute exist for in ``source.dbc`` and store the result in ``target.dlc``.
145156

146157
**delete ECU:**
147158

148159
::
149160

150-
$ canconvert.py --deleteECU=myEcu,myEcu2 source.dbc target.dbc
161+
$ canconvert --deleteECU=myEcu,myEcu2 source.dbc target.dbc
151162

152163
this will remove ECUs ``myEcu`` and ``myEcu2`` in ``source.dbc`` and store the result in ``target.dlc``.
153164

154165
**rename ECU:**
155166

156167
::
157168

158-
$ canconvert.py --renameECU=myEcu:myNewEcu,myEcu2:myNewEcu2 source.dbc target.dbc
169+
$ canconvert --renameECU=myEcu:myNewEcu,myEcu2:myNewEcu2 source.dbc target.dbc
159170

160171
this will load ``source.dbc`` and rename ECU ``myEcu`` in ``myNewEcu`` and ``myEcu2`` in ``myNewEcu2``.
161172
The result is stored in ``target.dlc``.
@@ -164,15 +175,15 @@ The result is stored in ``target.dlc``.
164175

165176
::
166177

167-
$ canconvert.py --deleteFrame=myFrame,myFrame2 source.dbc target.dbc
178+
$ canconvert --deleteFrame=myFrame,myFrame2 source.dbc target.dbc
168179

169180
this will remove frames ``myFrame`` and ``myFrame2`` in ``source.dbc`` and store the result in ``target.dlc``.
170181

171182
**rename Frame:**
172183

173184
::
174185

175-
$ canconvert.py --renameFrame=myFrame:myNewFrame,myFrame2:myNewFrame2 source.dbc target.dbc
186+
$ canconvert --renameFrame=myFrame:myNewFrame,myFrame2:myNewFrame2 source.dbc target.dbc
176187

177188
this will load ``source.dbc`` and rename frames ``myFrame`` in ``myNewFrame`` and ``myFrame2`` in ``myNewFrame2``.
178189
The result is stored in ``target.dlc``.
@@ -182,15 +193,15 @@ The result is stored in ``target.dlc``.
182193

183194
::
184195

185-
$ canconvert.py --deleteSignal=mySignal,mySignal2 source.dbc target.dbc
196+
$ canconvert --deleteSignal=mySignal,mySignal2 source.dbc target.dbc
186197

187198
this will remove signales ``mySignal`` and ``mySignal2`` in ``source.dbc`` and store the result in ``target.dlc``.
188199

189200
**rename Signal:**
190201

191202
::
192203

193-
$ canconvert.py --renameSignal=mySignal:myNewSignal,mySignal2:myNewSignal2 source.dbc target.dbc
204+
$ canconvert --renameSignal=mySignal:myNewSignal,mySignal2:myNewSignal2 source.dbc target.dbc
194205

195206
this will load ``source.dbc`` and rename signals ``mySignal`` in ``myNewSignal`` and ``mySignal2`` in ``myNewSignal2``.
196207
The result is stored in ``target.dlc``.
@@ -199,14 +210,14 @@ The result is stored in ``target.dlc``.
199210

200211
::
201212

202-
$ canconvert.py --setFrameFd=myFrame,myFrame2 source.dbc target.dbc
213+
$ canconvert --setFrameFd=myFrame,myFrame2 source.dbc target.dbc
203214

204215
this will set frame-type of ``myFrame`` and ``myFrame2`` in ``source.dbc`` to CANFD and store the result in ``target.dlc``
205216
list) Syntax: --setFrameFd=myFrame1,mySecondFrame
206217

207218
::
208219

209-
$ canconvert.py --unsetFrameFd=myFrame,myFrame2 source.dbc target.dbc
220+
$ canconvert --unsetFrameFd=myFrame,myFrame2 source.dbc target.dbc
210221

211222
this will set frame-type of ``myFrame`` and ``myFrame2`` in ``source.dbc`` to normal (not FD) and store the result in ``target.dlc``
212223
list) Syntax: --unsetFrameFd=myFrame1,mySecondFrame
@@ -219,7 +230,7 @@ __________________
219230

220231
::
221232

222-
$ canconvert.py --ecus=REAR_ECU source.dbc target.dbc
233+
$ canconvert --ecus=REAR_ECU source.dbc target.dbc
223234

224235
This generates a ``target.dbc`` with all Informations out of ``source.dbc`` which are needed for ``REAR_ECU``.
225236
All frames which are received or sent by ``REAR_ECU`` are extracted. Also all attributes of the frames and the ECU.
@@ -229,45 +240,54 @@ This is some *lite* ECU-Extract.
229240

230241
::
231242

232-
$ canconvert.py --ecus=FRONT_ECU,REAR_ECU source.dbc target.dbc
243+
$ canconvert --ecus=FRONT_ECU,REAR_ECU source.dbc target.dbc
244+
245+
**extract matrix with frames which FRONT_ECU receives and with frames REAR_ECUS transmits:**
246+
247+
::
248+
249+
$ canconvert --ecus=FRONT_ECU:rx,REAR_ECU:tx source.dbc target.dbc
250+
251+
252+
233253

234254
**extract frame[s] out of matrix:**
235255

236256
::
237257

238-
$ canconvert.py --frames=REAR_FRAME,FRONT_FRAME source.dbc target.dbc
258+
$ canconvert --frames=REAR_FRAME,FRONT_FRAME source.dbc target.dbc
239259

240260
Extracts the frames ``REAR_FRAME`` and ``FRONT_FRAME`` with the needed ECUs and attributes.
241261

242262
**merge multiple databases:**
243263

244264
::
245265

246-
$ canconvert.py --merge=second.dbc source.dbc target.dbc
266+
$ canconvert --merge=second.dbc source.dbc target.dbc
247267

248268
Merges ``source.dbc`` and ``second.dbc`` in ``target.dbc``.
249269

250270
**merge ECU from other database:**
251271

252272
::
253273

254-
$ canconvert.py --merge=second.dbc:ecu=REAR_ECU source.dbc target.dbc
274+
$ canconvert --merge=second.dbc:ecu=REAR_ECU source.dbc target.dbc
255275

256276
Merges REAR_ECU out of ``second.dbc`` with ``source.dbc`` and store result in ``target.dbc``.
257277

258278
**merge FRAME from other database:**
259279

260280
::
261281

262-
$ canconvert.py --merge=second.dbc:frame=REAR_FRAME source.dbc target.dbc
282+
$ canconvert --merge=second.dbc:frame=REAR_FRAME source.dbc target.dbc
263283

264284
Merges REAR_FRAME out of ``second.dbc`` with ``source.dbc`` and store result in ``target.dbc``.
265285

266286
**combinations and multiple extraction possible:**
267287

268288
::
269289

270-
$ canconvert.py --merge=second.dbc:ecu=REAR_ECU:ecu=FRONT_ECU:frame=FRAME1:FRAME=FRAME2 source.dbc target.dbc
290+
$ canconvert --merge=second.dbc:ecu=REAR_ECU:ecu=FRONT_ECU:frame=FRAME1:FRAME=FRAME2 source.dbc target.dbc
271291

272292
Merges REAR_ECU and FRONT_ECU and FRAME1 and FRAME2 out of ``second.dbc`` with ``source.dbc`` and store result in ``target.dbc``.
273293

@@ -403,6 +423,8 @@ ____________________
403423

404424

405425
* yaml
426+
* scapy
427+
* lua
406428
* json:
407429

408430
--jsonExportCanard

Diff for: docs/formats.rst

+60-10
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,17 @@ There are several importers (read) and exporters (write) for this object.
1515
* .sym [peak](http://www.peak-system.com) pcan can description
1616

1717
* supported file formats for export:
18-
19-
* .dbc
20-
* .dbf
21-
* .kcd
22-
* .xls(x)
23-
* .json [Canard](https://github.com/ericevenchick/CANard) (open source!)
24-
* .arxml (very basic implementation)
25-
* .yaml (dump of the python object)
26-
* .sym
27-
* .xml fibex
18+
* .dbc
19+
* .dbf
20+
* .kcd
21+
* .xls(x)
22+
* .json [Canard](https://github.com/ericevenchick/CANard) (open source!)
23+
* .arxml (very basic implementation)
24+
* .yaml (dump of the python object)
25+
* .sym
26+
* .xml fibex
27+
* .py [scapy] (https://scapy.net/) scapy can message decoder
28+
* .lua [wireshark] wireshark can subdissector
2829

2930

3031
Export
@@ -73,3 +74,52 @@ ______
7374
|xls(x)|+ |+ |+ |+ |+ | | |+ |p |p | |p | |
7475
+------+----+-----+-------------+---------+---------+---------+--------+---------+-------+-------+----------+------------+-------------+
7576

77+
78+
Scapy Export
79+
____________
80+
81+
Create can frame decoder for some can definition
82+
83+
Example:
84+
85+
$ canconvert source.dbc target.py
86+
87+
in scapy use like this:
88+
89+
.. code-block:: python
90+
91+
load_contrib("target")
92+
sock = CANSocket("can0", basecls=DBC)
93+
pkt = sock.recv()
94+
95+
96+
Wireshark Dissector
97+
___________________
98+
99+
$ canconvert source.dbc target.py
100+
101+
Example:
102+
103+
$ canconvert source.sdbc target.lua
104+
105+
in wireshark use like this:
106+
107+
$ wireshark -X lua_script:target.lua
108+
109+
Linux socketcan can directly traced with wireshark. In wireshark select some can frame.
110+
Right-click and select *decode as* and select *SIGNALDECODE* as subdissector
111+
112+
*dissect_canneloni.lua* in the canmatrix example folder shows an example for decoding can
113+
frames which are packet in UDP frames by cannelone (https://github.com/mguentner/cannelloni, https://github.com/PhilippFux/cannelloni)
114+
115+
you could use it like:
116+
117+
.. code-block:: bash
118+
119+
$ chdir canmatrix/examples
120+
$ canconvert some.dbc can_database.lua
121+
$ wireshark wireshark -X lua_script:dissect_cannelloni.lua
122+
123+
note: default cannelloni is mapped to UDP port 3333, you have to change it
124+
125+
note: *can_database* is hard coded in *dissect_cannelloni.lua*, you can customize it there

0 commit comments

Comments
 (0)