Tool to manage openinverter via CAN

Discussion about various user interfaces such as web interface, displays and apps
evMacGyver
Posts: 155
Joined: Tue Jun 15, 2021 5:44 pm
Location: Finland
Has thanked: 39 times
Been thanked: 8 times

Re: Tool to manage openinverter via CAN

Post by evMacGyver »

I might be too tired to find my mistake, cleared clara can map and run previously working oic script which no longer works for some reason. Tried with long time used 0.0.9 and also git version 0.1.0.

oic -n 22 can clear
CAN all mapping removed successfully.

oic -n 22 can add tx 0x109 UdcDivider 0 8 0 10
Adding CAN tx mapping with can_id=0x109 param='UdcDivider' position=0 length=8 gain=0.0 offset=10
Command or parameter not supported

CAN log:

Code: Select all

Time Stamp,ID,Extended,Dir,Bus,LEN,D1,D2,D3,D4,D5,D6,D7,D8
18977723,00000616,false,Rx,0,8,40,00,50,03,00,00,00,00,
18978367,00000596,false,Rx,0,8,43,00,50,03,13,EE,00,00,
18980910,00000616,false,Rx,0,8,23,00,30,00,09,01,00,00,
18981786,00000596,false,Rx,0,8,60,00,30,00,09,01,00,00,
18982152,00000616,false,Rx,0,8,23,00,30,01,01,00,00,08,
18982988,00000596,false,Rx,0,8,60,00,30,01,01,00,00,08,
18983209,00000616,false,Rx,0,8,23,00,30,02,00,00,00,0A,
18983990,00000596,false,Rx,0,8,80,00,30,02,00,00,02,06,
Tried can add help example with same error:
oic -n22 can add tx 0x101 temp3 32 8

Code: Select all

Time Stamp,ID,Extended,Dir,Bus,LEN,D1,D2,D3,D4,D5,D6,D7,D8
41307649,00000616,false,Rx,0,8,40,00,50,03,00,00,00,00,
41308306,00000596,false,Rx,0,8,43,00,50,03,13,EE,00,00,
41311027,00000616,false,Rx,0,8,23,00,30,00,01,01,00,00,
41311570,00000596,false,Rx,0,8,60,00,30,00,01,01,00,00,
41312064,00000616,false,Rx,0,8,23,00,30,01,D5,07,20,08,
41312602,00000596,false,Rx,0,8,60,00,30,01,D5,07,20,08,
41312975,00000616,false,Rx,0,8,23,00,30,02,E8,03,00,00,
41313572,00000596,false,Rx,0,8,80,00,30,02,00,00,02,06,
davefiddes
Posts: 277
Joined: Mon Jan 18, 2021 12:39 pm
Location: Edinburgh, Scotland, UK
Has thanked: 61 times
Been thanked: 88 times

Re: Tool to manage openinverter via CAN

Post by davefiddes »

A gain of 0 looks odd. stm32-sine is happy to set up a map with that it just outputs a constant "10".

Other than that the request looks fine it's just the remote device that doesn't like it.
evMacGyver
Posts: 155
Joined: Tue Jun 15, 2021 5:44 pm
Location: Finland
Has thanked: 39 times
Been thanked: 8 times

Re: Tool to manage openinverter via CAN

Post by evMacGyver »

Solved. CAN mapping showed none and always "Command or parameter not supported", no matter if I programmed bootloader and Clara with erase. Finally I did STM32CubeProgrammer full chip erase, which I believe is only erasing eeprom, programmer flash with openocd and voila.

Maybe I got into some libopeninv bug or something, but could not reproduce it with oic -n22 can clear tx ; oic -n22 can clear rx commands.
davefiddes
Posts: 277
Joined: Mon Jan 18, 2021 12:39 pm
Location: Edinburgh, Scotland, UK
Has thanked: 61 times
Been thanked: 88 times

Re: Tool to manage openinverter via CAN

Post by davefiddes »

Ah. That sounds a lot like the problem @tom91 got into viewtopic.php?p=73423#p73423 I think there's a bug in the libopeninv code when more complex maps are created.
davefiddes
Posts: 277
Joined: Mon Jan 18, 2021 12:39 pm
Location: Edinburgh, Scotland, UK
Has thanked: 61 times
Been thanked: 88 times

Re: Tool to manage openinverter via CAN

Post by davefiddes »

I have just release v0.2.0:

What's Changed:
  • Fully automatic firmware upgrade
  • Failed device recovery with or without serial number information
For best performance devices using stm32-CANBootloader should be running release v1.3 or later. This is particularly important when recovering devices on a network with multiple devices at power-on. Note: At this time there isn't a binary version of this release.

I have tested the upgrade process with all versions of the stm32-CANBootloader from 1.0 through 1.3 and it seems to work fine.
davefiddes
Posts: 277
Joined: Mon Jan 18, 2021 12:39 pm
Location: Edinburgh, Scotland, UK
Has thanked: 61 times
Been thanked: 88 times

