Click here for back issues.
https://www.simulationroom999.com/blog/diagnostic-communication-en-back-issue/
Introduction.
Explanation of CAN-FD simulation in python-can.
In this article, we will explain the modifications to playback with can.player and record with can.logger.
Actually…
This is… I noticed this after some preliminary experimentation…
CAN.player and CAN.logger did not support CAN-FD – !!!!
This is bad!
So I followed the internal code of python-can.
It seems that python-can itself supports CAN-FD.
Since can.player and can.logger are not CAN-FD compliant, I think I can get there by modifying them.
*The version of pyton-can is 3.3.3 at the time of writing this article.
*It may be supported in later versions.(version 4.x or later)
Location of python code for can.player
First, find the python code that can.player is writing.
For Anaconda, if you have it installed by default, you should find it as follows.
C:\ProgramData\Anaconda3\Lib\site-packages\can
And the code for can.player is player.py.
CAN-FD support for can.player
And put the following modifications.
player.py_old is the original one and player.py is the modified one.
--- C:/ProgramData/Anaconda3/Lib/site-packages/can/player.py_old
+++ C:/ProgramData/Anaconda3/Lib/site-packages/can/player.py
@@ -42,7 +41,14 @@
parser.add_argument('-b', '--bitrate', type=int,
help='''Bitrate to use for the CAN bus.''')
+
+ parser.add_argument("--fd", help="Activate CAN-FD support", action="store_true")
+ parser.add_argument(
+ "--data_bitrate",
+ type=int,
+ help="""Bitrate to use for the data phase in case of CAN-FD.""",
+ )
parser.add_argument('--ignore-timestamps', dest='timestamps',
help='''Ignore timestamps (send all frames immediately with minimum gap between frames)''',
action='store_false')
@@ -77,6 +83,7 @@
error_frames = results.error_frames
config = {"single_handle": True}
+ config["fd"]= results.fd
if results.interface:
config["interface"] = results.interface
if results.bitrate:
The module Bus in can.player has a parameter for CAN-FD, so I made it possible to add it from the startup options.
It was a simpler fix than I thought.
Location of can.logger python code
The can.logger code is located as follows, as well as can.player.
C:\ProgramData\Anaconda3\Lib\site-packages\can
The logger.py here is applicable.
CAN-FD support for can.logger
The modifications are as follows.
logger.py_old is the original one and logger.py is the modified one.
--- C:/ProgramData/Anaconda3/Lib/site-packages/can/logger.py_old
+++ C:/ProgramData/Anaconda3/Lib/site-packages/can/logger.py
@@ -57,6 +57,14 @@
parser.add_argument('-b', '--bitrate', type=int,
help='''Bitrate to use for the CAN bus.''')
+ parser.add_argument("--fd", help="Activate CAN-FD support", action="store_true")
+
+ parser.add_argument(
+ "--data_bitrate",
+ type=int,
+ help="""Bitrate to use for the data phase in case of CAN-FD.""",
+ )
+
state_group = parser.add_mutually_exclusive_group(required=False)
state_group.add_argument('--active', help="Start the bus as active, this is applied by default.",
action='store_true')
@@ -94,6 +102,10 @@
config["interface"] = results.interface
if results.bitrate:
config["bitrate"] = results.bitrate
+ if results.fd:
+ config["fd"] = True
+ if results.data_bitrate:
+ config["data_bitrate"] = results.data_bitrate
bus = Bus(results.channel, **config)
if results.active:
I added a parameter “fd” to this one too.
But… there are some problems with can.logger…
Well, I’ll explain a little when I get it working.
Conclusion.
- It was discovered that can.player and can.logger do not support CAN-FD.
- I immediately modified them to support CAN-FD.
- can.logger has a little different problem.
Click here for back issues.
コメント