rhysmorgan134 / react-carplay

MIT License
382 stars 58 forks source link

Setting Car Icon in Carplay #7

Open N95JPL opened 2 years ago

N95JPL commented 2 years ago

Hello, I have this working perfectly on my RPi! Thanks for your work on this!

One thing I am struggling with though, how do we set the Manufacture Icon on the device to show as say "Jaguar" rather than defaulting to "Audi MMI" - I can't seem to find any config files for the AutoKit it is using.

Installing AutoKit onto my Android device brings up the device settings and it is settable there

How have you changed yours?

Thanks!

Joshua

rhysmorgan134 commented 2 years ago

Hi,

unfortunately that had not been figured out yet! For now if you set it in the android app, it stays set indefinately, so that can be used a work around for now

N95JPL commented 2 years ago

Thank you! I will do it that way, it must store it somehow on the Dongle in that case?

I'm currently trying to get the CANBUS playing nicely... seems to connect but absolute 0 messages being received on the RPi Using the 2-CH CanBus module you linked in the other Repo

rhysmorgan134 commented 2 years ago

Yeah it will certainly be a message type where it transfers the image to the dongle.

For the canbus, it could be a bunch of things, wiring incorrect, car could be using a gateway, baud rate incorrect, if you list any of the set up here I can try and help

N95JPL commented 2 years ago

Thanks! So I have a 2010 XF S

I've basically replicated what you have put in your JaguarXf_Can

