openDsh / dash

Join us on Slack! https://join.slack.com/t/opendsh/shared_invite/zt-la398uly-a6eMH5ttEQhbtE6asVKx4Q
GNU General Public License v3.0
238 stars 69 forks source link

How to add car specific CANBUS settings? #94

Open drlohwk opened 2 years ago

drlohwk commented 2 years ago

Hi, I'm a noob here. Starting to learn some Qt and notejs programming.. I wanted to add some car settings using a GUI with socketcan. How to go about doing this and blend well with openDash system and theme? Will be nice to have a customizable page for such features that has slider, toggles and checks. Need some guidance. Thank you!

icecube45 commented 2 years ago

Take a look at https://github.com/icecube45/Dash_InfinitiG37/tree/develop this is a plugin I made for my Infiniti G37 - it listens for HVAC updates on the canbus and updates dash with them, as well as changing dash to dark/light mode depending on if the headlights are on. It also pauses any music playing through android auto when the engine shuts off. Tire pressure is also put onto a Debug tab within the vehicle page.

While the CAN messages won't be the same across cars, this might give you an idea of what's possible / how to hook into things. Happy to dive into specifics if you have questions.

drlohwk commented 2 years ago

thanks icecube45. So, can I say that I can add as many settings using the plugin you made by adding more widgets? do you have an image or video showing the plugin? I'm really new to this and a steep learning curve for a mechanical background person. I have sniffed some CAN messages already and now I'm trying to inject CAN messages into the system and see the reaction. some module would like an handshake before it offer the features. so to do this, I need a program to study the module reaction.

icecube45 commented 2 years ago

An older image on a really weird aspect ratio I was testing, but yea: image (6)

You could add widgets within tabs your plugin makes that could certainly be settings toggles.

https://github.com/openDsh/dash/blob/develop/plugins/vehicle/README.md this readme has some more info on using the canbus from within plugins too, it's totally possible to write to the bus from within dash.

kbader94 commented 2 years ago

What I'd recommend if your new to QT is to use QT Creator to layout the interface you want then convert it to c++ via UIC. When you create a vehicle plugin in opendsh it has a default blank tab called climate under the vehicle page you can replace it with your own. To reverse engineer the CAN frames I'd recommend a program called savvyCAN, you can log it with can-utils and load the log in savvyCAN OR you can compile savvyCAN on the pi for real-time reverse Engineering. Hopefully this helps.

drlohwk commented 2 years ago

Thanks icecube45 and kbader94. I have extracted all the needed canbus messages to start the UI creation in QT creator. I will start with QT creator to generate toggle buttons and sliders. then later I need to know how to port the cansocket into QT to manage the data frames. start with youtube!

drlohwk commented 2 years ago

wow the Qt is great tool but the version I have restricted me to add slider, buttons,.. in qmake setting. I really find it hard to understand the whole system. I also tried the Qt designer and again it doesn't allow me to build even I can create nice UI. I'm swarm with the info and I'm lost. I don't know where to start now other than trying different kind of "How to" in youtube video.

xdsquared commented 2 years ago

@kbader94 could you elaborate on the UIC program. Looking at Qt's site it says that it would compile a header file, but could you get it to a .cpp file as well? I am also trying to write a plugin for dash and am having difficulties getting a GUI to show up. I have QML and qt UI experience but I have never done it using traditional .cpp files like dash uses. Any pointers or help would be much appreciated.

robert5974 commented 2 years ago

Check this page out. Maybe some of 5hat can be helpful.

https://doc.qt.io/qt-5/uic.html

Robert Crowley

On Tue, Nov 16, 2021, 3:47 PM xdsquared @.***> wrote:

@kbader94 https://github.com/kbader94 could you elaborate on the UIC program. Looking at Qt's site it says that it would compile a header file, but could you get it to a .cpp file as well? I am also trying to write a plugin for dash and am having difficulties getting a GUI to show up. I have QML and qt UI experience but I have never done it using traditional .cpp files like dash uses. Any pointers or help would be much appreciated.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/openDsh/dash/issues/94#issuecomment-970665364, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABLUDVCER35SGFOMF6B7DUDUMK7OBANCNFSM5CFVJRPA .

xdsquared commented 2 years ago

Check this page out. Maybe some of 5hat can be helpful. https://doc.qt.io/qt-5/uic.html Robert Crowley

@robert5974 Thank you sir, that is what I was looking at originally. It does seem to specify that it will only create a header file unfortunately. Could anyone advise on how to create a button and have it display? I basically want to make a few buttons that push out specific CAN codes, but I cannot get anything to actually appear.

robert5974 commented 2 years ago

I thought it only said to remember to put in the header file the bit of code to use...

Robert Crowley

On Tue, Nov 16, 2021, 4:42 PM xdsquared @.***> wrote:

Check this page out. Maybe some of 5hat can be helpful. https://doc.qt.io/qt-5/uic.html Robert Crowley

