All of lore.kernel.org
 help / color / mirror / Atom feed
From: vklein <vk4514@arcor.de>
To: Oliver Hartkopp <socketcan@hartkopp.net>, linux-can@vger.kernel.org
Subject: Re: how to check if can0 is up
Date: Thu, 07 May 2015 13:44:37 +0200	[thread overview]
Message-ID: <554B5025.60600@arcor.de> (raw)
In-Reply-To: <20150507075947.GA14142@vandijck-laurijssen.be>

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






      reply	other threads:[~2015-05-07 11:44 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=554B5025.60600@arcor.de \
    --to=vk4514@arcor.de \
    --cc=linux-can@vger.kernel.org \
    --cc=socketcan@hartkopp.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.