Kvaser Linux CANLIB

CAN

Data Structures

struct  canNotifyData

Typedefs

typedef struct canNotifyData canNotifyData

Functions

canStatus canClose (const CanHandle hnd)
canStatus canBusOn (const CanHandle hnd)
canStatus canBusOff (const CanHandle hnd)
canStatus canSetBusParams (const CanHandle hnd, long freq, unsigned int tseg1, unsigned int tseg2, unsigned int sjw, unsigned int noSamp, unsigned int syncmode)
canStatus canGetBusParams (const CanHandle hnd, long *freq, unsigned int *tseg1, unsigned int *tseg2, unsigned int *sjw, unsigned int *noSamp, unsigned int *syncmode)
canStatus canSetBusOutputControl (const CanHandle hnd, const unsigned int drivertype)
canStatus canGetBusOutputControl (const CanHandle hnd, unsigned int *drivertype)
canStatus canAccept (const CanHandle hnd, const long envelope, const unsigned int flag)
canStatus canReadStatus (const CanHandle hnd, unsigned long *const flags)
canStatus canReadErrorCounters (const CanHandle hnd, unsigned int *txErr, unsigned int *rxErr, unsigned int *ovErr)
canStatus canWrite (const CanHandle hnd, long id, void *msg, unsigned int dlc, unsigned int flag)
canStatus canWriteSync (const CanHandle hnd, unsigned long timeout)
canStatus canRead (const CanHandle hnd, long *id, void *msg, unsigned int *dlc, unsigned int *flag, unsigned long *time)
canStatus canReadWait (const CanHandle hnd, long *id, void *msg, unsigned int *dlc, unsigned int *flag, unsigned long *time, unsigned long timeout)
canStatus canReadSync (const CanHandle hnd, unsigned long timeout)
canStatus canSetNotify (const CanHandle hnd, void(*callback)(canNotifyData *), unsigned int notifyFlags, void *tag)
canStatus canGetRawHandle (const CanHandle hnd, void *pvFd)
canStatus canTranslateBaud (long *const freq, unsigned int *const tseg1, unsigned int *const tseg2, unsigned int *const sjw, unsigned int *const nosamp, unsigned int *const syncMode)
canStatus canReadTimer (const CanHandle hnd, unsigned long *time)
CanHandle canOpenChannel (int channel, int flags)
canStatus canSetBusParamsC200 (const CanHandle hnd, BYTE btr0, BYTE btr1)
canStatus canResetBus (const CanHandle hnd)
canStatus canWriteWait (const CanHandle hnd, long id, void *msg, unsigned int dlc, unsigned int flag, unsigned long timeout)
canStatus canFlushReceiveQueue (const CanHandle hnd)
canStatus canFlushTransmitQueue (const CanHandle hnd)

Typedef Documentation

typedef struct canNotifyData canNotifyData

Function Documentation

canStatus canAccept ( const CanHandle  hnd,
const long  envelope,
const unsigned int  flag 
)

This routine sets the message acceptance filters on a CAN channel.

On some boards the acceptance filtering is done by the CAN hardware; on other boards (typically those with an embedded CPU,) the acceptance filtering is done by software. canAccept() behaves in the same way for all boards, however.

canSetAcceptanceFilter() and canAccept() both serve the same purpose but the former can set the code and mask in just one call.

If you want to remove a filter, call canAccept() with the mask set to 0.

Note:
You can set the extended code and mask only on CAN boards that support extended identifiers.
Not all CAN boards support different masks for standard and extended CAN identifiers.
Parameters:
[in]hndAn open handle to a CAN circuit.
[in]envelopeThe mask or code to set.
[in]flagAny of canFILTER_SET_CODE_STD, canFILTER_SET_MASK_STD, canFILTER_SET_CODE_EXT or canFILTER_SET_MASK_EXT
Returns:
canOK (zero) if success
canERR_xxx (negative) if failure
See also:
Code and Mask Format, Message Filters, Code Examples
canStatus canBusOff ( const CanHandle  hnd)

Takes the specified channel off-bus.

Parameters:
[in]hndAn open handle to a CAN channel.
Returns:
canOK (zero) if success
canERR_xxx (negative) if failure
See also:
Code Examples
canBusOn(), canResetBus()
Examples:
opentest.c, simplewrite.c, and writeloop.c.
canStatus canBusOn ( const CanHandle  hnd)

Takes the specified channel on-bus.

