Marcin648 / e90-dashboard-ets2

GNU General Public License v3.0
17 stars 10 forks source link

Help with BMW F/G series (F15 & G30) instrument cluster #6

Open VintageCollector opened 1 year ago

VintageCollector commented 1 year ago

Hello Marcin,

I couldn't find out a way to reach you, so I'm reaching out to you here. Hope you are doing good.

I'm currently working on an F15 6wa bmw cluster inspired from your dashboard project. I've been using your awesome code to identify how to get the cluster up and running. Some CAN IDs from your e90 code work right away like Hi/Lo beams and indicators. No abs or parking brake for now as I haven't looked into it yet. Unlike the e90, apart from an ignition code I had to also send a wake up code to keep it active else it goes to sleep like in 5-7 seconds. Speedo is the 0x0A5 from loopbunny (not the other one used in e90). Right now it's jumping around since the code needs to be refined. But good thing it works.

RPM took a while to figure out, but I managed to find info about it on this reddit post below:

https://www.reddit.com/r/CarHacking/comments/tufn5t/bmw_can_message_crc_checksum/

Since, I'm not much of a hardcore/expert coder like you, I need an opinion or advise from you. In the post they have discussed about one of the bytes being the CRC checksum. Do you think it is possible for someone to create a code to get this checksum byte value? Or it is impossible? If it is the latter case then I'm thinking of selling it off. Currently, the rpm needle just jumps for a second when I send a fixed stream of bytes from the above reddit post. What do you think?

The modified code is on my PC back home, I'll share it with you later in the evening when I get home if you wish to have a look at it. Thank you!

Marcin648 commented 1 year ago

Hello! That discover of CRC looks very promising! I will try to look deeper in e90 can frame and maybe found similar pattern. Calculation of CRC8 is not very complicated. I will try to write some code for that. Some information about crc and example codes can You find at http://sunshine2k.de/articles/coding/crc/understanding_crc.html Also some code is available in project linked on reddit https://github.com/Tom-evnut/BMWI3BMS/blob/master/CRC8.cpp

Most difficult for me in this project is that I don't have any can bus dump from real car. I use only information that I found in internet.

Thanks for this information!

VintageCollector commented 1 year ago

Hi!

Thank you for the reply. I'll try to also reach out to a few people and see if anyone has an F series and can help obtain a can bus data dump.

I got the cluster to get properly powered now. I had to move the ignition code to the loop function in the main.cpp and remove the ignition function you had originally written. For some reason it would cause the cluster not to stay awake properly and flciker. I'm attaching a link to the file for you to take a look. I have an F20 and F15 6wa cluster. Since I have the F15 I don't use the F20 anymore. If you would like to have the cluster I can sent it to you for free as you can test the code too. You are based in Poland right. Also, I am in a discord group and one of the members have coded a can bus generator, using that you can run a can code sweep test to see which codes trigger dash lights. and among other things. Feel free to jump in if you would like, I'm posting an invite link below.

https://discord.gg/u8sjNDxC8y

https://1drv.ms/u/s!Ag5Te4aKhAY27TAzFeTIxxMXT003?e=8Y6tRc

VintageCollector commented 1 year ago

Hello Marcin,

First of all wising you a happy new year! I have been working on a BMW G30 cluster. I have managed to figure out a few things and modded your code to get it working. But I am facing issues with rpm just like on the F series. Can you please help me out? I managed to find this crc8-j1850 code. Maybe the code can be modded?

Here is a link to the code for G30: https://drive.google.com/file/d/1EfFr-ozJE43fgwNpGdqLCvG-XSYId3AD/view?usp=sharing

And here is a link to the cluster running: https://www.youtube.com/shorts/bdm8qhoCSjM

This is the checksum calculator I found: https://github.com/II43/Crc8_J1850

Do you think using the above calculator code, we can adapt it for your cluster code for rpm checksum.

Thank you

Marcin648 commented 1 year ago

Hello! I wish you a happy new year too!😊 Sorry for the delay. I am busy for now with completely other project. I joined discord, and I am surprised that such a big community is around this topic! Nice! I have idea to create one big project that can support all clusters at one. I think it's possible with support with community support! End user only set some variables in config fine and upload it to Arduino. Finally, adding new cluster should be also much easier. It would be a bigger project, it will take some time for sure. I can cover programming stuff for this, but for cluster support I need community help. It would definitely be an free open source project. Anyway, together we can do something cool.

This is my proof of concept for checksum https://gist.github.com/Marcin648/3a149b5a31bcd1ce7b9f243abc40d728 It should work for 8bit can id.

VintageCollector commented 1 year ago

Thank you! Ohh I see, I wasn't aware you had joined. My discord user name(VintageCollector#5031) is same as on github. You can connect and ping me when you would like to contact. I wish github had a message section xD.

This is great! I have seen on xsimulator someone had made a UI to just load can ID and run. They had made one for the Mazda RX8 I think. But this was long ago and I think it's a dead project now. Yes, the community is quite big and there are some very good coders. You may have noticed in the discord group one of the owners Vampyr Yannik. He did comment on your e90 video. He is the one that posts a lot of arduino sketches for many clusters. I'll tell them about your project and it's nature. Hopefully this can lead to some interesting outcomes. Yannik has like 50+ car clusters so he has a lot of data from various cars that might be helpful. I can also help in whatever way I can.

