Tool to manage openinverter via CAN

Discussion about various user interfaces such as web interface, displays and apps
User avatar
celeron55
Posts: 785
Joined: Thu Jul 04, 2019 3:04 pm
Location: Finland
Has thanked: 32 times
Been thanked: 121 times
Contact:

Re: Tool to manage openinverter via CAN

Post by celeron55 »

I declare it done now, for my part. I think it's pretty good:

https://github.com/davefiddes/openinver ... ool/pull/1
User avatar
johu
Site Admin
Posts: 5933
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 183 times
Been thanked: 1120 times
Contact:

Re: Tool to manage openinverter via CAN

Post by johu »

Cool, will test

I hope some documentation will end the Finnish public holiday called Bashersday :P

https://openinverter.org/wiki/CAN_commu ... es_via_SDO

Maybe not the best possible solution but easy to implement on the server side
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
User avatar
celeron55
Posts: 785
Joined: Thu Jul 04, 2019 3:04 pm
Location: Finland
Has thanked: 32 times
Been thanked: 121 times
Contact:

Re: Tool to manage openinverter via CAN

Post by celeron55 »

Bashersday is any day someone thinks ESP32 is a good alternative to documentation!
User avatar
johu
Site Admin
Posts: 5933
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 183 times
Been thanked: 1120 times
Contact:

Re: Tool to manage openinverter via CAN

Post by johu »

:D

I tried to get chatgpt to write the documentation for me but the result can safey be called bullsh*tting
ChatGPT wrote:The SDO (Service Data Object) protocol is a communication protocol used in CANopen networks to access and manipulate data within CANopen devices. In the context of the libopeninv library, which is a library for interacting with CANopen devices, the SDO protocol likely plays a crucial role in reading from and writing to object dictionary entries in CANopen devices.
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
davefiddes
Posts: 224
Joined: Mon Jan 18, 2021 12:39 pm
Location: Edinburgh, Scotland, UK
Has thanked: 15 times
Been thanked: 44 times

Re: Tool to manage openinverter via CAN

Post by davefiddes »

Got fed up manually starting my SocketCAN interface on Linux. Turns out to be quite simple to configure a CAN bus to be started automatically:

https://www.pragmaticlinux.com/2021/07/ ... e-on-boot/

This uses systemd-network which knows how to manage SocketCAN networks as well as Ethernet. It can peacefully co-exist with NetworkManager so you don't break your existing network configuration. Will attempt to document for the next release of OIC.
evMacGyver
Posts: 134
Joined: Tue Jun 15, 2021 5:44 pm
Location: Finland
Has thanked: 26 times
Been thanked: 6 times

Re: Tool to manage openinverter via CAN

Post by evMacGyver »

I'm doing something wrong. How can I get can mapping to work, it seems 0.0.8 version not include it as I get for oic -n 22 can list:
Error: No such command 'can'.
Tried celeron55 github version too.

EDIT: Oh, I got wrong branch
davefiddes
Posts: 224
Joined: Mon Jan 18, 2021 12:39 pm
Location: Edinburgh, Scotland, UK
Has thanked: 15 times
Been thanked: 44 times

Re: Tool to manage openinverter via CAN

Post by davefiddes »

Try "oic map" in place of "oic can". I changed the verb to make a bit more sense.

It's not in a release version as I keep finding bugs in oic and libopeninv. It's OK as long as you avoid negative gains and offsets mostly.
evMacGyver
Posts: 134
Joined: Tue Jun 15, 2021 5:44 pm
Location: Finland
Has thanked: 26 times
Been thanked: 6 times

Re: Tool to manage openinverter via CAN

Post by evMacGyver »

Got mapping done. Nice tool. Only thing is should new mapping save permanently, did not see any extra save commands? Otherwise I have problem with focci board.
davefiddes
Posts: 224
Joined: Mon Jan 18, 2021 12:39 pm
Location: Edinburgh, Scotland, UK
Has thanked: 15 times
Been thanked: 44 times

Re: Tool to manage openinverter via CAN

Post by davefiddes »

