bvdberg01 / FiatStiloConnectNavOAP

Integrate Raspberry Pi with MCP2515 module into Fiat Stilo's CANbus network for enhanced connectivity and control. Use on own risk!!
4 stars 1 forks source link

Connectivity Issue with Stilo CAN Bus #1

Closed phobbi closed 6 months ago

phobbi commented 9 months ago

Hello,

I am currently experiencing difficulties in establishing a connection with the Stilo CAN bus. Even when attempting to use candump command, no data is being detected.

Could you please provide details on the method employed to connect to the CAN bus in the context of this project?

Fiat Stilo CAN bus operates at two different speeds, namely 50 kbps and 500 kbps. Could you confirm which speed is utilized by the project?

In terms of physical connection points, could you clarify whether the connection is behind the radio, through the OBD socket, or directly to the instrument cluster?

Your assistance is greatly appreciated.

Thank you for your time and support.

bvdberg01 commented 9 months ago

Could you please provide details on the method employed to connect to the CAN bus in the context of this project? The FiatStiloBackendApp connects to the canbus with the MCP2515 module that is connected to the raspberry pi.

You need to configure the MCP2515 like this: Add in /boot/config.txt the following line but make sure to match the oscillator value of your mcp2515 module: dtoverlay=mcp2515-can0,oscillator=8000000,interrupt=25

Bring the interface up with the following command, you need to do this every time you reboot your pi so it would be a good thing to make this automatic. sudo /sbin/ip link set can0 up type can bitrate 50000

Fiat Stilo CAN bus operates at two different speeds, namely 50 kbps and 500 kbps. Could you confirm which speed is utilized by the project?

All the features of this project are connected to the low-speed CAN bus so the 50 kbps network.

In terms of physical connection points, could you clarify whether the connection is behind the radio, through the OBD socket, or directly to the instrument cluster? I connected to the CAN bus where the original radio connected. So I used the CAN bus connection in the iso connector. image image

If you need more info let me know! But use this info at your own risk.

phobbi commented 9 months ago

Hello, I apologize for bothering you, but I can't get the CAN communication working. I've checked the wiring 100 times, reviewed the config.txt, and inspected everything, but I'm still unable to receive or transmit any data. I even bought a new CAN shield.

michal@navitronic:~ $ ip -details link show can0
4: can0: <NOARP,UP,LOWER_UP,ECHO> mtu 16 qdisc pfifo_fast state UP mode DEFAULT group default qlen 10
    link/can  promiscuity 0 minmtu 0 maxmtu 0
    can state ERROR-ACTIVE restart-ms 0
          bitrate 50000 sample-point 0.866
          tq 1333 prop-seg 6 phase-seg1 6 phase-seg2 2 sjw 1
          mcp251x: tseg1 3..16 tseg2 2..8 sjw 1..4 brp 1..64 brp-inc 1
          clock 6000000 numtxqueues 1 numrxqueues 1 gso_max_size 65536 gso_max_segs 65535

michal@navitronic:~ $ ifconfig can0
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

michal@navitronic:~ $ cd FiatStiloConnectNavOAP-main/
michal@navitronic:~/FiatStiloConnectNavOAP-main $ cd FiatStiloScripts/
michal@navitronic:~/FiatStiloConnectNavOAP-main/FiatStiloScripts $ python3 NavigationDemo.py
Pictogrammframe2: 0 Pictogrammframe2: 0
Pictogrammframe2: 0 Pictogrammframe2: 0
Pictogrammframe2: 0 Pictogrammframe2: 1
Pictogrammframe2: 0 Pictogrammframe2: 1
Pictogrammframe2: 0 Pictogrammframe2: 2
Pictogrammframe2: 0 Pictogrammframe2: 2
Pictogrammframe2: 0 Pictogrammframe2: 3
Pictogrammframe2: 0 Pictogrammframe2: 3
Pictogrammframe2: 0 Pictogrammframe2: 4
Pictogrammframe2: 0 Pictogrammframe2: 4
Pictogrammframe2: 0 Pictogrammframe2: 5
Pictogrammframe2: 0 Pictogrammframe2: 5
Traceback (most recent call last):
  File "/home/michal/.local/lib/python3.9/site-packages/can/interfaces/socketcan/socketcan.py", line 797, in _send_once
    sent = self.socket.send(data)