Pins 3/11 seem to be the right ones, accidentally cross-wired them and sent the whole car into shock mode (yikes don't do that) Anyway, fixed the wiring and now Can0 says it's "UP" it'll register with candump can0 but nothing shows

Components

RPi3b Waveshare 2-CH Can Bus Hat 7" Touchscreen

Can0

Baud Rate: 125000 CanL: Pin 11 CanH: Pin 3

Can1

Baud Rate: 500000 CanL: Not Wired CanH: Not Wired

rhysmorgan134 commented 2 years ago

Certainly makes it easier being an XF! Try ifconfig And see what it shows under can0 and can1 you are looking at rx and tax stats, also try candump can1, I believe some waveshare units had the interrupts wired different, if you can also show you /boot/config.txt and the command you then run to set it up.

finally make sure the terminating resistors are set to off, I have left these in by mistake and it hasn’t caused issues, but worth checking

rhysmorgan134 commented 2 years ago

Also dmesg | grep spi is worth running

N95JPL commented 2 years ago

I will apologise in advance for the long post! I have made some progress... not in the car, but earlier I couldnt even get can0/can1 talking to eachother, that's now working! So the Interrupts must be set correctly! So here is all the data from what you mentioned above, I will go and try in the car again! Commands to set up

sudo apt-get -y install can-utils libsocketcan2 libsocketcan-dev
sudo nano /boot/config.txt -- Then added lines as seen below
sudo /sbin/ip link set can0 up type can bitrate 125000
sudo /sbin/ip link set can1 up type can bitrate 500000
sudo nano /etc/rc.local -- Then appended same commands as above
sudo reboot now

dmesg | grep spi

n95jpl@carOS:~ $ dmesg | grep spi
[   13.320118] mcp251x spi0.1 can0: MCP2515 successfully initialized.
[   13.383533] mcp251x spi0.0 can1: MCP2515 successfully initialized.

ifconfig

n95jpl@carOS:~ $ ifconfig
can0: flags=193<UP,RUNNING,NOARP>  mtu 16
        unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  txqueuelen 10  (UNSPEC)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

can1: flags=193<UP,RUNNING,NOARP>  mtu 16
        unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  txqueuelen 10  (UNSPEC)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

/boot/config.txt


# For more options and information see
# http://rpf.io/configtxt
# Some settings may impact device functionality. See link above for details

# uncomment if you get no picture on HDMI for a default "safe" mode
#hdmi_safe=1

# uncomment the following to adjust overscan. Use positive numbers if console
# goes off screen, and negative if there is too much border
#overscan_left=16
#overscan_right=16
#overscan_top=16
#overscan_bottom=16

# uncomment to force a console size. By default it will be display's size minus
# overscan.
framebuffer_width=1024
framebuffer_height=614

# uncomment if hdmi display is not detected and composite is being output
#hdmi_force_hotplug=1

# uncomment to force a specific HDMI mode (this will force VGA)
#hdmi_group=1
#hdmi_mode=1

# uncomment to force a HDMI mode rather than DVI. This can make audio work in
# DMT (computer monitor) modes
#hdmi_drive=2

# uncomment to increase signal to HDMI, if you have interference, blanking, or
# no display
#config_hdmi_boost=4

# uncomment for composite PAL
#sdtv_mode=2

#uncomment to overclock the arm. 700 MHz is the default.
#arm_freq=800

# Uncomment some or all of these to enable the optional hardware interfaces
dtparam=i2c_arm=on
dtparam=i2s=on
dtparam=spi=on

# Uncomment this to enable infrared communication.
#dtoverlay=gpio-ir,gpio_pin=17
#dtoverlay=gpio-ir-tx,gpio_pin=18

# Additional overlays and parameters are documented /boot/overlays/README

# Enable audio (loads snd_bcm2835)
dtparam=audio=on

# Automatically load overlays for detected cameras
camera_auto_detect=1

# Automatically load overlays for detected DSI displays
display_auto_detect=1

# Enable DRM VC4 V3D driver
dtoverlay=vc4-kms-v3d
max_framebuffers=2

# Disable compensation for displays with overscan
disable_overscan=1

[cm4]
# Enable host mode on the 2711 built-in XHCI USB controller.
# This line should be removed if the legacy DWC2 controller is required
# (e.g. for USB device mode) or if USB support is not required.
otg_mode=1

[all]

[pi4]
# Run as fast as firmware / board allows
arm_boost=1

[all]
enable_uart=1
gpu_mem=64

#CAN bus controllers
dtparam=spi=on
dtoverlay=mcp2515-can0,oscillator=16000000,interrupt=23
dtoverlay=mcp2515-can1,oscillator=16000000,interrupt=25
N95JPL commented 2 years ago

Update: Total flop, with Pin 3 going to High and Pin 11 going to Low, the car went into complete shock before I even turned the ACC power on Every module on the Medium Speed Bus triggered a "Loss of Communication to module" code... Slightly alarming...but everything reset after a couple of minutes and the faults self-cleared So, checked wiring and it all checks out? I did though try swapping the lines... The car didn't freak-out and neither did the RPi but no messages were received..

Any ideas?

As a gift for helping me getting this working, if you ever need your website https://moderndaymods.com/ hosting with SSL Certificates etc, I will happily host it upon my VPS! Free of course as your project is basically the building blocks to the start of mine!

rhysmorgan134 commented 2 years ago

I have had this before, I think it is because in your /boot/config.txt you are enabling can0 first then can 1, if you read the waveshare wiki it lists it like this

dtparam=spi=on
dtoverlay=mcp2515-can1,oscillator=16000000,interrupt=25
dtoverlay=mcp2515-can0,oscillator=16000000,interrupt=23

I don't know how this makes a difference, but I had the exact same scenario and I am sure that was all I changed. you are correct in pin3 is high, pin 11 is low. If you want to check, set both to 125k baud, don't connect can1 to high speed, but then see if it still causes the car to go mad. I think it sets what is actually can0 to the baud rate set for can1

N95JPL commented 2 years ago

I don't know how or why enabling one before the other works...but it has!! I am now getting data and the car is happy as Larry! Pure witchcraft! I have even reset Can1 to 500000, rebooted and business resumes! Now onto the task of somehow decoding some additional buttons... I under-estimated how much of a task that would be, looking at cansniffer can0 even without touching a thing there are a good 10-12 IDs being updated!

Good work sir, good work!

rhysmorgan134 commented 2 years ago

Good to hear, I believe it is to do with spi addresses as they get initialised. Which other buttons are you after, I have a bunch of them done, just not implemented yet.

N95JPL commented 2 years ago

Is this file the values you currently have for the Medium Speed? (main focus for now) I can see a lot of the ones I require are there already although which IDs do they fall under? I am liking the canMap as that's nice and easy for me to read haha!

rhysmorgan134 commented 2 years ago

I've actually sneakily moved it all to a new repo, it needed a real tidy up!

best place is to look here

https://github.com/rhysmorgan134/jaguar-xf-canbus-app/tree/carplay/app/public/modules/mediumSpeed

the name of each file is the decimal representation of the ID

this line is then in every instance

    let arr = [...message];

that array then contains all the bytes, then just see what the bytes are refencing

https://github.com/rhysmorgan134/jaguar-xf-canbus-app/blob/c18483af4b63f9c25ab4ca7ac76e31177573795d/app/public/modules/mediumSpeed/40.js#L19

you can see there the entire byte is for light resistance

but in the same ID is the selected gear, which refences seperate bits of the byte

    let gear = arr[4];
    if(!(this.prevGear === gear)) {
        if(this.prevGear === 1) {
            // this.dash.page('Android Auto');
        }
        if (gear === 0) {
            console.log("in Park");
            this.data.gear = "park";
            this.prevGear = gear;
        } else {
            switch (gear) {
                case gear & 1:
                    console.log("in reverse");
                    this.data.gear = "reverse";
                    this.prevGear = gear;
                    // this.dash.page('Camera');
                    break;
                case gear & 2:
                    console.log("in neutral");
                    this.data.gear = "neutral";
                    this.prevGear = gear;
                    break;
                case gear & 4:
                    console.log("in drive");
                    this.data.gear = "drive";
                    this.prevGear = gear;
                    break;
                case gear & 8:
                    console.log("in sport");
                    this.data.gear = "sport";
                    this.prevGear = gear;
                    break;
            }

        }
rhysmorgan134 commented 2 years ago

The file you linked, is for sending commands out, so if it is just buttons you need, it is likely contained in the json.

Feel free to join the slack here

https://join.slack.com/t/canbusjagdeve-hl07333/shared_invite/zt-17oty0xdt-NRVILlQ0xn_xcL2p7I77RA