Linux CAN drivers development
 help / color / mirror / Atom feed
* SocketCAN device enumeration API
@ 2016-08-09 11:06 André Hartmann
  2016-08-09 12:33 ` Mirza Krak
  2016-08-09 14:04 ` Kurt Van Dijck
  0 siblings, 2 replies; 6+ messages in thread
From: André Hartmann @ 2016-08-09 11:06 UTC (permalink / raw)
  To: linux-can

Hello all,

I'm one of the developers working on the new QtSerialBus module [0], [1]
which encapsulates different CAN hardware drivers (including SocketCAN) 
in a C++ API.

For a new hardware enumerating function, I'd like to do the following:

* Enumerate the currently available (i.e. ready to use)
   SocketCAN devices
* Get hardware information/manufacturer/bus type for a device
* Find out if a device is virtual
* Find out if a device is CAN FD capable

Is there already a possibility to do this from a C/C++ program?
Some information can be parsed from the ip command output, but I'd 
rather use a real API.

If not already possible, could such functionality be added to SocketCAN?

Thanks in advance!

Best regards,
Andre

[0] http://doc.qt.io/qt-5/qtserialbus-index.html
[1] https://code.qt.io/qt/qtserialbus.git

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

* Re: SocketCAN device enumeration API
  2016-08-09 11:06 SocketCAN device enumeration API André Hartmann
@ 2016-08-09 12:33 ` Mirza Krak
  2016-08-09 14:04 ` Kurt Van Dijck
  1 sibling, 0 replies; 6+ messages in thread
From: Mirza Krak @ 2016-08-09 12:33 UTC (permalink / raw)
  To: André Hartmann; +Cc: linux-can@vger.kernel.org

2016-08-09 13:06 GMT+02:00 André Hartmann <aha_1980@gmx.de>:
> Hello all,
>
> I'm one of the developers working on the new QtSerialBus module [0], [1]
> which encapsulates different CAN hardware drivers (including SocketCAN) in a
> C++ API.

Interesting. As a Qt user/developer I have wondered why this kind of
module has not existed earlier :).

>
> For a new hardware enumerating function, I'd like to do the following:
>
> * Enumerate the currently available (i.e. ready to use)
>   SocketCAN devices
> * Get hardware information/manufacturer/bus type for a device
> * Find out if a device is virtual
> * Find out if a device is CAN FD capable
>
> Is there already a possibility to do this from a C/C++ program?
> Some information can be parsed from the ip command output, but I'd rather
> use a real API.

Most of it could probably be done from C/C++.

Some of this has been discussed earlier. Did some digging and found
[1]. There might all ready be something similar in Qt, see [2], which
could probably partially work since SocketCAN devices are exposed as
network devices.

Other good resources could be libsocketcan [3] which uses netlink to
configure and retrieve information about the devices.

Best Regards
Mirza

[1]. https://marc.info/?l=linux-can&m=142757462432402&w=2
[3]. http://doc.qt.io/qt-4.8/qnetworkinterface.html#QNetworkInterface
[3]. http://www.pengutronix.de/software/libsocketcan/download/

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

* Re: SocketCAN device enumeration API
  2016-08-09 11:06 SocketCAN device enumeration API André Hartmann
  2016-08-09 12:33 ` Mirza Krak
@ 2016-08-09 14:04 ` Kurt Van Dijck
  2016-08-11  8:36   ` André Hartmann
  1 sibling, 1 reply; 6+ messages in thread
From: Kurt Van Dijck @ 2016-08-09 14:04 UTC (permalink / raw)
  To: André Hartmann; +Cc: linux-can


--- Original message ---
> Date:	Tue, 9 Aug 2016 13:06:39 +0200
> From: André Hartmann <aha_1980@gmx.de>
> To: linux-can@vger.kernel.org
> Subject: SocketCAN device enumeration API
> User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
>  Thunderbird/45.2.0
> 
> Hello all,
> 
> I'm one of the developers working on the new QtSerialBus module [0], [1]
> which encapsulates different CAN hardware drivers (including SocketCAN) in a
> C++ API.
> 
> For a new hardware enumerating function, I'd like to do the following:
> 
> * Enumerate the currently available (i.e. ready to use)
>   SocketCAN devices

I did write myself an enumif() function (abstracted in libenumif)
that you can find on http://github.com/kurt-vd/enumif
You can easily enumerate only CAN interfaces, by hiding non-CAN
interfaces.

> * Get hardware information/manufacturer/bus type for a device
> * Find out if a device is virtual
> * Find out if a device is CAN FD capable

This is IMHO best done using libsocketcan.

Kind regards,
Kurt

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

* Re: SocketCAN device enumeration API
  2016-08-09 14:04 ` Kurt Van Dijck
@ 2016-08-11  8:36   ` André Hartmann
  2016-08-11 10:05     ` Kurt Van Dijck
  0 siblings, 1 reply; 6+ messages in thread
From: André Hartmann @ 2016-08-11  8:36 UTC (permalink / raw)
  To: linux-can; +Cc: Kurt Van Dijck, Mirza Krak

Hello Kurt and Mirza,

thanks for your pointers, I did already did search time, but haven't 
found much useful.

Kurt, your library does exactly what I need. I was impressed (and a bit 
shocked), how much code is necessary to do this work. I think (parts of) 
your library would also make a good extension to libsocketcan, as it 
seems I'm not the only one asking, so there is definitely a need for 
this function.