OSError: [Errno 105] No buffer space available

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/michal/FiatStiloConnectNavOAP-main/FiatStiloScripts/NavigationDemo.py", line 149, in <module>
    create_message(0)
  File "/home/michal/FiatStiloConnectNavOAP-main/FiatStiloScripts/NavigationDemo.py", line 141, in create_message
    bus.send(out)
  File "/home/michal/.local/lib/python3.9/site-packages/can/interfaces/socketcan/socketcan.py", line 782, in send
    sent = self._send_once(data, channel)
  File "/home/michal/.local/lib/python3.9/site-packages/can/interfaces/socketcan/socketcan.py", line 799, in _send_once
    raise can.CanOperationError(
can.exceptions.CanOperationError: Failed to transmit: No buffer space available [Error Code 105]
SocketcanBus was not properly shut down

This is interesting. When I bring can0 up for the first time after a reboot, it works, but as soon as I set it down and try to bring it up again, it gives me a Connection Timeout error. After the second try, the whole system freezes, and a restart of Raspberry is needed to do anything.

michal@navitronic:~/FiatStiloConnectNavOAP-main/FiatStiloScripts $ sudo /sbin/ip link set can0 down
michal@navitronic:~/FiatStiloConnectNavOAP-main/FiatStiloScripts $ sudo /sbin/ip link set can0 up type can bitrate 50000
RTNETLINK answers: Connection timed out
michal@navitronic:~/FiatStiloConnectNavOAP-main/FiatStiloScripts $ sudo /sbin/ip link set can0 up type can bitrate 50000

I am testing it on a clean Raspbian install on Raspberry Pi 3B with Waveshare RS485 CAN HAT on a Fiat Stilo, with proxy alignment done so that the Connect NAV+ is learned to all nodes in the car. Do you have any clue where the issue can be? Thank you.

bvdberg01 commented 9 months ago

Hello, I apologize for bothering you, but I can't get the CAN communication working. I've checked the wiring 100 times, reviewed the config.txt, and inspected everything, but I'm still unable to receive or transmit any data. I even bought a new CAN shield.

michal@navitronic:~ $ ip -details link show can0
4: can0: <NOARP,UP,LOWER_UP,ECHO> mtu 16 qdisc pfifo_fast state UP mode DEFAULT group default qlen 10
    link/can  promiscuity 0 minmtu 0 maxmtu 0
    can state ERROR-ACTIVE restart-ms 0
          bitrate 50000 sample-point 0.866
          tq 1333 prop-seg 6 phase-seg1 6 phase-seg2 2 sjw 1
          mcp251x: tseg1 3..16 tseg2 2..8 sjw 1..4 brp 1..64 brp-inc 1
          clock 6000000 numtxqueues 1 numrxqueues 1 gso_max_size 65536 gso_max_segs 65535

michal@navitronic:~ $ ifconfig can0
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

michal@navitronic:~ $ cd FiatStiloConnectNavOAP-main/
michal@navitronic:~/FiatStiloConnectNavOAP-main $ cd FiatStiloScripts/
michal@navitronic:~/FiatStiloConnectNavOAP-main/FiatStiloScripts $ python3 NavigationDemo.py
Pictogrammframe2: 0 Pictogrammframe2: 0
Pictogrammframe2: 0 Pictogrammframe2: 0
Pictogrammframe2: 0 Pictogrammframe2: 1
Pictogrammframe2: 0 Pictogrammframe2: 1
Pictogrammframe2: 0 Pictogrammframe2: 2
Pictogrammframe2: 0 Pictogrammframe2: 2
Pictogrammframe2: 0 Pictogrammframe2: 3
Pictogrammframe2: 0 Pictogrammframe2: 3
Pictogrammframe2: 0 Pictogrammframe2: 4
Pictogrammframe2: 0 Pictogrammframe2: 4
Pictogrammframe2: 0 Pictogrammframe2: 5
Pictogrammframe2: 0 Pictogrammframe2: 5
Traceback (most recent call last):
  File "/home/michal/.local/lib/python3.9/site-packages/can/interfaces/socketcan/socketcan.py", line 797, in _send_once
    sent = self.socket.send(data)
OSError: [Errno 105] No buffer space available

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/michal/FiatStiloConnectNavOAP-main/FiatStiloScripts/NavigationDemo.py", line 149, in <module>
    create_message(0)
  File "/home/michal/FiatStiloConnectNavOAP-main/FiatStiloScripts/NavigationDemo.py", line 141, in create_message
    bus.send(out)
  File "/home/michal/.local/lib/python3.9/site-packages/can/interfaces/socketcan/socketcan.py", line 782, in send
    sent = self._send_once(data, channel)
  File "/home/michal/.local/lib/python3.9/site-packages/can/interfaces/socketcan/socketcan.py", line 799, in _send_once
    raise can.CanOperationError(
can.exceptions.CanOperationError: Failed to transmit: No buffer space available [Error Code 105]
SocketcanBus was not properly shut down

This is interesting. When I bring can0 up for the first time after a reboot, it works, but as soon as I set it down and try to bring it up again, it gives me a Connection Timeout error. After the second try, the whole system freezes, and a restart of Raspberry is needed to do anything.

michal@navitronic:~/FiatStiloConnectNavOAP-main/FiatStiloScripts $ sudo /sbin/ip link set can0 down
michal@navitronic:~/FiatStiloConnectNavOAP-main/FiatStiloScripts $ sudo /sbin/ip link set can0 up type can bitrate 50000
RTNETLINK answers: Connection timed out
michal@navitronic:~/FiatStiloConnectNavOAP-main/FiatStiloScripts $ sudo /sbin/ip link set can0 up type can bitrate 50000

I am testing it on a clean Raspbian install on Raspberry Pi 3B with Waveshare RS485 CAN HAT on a Fiat Stilo, with proxy alignment done so that the Connect NAV+ is learned to all nodes in the car. Do you have any clue where the issue can be? Thank you.

Are you sure that you have the right config for the oscillator? looks like there are 2 versions of the waveshare can hat:

image

I own a generic mcp2515 module which works fine.

What version of Stilo do you own? The navigation demo is for the Abarth color LCD instrument cluster.

Do you maybe have another way of communicating? Discord or something like that?

phobbi commented 6 months ago

Hi, it's been a while since I've worked on this project. Today, I had time to focus on it again and managed to get the CAN communication up and running.

I found that I have the same problem as discussed here.

So, I first tried downgrading the kernel to version 5.4 (raspberrypi-kernel_1.20210108), and suddenly the communication started working. Trying to restart can0 no longer hangs the entire terminal, and traffic can be seen using ifconfig and candump.

I downgraded the kernel like this: wget -O kernel-headers_armhf.deb http://archive.raspberrypi.org/debian/pool/main/r/raspberrypi-firmware/raspberrypi-kernel-headers_1.20210108-1_armhf.deb wget -O kernel_armhf.deb http://archive.raspberrypi.org/debian/pool/main/r/raspberrypi-firmware/raspberrypi-kernel_1.20210108-1_armhf.deb sudo dpkg -i kernel-headers_armhf.deb kernel_armhf.deb sudo apt-mark hold raspberrypi-kernel-headers raspberrypi-kernel sudo apt-mark showhold

After that, I managed to successfully run and test the navigation demo script on my Stilo.

This is certainly not an ideal solution, but at least I know where to look for the problem. Now, I'm going to play with scripts with the old kernel. When I come up with something functional, I will look for a better solution.

I'm a fan of the OpenAuto project, but it's a very expensive and unnecessarily complicated solution for me. I now have Obdpeak k20 installed on my Stilo, which has a front and rear camera, widescreen, supports Android Auto, and has flawless sound transmission directly to the radio via Bluetooth without loss of quality. It can also be placed on top of the dashboard, so navigation is easier to see. I found out that it runs on some lightweight Linux, and I already managed to get root access to it.

So now, I will focus on adapting this project for use with Obdpeak k20 somehow.

I will keep you updated.

My Discord: flystarcz

Thank you!