smartgauges / canbox

Firmware for canbus boxes
66 stars 28 forks source link

Building firmware for XC90 #1

Open liamstears opened 1 year ago

liamstears commented 1 year ago

I am new to this so I apologize in advance

I would like to build the firmware for a volvo_od2 for use in an XC90

I assume to function I only need to update addresses of my modules at the end of canbox/cars/xc90_2007my.c?

What confuses me the most is how do I find all the addresses of my modules to be able to do this?

I really hope you can...

Edit: Also link to Virtual machine (https://drive.google.com/file/d/1XCHW03gKX6WUB6tFS7kKD0kZkctj8inW/view?usp=sharing) is down I cannot download...

smartgauges commented 1 year ago

hello, in general terms, yes you need to modify the addresses in the CAN handlers, the address of the modules changed depending on the year of manufacture. one man is currently doing support for all model years for the xc90, i think that after a while i will publish his work

liamstears commented 1 year ago

hello, in general terms, yes you need to modify the addresses in the CAN handlers, the address of the modules changed depending on the year of manufacture. one man is currently doing support for all model years for the xc90, i think that after a while i will publish his work

This sounds amazing, do we know how his work is progressing? Do we have any link to his work? I would very much like to incorporate this into my XC90...

liamstears commented 1 year ago

hello, in general terms, yes you need to modify the addresses in the CAN handlers, the address of the modules changed depending on the year of manufacture. one man is currently doing support for all model years for the xc90, i think that after a while i will publish his work

I have looked into everything, my year is same year as your code so I think I can flash directly and it will work. I have ST-Link V2 and spare OD-Volvo-02 canbus box. Is there an easy set of instructions of how I can flash? Preferably on Windows? Thanks

smartgauges commented 1 year ago

Hello, this is a new link to an image with programs for updating the firmware https://drive.google.com/file/d/1N1e5lfgBMYpkn2jB6EhOwpE1DNGCGoEL/view

liamstears commented 1 year ago

Hello, this is a new link to an image with programs for updating the firmware https://drive.google.com/file/d/1N1e5lfgBMYpkn2jB6EhOwpE1DNGCGoEL/view

After becoming root user (sudo su) and installing openocd (apt-get install openocd) I got it to run but I'm getting an error (unable to connect to the target)

Any ideas?

Screenshot: https://ibb.co/rc1KN9m

EDIT: It looks like that error is because I have to catch it immediately when connected or it doesn't connect. So I connect 3v pin and immediately run make flash and it runs but this time with a different error:

UNEXPECTED idcode: 0x2ba01477 expected 1 of 1: 0x1ba01477

Screenshot: https://ibb.co/ySjwfps

liamstears commented 1 year ago

Ok I got it to flash

What I did was I searched for stm32f1x.cfg and found this file 3 times, I changed "0x1ba01477" to "0x2ba01477" in all 3 of these files

The flash looks to have completed successfully

However I still have the error that I cannot read from serial output properly, my serial output even at 38400 is just scrambled

Screenshot: https://ibb.co/hRNYLTJ

I hope you can help...

liamstears commented 1 year ago

Wait I got it!

I had to copy and paste "OOOOOOOOOOOOO" to get the code in quick enough, I have successfully changed it to XC90

I found though that the configuration page flashes on and off and only stays on screen for a set amount of time so configuration changes have to be made quickly.

Next I will test in the car, fingers crossed

liamstears commented 1 year ago

Initial test in car is it is working!

Unfortunately though it's not working perfectly

Door open messages - Work perfect Parking sensors - Working but I only have rear sensors but display shows them as front and rear sensors, maybe a setting on head unit I am unaware of? Reverse trajectory lines - Although these work they move in the wrong direction for my car (right hand drive UK car) I wonder if this is because of a difference between left and right hand drive cars? Is there a way to switch these to the right direction? Can/Steering wheel buttons - Only skip track buttons work, they work and I can map them, no other canbus buttons work though :-( I have lost volume buttons, I hoped more buttons would work

I guess all of this can be fixed in the configuration before flashing the compiled firmware to my canbus box but I am new to this so it may not be easy for me to work out lol

EDIT: canbox.c

Would changing:

uint8_t fbuf[] = { 0x00, 0x00, 0x00, 0x00 };
fbuf[0] = fmax[0] + 1 - scale(radar.fr, 0, 99, 0, fmax[0]);
fbuf[1] = fmax[1] + 1 - scale(radar.frm, 0, 99, 0, fmax[1]);
fbuf[2] = fmax[2] + 1 - scale(radar.flm, 0, 99, 0, fmax[2]);
fbuf[3] = fmax[3] + 1 - scale(radar.fl, 0, 99, 0, fmax[3]);
snd_canbox_msg(0x23, fbuf, sizeof(fbuf));

uint8_t rbuf[] = { 0x00, 0x00, 0x00, 0x00 };
rbuf[0] = rmax[0] + 1 - scale(radar.rl, 0, 99, 0, rmax[0]);
rbuf[1] = rmax[1] + 1 - scale(radar.rlm, 0, 99, 0, rmax[1]);
rbuf[2] = rmax[2] + 1 - scale(radar.rrm, 0, 99, 0, rmax[2]);
rbuf[3] = rmax[3] + 1 - scale(radar.rr, 0, 99, 0, rmax[3]);
snd_canbox_msg(0x22, rbuf, `sizeof(rbuf));

to:

uint8_t fbuf[] = { 0x00, 0x00, 0x00, 0x00 };
fbuf[0] = fmax[0] + 1 - scale(radar.rl, 0, 99, 0, fmax[0]);
fbuf[1] = fmax[1] + 1 - scale(radar.rlm, 0, 99, 0, fmax[1]);
fbuf[2] = fmax[2] + 1 - scale(radar.rrm, 0, 99, 0, fmax[2]);
fbuf[3] = fmax[3] + 1 - scale(radar.rr, 0, 99, 0, fmax[3]);
snd_canbox_msg(0x23, fbuf, sizeof(fbuf));

uint8_t rbuf[] = { 0x00, 0x00, 0x00, 0x00 };
rbuf[0] = rmax[0] + 1 - scale(radar.fr, 0, 99, 0, rmax[0]);
rbuf[1] = rmax[1] + 1 - scale(radar.frm, 0, 99, 0, rmax[1]);
rbuf[2] = rmax[2] + 1 - scale(radar.flm, 0, 99, 0, rmax[2]);
rbuf[3] = rmax[3] + 1 - scale(radar.fl, 0, 99, 0, rmax[3]);
snd_canbox_msg(0x22, rbuf, sizeof(rbuf));

Fix the reverse trajectory turning the wrong way with the steering?

liamstears commented 1 year ago

Hello, this is a new link to an image with programs for updating the firmware https://drive.google.com/file/d/1N1e5lfgBMYpkn2jB6EhOwpE1DNGCGoEL/view

Ok so it turns out the trajectory problem can be fixed simply in the software so that's not an issue :-D

The biggest problem is canbus buttons. Volume buttons no longer work. Also would be nice if I can get phone buttons working.

Can you please help try to fix this...

liamstears commented 1 year ago

It is a shame for the lack of support on this because this would be a great solution for XC90 but unfortunately all functions do not work.

For anyone else looking at this for XC90 this is what I have found:

Door open messages - Work perfect Parking sensors - Working but I only have rear sensors and the display shows them as front and rear sensors Reverse trajectory lines - These work but initially in the wrong direction but this can be corrected in settings on the head unit Can/Steering wheel buttons - Only skip track buttons work and I can map them, no other canbus buttons work though Brightness/Dimming - This does not work

To fix steering wheel buttons and have brightness dim I will have to use another canbus box unfortunately

smartgauges commented 1 year ago

Hello, unfortunately I cannot help you with xc90 support, because I am not the owner of xc90. My friend has an xc90 and all the functionality of the adapter works correctly on his xc90. The fact is that different model years xc90 have different addresses in CAN blocks, so you need to determine the necessary addresses for your car yourself

liamstears commented 1 year ago

Hello, unfortunately I cannot help you with xc90 support, because I am not the owner of xc90. My friend has an xc90 and all the functionality of the adapter works correctly on his xc90. The fact is that different model years xc90 have different addresses in CAN blocks, so you need to determine the necessary addresses for your car yourself

I understand this but what doesn't make sense is buttons on steering wheel. Skip track works but volume doesn't. These are both on the same module and same coding should be used to access them so if skip tracks is working volume should work too unless there is some error in coding for this firmware.... I don't see another explanation

Brightness/dimming, I now have this working, for some reason on bench testing the changes I made to adapt brightness trigger setting did not save and I did not realise this, when connecting to car and changing settings I set it to I think 94 and now it works perfectly 😁

So again because all other functions work buttons must be your firmware issue. Maybe it is simply a typo in your code? I don't understand your code enough to work it out. Also because there is phone buttons in theory you should be able to make these work too as these are all on same module so same can address.

I have seen somewhere a list of available buttons can messages, I will see if I can find them for you to look at, maybe with this information you may see something that I am unable to understand which may help get a fix.....

smartgauges commented 1 year ago

The handling of the volume buttons on the xc90 is now commented out, so they don't work. just change #if 0 to #if 1 in line https://github.com/smartgauges/canbox/blob/main/cars/xc90_2007my.c#L128 and recompile a project My friend uses android with stock audio via aux so he doesn't have to control android volume with buttons

liamstears commented 1 year ago

The handling of the volume buttons on the xc90 is now commented out, so they don't work. just change #if 0 to #if 1 in line https://github.com/smartgauges/canbox/blob/main/cars/xc90_2007my.c#L128 and recompile a project My friend uses android with stock audio via aux so he doesn't have to control android volume with buttons

Thank you, yes I thought it must be something simple :-D

I have found the information I was looking for, with it do you think you could add extra buttons for XC90?

This is the page: https://github.com/olegel/VolvoCan/blob/master/doc/VolvoModules/swm.txt

As you can see all buttons send basically the same message just very small difference, I don't know how your coding works but I really hope with this you can add them?

There is also more info in other pages like: https://github.com/olegel/VolvoCan/blob/master/doc/VolvoModules/ccm.txt Here there is button to turn on/off park assist, this would be useful button but not as important

Really I hope you can look at the steering controls and add more....

liamstears commented 1 year ago

I have read your code many times, I understand if I wanted to add a new button I would have to add to canbox.c, canbox.h, car.c, main.c and xc90_2007my.c

What I don't understand is what exactly I would need to add to canbox.c using example a new button called "NEWBUTTON"

void canbox_NEWBUTTON(void)
{
    if ((e_cb_raise_vw_pq == conf_get_canbox()) || (e_cb_raise_vw_mqb == conf_get_canbox())) {

        uint8_t buf[] = { 0x09, 0x01 };  (Here, what do I put?)
        snd_canbox_msg(0x20, buf, sizeof(buf));

        buf[1] = 0x00;
        snd_canbox_msg(0x20, buf, sizeof(buf));
    }
}

Also in xc90_2007my.c

key_state.key_NEWBUTTON = STATE_UNDEF;

uint8_t key_prev = msg[7] & 0x01; (Here, what do I put?)

if ((key_state.key_NEWBUTTON == 1) && (key_NEWBUTTON == 0) && key_state.key_cb && key_state.key_cb->NEWBUTTON) key_state.key_cb->NEWBUTTON();

key_state.key_NEWBUTTON = key_NEWBUTTON;

The main buttons I want to add are enter and exit buttons from the link I posted previously, can you please help and point me in the right direction?

jesusvallejo commented 6 months ago

Soon i will pull request with changes adding the accept and reject call buttons, as well as the RTI (navigation) buttons. Just lacking some info about the RTI buttons and which message could i send to the radio so i can navigate.

liamstears commented 6 months ago

Soon i will pull request with changes adding the accept and reject call buttons, as well as the RTI (navigation) buttons. Just lacking some info about the RTI buttons and which message could i send to the radio so i can navigate.

This is excellent news, if there is anything I can do to help please let me know...

jesusvallejo commented 6 months ago

You can find under my fork the added buttons(allready on the compiled bin), also i added temp function, but for the moment i dont have access to the car so i cannot test it. i have checked on my bench and everyhting seems correct. The only thing that wont work is the temp as i set it to an older xc90 ccm canbus address. When i have access to my xc90 i will add the address for 2007-onwards canbus address. The buttons should reject and accept calls, and the enter and back from rti should be mute and mic activation. As stated, havent tried yet, but it should work.

liamstears commented 6 months ago

You can find under my fork the added buttons(allready on the compiled bin), also i added temp function, but for the moment i dont have access to the car so i cannot test it. i have checked on my bench and everyhting seems correct. The only thing that wont work is the temp as i set it to an older xc90 ccm canbus address. When i have access to my xc90 i will add the address for 2007-onwards canbus address. The buttons should reject and accept calls, and the enter and back from rti should be mute and mic activation. As stated, havent tried yet, but it should work.

Firstly just wanted to say thank you so much for looking into and helping with this!

I have now done some testing with what you have done and I'm here to share my findings

New enter and back buttons work perfectly, exactly as intended :-D

Answer and reject buttons still unfortunately don't seem to be working

The changes you made in main.c seem to stop the auto day/night switching of the backlight brightness. The added line: uint8_t near_lights = car_get_near_lights(); and changed line from: if (ill > conf_get_illum()) To: if (ill > conf_get_illum() || near_lights) Changing these back to as they were before brings function back as before.

I don't however understand the code so not sure what these changes are suppose to do?

As for buttons extremely pleased and we are on the right track, I can see you have also added the direction buttons, I don't have an app that can remap canbus buttons at the moment but I guess these could be mapped to something?

Look forward to hearing from you

jesusvallejo commented 6 months ago

Glad it sort of worked, hehe. Some of the things will need tweaking for sure that's why I haven't pull requested yet. Answer and reject buttons have a different payload from the rest of the buttons, this is because in the radio protocol both accept and reject are stated as SWC_CMD instead of SWC_KEY, so the payload has to arrive with 0x2f instead of 0x20. I'll have to dig deeper.

I changed that in the past so I can force the night mode if the near lights are on. This does not have to reach final version.

The only problem we have is that we are bound to what is developed by the Chinese manufacturers, if they don't add more functions to their canbus app, we are F*****!!!. I wanted to navigate the screen with the direction buttons, but as the golf does not have buttons for that. I'm afraid well never have that unless we can find another car and the Chinese serial protocol (highly unlikely ) and implement another canbox protocol. I have searched on Russian forums and on baidu for more information but could not find any new info. And mapping to any app is a general no, maybe we could map navigation, if the canbus app calls the standard navigation app that is set on settings of the headunit it should work, other apps or remaping, not possible.

Id like to get answer and reject working, and maybe ill test what other buttons stated in the MctCoreServices do in the head unit. After that id like to get ac info on the screen, just for the sake of it (not that it is needed). Can't promise anything, but ill try.

liamstears commented 6 months ago

Glad it sort of worked, hehe. Some of the things will need tweaking for sure that's why I haven't pull requested yet. Answer and reject buttons have a different payload from the rest of the buttons, this is because in the radio protocol both accept and reject are stated as SWC_CMD instead of SWC_KEY, so the payload has to arrive with 0x2f instead of 0x20. I'll have to dig deeper.

I changed that in the past so I can force the night mode if the near lights are on. This does not have to reach final version.

The only problem we have is that we are bound to what is developed by the Chinese manufacturers, if they don't add more functions to their canbus app, we are F*****!!!. I wanted to navigate the screen with the direction buttons, but as the golf does not have buttons for that. I'm afraid well never have that unless we can find another car and the Chinese serial protocol (highly unlikely ) and implement another canbox protocol. I have searched on Russian forums and on baidu for more information but could not find any new info. And mapping to any app is a general no, maybe we could map navigation, if the canbus app calls the standard navigation app that is set on settings of the headunit it should work, other apps or remaping, not possible.

Id like to get answer and reject working, and maybe ill test what other buttons stated in the MctCoreServices do in the head unit. After that id like to get ac info on the screen, just for the sake of it (not that it is needed). Can't promise anything, but ill try.

Interesting, I wonder why they made the phone buttons different in this way, doesn't make it easy to reverse engineer lol

Also interesting that you found a need to force the change of the brightness because I find it switches to night mode too soon before it gets dark enough, I do wonder if the brightness info from the car differs as mine is an early 2007 model and doesn't have auto headlights from factory, when connecting canbus over putty it seems to just between numbers 94 to 100 for example with nothing in between, oddly the brightness adjustment for dials in the car also affects this so I find it it changes to night mode too soon I can lower dial brightness slightly and screen goes back to day mode. How do you find this?

I'm not too worried about extra keys if it cannot be done, I like the idea of a mute button and a voice button I think that was a good idea, just need a way to cancel voice easy and get it to use the phone app now lol

A/c info would be very cool

Happy to test anything as you get it working or make changes, please keep me updated, also happy to be contacted directly if it's easier via FB messenger or preferably WhatsApp. Thanks again!

jesusvallejo commented 6 months ago

As stated by the creator on another issue, 0x2f will not work. He has shared a de compilation of the canbus.apk from his head unit and there is only a few possible key codes. I'll probably assing each code on the decompilation to a key and test what it does. This could be a problem as each person can have a different canbus.apk

liamstears commented 6 months ago

As stated by the creator on another issue, 0x2f will not work. He has shared a de compilation of the canbus.apk from his head unit and there is only a few possible key codes. I'll probably assing each code on the decompilation to a key and test what it does. This could be a problem as each person can have a different canbus.apk

Knowing how these units are made in China I would prob think it is handled very similarly across multiple units, the Chinese head units software they like to do as little work as possible lol, I have faith in you 😁

jesusvallejo commented 6 months ago

Ok, i edited the code to check what do some of the codes do, i added an excel to the repo with the codes and what to expect. Could you please flash it and test? i have mapped

ACTION PROTOCOL VARIANT CAR MAP OBSERVED ACTION
VOLUME UP RAISE PQ? + VOLUME UP
VOLUME DOWN RAISE PQ? - VOLUME DOWN
PREV RAISE PQ? < PREV
NEXT RAISE PQ? > NEXT
MUTE RAISE PQ? NAV BACK MUTE
SRC? RAISE PQ? NAV LEFT AND NAV RIGHT  
MICROPHONE RAISE PQ? NAV ENTER MICROPHONE?
CONT? RAISE PQ? ACCEPT CALL  
MODE? RAISE PQ? REJECT CALL  
MICI? RAISE PQ? NAV UP  
? RAISE PQ? NAV DOWN  

Id like you to fill the observed action for each empty one. Also does the mic action work correctly, what does it do.

liamstears commented 6 months ago

Ok, i edited the code to check what do some of the codes do, i added an excel to the repo with the codes and what to expect. Could you please flash it and test? i have mapped

ACTION PROTOCOL VARIANT CAR MAP OBSERVED ACTION VOLUME UP RAISE PQ? + VOLUME UP VOLUME DOWN RAISE PQ? - VOLUME DOWN PREV RAISE PQ? < PREV NEXT RAISE PQ? > NEXT MUTE RAISE PQ? NAV BACK MUTE SRC? RAISE PQ? NAV LEFT AND NAV RIGHT   MICROPHONE RAISE PQ? NAV ENTER MICROPHONE? CONT? RAISE PQ? ACCEPT CALL   MODE? RAISE PQ? REJECT CALL   MICI? RAISE PQ? NAV UP   ? RAISE PQ? NAV DOWN   Id like you to fill the observed action for each empty one. Also does the mic action work correctly, what does it do.

Thanks again, I will try this asap, prob be tomorrow, as for microphone when pressed it opens up the selected microphone app so for example mine opens up google so I can give voice commands to google

Will update you as soon as I can

EDIT: Although looking at your repo I can't see any changes have been made, did you push to your repo?

jesusvallejo commented 6 months ago

Forgot to commit, commited and pushed. Do you use Android Auto, if so does it summon google inside Android Auto?

liamstears commented 6 months ago

forgot to commit, commited and pushed.

No problem lol, I'll update you as soon as I can

liamstears commented 6 months ago

Forgot to commit, commited and pushed. Do you use Android Auto, if so does it summon google inside Android Auto?

I have just tested and for me it seems that there is no change at all, nav up down left and right do nothing, phone buttons still do nothing and all other buttons work as before

Did everything commit properly or maybe something is missing?

jesusvallejo commented 6 months ago

i could be missing something, or mb those only work under certain conditions, while in a call or if there is an incoming call. the call buttons codes where already on the owners code, just wanted to check were they for.

jesusvallejo commented 6 months ago

Sorry, difficult week at work, i suspect mb i didnt map correctly the pickup/hangup buttons on can level, i have pushed a version where they should trigger mute and mic(speech). If those work, pls tell me and they should be mapped to cont and mode, wich were already there by the original dev. i suspect that those only work if the phone is connected via bluetooth, and there is an incoming/ongoing call. Please test it.

jesusvallejo commented 6 months ago

Also i have found that d-pad action is there for a lexus, i wonder why these chinese did not make a more streamlined code. if code 1 -> volume up for all cars and so on. That would be much better because in that way they would have probably mapped D-PAD UP/DOWN etc. Such a shame.

jesusvallejo commented 6 months ago

This is the code for raise keys for pq version they are in dec, must be sent as hex.

package com.xygala.canbus.key;  

public class RaiseKey {
    public static final int ANSWER_CMD = 17;
    public static final int BACKWARD = 4;
    public static final int BACKWARD_CMD = 1;
    public static final int CH_DN = 132;
    public static final int CH_UP = 131;
    public static final int CONTINUE_CMD = 21;
    public static final int DISP = 24;
    public static final int DOWN = 20;
    public static final int ENTER = 22;
    public static final int EXCELLE_HOME = 80;
    public static final int EXCELLE_MEDIA = 84;
    public static final int EXCELLE_MENU = 83;
    public static final int FAST_BACK_CMD = 4;
    public static final int FAST_KEY_UP_CMD = 5;
    public static final int FAST_NEXT_CMD = 3;
    public static final int FORWARD = 3;
    public static final int FORWARD_CMD = 2;
    public static final int HANDS_FREE_CMD = 25;
    public static final int HANGUP = 10; -- HANGUP?
    public static final int HANG_UP_CMD = 18;
    public static final int HOLD_CMD = 20;
    public static final int KEY_LONG = 0;
    public static final int KEY_NONE = 0;
    public static final int KEY_PRESS = 0;
    public static final int LEFT = 4;-- PREV
    public static final int LGNORE_CMD = 19;
    public static final int MEDIA_AUX = 48;
    public static final int MEDIA_DVDVIDE0 = 33;
    public static final int MEDIA_ENHA = 17;
    public static final int MEDIA_FILE = 32;
    public static final int MEDIA_IPOD = 18;
    public static final int MEDIA_OFF = 0;
    public static final int MEDIA_OTHERVIDEO = 34;
    public static final int MEDIA_PHONE = 64;
    public static final int MEDIA_SIMPLE = 16;
    public static final int MEDIA_SIMPLE2 = 19;
    public static final int MEDIA_TUER = 1;
    public static final int MENU = 23;
    public static final int MIC_OFF_CMD = 22;
    public static final int MIC_ON_CMD = 23;
    public static final int MODE = 136;
    public static final int MUTE = 6;  -- MUTE
    public static final int NOKEY = 0;
    public static final int PEUGEOT_BAND = 80;
    public static final int PEUGEOT_DOWN = 57;
    public static final int PEUGEOT_DOWNP = 89;
    public static final int PEUGEOT_HANGUP = 49;
    public static final int PEUGEOT_LEFT = 64;
    public static final int PEUGEOT_MEDIA = 54;
    public static final int PEUGEOT_NAVI = 50;
    public static final int PEUGEOT_PHONE = 35;
    public static final int PEUGEOT_POWER = 128;
    public static final int PEUGEOT_RADIO = 51;
    public static final int PEUGEOT_RIGHT = 65;
    public static final int PEUGEOT_SCROLLDOWN = 67;
    public static final int PEUGEOT_SCROLLUP = 66;
    public static final int PEUGEOT_UP = 56;
    public static final int PEUGEOT_UPP = 88;
    public static final int PHONE = 5;
    public static final int PICKUP = 9; -- PICKUP?
    public static final int POWER = 135;
    public static final int PRIVATE_CMD = 24;
    public static final int RETURN = 21;
    public static final int RIGHT = 3; -- NEXT
    public static final int SCR = 7;
    public static final int SOURCE_AUX = 7;
    public static final int SOURCE_CD = 14;
    public static final int SOURCE_DISC = 2;
    public static final int SOURCE_DVBT = 10;
    public static final int SOURCE_DVD = 15;
    public static final int SOURCE_IPOD = 6;
    public static final int SOURCE_NAVI = 4;
    public static final int SOURCE_OFF = 0;
    public static final int SOURCE_OTHER = 12;
    public static final int SOURCE_PHONE = 5;
    public static final int SOURCE_PHONE_A2DP = 11;
    public static final int SOURCE_PHONE_CDC = 13;
    public static final int SOURCE_SD = 9;
    public static final int SOURCE_TUNER = 1;
    public static final int SOURCE_TV = 3;
    public static final int SOURCE_USB = 8;
    public static final int SPEECH = 8;  -- SUMMON MIC
    public static final int TUNE_DN = 134;
    public static final int TUNE_UP = 133;
    public static final int UP = 19;
    public static final int VOL_ADD = 1; -- VOL UP
    public static final int VOL_DN = 130;
    public static final int VOL_SUB = 2; -- VOL DOWN
    public static final int VOL_UP = 129;
}
liamstears commented 6 months ago

Sorry, difficult week at work, i suspect mb i didnt map correctly the pickup/hangup buttons on can level, i have pushed a version where they should trigger mute and mic(speech). If those work, pls tell me and they should be mapped to cont and mode, wich were already there by the original dev. i suspect that those only work if the phone is connected via bluetooth, and there is an incoming/ongoing call. Please test it.

Sorry for the delay, finally did some testing today and there is some progress

Volume up does volume up and "ok Google" too Answer/enter button mutes volume Hang up/exit does nothing Nav enter does "ok Google" Nav exit does mute

Looks like instead of being mapped to hang up button somehow it got mapped to volume up as well as original volume up action lol

The 4 dpad nav buttons do nothing

I hope this helps and I'm ready to test anything else, I can do testing tonight or tomorrow during the day

Thanks again this is so much progress!

jesusvallejo commented 6 months ago

So there is something wrong certainly, ill check when i have time.

liamstears commented 6 months ago

So there is something wrong certainly, ill check when i have time.

It can't be too bad because you are so close, you have got the call button functioning which didn't work before and 2 other buttons that previously didn't work so you are very close, I'm really excited to see where this leads, getting other stuff on the screen would be so cool, if I can help more please get in touch and I'll do what I can, I'd like to sniff off the canbus myself on my 90 but I failed miserably last time I tried, would love to find codes for some other features in the car and add them like turning child locks on/off, disabling reverse sensors using button, headlight turning, heating, heated seats etc etc haha

Look forward to your progress xD

jesusvallejo commented 6 months ago

I mapped it wrong, now it should work ( fingers crossed) . enter(pickup) -> speech (ok google) , exit(hangup) -> mute.

jesusvallejo commented 6 months ago

Regarding this, that would involve writting on the canbus if i got you right. That is riskier thant just listening. Showing heating or heated seats would be possible, but triggering it not so possible with my skill set jejeje. The thing is that you can trigger an SRS (airbag) light if you send something you shouldnt, and that can get expensive if you have to go to the dealer, or buy a DICE/VICE adapter and Software. Also for some things like heated seats i would need you to sniff some can bus codes as i dont have them fitted. I wont be at the end really using enter and exit as i planned, i retrofitted the buttons as well as the rti buttons but they do nothing. So i need you to try it.

would love to find codes for some other features in the car and add them like turning child locks on/off, disabling reverse sensors using button, headlight turning, heating, heated seats etc etc haha

liamstears commented 6 months ago

Regarding this, that would involve writting on the canbus if i got you right. That is riskier thant just listening. Showing heating or heated seats would be possible, but triggering it not so possible with my skill set jejeje. The thing is that you can trigger an SRS (airbag) light if you send something you shouldnt, and that can get expensive if you have to go to the dealer, or buy a DICE/VICE adapter and Software. Also for some things like heated seats i would need you to sniff some can bus codes as i dont have them fitted. I wont be at the end really using enter and exit as i planned, i retrofitted the buttons as well as the rti buttons but they do nothing. So i need you to try it.

would love to find codes for some other features in the car and add them like turning child locks on/off, disabling reverse sensors using button, headlight turning, heating, heated seats etc etc haha

Haha, thought it might be an easy mistake, we all do it lol

I will try this shortly and give you an update within the next hour or so

As for sniffing, like I said before I failed miserably but happy to try again with your guidance, as for errors I'm really not worried as long as it's something that can be rectified as I have full Vida/Vdash and dice to clear codes etc so not too worried about that, just getting the info up on screen would be a major leap ahead though, 1 of the things I would like to see is being about to turn on/off parking sensors, I believe someone has already done it for XC90 on a custom based canbus so there may be some helpful code there...

liamstears commented 6 months ago

I mapped it wrong, now it should work ( fingers crossed) . enter(pickup) -> speech (ok google) , exit(hangup) -> mute.

As expected all working! Just need to map them to the correct keys now 🤣

Thank you!

jesusvallejo commented 6 months ago

Ok, will try this evening if i have time after work. I will map them to what i think is accept and reject (reverse engineering points to them also , says something about bluetooth). Also temp should be working, and mb ac fan speed?

liamstears commented 6 months ago

Ok, will try this evening if i have time after work. I will map them to what i think is accept and reject (reverse engineering points to them also , says something about bluetooth). Also temp should be working, and mb ac fan speed?

I look forward to trying

As for temp I can't be 100% sure because I've now swapped to a custom firmware on my unit to fix another issue but I think it's still not working. What do you mean for "mb ac fan speed"?

Also noticed turning off parking sensors using the button now disabled them on screen too which makes sense but never use to be the case. I think this may be the custom firmware though maybe and not the canbus box...

jesusvallejo commented 6 months ago

Temp is working on my car, i meant "maybe air conditioner air speed is also working", when moving the fan speed dial it should show on screen the ac menu but for me it is not.

jesusvallejo commented 6 months ago

I could test it, in lunch break, temp is working, but temperature is not correct showing 10C should be 18-19C, the aircon speed is working sort of, only the first 3 speeds show, will have to check the conversion for both states.

jesusvallejo commented 6 months ago

Updated code, ac speed should be fixed, also the air recycling button, the temp should be correct , the function is all over the internet x*0.75-48 maybe my temp sensor is broken? Please test with raise vw pq in can bus settings, with oudi xc90 only the basics work, no ac option.

liamstears commented 6 months ago

Updated code, ac speed should be fixed, also the air recycling button, the temp should be correct , the function is all over the internet x*0.75-48 maybe my temp sensor is broken? Please test with raise vw pq in can bus settings, with oudi xc90 only the basics work, no ac option.

Tested already and for me it seems very close!

Fan speed 4/5/6/7 all working correctly. Fan speed below that all show as 1 less than should be. So speed 3 shows 2 on screen, 2 shows 1 on screen and 1 shows off, off doesn't show anything, switching from off to 1 does nothing, display shows up when I change to speed 2 and it shows speed 1 on screen.

Recirculation button doesn't sound anything for me.

Temperature is working but I think the temperature is wrong, it's showing 14C but my car under time was showing 18C but now shows 20C yet car still shows 14C

Phone buttons now not working at all as expected.

Hopefully this is helpful haha

Good work!

liamstears commented 6 months ago

Updated code, ac speed should be fixed, also the air recycling button, the temp should be correct , the function is all over the internet x*0.75-48 maybe my temp sensor is broken? Please test with raise vw pq in can bus settings, with oudi xc90 only the basics work, no ac option.

Something else I noticed today, outside temp went up today to about 21C but car still reported 14C, maybe the info is being pulled from the wrong place and that's why temp is wrong? As it's not updated when outside temp has changed by a fair amount...

jesusvallejo commented 6 months ago

It is the climate module sensor, it is inside the car, i dont know why it reads a few degrees below. Any way, today i have fixed the fan speed, also have tryed decoding other things related to climate control but cannot find any change on can bus data when changing the temp knobs or the air vents. dont know if the data is there any way, mb it is not broadcasted or it is embedded in a more complex way.

liamstears commented 6 months ago

It is the climate module sensor, it is inside the car, i dont know why it reads a few degrees below. Any way, today i have fixed the fan speed, also have tryed decoding other things related to climate control but cannot find any change on can bus data when changing the temp knobs or the air vents. dont know if the data is there any way, mb it is not broadcasted or it is embedded in a more complex way.

Ah, in that case maybe it is reading correctly, I will try to borrow a thermometer that works in the car to try to compare temps and see if it is accurate

I will try this new version tomorrow

I would think these messages would be present in can to be able to send signals to various parts of the car although I suppose it is possible that these messages may only be sent over the linbus? I am not too familiar with how it works in this car but I hope you can find it and make the display for heating fully functional. Heated seats should be in canbus so hopefully we can find them at some point too :-D

Have you had any more luck yet with phone buttons? These are quite important for me so my fingers are crossed

I did also find some information when doing some searches which may help in adding some other canbus stuff? I know there is a "car app" on the head unit which should show some things but most do not work so possibly could be added, on this link:

https://xdaforums.com/t/yt9218c-8227l-steering-wheel-controls-and-canbus-hardware-support.3953011/post-80016258

is possible information to add parking brake, wiper fluid level to this app, dont know if seatbelt is helpful? And this information maybe helpful for speed and rpm:

0x12177FC 01 02 40 00 10 40 3A B8 //speed: B6 b0-b1 – B7 b0-b7, divide by 4, 174km/h

0x2A07428 0B 0D C4 0E 0F FD 2F 17 //revs: B6 b0-b3 - B7 b0-b7, 3863 per minute

I can't say for sure if this information will be correct but I hope it helps

jesusvallejo commented 6 months ago

Supposedly there are multiple lin bus networks, and this attach to a "master" ECU and is the master ECU the one that sends the can data to the can bus. This is something that happens for example with SWC. As i said , if the data is there, and the radio expects it we can code it. My car does not "have" those buttons, it does physically (it didn't in the past), but it does not for the ECU, that is why i think they do not work (i wish they did haha), the main problem is that we do not know what to expect from the android hu when we send 0x09 or 0x0a. it should work i don't know why it doesn't.

Where did you get those can bus codes? i cannot find those addresses on my sniffing's.

liamstears commented 6 months ago

Supposedly there are multiple lin bus networks, and this attach to a "master" ECU and is the master ECU the one that sends the can data to the can bus. This is something that happens for example with SWC. As i said , if the data is there, and the radio expects it we can code it. My car does not "have" those buttons, it does physically (it didn't in the past), but it does not for the ECU, that is why i think they do not work (i wish they did haha), the main problem is that we do not know what to expect from the android hu when we send 0x09 or 0x0a. it should work i don't know why it doesn't.

  • Parking brake, i tried to see if it made any change on canbus, couldn't see anything.
  • Wiper fluid level, who knows, does the car even know the wipers fluid level?
  • Seat belt, probably on canbus HS, we are tapping into can bus LS.

Where did you get those can bus codes? i cannot find those addresses on my sniffing's.

I am happy to try sniffing if it will help, I don't know how but could do it with guidance

Wiper fluid yes car knows as it comes up when it's empty

I just googled, I can't remember exactly where now I found them

I tested today anyway and most levels now work on heating but level 3 doesn't work at all and level 2 can be hit or miss when coming back down levels but it's much better. Still no other buttons do anything for heating.

For answer/hangup buttons you were able to successfully make them do other functions so I assume reading the data from the car is fine it's only sending the correct data to the car now for answer/hangup and I think this will be the same for all cars so maybe look into what is sent for other vehicles to make this work?

Heating system is an odd one and it may be that this cannot be fully implemented which would be a shame but I also never expected it so any work you do is much appreciated