If you are using multiple handles to the same physical channel, for example if you are writing a threaded application, you must call canBusOn() once for each handle. The same applies to canBusOff() - the physical channel will not go off bus until the last handle to the channel goes off bus.

Parameters:
[in]hndAn open handle to a CAN channel.
Returns:
canOK (zero) if success
canERR_xxx (negative) if failure
See also:
Code Examples
canBusOff(), canResetBus()
Examples:
cancount.c, canmonitor.c, opentest.c, simplewrite.c, and writeloop.c.
canStatus canClose ( const CanHandle  hnd)

Closes the channel associated with the handle. If no other threads are using the CAN circuit, it is taken off bus. The handle can not be used for further references to the channel, so any variable containing it should be zeroed.

canClose() will almost always return canOK; the specified handle is closed on an best-effort basis.

Parameters:
[in]hndAn open handle to a CAN channel.
Returns:
canOK (zero) if success
canERR_xxx (negative) if failure
See also:
Code Examples
canOpenChannel(), canBusOn(), canBusOff()
Examples:
canmonitor.c, opentest.c, readTimerTest.c, simplewrite.c, and writeloop.c.
canStatus canFlushReceiveQueue ( const CanHandle  hnd)

This function removes all received messages from the handle's receive queue. Other handles open to the same channel are not affcted by this operation. That is, only the messages belonging to the handle you are passing to canFlushReceiveQueue are discarded.

Note:
This call has the same effect as calling canIoCtl() with a function code of canIOCTL_FLUSH_RX_BUFFER.
Parameters:
[in]hndA handle to an open circuit.
Returns:
canOK (zero) if success
canERR_xxx (negative) if failure
See also:
canFlushTransmitQueue()
canStatus canFlushTransmitQueue ( const CanHandle  hnd)

This function removes all messages pending transmission from the transmit queue of the circuit.

Note:
If there are other handles open to the same circuit, they are also flushed.
This call has the same effect as calling canIoCtl() with a function code of canIOCTL_FLUSH_TX_BUFFER.
Parameters:
[in]hndA handle to an open circuit.
Returns:
canOK (zero) if success
canERR_xxx (negative) if failure
See also:
canFlushReceiveQueue()
canStatus canGetBusOutputControl ( const CanHandle  hnd,
unsigned int *  drivertype 
)

This function retrieves the current CAN controller driver type. This corresponds loosely to the bus output control register in the CAN controller, hence the name of this function. CANLIB does not allow for direct manipulation of the bus output control register; instead, symbolic constants are used to select the desired driver type.

Note:
Don't confuse the CAN controller driver type with the bus driver type. The CAN controller is not connected directly to the CAN bus; instead, it is connected to a bus transceiver circuit which interfaces directly to the bus. The "CAN controller driver type" we are talking about here refers to the mode which the CAN controller uses to drive the bus transceiver circuit.
Silent Mode is not supported by all CAN controllers.
Parameters:
[in]hndAn open handle to a CAN circuit.
[in]drivertypeA pointer to an unsigned int which receives the current driver type. The driver type can be either canDRIVER_NORMAL or canDRIVER_SILENT.
Returns:
canOK (zero) if success
canERR_xxx (negative) if failure
See also:
canSetBusOutputControl()
canStatus canGetBusParams ( const CanHandle  hnd,
long *  freq,
unsigned int *  tseg1,
unsigned int *  tseg2,
unsigned int *  sjw,
unsigned int *  noSamp,
unsigned int *  syncmode 
)

This function retrieves the current bus parameters for the specified channel.

The anatomy of a CAN bit is discussed in detail at Kvaser's web site at www.kvaser.com.

Parameters:
[in]hndAn open handle to a CAN controller.
[out]freqBit rate (bits per second).
[out]tseg1Time segment 1, that is, the number of quanta from (but not including) the Sync Segment to the sampling point.
[out]tseg2Time segment 2, that is, the number of quanta from the sampling point to the end of the bit.
[out]sjwThe Synchronization Jump Width; can be 1,2,3, or 4.
[out]noSampThe number of sampling points; can be 1 or 3.
[out]syncmodeUnsupported, always read as zero.
Returns:
canOK (zero) if success
canERR_xxx (negative) if failure
See also:
Bit Rate Examples, Bit Rate and Other Bus Parameters
canSetBusParams(), canSetBusParamsC200()
Examples:
busparms.c.
canStatus canGetRawHandle ( const CanHandle  hnd,
void *  pvFd 
)

Returns raw handle/file descriptor for use in system calls.

