Sample Header Ad - 728x90

Unix & Linux Stack Exchange

Q&A for users of Linux, FreeBSD and other Unix-like operating systems

Latest Questions

0 votes
0 answers
427 views
can-config sample-point setup
I need to set up sample-points for CANFD bus.  The following help command shows how to set up sample-points for can, but my can configuration is not showing any sample points argument. ``` ip link set can0 type can help Usage: ip link set DEVICE type can [ bitrate BITRATE [ sample-point SA...
I need to set up sample-points for CANFD bus.  The following help command shows how to set up sample-points for can, but my can configuration is not showing any sample points argument.
ip link set can0 type can help
Usage: ip link set DEVICE type can
        [ bitrate BITRATE [ sample-point SAMPLE-POINT] ] |
        [ tq TQ prop-seg PROP_SEG phase-seg1 PHASE-SEG1
          phase-seg2 PHASE-SEG2 [ sjw SJW ] ]

        [ dbitrate BITRATE [ dsample-point SAMPLE-POINT] ] |
        [ dtq TQ dprop-seg PROP_SEG dphase-seg1 PHASE-SEG1
          dphase-seg2 PHASE-SEG2 [ dsjw SJW ] ]
        [ tdcv TDCV tdco TDCO tdcf TDCF ]

        [ loopback { on | off } ]
        [ listen-only { on | off } ]
        [ triple-sampling { on | off } ]
        [ one-shot { on | off } ]
        [ berr-reporting { on | off } ]
        [ fd { on | off } ]
        [ fd-non-iso { on | off } ]
        [ presume-ack { on | off } ]
        [ cc-len8-dlc { on | off } ]
        [ tdc-mode { auto | manual | off } ]

        [ restart-ms TIME-MS ]
        [ restart ]

        [ termination { 0..65535 } ]

        Where: BITRATE  := { NUMBER in bps }
                  SAMPLE-POINT  := { 0.000..0.999 }
                  TQ            := { NUMBER in ns }
                  PROP-SEG      := { NUMBER in tq }
                  PHASE-SEG1    := { NUMBER in tq }
                  PHASE-SEG2    := { NUMBER in tq }
                  SJW           := { NUMBER in tq }
                  TDCV          := { NUMBER in tc }
                  TDCO          := { NUMBER in tc }
                  TDCF          := { NUMBER in tc }
                  RESTART-MS    := { 0 | NUMBER in ms }
I suspect this is set to 0 by default, which matches the can.txt resources.  This document mentions calculation of bit-timing manipulation is enabled in the kernel (CONFIG_CAN_CALC_BITTIMING). But I am having trouble at which location this (CONFIG_CAN_CALC_BITTIMING) enabling should happen in kernel file.  I would really appreciate help on this.
L Galib (1 rep)
Oct 11, 2023, 09:00 PM • Last activity: Mar 13, 2025, 03:22 AM
0 votes
0 answers
32 views
RS232-RS485-CAN-Board erros
I've got this marvelous pi hat [RS232-RS485-CAN-Board][1] With this config: enable_uart=1 kernel=u-boot.bin [all] device_tree=bcm2711-rpi-4-b.dtb dtparam=spi=on dtoverlay=i2c0 dtoverlay=spi1-3cs dtoverlay=sc16is752-spi1,int_pin=25 dtoverlay=mcp2515,spi0-0,oscillator=16000000,interrupt=23 dtoverlay=m...
I've got this marvelous pi hat RS232-RS485-CAN-Board With this config: enable_uart=1 kernel=u-boot.bin [all] device_tree=bcm2711-rpi-4-b.dtb dtparam=spi=on dtoverlay=i2c0 dtoverlay=spi1-3cs dtoverlay=sc16is752-spi1,int_pin=25 dtoverlay=mcp2515,spi0-0,oscillator=16000000,interrupt=23 dtoverlay=mcp251xfd,spi0-1,interrupt=24 And both can interfaces won't show at the same time, not sure why When I comment out one of them the other show's up in the ifconfig Additionally, the mcp2515 works but the mcp251xfd fails with this: [ 52.157476] IPv6: ADDRCONF(NETDEV_CHANGE): can0: link becomes ready [ 52.167715] NOHZ tick-stop error: Non-RCU local softirq work is pending, handler #08!!! [ 53.040857] mcp251xfd spi0.1 can0: bus-off, scheduling restart in 100 ms [ 53.047739] NOHZ tick-stop error: Non-RCU local softirq work is pending, handler #08!!! [ 53.167475] IPv6: ADDRCONF(NETDEV_CHANGE): can0: link becomes ready [ 54.038527] mcp251xfd spi0.1 can0: bus-off, scheduling restart in 100 ms [ 54.045380] NOHZ tick-stop error: Non-RCU local softirq work is pending, handler #08!!! [ 54.164644] NOHZ tick-stop error: Non-RCU local softirq work is pending, handler #08!!! [ 54.177464] IPv6: ADDRCONF(NETDEV_CHANGE): can0: link becomes ready [ 55.038128] mcp251xfd spi0.1 can0: bus-off, scheduling restart in 100 ms [ 55.187477] IPv6: ADDRCONF(NETDEV_CHANGE): can0: link becomes ready [ 56.040062] mcp251xfd spi0.1 can0: bus-off, scheduling restart in 100 ms [ 56.197468] IPv6: ADDRCONF(NETDEV_CHANGE): can0: link becomes ready It's on Venus OS for RPI I'm lost and have no idea how to solves those 2 issues Thanks in advance!
Simon (1 rep)
Nov 26, 2024, 07:43 AM
2 votes
1 answers
519 views
systemd-networkd-wait-online failing with SocketCAN interface
I have configured a SocketCAN interface, `can0` (confirmed working using `can-utils`). I have the below `.network` config file, so that `systemd-networkd` brings up the interface on boot. ``` #/etc/systemd/network/80-can.network [Match] Name=can0 [CAN] BitRate=250K RestartSec=100ms [Link] Unmanaged=...
I have configured a SocketCAN interface, can0 (confirmed working using can-utils). I have the below .network config file, so that systemd-networkd brings up the interface on boot.
#/etc/systemd/network/80-can.network
[Match]
Name=can0

