Kvaser Linux CANLIB
|
Functions | ||||||||||
void | canInitializeLibrary (void) | |||||||||
canStatus | canGetErrorText (canStatus err, char *buf, unsigned int bufsiz) | |||||||||
unsigned short | canGetVersion (void) | |||||||||
canStatus | canIoCtl (const CanHandle hnd, unsigned int func, void *buf, unsigned int buflen) | |||||||||
canStatus | canGetNumberOfChannels (int *channelCount) | |||||||||
canStatus | canGetChannelData (int channel, int item, void *buffer, size_t bufsize) | |||||||||
kvCallback_t | ||||||||||
kvCallback_t is used by the function kvSetNotifyCallback()The callback function is called with the following arguments:
| ||||||||||
kvStatus | kvSetNotifyCallback (const CanHandle hnd, kvCallback_t callback, void *context, unsigned int notifyFlags) |
canStatus canGetChannelData | ( | int | channel, |
int | item, | ||
void * | buffer, | ||
size_t | bufsize | ||
) |
This function can be used to retrieve certain pieces of information about a channel.
[in] | channel | The number of the channel you are interested in. Channel numbers are integers in the interval beginning at 0 (zero) and ending at the value returned by canGetNumberOfChannels() minus 1. |
[in] | item | This parameter specifies what data to obtain for the specified channel. The value is one of the constants canCHANNELDATA_xxx. |
[in,out] | buffer | The address of a buffer which is to receive the data. |
[in] | bufsize | The size of the buffer to which the buffer parameter points. |
This function translates an error code (canERR_xxx) to a human-readable, English text.
[in] | err | The error code. |
[in,out] | buf | The buffer which is to receive the text, which is a zero-terminated string (provided the buffer is large enough.) |
[in] | bufsiz | The length of the input buffer. |
canStatus canGetNumberOfChannels | ( | int * | channelCount | ) |
This function returns the number of available CAN channels in the computer. The virtual channels are included in this number.
[out] | channelCount | A pointer to a DWORD which will receive the current number of channels. |
unsigned short canGetVersion | ( | void | ) |
This API call returns the version of the CANLIB API library (libcanlib.so.x.y). The most significant byte is the major version number and the least significant byte is the minor version number.
void canInitializeLibrary | ( | void | ) |
This function must be called before any other functions is used. It will initialize the driver.
You may call canInitializeLibrary() more than once. The actual initialization will take place only once.
Any errors encountered during library initialization will be "silent" and an appropriate canERR_xxx error code will be returned later on when canOpenChannel() (or any other API call that requires initialization) is called.
This API call performs several different functions; these are described below. The functions are handle-specific unless otherwise noted; this means that they affect only the handle you pass to canIoCtl(), whereas other open handles will remain unaffected. The contents of buf after the call is dependent on the function code you specified.
[in] | hnd | A handle to an open circuit. |
[in] | func | A canIOCTL_xxx function code |
[in,out] | buf | Pointer to a buffer containing function-dependent data; or a NULL pointer for certain function codes. The buffer can be used for both input and output depending on the function code. See canIOCTL_xxx. |
[in] | buflen | The length of the buffer. |
kvStatus kvSetNotifyCallback | ( | const CanHandle | hnd, |
kvCallback_t | callback, | ||
void * | context, | ||
unsigned int | notifyFlags | ||
) |
The kvSetNotifyCallback() function registers a callback function which is called when certain events occur.
You can register at most one callback function per handle at any time.
To remove the callback, call kvSetNotifyCallback() with a NULL
pointer in the callback argument.
[in] | hnd | An open handle to a CAN channel. |
[in] | callback | A pointer to a callback function of type kvCallback_t |
[in] | context | A pointer to arbitrary user-defined context data which is passed to the callback function. |
[in] | notifyFlags | One or more of the canNOTIFY_xxx flags. |