However, the only possiblity I see for me now, would be to ship a copy 
of libenumif along with Qt and to integrate it into Qt's build system 
for cross-platform builds.

Thats where my problems begin. I neither know about the technical, nor 
the legal possibilities to do so :(

The other possiblility according to Mirza's links seems to parse 
/sys/class/net/ - I will give this a try too.

QNetworkInterface gives me a list of interfaces, but has the same 
problems like a simple getifaddrs(), you cannot find out if an interface 
is of type CAN.

I also found this extension to libsocketcan:

https://github.com/ajneu/libsocketcan/commit/26ef

Is there any chance that this extension can be merged upstream? It 
contains the can_get_typekind function to query whether an interface is 
virtual or not.

Best regards,
Andre


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

* Re: SocketCAN device enumeration API
  2016-08-11  8:36   ` André Hartmann
@ 2016-08-11 10:05     ` Kurt Van Dijck
  2016-08-11 10:31       ` André Hartmann
  0 siblings, 1 reply; 6+ messages in thread
From: Kurt Van Dijck @ 2016-08-11 10:05 UTC (permalink / raw)
  To: André Hartmann; +Cc: linux-can, Mirza Krak

> Hello Kurt and Mirza,
> 
> thanks for your pointers, I did already did search time, but haven't found
> much useful.
> 
> Kurt, your library does exactly what I need. I was impressed (and a bit
> shocked), how much code is necessary to do this work.

I too think netlink was as such not designed to be an end-user
interface, but a generic mechanism to create libraries like
libsocketcan, of libenumif.

> I think (parts of)
> your library would also make a good extension to libsocketcan, as it seems
> I'm not the only one asking, so there is definitely a need for this
> function.

Well, libsocketcan could copy part of the code for easy CAN enumeration.
libenumif is not really restricted to CAN, or any other type.

> 
> However, the only possiblity I see for me now, would be to ship a copy of
> libenumif along with Qt and to integrate it into Qt's build system for
> cross-platform builds.

When you ship libenumif along with QT, doesn't that imply that it should
stay out of QT.
Or did you mean to ship libenumif as shared object along with QT's
shared objects?

> 
> Thats where my problems begin. I neither know about the technical, nor the
> legal possibilities to do so :(

QT is not my technical competence.
Legally, libenumif is shipped with LGPLv3. I don't see a problem
shipping it. LGPL allows to use the library (as shared object) from
non-GPL code AFAIK.

Kurt

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

* Re: SocketCAN device enumeration API
  2016-08-11 10:05     ` Kurt Van Dijck
@ 2016-08-11 10:31       ` André Hartmann
  0 siblings, 0 replies; 6+ messages in thread
From: André Hartmann @ 2016-08-11 10:31 UTC (permalink / raw)
  To: linux-can; +Cc: Mirza Krak, Kurt Van Dijck

Hi Kurt,

 > When you ship libenumif along with QT, doesn't that imply that it
 > should stay out of QT.
 > Or did you mean to ship libenumif as shared object along with QT's
 > shared objects?

I don't know how this is handled in general in the Qt project, I'm just 
an external contributor. I just know, that they have the source of some 
libraries included in 3rdparty subdirs. That code is build together with 
Qt for all supported platforms (Linux specific code is not compiled for 
Windows). I guess, the generated shared object files are then 
distributed along with Qt.

I assume the libraries source code needs to be copied into Qt's source 
tree, as otherwise lots of builds will break because of unsatisfied 
dependencies. Introducing more compile dependencies is a no-go I guess.

So I will have to ask the Qt developer mailing list how to proceed.

Best regards and thanks for your great work!

Andre

Am 11.08.2016 um 12:05 schrieb Kurt Van Dijck:
>> Hello Kurt and Mirza,
>>
>> thanks for your pointers, I did already did search time, but haven't found
>> much useful.
>>
>> Kurt, your library does exactly what I need. I was impressed (and a bit
>> shocked), how much code is necessary to do this work.
>
> I too think netlink was as such not designed to be an end-user
> interface, but a generic mechanism to create libraries like
> libsocketcan, of libenumif.
>
>> I think (parts of)
>> your library would also make a good extension to libsocketcan, as it seems
>> I'm not the only one asking, so there is definitely a need for this
>> function.
>
> Well, libsocketcan could copy part of the code for easy CAN enumeration.
> libenumif is not really restricted to CAN, or any other type.
>
>>
>> However, the only possiblity I see for me now, would be to ship a copy of
>> libenumif along with Qt and to integrate it into Qt's build system for
>> cross-platform builds.
>
> When you ship libenumif along with QT, doesn't that imply that it should
> stay out of QT.
> Or did you mean to ship libenumif as shared object along with QT's
> shared objects?
>
>>
>> Thats where my problems begin. I neither know about the technical, nor the
>> legal possibilities to do so :(
>
> QT is not my technical competence.
> Legally, libenumif is shipped with LGPLv3. I don't see a problem
> shipping it. LGPL allows to use the library (as shared object) from
> non-GPL code AFAIK.
>
> Kurt
>


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

end of thread, other threads:[~2016-08-11 10:31 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-08-09 11:06 SocketCAN device enumeration API André Hartmann
2016-08-09 12:33 ` Mirza Krak
2016-08-09 14:04 ` Kurt Van Dijck
2016-08-11  8:36   ` André Hartmann
2016-08-11 10:05     ` Kurt Van Dijck
2016-08-11 10:31       ` André Hartmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox