@@ -12,22 +12,21 @@ SAE J1939 for Python
12
12
:alt: Documentation build Status
13
13
14
14
15
- An implementation of the CAN SAE J1939 standard for Python.
16
- This implementation was taken from https://github.com/benkfra/j1939, as no
17
- further development took place.
15
+ An implementation of the CAN SAE J1939 standard for Python.
16
+ This is the first J1939-22 (J1939-FD) implementation!
18
17
19
- If you experience a problem or think the stack would not behave properly, do
18
+ If you experience a problem or think the stack would not behave properly, do
20
19
not hesitate to open a ticket or write an email.
21
20
Pullrequests are of course even more welcome!
22
21
23
- The project uses the python-can _ package to support multiple hardware drivers.
24
- At the time of writing the supported interfaces are
22
+ The project uses the python-can _ package to support multiple hardware drivers.
23
+ At the time of writing the supported interfaces are
25
24
26
25
* CAN over Serial
27
26
* CAN over Serial / SLCAN
28
27
* CANalyst-II
29
28
* IXXAT Virtual CAN Interface
30
- * Kvaser’s CANLIB
29
+ * Kvasers CANLIB
31
30
* NEOVI Interface
32
31
* NI-CAN
33
32
* PCAN Basic API
@@ -41,14 +40,14 @@ At the time of writing the supported interfaces are
41
40
Overview
42
41
--------
43
42
44
- An SAE J1939 CAN Network consists of multiple Electronic Control Units (ECUs).
45
- Each ECU can have one or more Controller Applications (CAs). Each CA has its
46
- own (unique) Address on the bus. This address is either acquired within the
43
+ An SAE J1939 CAN Network consists of multiple Electronic Control Units (ECUs).
44
+ Each ECU can have one or more Controller Applications (CAs). Each CA has its
45
+ own (unique) Address on the bus. This address is either acquired within the
47
46
address claiming procedure or set to a fixed value. In the latter case, the CA
48
47
has to announce its address to the bus to check whether it is free.
49
48
50
49
The CAN messages in a SAE J1939 network are called Protocol Data Units (PDUs).
51
- This definition is not completely correct, but close enough to think of PDUs
50
+ This definition is not completely correct, but close enough to think of PDUs
52
51
as the CAN messages.
53
52
54
53
@@ -57,17 +56,22 @@ Features
57
56
58
57
* one ElectronicControlUnit (ECU) can hold multiple ControllerApplications (CA)
59
58
* ECU (CA) Naming according SAE J1939/81
60
- * (under construction) full featured address claiming procedure according SAE J1939/81
61
- * full support of transport protocol (up to 1785 bytes) according SAE J1939/21 for sending and receiveing
59
+ * full featured address claiming procedure according SAE J1939/81
60
+ * full support of transport protocol (up to 1785 bytes) according SAE J1939/21 for sending and receiving
62
61
63
62
- Connection Mode Data Transfers (CMDT)
64
63
- Broadcast Announce Message (BAM)
64
+ * support of Multi-PG according SAE J1939/22
65
+ - currently FEFF (Flexible Data Rate Extended Frame Format) supported only
66
+ * full support of fd-transport protocol according SAE J1939/22 (J1939-FD) for sending and receiving
65
67
66
- * (under construction) Requests (global and specific)
68
+ - RTS/CTS (Destination Specific) Transfer with up to 8 concurrent sessions and up to 16777215 bytes of data per session
69
+ - Broadcast Announce Message (BAM) with up to 4 concurrent sessions and up to 15300 bytes of data per session
70
+
71
+ * Requests (global and specific)
67
72
* correct timeout and deadline handling
68
73
* (under construction) almost complete testcoverage
69
- * (under construction) diagnostic messages (see https://github.com/juergenH87/python-can-j1939/tree/master/examples/diagnostic_message.py)
70
-
74
+ * diagnostic messages (see https://github.com/juergenH87/python-can-j1939/tree/master/examples/diagnostic_message.py)
71
75
- support of DM1 Tool and ECU functionaliy
72
76
- support of DM11 Tool functionaliy
73
77
- support of DM22 Tool functionaliy
@@ -139,7 +143,7 @@ To simply receive all passing (public) messages on the bus you can subscribe to
139
143
ecu.connect(bustype = ' pcan' , channel = ' PCAN_USBBUS1' , bitrate = 250000 )
140
144
# ecu.connect(bustype='ixxat', channel=0, bitrate=250000)
141
145
# ecu.connect(bustype='vector', app_name='CANalyzer', channel=0, bitrate=250000)
142
- # ecu.connect(bustype='nican', channel='CAN0', bitrate=250000)
146
+ # ecu.connect(bustype='nican', channel='CAN0', bitrate=250000)
143
147
144
148
# subscribe to all (global) messages on the bus
145
149
ecu.subscribe(on_message)
@@ -150,7 +154,7 @@ To simply receive all passing (public) messages on the bus you can subscribe to
150
154
ecu.disconnect()
151
155
152
156
if __name__ == ' __main__' :
153
- main()
157
+ main()
154
158
155
159
A more sophisticated example in which the CA class was overloaded to include its own functionality:
156
160
@@ -166,7 +170,7 @@ A more sophisticated example in which the CA class was overloaded to include its
166
170
167
171
# compose the name descriptor for the new ca
168
172
name = j1939.Name(
169
- arbitrary_address_capable = 0 ,
173
+ arbitrary_address_capable = 0 ,
170
174
industry_group = j1939.Name.IndustryGroup.Industrial,
171
175
vehicle_system_instance = 1 ,
172
176
vehicle_system = 1 ,
@@ -200,7 +204,7 @@ A more sophisticated example in which the CA class was overloaded to include its
200
204
def ca_timer_callback1 (cookie ):
201
205
""" Callback for sending messages
202
206
203
- This callback is registered at the ECU timer event mechanism to be
207
+ This callback is registered at the ECU timer event mechanism to be
204
208
executed every 500ms.
205
209
206
210
:param cookie:
@@ -227,7 +231,7 @@ A more sophisticated example in which the CA class was overloaded to include its
227
231
def ca_timer_callback2 (cookie ):
228
232
""" Callback for sending messages
229
233
230
- This callback is registered at the ECU timer event mechanism to be
234
+ This callback is registered at the ECU timer event mechanism to be
231
235
executed every 500ms.
232
236
233
237
:param cookie:
@@ -264,7 +268,7 @@ A more sophisticated example in which the CA class was overloaded to include its
264
268
ecu.connect(bustype = ' pcan' , channel = ' PCAN_USBBUS1' , bitrate = 250000 )
265
269
# ecu.connect(bustype='ixxat', channel=0, bitrate=250000)
266
270
# ecu.connect(bustype='vector', app_name='CANalyzer', channel=0, bitrate=250000)
267
- # ecu.connect(bustype='nican', channel='CAN0', bitrate=250000)
271
+ # ecu.connect(bustype='nican', channel='CAN0', bitrate=250000)
268
272
# ecu.connect('testchannel_1', bustype='virtual')
269
273
270
274
# add CA to the ECU
@@ -276,27 +280,24 @@ A more sophisticated example in which the CA class was overloaded to include its
276
280
ca.add_timer(5 , ca_timer_callback2)
277
281
# by starting the CA it starts the address claiming procedure on the bus
278
282
ca.start()
279
-
283
+
280
284
time.sleep(120 )
281
285
282
286
print (" Deinitializing" )
283
287
ca.stop()
284
288
ecu.disconnect()
285
289
286
290
if __name__ == ' __main__' :
287
- main()
291
+ main()
292
+
288
293
289
294
Credits
290
295
-------
296
+ This implementation was taken from https://github.com/benkfra/j1939, as no further development took place.
291
297
292
- This implementation was initially inspired by the `CANopen project of Christian Sandberg `_.
293
298
Thanks for your great work!
294
299
295
- Most of the informations about SAE J1939 are taken from the papers and the book of
296
- `Copperhill technologies `_ and from my many years of experience in J1939 of course :-)
297
-
298
300
299
301
300
302
.. _python-can : https://python-can.readthedocs.org/en/stable/
301
303
.. _Copperhill technologies : http://copperhilltech.com/a-brief-introduction-to-the-sae-j1939-protocol/
302
- .. _CANopen project of Christian Sandberg : http://canopen.readthedocs.io/en/stable/
0 commit comments