If I want to list the devices in my FPC application, how can I get the devices through FPC code?
Either asume that ifconfig is installed and each CAN interface has CAN word in it's name so you can use output of this command line:
avra@vm-debian:~$ ifconfig | grep can | sed -r 's#:.*##'
vcan0
vcan1
or analyze source code of ifconfig and try to replicate part of it's functionality in pascal:
https://github.com/giftnuss/net-tools/blob/master/ifconfig.cEDIT:
Ok, I was playing a little so here is version 2 which still depends on net-tools package and CAN substring in interface name:
avra@vm-debian:~$ netstat -i | grep can | sed -r 's# .*##'
vcan0
vcan1
and version 3 which lists all can, vcan and vxcan interfaces without depending on net-tools package or CAN substring in their name:
avra@vm-debian:~$ ip link show type can | grep : | sed -r 's#: <.*##' | sed -r 's#.* ##' && ip link show type vcan | grep : | sed -r 's#: <.*##' | sed -r 's#.* ##' && ip link show type vxcan | grep : | sed -r 's#: <.*##' | sed -r 's#.* ##'
vcan0
vcan1
As you can guess, of all command lines version 3 is the best since ip command exists in most modern distros (iproute2 package). However, you should not asume anything and always do the checking on your own.