[CAN]
BitRate=250K
RestartSec=100ms

[Link]
Unmanaged=no
RequiredForOnline=yes
After a bootup, I can see that the interface is up (note UP flag set) with either
$ ip link show can0
5: can0:  mtu 16 qdisc pfifo_fast state UP mode DEFAULT group default qlen 65536
    link/can
or
$ ifconfig can0
can0: flags=193  mtu 16
        unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  txqueuelen 65536  (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
I want to run a oneshot service after systemd-networkd brings the network up. Some searching indicates that I should modify the systemd-networkd-wait-online service to pass the flag -i [interface], which I've done as
$ sudo systemctl edit systemd-networkd-wait-online
#/etc/systemd/system/systemd-networkd-wait-online.service.d/override.conf
[Service]
ExecStart=
ExecStart=/lib/systemd/systemd-networkd-wait-online -i can0 --timeout=5
In my custom service I use
[Unit]
...
After=systemd-networkd-wait-online.service
Requires=systemd-networkd-wait-online.service
However, the systemd-networkd-wait-online fails on boot, and when I run the command in isolation it fails after timing out:
$ /lib/systemd/systemd-networkd-wait-online -i can0 --timeout=5
Event loop failed: Connection timed out
For comparison, it succeeds "instantly" when passing -i eth0. So, question(s): 1. Does systemd-networkd-wait-online even work with a SocketCAN interface? 2. If it does, what am I doing wrong? or 3. If it doesn't, what would be a functional way to trigger a service at some point after systemd-networkd has brought the interface up?
Joshua Voskamp (153 rep)
Sep 7, 2022, 06:45 PM • Last activity: Sep 7, 2023, 07:47 AM
1 votes
1 answers
733 views
Getting a Waveshare CAN HAT working on a Banana Pi BPI-M2 Zero
Waveshare makes a great CAN HAT for the Raspberry Pi (see [here][1]), but the instructions only work for Raspberry Pi OS, not for Armbian. The Banana Pi BPI-M2 Zero has the same pin header layout as the Raspberry Pi, but runs Armbian. How do you setup the Waveshare CAN HAT using Armbian's overlay sy...
Waveshare makes a great CAN HAT for the Raspberry Pi (see here ), but the instructions only work for Raspberry Pi OS, not for Armbian. The Banana Pi BPI-M2 Zero has the same pin header layout as the Raspberry Pi, but runs Armbian. How do you setup the Waveshare CAN HAT using Armbian's overlay system?
johnnyb (101 rep)
Apr 10, 2023, 01:38 AM • Last activity: Aug 17, 2023, 08:13 PM
1 votes
0 answers
2677 views
How to verify CAN interfaces with Linux?
I want to verify the CAN interfaces on my embedded system. It has two can ports: `can0` and `can1`. I bring them both up with the following sequence: # ip link set can0 type can bitrate 1000000 dbitrate 2000000 fd on # ip link set can0 up # ip link set can1 type can bitrate 1000000 dbitrate 2000000...
I want to verify the CAN interfaces on my embedded system. It has two can ports: can0 and can1. I bring them both up with the following sequence: # ip link set can0 type can bitrate 1000000 dbitrate 2000000 fd on # ip link set can0 up # ip link set can1 type can bitrate 1000000 dbitrate 2000000 fd on # ip link set can1 up I hooked them up to each other (CANHCANH, CANLCANL & GNDGND) with termination resistors on each side after the trabnsceivers. Now when I want to send traffic out on can0 and dump rthe incoming traffic on can1. I started candump -c -a any while I invoke:
# cansend can0 01a#11223344AABBCCDD
But after this, I get a bunch of kernel errors that look like: [ 1506.337694] rcar_canfd 10050000.can can0: ch erfl 401 txerr 128 rxerr 0 [ 1506.337702] rcar_canfd 10050000.can can0: Bus error [ 1506.337707] rcar_canfd 10050000.can can0: ACK Error Appears like 128 stands for CAN_ERROR_PASSIVE_THRESHOLD which indicates that about which I read: > **Error Passive**: In this state, the CAN node is still able to transmit data, but it now raises 'Passive Error Flags' when detecting > errors. Further, the CAN node now has to wait for an extra 8 bits (aka > Suspend Transmission Time) in addition to the 3 bit intermission time > before it can resume data transmission (to allow other CAN nodes to > take control of the bus) source: https://www.csselectronics.com/pages/can-bus-errors-intro-tutorial#:~:text=A%20CAN%20node%20enters%20the,if%20the%20TEC%20exceeds%20255 There's nothing showing with candump, though. The above messages show up in dmesg. But I still can see data on the CAN lines (with a scope). What do the errors mean, how can I address them and how can I actually see data with candump?
MisdeBug (43 rep)
Jun 23, 2023, 02:35 PM • Last activity: Jun 23, 2023, 07:11 PM
0 votes
1 answers
655 views
information regarding can, can-dev kernel modules on Debian GNU/Linux 10 (buster) Linux 4.19.94-ti-r42
I seem to be missing a couple of kernel modules. Specifically, `can` and `can_dev`. The modules don't load when I run `modprobe can` or `modprobe can-dev`. The reason for this I believe is because the modules are not in the directory ```lang-shellsession [/lib/modules/4.19.94-ti-r42/kernel/drivers/n...
I seem to be missing a couple of kernel modules. Specifically, can and can_dev. The modules don't load when I run modprobe can or modprobe can-dev. The reason for this I believe is because the modules are not in the directory
-shellsession
[/lib/modules/4.19.94-ti-r42/kernel/drivers/net/can]$ ls
slcan.ko.xz  spi  usb  vcan.ko.xz
The only loaded CAN module is can_raw, which seems to work fine with SocketCAN. My problem is that I am trying to use [ValueCAN](https://intrepidcs.com/socketcan-vcan4/) which depends on the 2 modules. I tried downloading the kernel and when I ran menuconfig, I don't see the CAN modules. I have no idea how to proceed. The following is menuconfig selections.
--- CAN bus subsystem support   

        Raw CAN Protocol (raw access with CAN-ID filtering) 
         Broadcast Manager CAN Protocol (with content filtering)
         CAN Gateway/Router (with netlink configuration)      
            CAN Device Drivers  --->
    
       Virtual Local CAN Interface (vcan)                        
       Virtual CAN Tunnel (vxcan)                             
       Serial / USB serial CAN Adaptors (slcan)               
       Platform CAN drivers with Netlink support              
      [*]   CAN bit-timing calculation (NEW)                     
         Support for Freescale FLEXCAN based chips (NEW)      
         Aeroflex Gaisler GRCAN and GRHCAN CAN devices (NEW)  
         TI High End CAN Controller (NEW)                     
         Bosch C_CAN/D_CAN devices (NEW)  ----                
         Bosch CC770 and Intel AN82527 devices (NEW)  ----
         IFI CAN_FD IP (NEW)                                  
         Bosch M_CAN devices (NEW)                            
         Renesas R-Car CAN controller (NEW)                   
         Renesas R-Car CAN FD controller (NEW)                
         Philips/NXP SJA1000 devices (NEW)  ----              
         Softing Gmbh CAN generic support (NEW)               
            CAN SPI interfaces  --->                             
            CAN USB interfaces  --->                             
            [ ] CAN devices debugging messages (NEW)
HPVoxx (1 rep)
Mar 27, 2023, 12:02 PM • Last activity: Mar 30, 2023, 02:20 PM
0 votes
0 answers
40 views
CANbus adapter stuff in 11-bit mode
I have a PEAK canbus adapter (USB) connected to my Linux box, access from Qt C++ program. While all works well, when I receive frames they are all SFF (11-bit) ID's. candumps are all 11-bit ID's. Even if I send EFF (29-bit) frames, it only shows incoming frames in SFF. The same happens if I use cand...
I have a PEAK canbus adapter (USB) connected to my Linux box, access from Qt C++ program. While all works well, when I receive frames they are all SFF (11-bit) ID's. candumps are all 11-bit ID's. Even if I send EFF (29-bit) frames, it only shows incoming frames in SFF. The same happens if I use candump, all frames show SFF ID's. However, after I switched my laptop to Windows and ran PEAK viewer, and then back to Linux, suddenly my frames were all showing in EFF in candump. Is there something I need to set (in Linux/ip command/qt c++) to force the adapter to use EFF mode?
TSG (1983 rep)
Mar 11, 2023, 02:35 AM
1 votes
1 answers
813 views
Consistent / persistent network connection naming, like udev
I have multiple similar USB network devices, in this case CAN (can0 and can1) connections to different networks but I figure it is a similar problem with multiple other networks (eg WiFi, Ethernet etc). These currently show as can0 and can1 and I may connect more. I am trying to maintain some sort o...
I have multiple similar USB network devices, in this case CAN (can0 and can1) connections to different networks but I figure it is a similar problem with multiple other networks (eg WiFi, Ethernet etc). These currently show as can0 and can1 and I may connect more. I am trying to maintain some sort of persistency in the locations for access to each. For non-network devices using udev allows custom symlinks to be referenced to the idVendor, idProduct, and serial numbers so I can ensure the correct code accesses the correct device. How can à similar persistency be achieved for divices under ifconfig? I have the IDs and serial details for each ready to reference I don't want device x to always be can0 and device y to always be can1. As there might only be one device which I think would need to be can0. But if they are plugged in differently or started in a different order then I want to check that can0 is device x or y and run the correct code, or if not run the alternative. I figured this is the better approach than the udev logic but can't seem to find out the methodology Hoping for some pointers on this one. TIA
ShaunMc (13 rep)
Nov 25, 2022, 11:35 AM • Last activity: Feb 14, 2023, 09:18 AM
1 votes
1 answers
3137 views
Clear socket buffer of CAN adapter
I have a USB/CAN adapter, from `lsusb`: > OpenMoko, Inc. Geschwister Schneider CAN adapter it provides a socket interface, from `ip addr`: 5: can0: mtu 16 qdisc pfifo_fast state UP group default qlen 10 link/can On the bus there are other devices that sends data continuously. If I reboot my PC, I ca...
I have a USB/CAN adapter, from lsusb: > OpenMoko, Inc. Geschwister Schneider CAN adapter it provides a socket interface, from ip addr: 5: can0: mtu 16 qdisc pfifo_fast state UP group default qlen 10 link/can On the bus there are other devices that sends data continuously. If I reboot my PC, I cannot send/receive data anymore, because I get the following error: > No buffer space available I guess that while the device is "disconnected" from the PC (because it's rebooting, but still powered) the internal buffers fill up. Is there a command I can issue to clear the buffers?
Mark (815 rep)
Mar 18, 2022, 10:30 AM • Last activity: Jul 15, 2022, 06:38 PM
1 votes
0 answers
277 views
Virtualbox Linux Adding SocketCAN Interface
Does anyone have experience using SocketCAN within Virtualbox? I'm using Xubuntu. I started by modprobing can, can_raw, can_dev and the relevant driver for the particular can module I'm using. In addition, I directed Virtualbox to pass through the CAN-USB device that I wanted to interface with. When...
Does anyone have experience using SocketCAN within Virtualbox? I'm using Xubuntu. I started by modprobing can, can_raw, can_dev and the relevant driver for the particular can module I'm using. In addition, I directed Virtualbox to pass through the CAN-USB device that I wanted to interface with. When I ran the command sudo ip link set can0 type can bitrate [bitrate], I got: Cannot find device 'can0'. I checked /dev, and I didn't find anything CAN related. I ran sudo dmesg | grep 'usb', and it looks like it is registered as a usb device, but not a CAN device. Does anyone have any experience with SocketCAN? Is there some way to direct Linux to use a certain USB as a CAN socket?
Dan (11 rep)
May 18, 2022, 05:12 PM • Last activity: May 20, 2022, 11:13 AM
0 votes
1 answers
377 views
Unable to bring up the CANbus interface on a Beaglebone black
To automatically bring up the interface on boot, I edited the `/etc/network/interfaces` file as follows: `debian@beaglebone:~$ sudo nano /etc/network/interfaces` And added the following at the end of the file: ```console auto can1 iface can1 inet manual pre-up /sbin/ip link set can1 type can bitrate...
To automatically bring up the interface on boot, I edited the /etc/network/interfaces file as follows: debian@beaglebone:~$ sudo nano /etc/network/interfaces And added the following at the end of the file:
auto can1
iface can1 inet manual
    pre-up /sbin/ip link set can1 type can bitrate 250000 #triple-sampling on restart-ms 100
    up /sbin/ifconfig can1 up
    down /sbin/ifconfig can1 down
But when I reboot, I still need to do $ sudo /sbin/ip link set can1 up type can bitrate 250000 in order for the $ candump can1 to work. What should I do? [UPDATE] In case it makes a difference, here is my whole /etc/network/interfaces/`
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
#auto eth0
#iface eth0 inet dhcp
# Example to keep MAC address between reboots
#hwaddress ether DE:AD:BE:EF:CA:FE

##connman: ethX static config
#connmanctl services
#Using the appropriate ethernet service, tell connman to setup a static IP address for that service:
#sudo connmanctl config  --ipv4 manual    --nameservers 

##connman: WiFi
#
#connmanctl
#connmanctl> tether wifi off
#connmanctl> enable wifi
#connmanctl> scan wifi
#connmanctl> services
#connmanctl> agent on
#connmanctl> connect wifi_*_managed_psk
#connmanctl> quit

console


auto can1
iface can1 inet manual
    pre-up /sbin/ip link set can1 type can bitrate 250000
    up /sbin/ifconfig can1 up
    down /sbin/ifconfig can1 down
[UPDATE] My /boot/uEnv.txt
#Docs: http://elinux.org/Beagleboard:U-boot_partitioning_layout_2.0 

uname_r=4.14.108-ti-r131
#uuid=
#dtb=am335x-boneblack-emmc-overlay.dtb

###U-Boot Overlays###
###Documentation: http://elinux.org/Beagleboard:BeagleBoneBlack_Debian#U-Boot_Overlays 
###Master Enable
enable_uboot_overlays=1
###
###Overide capes with eeprom
#uboot_overlay_addr0=/lib/firmware/BB-UART1-00A0.dtbo
uboot_overlay_addr1=/lib/firmware/BB-UART2-00A0.dtbo
#uboot_overlay_addr2=/lib/firmware/BB-UART4-RS485-00A0.dtbo
#uboot_overlay_addr3=/lib/firmware/BB-UART5-00A0.dtbo
###
###Custom Cape
#dtb_overlay=/lib/firmware/.dtbo
###
###Disable auto loading of virtual capes (emmc/video/wireless/adc)
disable_uboot_overlay_emmc=1
disable_uboot_overlay_video=1
disable_uboot_overlay_audio=1
disable_uboot_overlay_wireless=1
disable_uboot_overlay_adc=1
###
###PRUSS OPTIONS
###pru_rproc (4.14.x-ti kernel)
uboot_overlay_pru=/lib/firmware/AM335X-PRU-RPROC-4-14-TI-00A0.dtbo
###pru_rproc (4.19.x-ti kernel)
#uboot_overlay_pru=/lib/firmware/AM335X-PRU-RPROC-4-19-TI-00A0.dtbo
###pru_uio (4.14.x-ti, 4.19.x-ti & mainline/bone kernel)
#uboot_overlay_pru=/lib/firmware/AM335X-PRU-UIO-00A0.dtbo
###
###Cape Universal Enable
enable_uboot_cape_universal=1
###
###Debug: disable uboot autoload of Cape
#disable_uboot_overlay_addr0=1
#disable_uboot_overlay_addr1=1
#disable_uboot_overlay_addr2=1
#disable_uboot_overlay_addr3=1
###
###U-Boot fdt tweaks... (60000 = 384KB)
#uboot_fdt_buffer=0x60000
###U-Boot Overlays###

cmdline=coherent_pool=1M net.ifnames=0 lpj=1990656 rng_core.default_quality=100 quiet

#In the event of edid real failures, uncomment this next line:
#cmdline=coherent_pool=1M net.ifnames=0 lpj=1990656 rng_core.default_quality=100 quiet video=HDMI-A-1:1024x768@60e

##enable Generic eMMC Flasher:
##make sure, these tools are installed: dosfstools rsync
#cmdline=init=/opt/scripts/tools/eMMC/init-eMMC-flasher-v3.sh
Stéphane de Luca (173 rep)
Apr 8, 2022, 07:36 AM • Last activity: Apr 8, 2022, 08:50 AM
1 votes
1 answers
731 views
On a system, can two CAN ports have the same CAN-ids?
If a device with two CAN ports have the same CAN-id, will this cause trouble? The networks are separated for some reason, but the "master" should be the same for both networks. Edit: Below the network topology. ``` ("master") CAN-BUS 0 +----------+ +----------+ |------->| CAN-ID 2 | | | | CAN-ID 3 |...
If a device with two CAN ports have the same CAN-id, will this cause trouble? The networks are separated for some reason, but the "master" should be the same for both networks. Edit: Below the network topology.
("master")   CAN-BUS 0     +----------+
+----------+       |------->| CAN-ID 2 |
|          || CAN-ID 3 |
              CAN-BUS 1     +----------+
As what I now understand is that the CAN-id is set in software. If I play around with ifconfig you can not set the CAN-id. Instead, this is set when I want to generate CAN traffic through cangen:
CANID=1
ip link set can0 type can bitrate 125000
ip link set up can0
cangen can0 -I $CANID -L 8 -v
Bayou (175 rep)
Mar 8, 2022, 12:28 PM • Last activity: Mar 9, 2022, 02:49 PM
0 votes
0 answers
508 views
MCP251x driver missing
I'm trying to install the `mcp251x` driver on a Linux system with kernel 4.9.253-tegra and I used the command: # modprobe mcp251x I checked with the command # dmesg | grep mcp251x but it doesn't show anything. The driver exists in the folder, `` /lib/modules/4.9.253-tegra/kernel/drivers/net/can/spi/...
I'm trying to install the mcp251x driver on a Linux system with kernel 4.9.253-tegra and I used the command: # modprobe mcp251x I checked with the command # dmesg | grep mcp251x but it doesn't show anything. The driver exists in the folder, `` /lib/modules/4.9.253-tegra/kernel/drivers/net/can/spi/mcp251x.ko `` and even then it doesn't load. How to install this driver correctly in this kernel version? To edit: 1. I use jetson kernel 4.9.253-tegra 2. I insert mcp251x with modprobe. lsmod output show vcan 3597 0 can 46600 0 mcp251x 13742 0 can_dev 13592 1 mcp251x fuse 104554 3 xt_conntrack 3609 1 ipt_MASQUERADE 2346 1 nf_nat_masquerade_ipv4 3111 1 ipt_MASQUERADE nf_conntrack_netlink 29413 0 nfnetlink 7959 2 nf_conntrack_netlink xt_addrtype 3670 2 iptable_filter 2481 1 iptable_nat 2882 1 nf_conntrack_ipv4 11992 2 nf_defrag_ipv4 1836 1 nf_conntrack_ipv4 nf_nat_ipv4 6712 1 iptable_nat nf_nat 20406 2 nf_nat_masquerade_ipv4,nf_nat_ipv4 nf_conntrack 106659 6 nf_conntrack_ipv4,nf_conntrack_netlink,nf_nat_masquerade_ipv4,xt_conntrack,nf_nat_ipv4,nf_nat br_netfilter 16216 0 zram 25920 4 overlay 48718 0 userspace_alert 5828 0 nvgpu 1589200 13 ip_tables 19441 2 iptable_filter,iptable_nat x_tables 28951 5 ip_tables,iptable_filter,ipt_MASQUERADE,xt_addrtype,xt_conntrack 3. the command dmesg | grep -i mcp dont show nothing.
albert (101 rep)
Nov 13, 2021, 05:31 AM • Last activity: Nov 16, 2021, 12:13 AM
1 votes
1 answers
971 views
Udev rule to connect USB to CAN Lawicell
I am using a Lawicel CAN adapter to connect to a sensor, and would like to setup a udev rule to avoid the manual can setup. The manual can setup: ```bash sudo slcand -o -c -f -s6 /dev/ttyUSB0 slcan0 sudo ifconfig slcan0 up ``` Running `candump slcan0` shows, by printing data, that the connection wor...
I am using a Lawicel CAN adapter to connect to a sensor, and would like to setup a udev rule to avoid the manual can setup. The manual can setup:
sudo slcand -o -c -f -s6 /dev/ttyUSB0 slcan0
sudo ifconfig slcan0 up
Running candump slcan0 shows, by printing data, that the connection works. I am thus following a guide to setting up the udev rule from [link](http://pascal-walter.blogspot.com/2015/08/installing-lawicel-canusb-on-linux.html) . But this doesn't work. The udev rule is
# Lawicel CANUSB module
ACTION=="add", ENV{ID_MODEL}=="CANUSB", ENV{SUBSYSTEM}=="tty", RUN+="/usr/bin/logger [udev] Lawicel CANUSB detected - running slcan_add.sh!", RUN+="/usr/local/bin/slcan_add.sh $kernel"
ACTION=="remove", ENV{ID_MODEL}=="CANUSB", ENV{SUBSYSTEM}=="usb", RUN+="/usr/bin/logger [udev] Lawicel CANUSB removed - running slcan_remove.sh!", RUN+="/usr/local/bin/slcan_remove.sh"
and the slcan_add.sh script is
#!/bin/sh
# Bind the USBCAN device
slcand -o -c -f -s6 /dev/$1 slcan0
sleep 2
ifconfig slcan0 up
then I reload the rules and restart udev, and tail -f /var/log/syslog returns the following
morten@thinkpad:~$ tail -f /var/log/syslog
Oct  7 10:56:21 thinkpad kernel: [ 1580.917239] usb 1-1: Detected FT232RL
Oct  7 10:56:21 thinkpad kernel: [ 1580.918002] usb 1-1: FTDI USB Serial Device converter now attached to ttyUSB0
Oct  7 10:56:21 thinkpad mtp-probe: checking bus 1, device 10: "/sys/devices/pci0000:00/0000:00:14.0/usb1/1-1"
Oct  7 10:56:21 thinkpad mtp-probe: bus: 1, device: 10 was not an MTP device
Oct  7 10:56:21 thinkpad root: [udev] Lawicel CANUSB detected - running slcan_add.sh!
Oct  7 10:56:21 thinkpad slcand: starting on TTY device /dev/ttyUSB0
Oct  7 10:56:21 thinkpad slcand: attached TTY /dev/ttyUSB0 to netdevice slcan0
Oct  7 10:56:21 thinkpad slcand: netdevice slcan0 renamed to slcan0
Oct  7 10:56:21 thinkpad NetworkManager:   [1633596981.6497] manager: (slcan0): new Generic device (/org/freedesktop/NetworkManager/Devices/8)
Oct  7 10:56:21 thinkpad systemd-udevd: ethtool: autonegotiation is unset or enabled, the speed and duplex are not writable.
Oct  7 10:56:23 thinkpad snapd: hotplug.go:199: hotplug device add event ignored, enable experimental.hotplug
Oct  7 10:56:23 thinkpad mtp-probe: checking bus 1, device 10: "/sys/devices/pci0000:00/0000:00:14.0/usb1/1-1"
Oct  7 10:56:23 thinkpad mtp-probe: bus: 1, device: 10 was not an MTP device
Oct  7 10:56:26 thinkpad ModemManager:   [base-manager] couldn't check support for device '/sys/devices/pci0000:00/0000:00:14.0/usb1/1-1': not supported by any plugin
Oct  7 10:56:27 thinkpad gnome-shell: Removing a network device that was not added
Oct  7 10:56:27 thinkpad gnome-shell: Removing a network device that was not added
and candump slcan0 returns SIOCGIFINDEX: No such device. How should I fix this? **NOTE**: Using ubuntu 20.04. **EDIT**: The udev rule properly recognizes the device and runs the script, so the udev rule should work I figure. If I manually set the usb port and run the shell script with sudo ./sclan_add.sh then it also works, displaying the following in tail -f /var/log/syslog
Oct  7 12:53:26 agrirobot slcand: starting on TTY device /dev/ttyUSB0
Oct  7 12:53:26 agrirobot slcand: attached TTY /dev/ttyUSB0 to netdevice slcan0
Oct  7 12:53:26 agrirobot slcand: netdevice slcan0 renamed to slcan0
Oct  7 12:53:26 agrirobot NetworkManager:   [1633604006.8360] manager: (slcan0): new Generic device (/org/freedesktop/NetworkManager/Devices/22)
Oct  7 12:53:26 agrirobot systemd-udevd: ethtool: autonegotiation is unset or enabled, the speed and duplex are not writable.
I can't really see what the problem is with the udev rule calling the shell script, but for some reason this makes the difference.
Morten Nissov (130 rep)
Oct 7, 2021, 08:59 AM • Last activity: Oct 25, 2021, 01:30 PM
Showing page 1 of 14 total questions