systeminformation icon indicating copy to clipboard operation
systeminformation copied to clipboard

Canbus interfaces

Open rhysmorgan134 opened this issue 2 years ago • 3 comments

Hi,

Great project all! I was hoping to use this to get a list of canbus interfaces that are present on a machine that's running socketcan. These interfaces are listed under ifconfig so I would have thought the logical place for them to sit would be under network interfaces. Is this likely to be a possibility?

Thanks

Rhys

rhysmorgan134 avatar Jan 09 '23 22:01 rhysmorgan134

@rhysmorgan134 can you provide an output of what ifconfig then returns ... as I do not have can bus interfaces here ...? Thank you in advance...

sebhildebrandt avatar Jan 10 '23 08:01 sebhildebrandt

Sorry I should of included that, output of ifconfig below

ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.16.155.129  netmask 255.255.255.0  broadcast 172.16.155.255
        inet6 fe80::c7c3:938:22c4:6b41  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:4c:43:78  txqueuelen 1000  (Ethernet)
        RX packets 667930  bytes 981224811 (981.2 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 47951  bytes 5095350 (5.0 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 2745  bytes 1231219 (1.2 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 2745  bytes 1231219 (1.2 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

vcan0: flags=193<UP,RUNNING,NOARP>  mtu 72
        unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  txqueuelen 1000  (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

Also ip a returns

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 00:0c:29:4c:43:78 brd ff:ff:ff:ff:ff:ff
    altname enp2s1
    inet 172.16.155.129/24 brd 172.16.155.255 scope global dynamic noprefixroute ens33
       valid_lft 1639sec preferred_lft 1639sec
    inet6 fe80::c7c3:938:22c4:6b41/64 scope link noprefixroute 
       valid_lft forever preferred_lft forever
3: vcan0: <NOARP,UP,LOWER_UP> mtu 72 qdisc noqueue state UNKNOWN group default qlen 1000
    link/can 

If can-utils is installed then a virtual canbus can be created using the below

sudo modprobe vcan
sudo ip link add dev vcan0 type vcan
sudo ip link set up vcan0

rhysmorgan134 avatar Jan 10 '23 18:01 rhysmorgan134

@rhysmorgan134 THANK YOU! This helps a lot. Will think of an implementation for that!

sebhildebrandt avatar Jan 10 '23 19:01 sebhildebrandt