Package: openinverter-can-tool
openinverter CAN toolA tool to allow configuration and operating of openinverter systems for
electric vehicles over a CAN connection.FeaturesDisplay all available modifiable parameters and read-only values supported by a given inverter firmware versionRead a specified parameter/valueWrite a new value to a specified parameterDisplay the current value of each parameter/value on a given deviceLog a list of parameters to a CSV file at regular intervalsSave and load all parameters to and from a JSON fileDisplay the inverter serial numberCommand the inverter to:StartStopLoad parameters from flashSave parameters to flashRevert parameters to their default valuesResetScan a CAN bus for possible nodesRuns on Linux, Windows and MacOS with python 3.7+Works with any CAN adapter supported bypython-canSupportsstm32-sine5.24.R or laterAutomatic parameter database download and caching (requires stm32-sine development branch - likely 5.27.R or later)InstallationThe most recent release may be installed using pip:pip install openinverter_can_toolTo install directly from github:git clone https://github.com/davefiddes/openinverter_can_tool.git
    cd openinverter_can_tool
    pip install -e .LinuxLinux users may reduce the potential of package conflicts by installing python dependencies from their package manager. This should be done before runningpip.Fedorasudo dnf install python3-setuptools python3-pip python3-click python3-can python3-appdirsUbuntu/Debiansudo apt install python3-setuptools python3-pip python3-click python3-can python3-appsdirsConfigurationBefore the tool can be used the CAN interface adapter needs to be configured. To do this create~/.canrcon Linux or%USERPROFILE%/can.confon Windows. Details on interfaces supported and the configuration file format can be found in thepython-candocumentation.An example configuration file for aSocketCANcompatible adapter on Linux would look like:[default]
interface = socketcan
channel = can0
bitrate = 500000Note: Before the tool can on Linux run the SocketCAN network interface needs to be started:sudo ip link set can0 up type can bitrate 500000An example configuration file for aSLCANadapter such asGVRETon Windows would look like:[default]
interface = slcan
channel = COM8
bitrate = 500000Tested interfaces:Innomaker USB2CANCAN interface in Linux.GVRETCAN interface usingslcanin LinuxLet me know if you have used a particular CAN interface successfully and I can expand this list.UsageThe parameters and values supported by a given openinverter firmware will often vary from release to release and by firmware type (e.g. Sine to Field Oriented Control(FOC)). The tool comes with a small collection of  parameter databases for recent openinverter releases. These can be found in the parameter-databases directory in the install location. Versions of stm32-sine from 5.25.R and onwards support automatic download of parameter databases and the database option does not need to be specified.To get the usage information for the tool run theoiccommand with no parameters:Usage: oic [OPTIONS] COMMAND [ARGS]...

      openinverter CAN Tool allows querying and setting configuration of inverter
      parameters over a CAN connection

    Options:
      -d, --database FILE  Override the openinverter JSON parameter database to
                           use
      -c, --context TEXT   Which python-can configuration context to use
      -n, --node INTEGER   The CAN SDO node ID to communicate with  [default: 1]
      -t, --timeout FLOAT  Response timeout in seconds  [default: 1.0]
      --version            Show the version and exit.
      --help               Show this message and exit.

    Commands:
      cache       Parameter database cache management commands
      cmd         Execute a command on a device
      dumpall     Dump the values of all available parameters and values
      listparams  List all available parameters and values
      load        Load all parameters from json IN_FILE
      log         Log the value of PARAMS from the device periodically in CSV...
      read        Read the value of PARAM from the device
      save        Save all parameters in json to OUT_FILE
      scan        Scan the CAN bus for available nodes
      serialno    Read the device serial number.
      write       Write the value to the parameter PARAM on the deviceTo read a specific parameter from 5.24.R firmware:$ oic -d parameter-databases/stm32-sine.5.24.R-foc.json read brakeregen
    brakeregen: -13 [%]To write a new value to a parameter with 5.27.R or later firmware with automatic database download:oic write brakeregen -30.5Values may be changed using symbolic names:oic write potmode DualChannel
    oic write pinswap PWMOutput13,PWMOutput23The list of allowed values for a given parameter can be found using thelistparamscommand.DevelopmentIf you want to be able to change the code while using it, clone it then install
it in development mode:git clone https://github.com/davefiddes/openinverter_can_tool.git
    cd openinverter_can_tool
    virtualenv venv
    . venv/bin/activate
    pip install -e .[dev,test]To exit the virtualenv environment use use the system installedoicrundectivate. To resume development operation the virtualenv can be restarted by running:. venv/bin/activateUnit tests and python code linting can be run on all supported python versions using thetoxtest framework.Code is written to conform to PEP8 conventions and enforced bypylintandflake8linting.