Note:
Use this function with caution.
Parameters:
[in]hndCanHandle
[out]pvFdPointer to raw can data.
Returns:
canOK (zero) if success
canERR_xxx (negative) if failure
CanHandle canOpenChannel ( int  channel,
int  flags 
)

Opens a CAN channel (circuit) and returns a handle which is used in subsequent calls to CANLIB.

Channel numbering is dependent on the installed hardware. The first channel always has number 0.

For example,

  • If you have a single LAPcan, the channels are numbered 0 and 1.
  • If you have a USBcan Professional, the channels are numbered 0-1 according to the labels on the cables.
  • The virtual channels come after all physical channels.

If you are using multiple threads, note that the returned handle is usable only in the context of the thread that created it. That is, you must call canOpenChannel() in each of the threads in your application that uses the CAN bus. You can open the same channel from multiple threads, but you must call canOpenChannel() once per thread.

If you are using the same channel via multiple handles, note that the default behaviour is that the different handles will "hear" each other just as if each handle referred to a channel of its own. If you open, say, channel 0 from thread A and thread B and then send a message from thread A, it will be "received" by thread B. This behaviour can be changed using canIOCTL_SET_LOCAL_TXECHO.

Note:
The handle returned may be zero which is perfectly valid.
This call replaces the canOpen() API call and serves the same purpose.
Parameters:
[in]channelThe number of the channel. Channel numbering is hardware dependent.
[in]flagsA combination of canOPEN_xxx flags
Returns:
Returns a handle to the opened circuit, or canERR_xxx (negative) if the call failed.
See also:
Code Examples, Virtual Channels
canGetNumberOfChannels(), canGetChannelData(), canIoCtl()
Examples:
busparms.c, cancount.c, canmonitor.c, opentest.c, readTimerTest.c, simplewrite.c, and writeloop.c.
canStatus canRead ( const CanHandle  hnd,
long *  id,
void *  msg,
unsigned int *  dlc,
unsigned int *  flag,
unsigned long *  time 
)

Reads a message from the receive buffer. If no message is available, the function returns immediately with return code canERR_NOMSG.

If you are using the same channel via multiple handles, note that the default behaviour is that the different handles will "hear" each other just as if each handle referred to a channel of its own. If you open, say, channel 0 from thread A and thread B and then send a message from thread A, it will be "received" by thread B. This behaviour can be changed using canIOCTL_SET_LOCAL_TXECHO.

It is allowed to pass NULL as the value of id, msg, dlc, flag, and time.

Parameters:
[in]hndA handle to an open circuit.
[out]idPointer to a buffer which receives the CAN identifier. This buffer will only get the identifier. To determine whether this identifier was standard (11-bit) or extended (29-bit), and/or whether it was remote or not, or if it was an error frame, examine the contents of the flag argument.
[out]msgPointer to the buffer which receives the message data. This buffer must be large enough (i.e. 8 bytes.) Only the message data is copied; the rest of the buffer is left as-is.
[out]dlcPointer to a buffer which receives the message length.
[out]flagPointer to a buffer which receives the message flags, which is a combination of the canMSG_xxx and canMSGERR_xxx values.
[out]timePointer to a buffer which receives the message time stamp.
Returns:
canOK (zero) if a message was read.
canERR_NOMSG (negative) if there was no message available.
canERR_xxx (negative) if failure
See also:
Reading Messages, Message Mailboxes, Code Examples, Time Stamping Accuracy and Resolution
canReadSpecific(), canReadSpecificSkip(), canReadSync(), canReadSyncSpecific(), canReadWait()
canStatus canReadErrorCounters ( const CanHandle  hnd,
unsigned int *  txErr,
unsigned int *  rxErr,
unsigned int *  ovErr 
)

Reads the error counters of the CAN controller.

canReadErrorCounters() returns the latest known values of the error counters in the specified circuit. If the error counters change values precisely when canReadErrorCounters() is called, it may not be reflected in the returned result.

It is allowed to pass NULL as the value of the txErr, rxErr, and ovErr parameters.

Use canIoCtl() to clear the counters.

Note:
Not all CAN controllers provide access to the error counters; in this case, an educated guess is returned.
Parameters:
[in]hndA handle to an open circuit.
[out]txErrA pointer to a DWORD which receives the transmit error counter.
[out]rxErrA pointer to a DWORD which receives the receive error counter.
[out]ovErrA pointer to a DWORD which receives the number of overrun errors.
Returns:
canOK (zero) if success
canERR_xxx (negative) if failure
See also:
canIoCtl()
canStatus canReadStatus ( const CanHandle  hnd,
unsigned long *const  flags 
)