The mapping commands edit the running configuration just like changing parameters. To save the parameters and CAN mapping you need to issue a "oic cmd save" which is equivalent to pressing the "Save Parameters to Flash" on the web interface.
evMacGyver
Posts: 134
Joined: Tue Jun 15, 2021 5:44 pm
Location: Finland
Has thanked: 26 times
Been thanked: 6 times

Re: Tool to manage openinverter via CAN

Post by evMacGyver »

Now that I've used oic for Focci (and I like both very much ;)), what it would take to add support to zombie? Zombie param_prj.h does not have NodeId, so I assume its not possible out of a box?
User avatar
johu
Site Admin
Posts: 5933
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 183 times
Been thanked: 1120 times
Contact:

Re: Tool to manage openinverter via CAN

Post by johu »

It has a fixed node id, I think 2. Check main where the CanSdo object is created.
It also needs to run the latest libopeninv

https://github.com/damienmaguire/Stm32- ... .cpp#L1049

Node id is 3 and it is tied to CAN1
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
davefiddes
Posts: 224
Joined: Mon Jan 18, 2021 12:39 pm
Location: Edinburgh, Scotland, UK
Has thanked: 15 times
Been thanked: 44 times

Re: Tool to manage openinverter via CAN

Post by davefiddes »

You can use the "oic scan" command to search a bus for any compatible devices. This is especially useful if you don't know what the node id is.

Looks like the VCU should be able to be configured with OIC (or the ESP32 CAN interface). It doesn't have the latest CAN message parameter mapping code but other than that should be usable. If you get it working it would be a kindness to update the issue I raised last year: https://github.com/damienmaguire/Stm32-vcu/issues/49
evMacGyver
Posts: 134
Joined: Tue Jun 15, 2021 5:44 pm
Location: Finland
Has thanked: 26 times
Been thanked: 6 times

Re: Tool to manage openinverter via CAN

Post by evMacGyver »

oic scan found possibly node 3 as open inverter, but another commands did not work. I think latest libopeninv was compiled, need to verify.
Also scan did not found Focci, even it otherwise works.
davefiddes
Posts: 224
Joined: Mon Jan 18, 2021 12:39 pm
Location: Edinburgh, Scotland, UK
Has thanked: 15 times
Been thanked: 44 times

Re: Tool to manage openinverter via CAN

Post by davefiddes »

That's really odd behaviour from the VCU and not what I would expect. Are you in a position to capture CAN frames? On Linux it is easy to run Wireshark, SavvyCAN or candump at the same time as oic. If you could run can run:

Code: Select all

oic cache clean
oic -n 3 dumpall
and capture the results I can look into it. I don't have VCU hardware so can debug directly.

I am surprised by the behaviour of Focci. Is this on the same bus as the VCU? A capture of the "oic scan" command would also be helpful.
User avatar
uhi22
Posts: 716
Joined: Mon Mar 14, 2022 3:20 pm
Location: Ingolstadt/Germany
Has thanked: 104 times
Been thanked: 456 times

Re: Tool to manage openinverter via CAN

Post by uhi22 »

What is the range of node ids when scanning? Foccci is at 22, maybe not in the scan range?
davefiddes
Posts: 224
Joined: Mon Jan 18, 2021 12:39 pm
Location: Edinburgh, Scotland, UK
Has thanked: 15 times
Been thanked: 44 times

Re: Tool to manage openinverter via CAN

Post by davefiddes »

Doh! That's it. There seems to be a problem with the canopen python library which stops it from scanning more than 20 node ids. Surely 20 nodes would be enough for anyone thought I... :)
User avatar
johu
Site Admin
Posts: 5933
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 183 times
Been thanked: 1120 times
Contact:

Re: Tool to manage openinverter via CAN

Post by johu »

We can knock the default id for Clara down to 5 and let the BMS start at 6 or 10
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
User avatar
uhi22
Posts: 716
Joined: Mon Mar 14, 2022 3:20 pm
Location: Ingolstadt/Germany
Has thanked: 104 times
Been thanked: 456 times

Re: Tool to manage openinverter via CAN

Post by uhi22 »

Or create a pull request for the canopen python library.
davefiddes
Posts: 224
Joined: Mon Jan 18, 2021 12:39 pm
Location: Edinburgh, Scotland, UK
Has thanked: 15 times
Been thanked: 44 times

