linux-can.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* how to check if can0 is up
@ 2015-05-04 19:10 vklein
  2015-05-06 15:28 ` Oliver Hartkopp
  0 siblings, 1 reply; 4+ messages in thread
From: vklein @ 2015-05-04 19:10 UTC (permalink / raw)
  To: linux-can

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: how to check if can0 is up
  2015-05-04 19:10 how to check if can0 is up vklein
@ 2015-05-06 15:28 ` Oliver Hartkopp
  2015-05-07  7:59   ` Kurt Van Dijck
  0 siblings, 1 reply; 4+ messages in thread
From: Oliver Hartkopp @ 2015-05-06 15:28 UTC (permalink / raw)
  To: vklein, linux-can

Hi Victor,

On 05/04/2015 09:10 PM, vklein wrote:

> 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.

> 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"

The question is whether operstate is always set correctly ...

> 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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: how to check if can0 is up
  2015-05-06 15:28 ` Oliver Hartkopp
@ 2015-05-07  7:59   ` Kurt Van Dijck
  2015-05-07 11:44     ` vklein
  0 siblings, 1 reply; 4+ messages in thread
From: Kurt Van Dijck @ 2015-05-07  7:59 UTC (permalink / raw)
  To: vklein; +Cc: Oliver Hartkopp, linux-can

Hey,

--- Original message ---
> On 05/04/2015 09:10 PM, vklein wrote:
> 
> > 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.
> 
> > 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"
> 
> The question is whether operstate is always set correctly ...
> 
> > 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.

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: how to check if can0 is up
  2015-05-07  7:59   ` Kurt Van Dijck
@ 2015-05-07 11:44     ` vklein
  0 siblings, 0 replies; 4+ messages in thread
From: vklein @ 2015-05-07 11:44 UTC (permalink / raw)
  To: Oliver Hartkopp, linux-can

Am 07.05.2015 um 09:59 schrieb Kurt Van Dijck:
> Hey,
>
> --- Original message ---
>> On 05/04/2015 09:10 PM, vklein wrote:
>>
>>> 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.
>>
>>> 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"
>> The question is whether operstate is always set correctly ...
>>
>>> 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.
> 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






^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-05-07 11:44 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-05-04 19:10 how to check if can0 is up vklein
2015-05-06 15:28 ` Oliver Hartkopp
2015-05-07  7:59   ` Kurt Van Dijck
2015-05-07 11:44     ` vklein

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).