@robert5974 https://github.com/robert5974 Thank you sir, that is what I was looking at originally. It does seem to specify that it will only create a header file unfortunately. Could anyone advise on how to create a button and have it display? I basically want to make a few buttons that push out specific CAN codes, but I cannot get anything to actually appear.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/openDsh/dash/issues/94#issuecomment-970704482, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABLUDVC7VWZ343FL3EN34G3UMLF6BANCNFSM5CFVJRPA .

robert5974 commented 2 years ago

Here's more of what you were looking for I think.

https://doc.qt.io/archives/2.3/designer/chap2_3.html

Robert Crowley

On Tue, Nov 16, 2021, 5:07 PM robert crowley @.***> wrote:

I thought it only said to remember to put in the header file the bit of code to use...

Robert Crowley

On Tue, Nov 16, 2021, 4:42 PM xdsquared @.***> wrote:

Check this page out. Maybe some of 5hat can be helpful. https://doc.qt.io/qt-5/uic.html Robert Crowley

@robert5974 https://github.com/robert5974 Thank you sir, that is what I was looking at originally. It does seem to specify that it will only create a header file unfortunately. Could anyone advise on how to create a button and have it display? I basically want to make a few buttons that push out specific CAN codes, but I cannot get anything to actually appear.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/openDsh/dash/issues/94#issuecomment-970704482, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABLUDVC7VWZ343FL3EN34G3UMLF6BANCNFSM5CFVJRPA .

kbader94 commented 2 years ago

You'd have to alter it a bit but any code from a header file is valid inside the cpp file. Basically you can just run UIC on a .ui file from the command line and use the headers output code to initialize your widgets. All you need to do is copy the variables and the code from inside the initialization function generated in the UIC output to wherever you need it, preferably into an object that inherits from a type of QObject to simplify things.

Maybe it's just me but I sometimes found the layout for QT awkward to do strictly from code when I was first learning, I found it useful to layout the widgets using QT Creator and then get the code using UIC from command line. At the very least it'll show you how the code works to make the desired layout.

xdsquared commented 2 years ago

wow, thankyou both @kbader94 @robert5974. I will look over the link to figure out how to get it all working, but this does look to be what I am after :) Here's hoping I can get it going.

robert5974 commented 2 years ago

No problem. I tried using UIC last night and was able to make a header file. simple enough.

Robert Crowley

On Thu, Nov 18, 2021, 12:46 PM xdsquared @.***> wrote:

wow, thankyou both @kbader94 https://github.com/kbader94 @robert5974 https://github.com/robert5974. I will look over the link to figure out how to get it all working, but this does look to be what I am after :) Here's hoping I can get it going.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/openDsh/dash/issues/94#issuecomment-973109446, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABLUDVBO23MVYCVKWPTTKSLUMU3WHANCNFSM5CFVJRPA .

xdsquared commented 2 years ago

I was able to get the header file built no problem :) Dash didn't like it though, so I'm going to look into that some more. I have another question. How would I go about sending dash fake CAN data to get the speedometer and other gauges on the front page to change? I was able to set up a socketCAN channel with a pihat and can see that dash is putting out messages, but haven't had luck sending data in. I saw on the dash/src/obd/command.cpp the different ID's but I am not certain what other information is needed to get speed or rpm to change. So far I tried sending a CAN message with the 020 ID for speed and then just randomly changed the other values to see if something would happen

icecube45 commented 2 years ago

The gauges built into dash are sending out OBDII commands and waiting for responses - I think this website has a decent write up on the raw OBD II format. Dash is sending out OBD commands on the 0x7df frame ID and looking for responses on 0x7df+0x9. Wikipedia gives a good table specifying the format each OBD PID is in, if you wanted to mimic them.. To send data to the canbus, you can use cansend from the can-utils package

xdsquared commented 2 years ago

I was able to get CAN messages going. Took me a minute but I was able to get the dash gauges to all fluctuate! Now I am trying to link a button press to send out a specific frame or pick a message from an array of different frames. I have been looking at dash's code for a while now and I can't quite piece together how to send a frame on the canbus from inside dash. Could anyone recommend how best to create function to write a frame or where best in the code to go look again? I have another question on getting a button have an image over it, but I am not certain if I should ask that here. Is there another thread I could go or start for GUI specific questions?

icecube45 commented 2 years ago

Am I correct in assuming you're writing a plugin for dash? If so you can use the writeFrame method as documented here. In regards to your button question, I'd encourage you to join us on slack for questions like that, as they don't necessarily relate to dash, but rather the usage of QT.

xdsquared commented 2 years ago

Yes I am. Ok, I will go there. thank you

Bradxyz commented 1 year ago

hello I know this page is a bit old but I'm trying to use the Infiniti G37 plugin and am having trouble getting it to work I may be doing something wrong, any help would be great

xdsquared commented 1 year ago

@Bradxyz It's been a minute since I used OpenDsh, but I can try. I will need more details on what the issue is though. Not working how? What specifically? The plugin in won't load or your vehicle isn't giving any information?

Bradxyz commented 1 year ago

it was nothing I just forgot to reinstall the software after downloading the files

Bradxyz commented 1 year ago

and adding them to the directory