Returns the status for the specified circuit. flags points to a longword which receives a combination of the canSTAT_xxx flags.

Note:
canReadStatus() returns the latest known status of the specified circuit. If a status change happens precisely when canReadStatus() is called, it may not be reflected in the returned result.
Parameters:
[in]hndA handle to an open circuit.
[out]flagsPointer to a DWORD which receives the status flags; this is a combination of any of the canSTAT_xxx.
Returns:
canOK (zero) if success
canERR_xxx (negative) if failure
canStatus canReadSync ( const CanHandle  hnd,
unsigned long  timeout 
)

Waits until the receive buffer contains at least one message or a timeout occurs.

If you are using the same channel via multiple handles, note that the default behaviour is that the different handles will "hear" each other just as if each handle referred to a channel of its own. If you open, say, channel 0 from thread A and thread B and then send a message from thread A, it will be "received" by thread B. This behaviour can be changed using canIOCTL_SET_LOCAL_TXECHO.

Parameters:
[in]hndA handle to an open circuit.
[in]timeoutThe timeout in milliseconds. 0xFFFFFFFF gives an infinite timeout.
Returns:
canOK (zero) if the queue contains the desired message.
canERR_TIMEOUT (negative) if a timeout occurs before a message arrived.
canERR_xxx (negative) if the call fails.
See also:
canRead(), canReadWait()
canStatus canReadTimer ( const CanHandle  hnd,
unsigned long *  time 
)

Reads the current time from the clock used to timestamp the messages for the indicated circuit.

This API may return canERR_INVHANDLE and/or canERR_NOTINITIALIZED! This happens if hnd is invalid, or if the library was not initialized.

Note:
The clock used to timestamp the messages may not be available for direct reading on all platforms. In such cases, the PC's clock is used to return an approximation of the current time. Note that clock drift might occur in this case.
Parameters:
[in]hndA handle to an open circuit.
[out]timeThe current time, with the prevailing time resolution.
Returns:
canOK (zero) if success
canERR_xxx (negative) if failure
See also:
Time Stamping Accuracy and Resolution
kvReadTimer()
Examples:
readTimerTest.c.
canStatus canReadWait ( const CanHandle  hnd,
long *  id,
void *  msg,
unsigned int *  dlc,
unsigned int *  flag,
unsigned long *  time,
unsigned long  timeout 
)

Reads a message from the receive buffer. If no message is available, the function waits until a message arrives or a timeout occurs.

If you are using the same channel via multiple handles, note that the default behaviour is that the different handles will "hear" each other just as if each handle referred to a channel of its own. If you open, say, channel 0 from thread A and thread B and then send a message from thread A, it will be "received" by thread B. This behaviour can be changed using canIOCTL_SET_LOCAL_TXECHO.

It is allowed to pass NULL as the value of id, msg, dlc, flag, and time.

Parameters:
[in]hndA handle to an open circuit.
[out]idPointer to a buffer which receives the CAN identifier. This buffer will only get the identifier. To determine whether this identifier was standard (11-bit) or extended (29-bit), and/or whether it was remote or not, or if it was an error frame, examine the contents of the flag argument.
[out]msgPointer to the buffer which receives the message data. This buffer must be large enough (i.e. 8 bytes.).
[out]dlcPointer to a buffer which receives the message length.
[out]flagPointer to a buffer which receives the message flags, which is a combination of the canMSG_xxx and canMSGERR_xxx values.
[out]timePointer to a buffer which receives the message time stamp.
[in]timeoutIf no message is immediately available, this parameter gives the number of milliseconds to wait for a message before returning. 0xFFFFFFFF gives an infinite timeout.
Returns:
canOK (zero) if a message was read.
canERR_NOMSG (negative) if there was no message available.
canERR_xxx (negative) if failure
See also:
canRead(), canReadSync()
Time Stamping Accuracy and Resolution
Examples:
cancount.c, and canmonitor.c.
canStatus canResetBus ( const CanHandle  hnd)

This function tries to reset a CAN bus controller by taking the channel off bus and then on bus again (if it was on bus before the call to canResetBus().)

This function will affect the hardware (and cause a real reset of the CAN chip) only if hnd is the only handle open on the channel. If there are other open handles, this operation will not affect the hardware.

