how to check if can0 is up
Hi
I want to test the status of can0 on a BeagleBoneBlack with serial-can cape from Logic Supply.
The interface is initialized with
ip link set can0 type can bitrate 250000
ifconfig can0 up
I have tried
cat /sys/class/net/can0/operstate
but this does not work correctly
if can0 is down, I get "down"
if can0 is up , I get "unknown"
ifconfig says:
can0 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
UP RUNNING NOARP MTU:16 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:10
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B) Interrupt:55
help appreciated
Victor
Hi Victor,
Quoted 6 lines · vklein
I want to test the status of can0 on a BeagleBoneBlack with serial-can cape from Logic Supply.
The interface is initialized with
ip link set can0 type can bitrate 250000
ifconfig can0 up
Good.
Quoted 7 lines
I have tried
cat/sys/class/net/can0/operstate
but this does not work correctlyif can0 is down, I get "down"
if can0 is up , I get "unknown"
The question is whether operstate is always set correctly ...
Quoted 10 lines
ifconfig says:
can0 Link encap:UNSPEC HWaddr
00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
UP RUNNING NOARP MTU:16 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:10
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B) Interrupt:55
What does
ip -det link show can0
tell you?
Using the 'ip' tool is recommended to get the device state.
Maybe the setting of the operstate in sysfs has to be fixed ?!?
Regards,
Oliver
Hey,
--- Original message ---
Quoted 32 lines · vklein
Quoted 7 lines
I want to test the status of can0 on a BeagleBoneBlack with serial-can cape from Logic Supply.
The interface is initialized with
ip link set can0 type can bitrate 250000
ifconfig can0 upGood.
Quoted 7 lines
I have tried
cat/sys/class/net/can0/operstate
but this does not work correctlyif can0 is down, I get "down"
if can0 is up , I get "unknown"
The question is whether operstate is always set correctly ...
Quoted 10 lines
ifconfig says:
can0 Link encap:UNSPEC HWaddr
00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
UP RUNNING NOARP MTU:16 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:10
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B) Interrupt:55
Quoted 7 lines
What does
ip -det link show can0
tell you?
Using the 'ip' tool is recommended to get the device state.
I agree that 'ip' is the recommended way.
ip is an interactive tool.
To access it from c code, I wrote myself a library with example code:
https://github.com/kurt-vd/enumif
regards,
Kurt
Am 07.05.2015 um 09:59 schrieb Kurt Van Dijck:
Quoted 39 lines
Hey,
--- Original message ---
Quoted 29 lines · vklein
Quoted 7 lines
I want to test the status of can0 on a BeagleBoneBlack with serial-can cape from Logic Supply.
The interface is initialized with
ip link set can0 type can bitrate 250000
ifconfig can0 upGood.
Quoted 7 lines
I have tried
cat/sys/class/net/can0/operstate
but this does not work correctlyif can0 is down, I get "down"
if can0 is up , I get "unknown"
The question is whether operstate is always set correctly ...
Quoted 10 lines
ifconfig says:
can0 Link encap:UNSPEC HWaddr
00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
UP RUNNING NOARP MTU:16 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:10
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B) Interrupt:55Quoted 7 lines
What does
ip -det link show can0
tell you?
Using the 'ip' tool is recommended to get the device state.
Quoted 8 lines
I agree that 'ip' is the recommended way.
ip is an interactive tool.
To access it from c code, I wrote myself a library with example code:https://github.com/kurt-vd/enumif
regards,
Kurt
ip -det link show can0 | grep UP
works for me
Victor