Stuart Longland wrote:
> Hi all,
> I was wondering if anyone knew what system calls one used to get a list
> of CAN devices that are up and running via SocketCAN?
>
> I have a cross-platform[1] GUI application (Qt-based) that allows
> configuration of some motor controllers via CANbus. The CAN interfacing
> is done at the moment via an in-house developed library (which I call
> "libcan") which started its life out as a heavily hacked-up version of a
> Microchip MCP2515 CAN device driver and API written for MSP430 by
> Tritium[1].
>
> Since then, it has been reworked many times, gaining support for the
> CAN module built into the TI TMS320LF2406A DSP, Lawicel's CANUSB devices
> on Windows, and the SocketCAN interface... with a planned new driver for
> Luminary Micro Stellaris controllers coming. Ultimately I hope to
> release it as BSD or LGPL someday. It supports one device at a time...
> and at the moment, the interface to use is either picked semi-random or
> hard-coded.
>
> I'd like to have it provide a list of possible interfaces to the
> application for display so that the user can choose at runtime where
> appropriate. Ideally a meaningful description would be helpful (e.g.
> "vcan0 - Virtual CAN Device" or "slcan0 - Lawicel CAN232 on
> /dev/ttyUSB0") but I'm not sure that information is exposed anywhere,
> just the device name itself ("vcan0" or "slcan0" in this example) would
> suffice.
>
> Is it possible to generate such a list, and how would I go about it?
The ifconfig or ip utilities list the network devices e.g.:
# ip -d -s link
I think the simplest way to get the list is to use the ioctl request
"SIOCGIFCONF". Other ioctl request may then help to find out the
protocol and device name used to isolate CAN devices. More details of a
CAN device can be queried via netlink interface.
Wolfgang.
_______________________________________________
Socketcan-users mailing list
[email protected]
https://lists.berlios.de/mailman/listinfo/socketcan-users