Parameters:
[in]hndA handle to an open circuit.
Returns:
canOK (zero) if success
canERR_xxx (negative) if failure
See also:
canBusOn(), canBusOff()
canStatus canSetBusOutputControl ( const CanHandle  hnd,
const unsigned int  drivertype 
)

This function sets the driver type for a CAN controller. This corresponds loosely to the bus output control register in the CAN controller, hence the name of this function. CANLIB does not allow for direct manipulation of the bus output control register; instead, symbolic constants are used to select the desired driver type.

Note:
Not all CAN driver types are supported on all cards.
Parameters:
[in]hndA handle to an open circuit.
[out]drivertypeCan driver type, canDRIVER_xxx)
Returns:
canOK (zero) if success
canERR_xxx (negative) if failure
See also:
canGetBusOutputControl()
Examples:
canmonitor.c, simplewrite.c, and writeloop.c.
canStatus canSetBusParams ( const CanHandle  hnd,
long  freq,
unsigned int  tseg1,
unsigned int  tseg2,
unsigned int  sjw,
unsigned int  noSamp,
unsigned int  syncmode 
)

This function sets the bus timing parameters for the specified CAN controller.

The library provides default values for tseg1, tseg2, sjw and noSamp when freq is specified to one of the pre-defined constants, canBITRATE_xxx.

If freq is any other value, no default values are supplied by the library.

If you are using multiple handles to the same physical channel, for example if you are writing a threaded application, you must call canBusOff() once for each handle. The same applies to canBusOn() - the physical channel will not go off bus until the last handle to the channel goes off bus.

Note:
Use canSetBusParamsC200() to set the bus timing parameters in the ubiquitous 82c200 bit-timing register format.
Parameters:
[in]hndAn open handle to a CAN controller.
[in]freqBit rate (measured in bits per second); or one of the predefined constants canBITRATE_xxx, which are described below.
[in]tseg1Time segment 1, that is, the number of quanta from (but not including) the Sync Segment to the sampling point.
[in]tseg2Time segment 2, that is, the number of quanta from the sampling point to the end of the bit.
[in]sjwThe Synchronization Jump Width; can be 1,2,3, or 4.
[in]noSampThe number of sampling points; can be 1 or 3.
[in]syncmodeUnsupported and ignored.
Returns:
canOK (zero) if success
canERR_xxx (negative) if failure
See also:
Bit Rate Examples, Bit Rate Constants, Bit Rate and Other Bus Parameters, Code Examples
canSetBusParamsC200(), canGetBusParams()
Examples:
busparms.c, cancount.c, canmonitor.c, opentest.c, simplewrite.c, and writeloop.c.
canStatus canSetBusParamsC200 ( const CanHandle  hnd,
BYTE  btr0,
BYTE  btr1 
)

This function sets the bus timing parameters using the same convention as the 82c200 CAN controller (which is the same as many other CAN controllers, for example, the 82527.)

To calculate the bit timing parameters, you can use the bit timing calculator that is included with CANLIB SDK. Look in the BIN directory.

82c200 Bit Timing

  • btr0 [b7..b6]: SJW - 1
  • btr0 [b5..b0]: Prescaler -1
  • btr1 [b7]: 1: 3 samples, 0: 1 samples
  • btr1 [b6..b4]: tseg2 - 1
  • btr1 [b3..b0]: tseg1 - 2
Note:
CANLIB will always behave as if the clock frequency is 16 MHz. It does not matter if the device has a different physical clock, since this will be compensated for by the driver.
Parameters:
[in]hndA handle to an open CAN circuit.
[in]btr0The desired bit timing, formatted as the contents of the BTR0 register in the 82c200.
[in]btr1The desired bit timing, formatted as the contents of the BTR1 register in the 82c200.
Returns:
canOK (zero) if success
canERR_xxx (negative) if failure
See also:
Bit Rate Examples, Bit Rate Constants
canSetBusParams()
canStatus canSetNotify ( const CanHandle  hnd,
void(*)(canNotifyData *)  callback,
unsigned int  notifyFlags,
void *  tag 
)

This function associates a callback function with the CAN circuit.

Parameters:
[in]hndA handle to an open CAN circuit.
[in]callbackHandle to callback routine.
[in]notifyFlagsThe events specified with canNOTIFY_xxx, for which callback should be called.
[in]tagPointer to user defined data. Passed to callback in the canNotifyData struct.
Returns:
canOK (zero) if success
canERR_xxx (negative) if failure
canStatus canTranslateBaud ( long *const  freq,
unsigned int *const  tseg1,
unsigned int *const  tseg2,
unsigned int *const  sjw,
unsigned int *const  nosamp,
unsigned int *const  syncMode 
)