Re: Tool to manage openinverter via CAN

Post by davefiddes »

I have just released v0.2.1:

What's Changed:
  • Fix DBC generation for enum and bitfield parameters to apply the gain and offset on the CAN mapping.
Found this while trying to answer a CAN mapping query. I'm not sure it makes a lot of sense to have gains and offsets on bitfield values in particular. It's possible to configure them so generated DBC files should be able to interpret what openinverter devices output.
User avatar
Proton
Posts: 238
Joined: Sat May 06, 2023 2:23 am
Location: Georgia/US
Has thanked: 160 times
Been thanked: 26 times

Re: Tool to manage openinverter via CAN

Post by Proton »

Can anybody here make a video on how to install and connect the BMS? I bought one BMS about 1 year ago but was not able to install the linux tool. Something did not install right. I want to buy 5 more bms boards for my battery but without clear instructions I am going to hold on for now.
davefiddes
Posts: 277
Joined: Mon Jan 18, 2021 12:39 pm
Location: Edinburgh, Scotland, UK
Has thanked: 61 times
Been thanked: 88 times

Re: Tool to manage openinverter via CAN

Post by davefiddes »

Not sure a video is going to be very helpful. Do you have any details on the CAN adapter you are using, which version if Linux and are there any error messages?
davefiddes
Posts: 277
Joined: Mon Jan 18, 2021 12:39 pm
Location: Edinburgh, Scotland, UK
Has thanked: 61 times
Been thanked: 88 times

Re: Tool to manage openinverter via CAN

Post by davefiddes »

I have just release v0.2.3 of the tool:

What's Changed:
  • Fix problems parsing parameters with Zombieverter V2.20A firmware
  • Add support for python 3.13
Just a minor fix of some niggles with the TorqDerate and CAN3Speed parameters in the recent Zombieverter firmware release. The tool should now behave in a similar, more tolerant, way to incorrectly punctuated parameter names as the web interface(s). So if it works for one tool it should work for all.

v0.2.2 can be ignored. It failed due to some GitHub release signing busywork.
davefiddes
Posts: 277
Joined: Mon Jan 18, 2021 12:39 pm
Location: Edinburgh, Scotland, UK
Has thanked: 61 times
Been thanked: 88 times

Re: Tool to manage openinverter via CAN

Post by davefiddes »

I've just released v0.3.0 of the tool:

What's New
  • Log symbolic values for enum and bit-field params by default. The old behaviour can be re-enabled with the "--numeric" option.
  • Add a "listparam" command to explain a single parameter.
  • Add a "--debug" option to all commands to allow problems to be investigated more easily.
  • Close CAN connections properly. This addresses problems with some CAN adapters on Windows.
User avatar
muehlpower
Posts: 679
Joined: Fri Oct 11, 2019 10:51 am
Location: Germany Fürstenfeldbruck
Has thanked: 14 times
Been thanked: 133 times

Re: Tool to manage openinverter via CAN

Post by muehlpower »

I still haven't managed to get this tool to work. What am I doing wrong? I have installed python. When I enter 'Python' in the comandline something happens. When I enter 'pip' I get a help text. When I type 'pip install openinverter_can_tool' something seems to be installed. And now? If I enter 'oic' it is unknown.
davefiddes
Posts: 277
Joined: Mon Jan 18, 2021 12:39 pm
Location: Edinburgh, Scotland, UK
Has thanked: 61 times
Been thanked: 88 times

Re: Tool to manage openinverter via CAN

Post by davefiddes »

If the "oic" command isn't available that sounds like where it is installed to is not on the path. To help out it would be useful to know the platform you are using and the output of the install command. It would also be helpful to know the CAN adapter you would like to use with it.
User avatar
muehlpower
Posts: 679
Joined: Fri Oct 11, 2019 10:51 am
Location: Germany Fürstenfeldbruck
Has thanked: 14 times
Been thanked: 133 times

Re: Tool to manage openinverter via CAN

Post by muehlpower »

I don't know where it was installed, how to find it, nor how to specify or change a path. I am using Windows 10 and python 3.13.3
install.png
User avatar
muehlpower
Posts: 679
Joined: Fri Oct 11, 2019 10:51 am
Location: Germany Fürstenfeldbruck
Has thanked: 14 times
Been thanked: 133 times

Re: Tool to manage openinverter via CAN

Post by muehlpower »

USB2CAN.jpg
this is the adapter I have and want to use

https://www.inno-maker.com/product/usb-can/
davefiddes
Posts: 277
Joined: Mon Jan 18, 2021 12:39 pm
Location: Edinburgh, Scotland, UK
Has thanked: 61 times
Been thanked: 88 times

Re: Tool to manage openinverter via CAN