You are right, the difficulty is with getting the can bus data. And with manufacturers adding multiple types of CAN buses for powertrain, dashlights, comfort can etc. it takes a bit of time. My last month was mainly busy with identifying the can ID of a Panamera 970 cluster. Using only the CAN Bus generator I mentioned above I was able to map almost everything on it. But with some clusters like Jaguars for example it can be a real pain to even wake up the cluster.

Thank you very much for the quick code! Appreciate your help a lot:) I'll definitely give it a try when I get home from work today. I'll also need to see the pattern of the rpm IDs and it's relation to the rpm value. I'll give you an update soon after some testing.

VintageCollector commented 1 year ago

Hi Marcin,

A quick update. On the G30 apparently the checksum isn't required. For the F15 though checksum is required. I'm happy to report that the checksum calculator works great :). On a F10 & 20 though the rpm keeps resetting. I believe this is due to gear selection mode being absent. Looks like this needs to be implemented to solve it. I mean the checksum and ID.

Thank you so much once again!!

VintageCollector commented 1 year ago

I'll be looking at the checksum for the gear selection for F10 & F20 and see if I can do it.

I'll need to adapt this to the code:

https://www.projectgus.com/2022/07/bmw-f-series-gear-selector-part-three-success/

I'll keep you posted how it goes. Here is a link below for the F15 rpm working great with after the checksum code you gave. I've implemented it to the variant from your e90 dash project.

https://github.com/VintageCollector/cluster-dashboard-ets2-ats/tree/F15-6WA-variant

https://youtube.com/shorts/hUrF_S29sS0?feature=share

You have no idea how many folks had told me it's impossible, said it's better to sell off and forget this cluster...I had some good hope when I came across the Reddit post. 😃

BTW yannik (Vampyr Yannik#0001) said he is interested in the project idea you mentioned above, it he said he cannot find you on discord to contact you. I've added his username so that you can reach out to him directly if you don't want to post your username here.

VintageCollector commented 1 year ago

Hi Marcin,

Hope you are doing great! I've been working on a Porsche Panamera 970 cluster and it is going good so far. But I've hit a roadblock with something, I hope you can help me out sorting it out, so I've been trying to add oil temp, oil pressure, displayed gear & engine gear number in the "globals.h" file like you have done for igntion, rpm,..etc (s_ignition, s_rpm,...etc) using the variables in the telemetry python scripts. But when I tried making modifications to telemetry python it causes the who thing to stop working lol! If you don't mind could you please help me to pull the telemetry data and add three variables (s_oiltemp, s_oilpressure, s_geardisplay & s_gear)? Is displaygear the gear number & engine gear the gear selection like Park, Drive etc?

Thanks

Marcin648 commented 1 year ago

Hi! I'm fine! I am working on a universal project, and it's also going good, slowly but good. :) For now, it's mostly architecture stuff like hardware abstraction layer, command parser than, CAN cluster stuff but still progress :) I still have no idea what to name this project. I wish it was universal enough to cover avionic, maritime, train and other stuff as well.

About Your problems. Take oilpressure for example. First, add variable s_oilpressure to states.cpp, probably as uint16_t. Next, this variable to be global need to be defined as extern. Do this in globals.h by extern uint16_t s_oilpressure; For now this variable is available globally and can be use in can functions, but it's not updated.

Exchange data packet are defined in serial.cpp in struct SerialPacket. In this place, it's important to keep order of variables the same as in Python script. I think that a good place for oil pressure is under uint16_t fuel; so add uint16_t oilpressure; to it. Next in serialReceive update global variable by s_oilpressure = serialPacket->oilpressure;

That all in Arduino code, next go to Python script. In dashboard.py add self.oilpressure to __init__ of Dashboard object. Now in update function pack data to binary in the same order as in arduino code. So after fuel. packet += int(self.oilpressure).to_bytes(2, 'little') Use .to_bytes(2, 'little') for 16bit variables and .to_bytes(1, 'little') for 8bit variables.

Now it's should work. But for update data from game also self.oilpressure variable should be updated in ets2.py, def run(self) method, depends on game. Probably like this self.dashboard.oilpressure = self.telemetry.truck.oil_pressure for ets2.

VintageCollector commented 1 year ago

Hi Marcin,

Thank you for the detailed instructions. That sounds great! I'm more than happy to share any can bus ID info for the clusters I have if it might help you. For the Panamera 970 especially I've an almost full info of the CAN IDs for this cluster.

Avionics is a very interesting one too. You could like make your own gauges which us easier route I guess. I have an avionics simulator project I paused about a year ago, due to this panamera project I'm working on. Was trying to get some old US Navy/AF flight gauges and then using syncro resolvers/transmitters to control them in tandem with Arduino servos. OLD school method xD.

I managed to make changes as you have advised. With the original code without these new variables it works great on ets2 and beamng. But after I added the new variables for oilpressure, oiltemperature, enginegear & displaygear, all the gauges on ets2 are suddendly erratic. On beamng it doesn't respond either anymore. Could you please take a look at the four files I've attached in teh below google drive link?

Also, what is the output of engine_gear & display_gear from "EtsTelemetryClient.py"?

https://drive.google.com/drive/folders/1zeBeji0dH-sZPfT_lL9mdGdrQe2CBl12?usp=sharing