This function translates the canBITRATE_xxx constants to their corresponding bus parameter values. At return, this freq contains the actual bit rate (in bits per second). TSeg1 is the number of quanta (less one) in a bit before the sampling point. TSeg2 is the number of quanta after the sampling point.

Parameters:
[in]freqA pointer to a DWORD which contains the canBITRATE_xxx constant to translate
[in]tseg1A pointer to a buffer which receives the Time segment 1, that is, the number of quanta from (but not including) the Sync Segment to the sampling point.
[in]tseg2A pointer to a buffer which receives the Time segment 2, that is, the number of quanta from the sampling point to the end of the bit.
[in]sjwA pointer to a buffer which receives the Synchronization Jump Width; can be 1,2,3, or 4.
[in]nosampA pointer to a buffer which receives the number of sampling points; can be 1 or 3.
[in]syncModeUnsupported, always read as zero.
Returns:
canOK (zero) if success
canERR_xxx (negative) if failure
See also:
canSetBusParams()
canStatus canWrite ( const CanHandle  hnd,
long  id,
void *  msg,
unsigned int  dlc,
unsigned int  flag 
)

This function sends a CAN message. The call returns immediately after queuing the message to the driver.

If you are using the same channel via multiple handles, note that the default behaviour is that the different handles will "hear" each other just as if each handle referred to a channel of its own. If you open, say, channel 0 from thread A and thread B and then send a message from thread A, it will be "received" by thread B. This behaviour can be changed using canIOCTL_SET_LOCAL_TXECHO.

Note:
The message has been queued for transmission when this calls return. It has not necessarily been sent.
Parameters:
[in]hndA handle to an open CAN circuit.
[in]idThe identifier of the CAN message to send.
[in]msgA pointer to the message data, or NULL.
[in]dlcThe length of the message. Can be at most 8.
[in]flagA combination of message flags, canMSG_xxx. Use this parameter to send extended (29-bit) frames and/or remote frames. Use canMSG_EXT and/or canMSG_RTR for this purpose.
Returns:
canOK (zero) if success
canERR_xxx (negative) if failure
See also:
Sending Messages, Code Examples
canWriteSync(), canWriteWait()
Examples:
simplewrite.c.
canStatus canWriteSync ( const CanHandle  hnd,
unsigned long  timeout 
)

Waits until all CAN messages for the specified handle are sent, or the timeout period expires.

Parameters:
[in]hndA handle to an open CAN circuit.
[in]timeoutThe timeout in milliseconds. 0xFFFFFFFF gives an infinite timeout.
Returns:
canOK (zero) if the queue emptied before the timeout period came to its end.
canERR_TIMEOUT (negative) not all messages were transmitted when the timeout occurred.
canERR_PARAM (negative) This could be caused by an erroneous parameter, or if you have turned TXACKs off (by using canIoCtl()) because if you do you can't use this call. The driver simply doesn't know when all the messages are sent!
canERR_xxx (negative) if failure
See also:
canWrite(), canWriteWait()
Examples:
simplewrite.c, and writeloop.c.
canStatus canWriteWait ( const CanHandle  hnd,
long  id,
void *  msg,
unsigned int  dlc,
unsigned int  flag,
unsigned long  timeout 
)

This function sends a CAN message. It returns when the message is sent, or the timeout expires.

This is a convenience function that combines canWrite() and canWriteSync().

If you are using the same channel via multiple handles, note that the default behaviour is that the different handles will "hear" each other just as if each handle referred to a channel of its own. If you open, say, channel 0 from thread A and thread B and then send a message from thread A, it will be "received" by thread B. This behaviour can be changed using canIOCTL_SET_LOCAL_TXECHO.

Parameters:
[in]hndA handle to an open CAN circuit.
[in]idThe identifier of the CAN message to send.
[in]msgA pointer to the message data, or NULL.
[in]dlcThe length of the message. Can be at most 8.
[in]flagA combination of message flags, canMSG_xxx. Use this parameter to send extended (29-bit) frames and/or remote frames. Use canMSG_EXT and/or canMSG_RTR for this purpose.
[in]timeoutThe timeout, in milliseconds. 0xFFFFFFFF gives an infinite timeout.
Returns:
canOK (zero) if success
canERR_xxx (negative) if failure
Examples:
writeloop.c.