Kvaser Linux CANLIB
|
A CAN interface card often have more than one CAN chip. You allocate a handle to a certain CAN chip by calling canOpenChannel(). This routine takes two arguments, the first of which is the number of the desired channel. The channel numbering is dependent on the hardware you are using.
You can enumerate the CAN channels in the system using canGetChannelData(). First call canGetNumberOfChannels() to get the number of channels in the system. Then call canGetChannelData() for channel numbers 0, 1, 2,…, n-1 where n is the number returned by canGetNumberOfChannels().
Two or more applications can share the same CAN controller. You can, for example, have one application send messages on the bus and another application that just monitors the bus. If this is not desired (for performance or other reasons) you can open an exclusive handle to a chip. This means that no other application can open a handle to the same chip. Do this by passing the canOPEN_EXCLUSIVE flag in the flags argument to canOpenChannel().