Page 5 of 7

Re: Tool to manage openinverter via CAN

Posted: Sat Feb 17, 2024 3:37 pm
by celeron55
I declare it done now, for my part. I think it's pretty good:

https://github.com/davefiddes/openinver ... ool/pull/1

Re: Tool to manage openinverter via CAN

Posted: Sat Feb 17, 2024 4:41 pm
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

Re: Tool to manage openinverter via CAN

Posted: Sun Feb 18, 2024 9:26 am
by celeron55
Bashersday is any day someone thinks ESP32 is a good alternative to documentation!

Re: Tool to manage openinverter via CAN

Posted: Sun Feb 18, 2024 6:44 pm
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.

Re: Tool to manage openinverter via CAN

Posted: Wed Feb 28, 2024 12:16 pm
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.

Re: Tool to manage openinverter via CAN

Posted: Tue Apr 23, 2024 2:29 pm
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

Re: Tool to manage openinverter via CAN

Posted: Tue Apr 23, 2024 3:56 pm
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.

Re: Tool to manage openinverter via CAN

Posted: Tue Apr 23, 2024 4:44 pm
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.

Re: Tool to manage openinverter via CAN

Posted: Tue Apr 23, 2024 5:17 pm
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.

Re: Tool to manage openinverter via CAN

Posted: Sun Jun 02, 2024 7:17 am
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?

Re: Tool to manage openinverter via CAN

Posted: Sun Jun 02, 2024 7:29 am
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

Re: Tool to manage openinverter via CAN

Posted: Sun Jun 02, 2024 10:40 am
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

Re: Tool to manage openinverter via CAN

Posted: Tue Jun 04, 2024 8:04 pm
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.

Re: Tool to manage openinverter via CAN

Posted: Wed Jun 05, 2024 10:12 am
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.

Re: Tool to manage openinverter via CAN

Posted: Wed Jun 05, 2024 10:18 am
by uhi22
What is the range of node ids when scanning? Foccci is at 22, maybe not in the scan range?

Re: Tool to manage openinverter via CAN

Posted: Wed Jun 05, 2024 10:26 am
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... :)

Re: Tool to manage openinverter via CAN

Posted: Wed Jun 05, 2024 11:00 am
by johu
We can knock the default id for Clara down to 5 and let the BMS start at 6 or 10

Re: Tool to manage openinverter via CAN

Posted: Wed Jun 05, 2024 11:08 am
by uhi22
Or create a pull request for the canopen python library.

Re: Tool to manage openinverter via CAN

Posted: Wed Jun 05, 2024 12:47 pm
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.

Re: Tool to manage openinverter via CAN

Posted: Wed Jun 05, 2024 2:25 pm
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.

Re: Tool to manage openinverter via CAN

Posted: Thu Jun 20, 2024 9:19 am
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.

Re: Tool to manage openinverter via CAN

Posted: Thu Jun 20, 2024 10:20 am
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.

Re: Tool to manage openinverter via CAN

Posted: Thu Jun 20, 2024 11:37 am
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

Re: Tool to manage openinverter via CAN

Posted: Thu Jun 20, 2024 12:07 pm
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.

Re: Tool to manage openinverter via CAN

Posted: Fri Jun 21, 2024 1:43 pm
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.