Re: Tool to manage openinverter via CAN

Post by davefiddes »

I think I'll work around it in my tool. There is an open issue that describes the problem (https://github.com/christiansandberg/canopen/issues/369) but there doesn't seem to be much appetite to fix it in the canopen library. The root of the problem is a too short can message queue on the Linux CAN interface. I have experimented this morning with increasing the queue length "sudo ip link set can0 txqueuelen 1000" and I am able to scan the full 127 possible nodes on the network. Big queues on CAN interfaces is a bad idea generally so a more intelligent way of dealing with a full queue during a scan would be a better way to do it.
User avatar
uhi22
Posts: 716
Joined: Mon Mar 14, 2022 3:20 pm
Location: Ingolstadt/Germany
Has thanked: 104 times
Been thanked: 456 times

Re: Tool to manage openinverter via CAN

Post by uhi22 »

Maybe just wait 10ms or 20ms between the requests, to give the messages the chance to be transmitted. Then a complete scan of 127 nodes would take less than three seconds, which sounds acceptable from my point of view for our use case.
evMacGyver
Posts: 134
Joined: Tue Jun 15, 2021 5:44 pm
Location: Finland
Has thanked: 26 times
Been thanked: 6 times

Re: Tool to manage openinverter via CAN

Post by evMacGyver »

Did cache clean and try dumpall while Savvycan listening. Also pulled latest libopeninv. Dumps are long to paste here and don't know how to attach file.

I did compare CAN logs while dumpall command for both boards, Focci dumpall I see similar messages 0x616&0x596 as 0x603&0x583 with Zombie, only at the end there is difference.

This is from Focci just when things are happening, meaning quite end:

Code: Select all

..
5042146,00000596,false,Rx,0,8,00,30,38,36,31,32,34,22,
5043485,00000596,false,Rx,0,8,10,2C,22,69,73,70,61,72,
5044735,00000596,false,Rx,0,8,00,61,6D,22,3A,66,61,6C,
5045994,00000596,false,Rx,0,8,10,73,65,7D,0D,0A,7D,0D,
5047459,00000596,false,Rx,0,8,0D,0A,00,00,00,00,00,00,
5060258,00000596,false,Rx,0,8,43,00,21,01,40,01,00,00,
5062409,00000596,false,Rx,0,8,43,00,21,07,80,0C,00,00,
5064586,00000596,false,Rx,0,8,43,00,21,08,20,00,00,00,
5066561,00000596,false,Rx,0,8,43,00,21,0E,C0,F9,FF,FF,
5068561,00000596,false,Rx,0,8,43,00,21,0D,80,57,00,00,
...
This at end of Zombie log, first time b0 is other than 0x00 or 0x10:

Code: Select all

..
17685478,00000583,false,Rx,0,8,10,22,22,2C,22,76,61,6C,
17687224,00000583,false,Rx,0,8,00,75,65,22,3A,22,34,33,
17688348,00000583,false,Rx,0,8,10,31,39,32,34,35,30,22,
17690496,00000583,false,Rx,0,8,00,2C,22,69,73,70,61,72,
17691799,00000583,false,Rx,0,8,10,61,6D,22,3A,66,61,6C,
17693041,00000583,false,Rx,0,8,00,73,65,7D,0D,0A,7D,0D,
17694360,00000583,false,Rx,0,8,1D,0A,00,00,00,00,00,00,
Zombie 0x603 is constant, snip from the beginning:

Code: Select all

12697363,00000603,false,Rx,0,8,40,00,50,03,00,00,00,00,
12698483,00000603,false,Rx,0,8,40,01,50,00,00,00,00,00,
12699332,00000603,false,Rx,0,8,60,00,00,00,00,00,00,00,
12700107,00000603,false,Rx,0,8,70,00,00,00,00,00,00,00,
..
I was thinking timeout, because last zombie 0x583 b0 is first time other than 0x00 or 0x10, but Focci 108 frames captured and zombie 7528 frames.

Txqueuelen 1000 for Focci scan did not help with me, but this is not that big of a problem really as otherwise tool works flawlessly with Focci.
davefiddes
Posts: 224
Joined: Mon Jan 18, 2021 12:39 pm
Location: Edinburgh, Scotland, UK
Has thanked: 15 times
Been thanked: 44 times