Post by davefiddes »

Had a very frustrating day trying to get this to work on Windows 11 (10 should be the same). The TLDR version is that it doesn't at the moment. For the time being I'd recommend using a Linux virtual machine and pass-through the USB CAN adapter to the VM. VirtualBox is your best bet on Windows 10 though I believe WSL can do this on Windows 11. You could also use a raspberry pi or any other Linux box.

What follows is how to set up openinverter_can_tool on Windows with an Innomaker USB2CAN or any other CAN adapter using the Geschwister Schneider protocol.

The problem with being unable to find the "oic" command is because of a missing path. You need to update it using the System Properties | Environment Variables. It should contain

Code: Select all

C:\Users\mb\AppData\Local\Programs\Python\Python313
C:\Users\mb\AppData\Local\Programs\Python\Python313\Scripts
If you look in C:\Users\mb\AppData\Local\Programs\Python\Python313\Scripts you should see an "oic.exe". When you log-out and log back in again it should run from a Command Prompt.

Once this is done you need to install the USB driver for the USB2CAN adapter. To do this you need to download a utility called Zadig. This program assigns a device driver to a specific USB device. When you run the utility pick the "Options | List All Devices" option. Then you pick the "USB2CAN v1 (Interface 0)" in the drop-down:
Screenshot 2025-04-21 185733.png
Change the spin-control next to the green arrow to read "libusbK (v3.1.0.0)" and press the Replace Driver option:
Screenshot 2025-04-21 185855.png
With this done you need to install an additional python driver:

Code: Select all

pip install python-can[gs_usb]
Then you need to set up a CAN configuration so that openinverter_can_tool and other python tools can find your interface. Create a new file using Notepad called "can.conf" in c:\Users\mb with the following:

Code: Select all

[default]
interface = gs_usb
channel = USB2CAN v1
index = 0
bitrate = 500000
The tool should then work for exactly one command until you remove the USB device and plug it back in again (go figure):

Code: Select all

C:\Users\dave>oic scan
Scanning for devices. Please wait...

Found possible openinverter node: 1

C:\Users\dave>
There's something getting screwed up when a command finishes that confuses the interface so that it things it is still in the middle of sending the CAN frame that was sent when the interface was shut down at the end of the previous command. I've no idea whether it's my code or some part of hot-mess of python libraries this lot depends on. I'm not proposing to investigate further until I'm a lot less fed up.
User avatar
muehlpower
Posts: 679
Joined: Fri Oct 11, 2019 10:51 am
Location: Germany Fürstenfeldbruck
Has thanked: 14 times
Been thanked: 133 times

Re: Tool to manage openinverter via CAN

Post by muehlpower »

now i have a bad conscience that i asked. I also spent the day yesterday trying. I also found out about the path and it worked. But I failed with the CAN adapter. I am not a computer specialist and I have no idea about linux. I ordered a new wifi CAN module from Johu after I killed mine. Hopefully it will work with that.
Thanks again for your efforts, maybe someone will find a windows cable solution for configuring that is doable for idiots like me.
davefiddes
Posts: 277
Joined: Mon Jan 18, 2021 12:39 pm
Location: Edinburgh, Scotland, UK
Has thanked: 61 times
Been thanked: 88 times

Re: Tool to manage openinverter via CAN

Post by davefiddes »

Don't worry about asking, you weren't to know it was going to be quite as frustrating as it turned out. Having slept on it, unsurprisingly, I have ideas for a way forward...
davefiddes
Posts: 277
Joined: Mon Jan 18, 2021 12:39 pm
Location: Edinburgh, Scotland, UK
Has thanked: 61 times
Been thanked: 88 times

Re: Tool to manage openinverter via CAN

Post by davefiddes »

I've just released v0.3.1 of the tool:

What's New
  • Include support for serial and slcan python-can drivers by default
  • Update README with details of working and not working Windows CAN interface
    adapters
The good news is that I've found a CAN adapter that works very reliably in Windows (and also Linux). The MKS CANable Pro v2.0 (available from eBay, Amazon sellers, etc as well) comes with slcan firmware by default. This works well with openinverter-can-tool and SavvyCAN in Windows and is very simple to configure. The HW doesn't have as good isolation distances IMO as the Innomaker USB2CAN adapter but is probably good enough for most purposes (e.g. not shoving 12V into your laptop's USB port).

If using Linux it is possible to swap the firmware on the adapters to the candleLight firmware which has a native socketcan driver. This is useful if you want to run tools like openinverter-can-tool, SavvyCAN and Wireshark all at the same time. If you don't need to do this then sticking with the slcan firmware is probably simplest.

If you don't need CAN FD support the V2.0 non-Pro version will save a bit of money but still give you galvanic isolation. The V1.0 adapter is cheaper still but how much is your computer's USB port worth?
Post Reply