SuperCAN plugin for python-can
This plugin is required on Windows to get access to SuperCAN devices from Python. On Linux, simply use can.Bus(interface='socketcan', ...).
Open a native command prompt.
-
Open a MinGW shell suitable for your system (MinGW64, typically).
-
Ensure you have the necessary packages installed, i.e
pacman -S mingw-w64-x86_64-toolchain mingw64/mingw-w64-x86_64-python-pip
-
Copy the content of the
SuperCANdirectory to a writable location. -
Navigate to this directory
-
Run
python -m pip install .
-
Ensure your device is upgraded to firmware version 0.6.0 or better.
-
Optionally, register the COM server (
supercan_srv64.exe) for shared channel access. If you used the installer, this step is already done. Otherwise, from an admin console, runsupercan_srv64.exe /RegServer -
Access the CAN channel from Python
import can e = can.Bus( interface="supercan", serial="12345678", # device serial bitrate=500000)
You can force shared mode like so:
import can e = can.Bus( interface="supercan", serial="12345678", # device serial bitrate=500000, shared=True) # request shared mode, fail if unavailable
Note, exclusive mode is always available. This should always work:
import can e = can.Bus( interface="supercan", serial="12345678", # device serial bitrate=500000, shared=False) # request exclusive mode
Setup a virtual env and install / build the module with debug symbols:
(.venv) supercan\Windows\python>python setup.py build --sc-debug-build
(.venv) supercan\Windows\python>python setup.py install
{
"name": "Python C",
"type": "cppvsdbg",
"request": "launch",
"program": "C:\\Program Files\\Python312\\python.exe",
"args": [
"<PATH TO PYTHON SCRIPT>\\test.py"
],
"stopAtEntry": false,
"cwd": "${fileDirname}",
"environment": [
{
"name": "PYTHONPATH",
"value": "<PATH TO PYTHON VENV SITE-PACKAGES"
}
],
"console": "externalTerminal",
}