Re: Tool to manage openinverter via CAN

Post by davefiddes »

Thanks for getting the captures. I think I need to see the files to figure out what's going on.

You can attach files to the forum by clicking on the "Full Editor" and dragging-and-dropping files to the message area or clicking on the "Attachments" tab underneath the message and there's an "Add files" button. Alternatively if you have a Github account then feel free to raise an issue or just drop them in an email to D.J@fiddes.net and I'll raise the issue.

Edit: I've fixed the scanning problem. It'll be in the next release which I'll make as soon as I figure out what is going on with the Zombieverter.
evMacGyver
Posts: 134
Joined: Tue Jun 15, 2021 5:44 pm
Location: Finland
Has thanked: 26 times
Been thanked: 6 times

Re: Tool to manage openinverter via CAN

Post by evMacGyver »

I once again try to remove my dumb fault from the equation and verified libopeninv is indeed changed to master branch, get deps is not fetching the latest.

Noticed that "cmd save" is sent successfully, also verified behavior powering off Zombie, when there will be error "No SDO response received":

Code: Select all

Time Stamp,ID,Extended,Dir,Bus,LEN,D1,D2,D3,D4,D5,D6,D7,D8
14940507,00000603,false,Rx,0,8,23,02,50,00,00,00,00,00,
15062992,00000583,false,Rx,0,8,60,02,50,00,00,00,00,00, <- succesfully
26021711,00000603,false,Rx,0,8,23,02,50,00,00,00,00,00, <- now same zombie off
27022570,00000603,false,Rx,0,8,80,00,00,00,00,00,04,05,
36024181,00000000,false,Rx,0,8,00,30,00,00,00,00,00,00, <- also Savvycan did not like 0x00 address
Attachments
oic zombie.csv
oic -n3 dumpall
(411.75 KiB) Downloaded 1 time
davefiddes
Posts: 224
Joined: Mon Jan 18, 2021 12:39 pm
Location: Edinburgh, Scotland, UK
Has thanked: 15 times
Been thanked: 44 times

Re: Tool to manage openinverter via CAN

Post by davefiddes »

Thanks. It looks like oic is just giving up after downloading the parameter database from the zombieverter. I'll need to write some tooling to extract the database and figure out what's going wrong. Bear with me.
davefiddes
Posts: 224
Joined: Mon Jan 18, 2021 12:39 pm
Location: Edinburgh, Scotland, UK
Has thanked: 15 times
Been thanked: 44 times

Re: Tool to manage openinverter via CAN

Post by davefiddes »

Looks like there's a bunch of bugs in the Zombieverter parameter database which in turn upsets openinverter_can_tool's database parsing in horrible ways.

To get you up and running you can download the attached parameter database which I have fixed up manually then specify it manually:

Code: Select all

oic -n 3 -d zombie-fixed.json dumpall
I've got a bunch of problems to fix which will take me some time. I'll submit fixes to the Zombieverter project as well.

Edit: Problem fix on the tip. I now flag badly formed enumeration and bitfield parameters and treat them as plain numerical values. This means you can set them by specifying the appropriate number but not symbolically. For example:

Code: Select all

$ oic listparams | grep "DB FORMAT"
Inverter [0=None, 1=Leaf_Gen1, 2=GS450H, 3=UserCAN, 4=OpenI, 5=Prius_Gen3, 6=Outlander, 7=GS300H 8=RearOutlander [DB FORMAT ERROR]] - min: 0 max: 8 default: 0
chargemodes [0=Off, 1=EXT_DIGI, 2=Volt_Ampera, 3=Leaf_PDM, 4=TeslaOI, 5=Out_lander 6=Elcon [DB FORMAT ERROR]] - min: 0 max: 6 default: 0
CAN3Speed [0=k33.3, 1=k500. 2=k100 [DB FORMAT ERROR]] - min: 0 max: 2 default: 0
$ oic write Inverter 6
I've raised a PR to fix the punctuation errors in the Zombieverter firmware.

I've got a bit of admin to do but there will be a new release of openinverter_can_tool shortly.
Attachments
zombie-fixed.json
(38.32 KiB) Downloaded 2 times
Post Reply