How can I add the pican-m drivers to Hass OS

Hi, I would like to add the SignalK addon (hassio-addons/signalk at master · alexbelgium/hassio-addons · GitHub) to my Home Assistant running RPi4 8GB RAM in my powerboat. I would like to use the Pican-M hat (PICAN-M - NMEA 0183 & NMEA 2000 HAT For Raspberry Pi) to enable NMEA2000 communication to the SignalK addon.

The problem is that I have a hard time loading all the Pican-M dependencies into Hass OS. This is the install guide for the Raspbian RPi image. https://copperhilltech.com/content/pican-m_UGB_10.pdf

Enabling the Pican-M hat involves adding some stuff to the boot/config.txt

dtparam=i2c_arm=on
dtparam=spi=on
dtoverlay=mcp2515-can0,oscillator=16000000,interrupt=25 
dtoverlay=spi-bcm2835-overlay

Installing can utils
sudo apt-get install can-utils

Bring up the can interface
sudo /sbin/ip link set can0 up type can bitrate 250000

Try to dump the can messages
candump can0

Somehow automatically bring up can0 at boot

Any ideas on how I can get the Pican-M hat to function with Hass OS?

HAOS is not meant to allow access to install other things in the OS. If you do want OS control on the device running HA, you will need to use another installation method, such as container. That will mean you cannot use addons but need to do everything in containers.

The other option would mean running HAOS in a VM, but I don’t think you can do that on a rpi4.

Could it be those tools you need are already installed in the addon? They might not need to be installed on the bare os.

Thanks for the reply. I run HA in containers in some other installations, but I would like use Hass OS in the powerboat setup, just for simplicity. I more and more start to enjoy the pure simplicity and stability of Hass OS.

If I add the necessary binaries and tools to the container, will the container be able to enable/reach the can0 device? I mean, the hat is physically attached to the RPi and I guess the RPi needs to recognize the device to even present it to the addon container, right?

Anything you succeed in installing will probably be removed with next HAOS update.

Yeah, I currently run SignalK on a separate RPi, and I will probably continue to do so. But I still wonder if the can tools in a container potentially/in theory could reach the Pican-M hat if attached to a Hass OS RPi.

I know this is not exactly answering your question, but you can connect your NMEA2000 network directly to HA without the need of SignalK. This makes the deployment much easier. I wrote new HA integration just for that. Will be glad to any feedback if you decide to try it out.

I have the exact same issue here, except that I’m using the 2CH CAN HAT+ from Waveshare.

I solved the problem with a can2tcp AddOn to the SignalK server AddOn that runs in network=host mode or in AddOn terms host_network: true and implements the YachtDevice RAW as described in Appendix E here: https://www.yachtd.com/downloads/ydnu02.pdf

Then I added the SignalK Server AddOn and configured a NMEA2K connection of type “Yacht Devices RAW TCP (canboatjs)” and it works. All other plugins etc that I’m using in SignalK work as far as I know.

It’s not the ideal solution, as it runs in host-mode and opens a tcp port with the can data that will be accessible from the outside and could potentially cause issues with other services/addons. The second is easily remedied as the port-number is configurable, but the first issue is a bit more tricky and not very elegant: Make the host-mode AddOn push the can data to the SignalK server or an intermediate AddOn, that will then expose the port internally.

But at the moment, I’m happy it works.

I also have the Sh-Rpi HAT as a safety measure against power outages and therefore data corruption and that is the next thing that needs integrating.