Index: trunk/CanGateway/driver/kvaser/windows/canevt.h
===================================================================
--- trunk/CanGateway/driver/kvaser/windows/canevt.h	(revision 93)
+++ trunk/CanGateway/driver/kvaser/windows/canevt.h	(revision 93)
@@ -0,0 +1,249 @@
+/*
+**                         Copyright 1999 by KVASER AB            
+**                   P.O Box 4076 SE-51104 KINNAHULT, SWEDEN
+**             E-mail: staff@kvaser.se   WWW: http://www.kvaser.se
+**
+** This software is furnished under a license and may be used and copied
+** only in accordance with the terms of such license.
+**
+**
+** Description:
+**
+**
+**
+**
+**
+**
+** 
+**   DO NOT USE THIS FILE.  THE DATA STRUCTURES AND CONSTANTS HERE ARE
+**   NOT YET IMPLEMENTED AND WILL CHANGE IN A FUTURE RELEASE.
+**
+**
+**
+**
+**
+**
+**
+**
+**   
+**
+*/
+#ifndef _CANEVT_H_
+#define _CANEVT_H_
+
+#include <pshpack1.h>
+
+#define CANEVT_NO_COMMAND            0
+                                  
+  // Events                       
+#define CANEVT_RECEIVE_MSG           1
+#define CANEVT_STATISTIC_STD         2
+#define CANEVT_STATISTIC_EXT         3
+#define CANEVT_CHIP_STATE            4
+#define CANEVT_CLOCK_OVERFLOW        5
+#define CANEVT_TRIGGER               6
+#define CANEVT_ERROR                 7
+#define CANEVT_TIMER                 8
+#define CANEVT_TRANSCEIVER           9
+                                  
+  // Commands                     
+#define CANEVT_TRANSMIT_MSG          10
+#define CANEVT_SET_TIMER             11
+#define CANEVT_RESET_CLOCK           12
+#define CANEVT_INIT_CHIP             13
+#define CANEVT_START_CHIP            14
+#define CANEVT_STOP_CHIP             15
+#define CANEVT_RESET_CHIP            16
+#define CANEVT_SET_ACCEPTANCE        17
+//#define CANEVT_SET_DRIVERMODE        18
+#define CANEVT_GET_STATISTIC         19
+#define CANEVT_GET_CHIP_STATE        20
+#define CANEVT_SET_OUTPUT_MODE       21
+#define CANEVT_FUNCTION              22
+#define CANEVT_GET_TRANSCEIVER       23
+#define CANEVT_GET_TRANSCEIVER_RESP  24
+#define CANEVT_SET_TRANSCEIVER       25
+// 26, 27, 28 reserved
+#define CANEVT_INIT_HARDWARE         29
+#define CANEVT_EXIT_HARDWARE         30
+#define CANEVT_READ_CLOCK            31
+
+
+#define MAX_MSG_LEN 8
+#define EXT_MSG                     0x80000000  // signs an extended identifier
+
+#define MSGFLAG_ERROR_FRAME         0x01        // Msg is a bus error
+#define MSGFLAG_OVERRUN             0x02        // Msgs following this has been lost
+#define MSGFLAG_NERR                0x04        // NERR active during this msg
+#define MSGFLAG_WAKEUP              0x08        // Msg rcv'd in wakeup mode
+#define MSGFLAG_REMOTE_FRAME        0x10        // Msg is a remote frame
+#define MSGFLAG_RESERVED_1          0x20        // Reserved for future usage
+#define MSGFLAG_TX                  0x40        // TX acknowledge
+#define MSGFLAG_TXRQ                0x80        // TX request
+
+typedef struct {
+  unsigned long id;
+  unsigned char flags;
+  unsigned char dlc;
+  unsigned char data[MAX_MSG_LEN];
+} CanEventMessage;
+
+
+#define CHIPSTAT_BUSOFF              0x01
+#define CHIPSTAT_ERROR_PASSIVE       0x02
+#define CHIPSTAT_ERROR_WARNING       0x04
+#define CHIPSTAT_ERROR_ACTIVE        0x08
+
+typedef struct {
+  unsigned char busStatus;
+  unsigned char txErrorCounter;
+  unsigned char rxErrorCounter;
+} CanEventChipState;
+
+typedef struct {
+  unsigned long  stdData;
+  unsigned long  stdRemote;
+  unsigned long  errFrame;
+  unsigned short busLoad; // 0.00-100.00%
+} CanEventStatisticsStd;
+
+typedef struct {
+  unsigned long  extData;
+  unsigned long  extRemote;
+  unsigned long  ovrFrame;
+} CanEventStatisticsExt;
+
+typedef struct {
+  unsigned char code; // qqq
+} CanEventErrorCode;
+
+//------------------------------------------------------------------------------
+// commands
+//------------------------------------------------------------------------------
+
+typedef struct {
+  unsigned long code;
+  unsigned long mask;
+} CanEventAcceptanceFilter;
+
+typedef struct {
+  unsigned char mode;
+} CanEventDriverMode;
+
+typedef struct {
+  unsigned long rate;
+} CanEventSetTimer;
+
+typedef struct {
+  unsigned char level;
+} CanEventSetDebugLevel;
+
+#define OUTPUT_MODE_SILENT 0
+#define OUTPUT_MODE_NORMAL 1
+
+typedef struct {
+  unsigned char mode;
+} CanEventSetOutputMode;
+
+typedef struct {
+  unsigned char code;
+} CanEventFunction;
+
+// The following definitions are copied from lapcmds.h !!
+#if 0
+#define TRANSCEIVER_EVENT_ERROR   1
+#define TRANSCEIVER_EVENT_CHANGED 2
+
+// event
+#define TRANSCEIVER_EVENT_NONE           0
+#define TRANSCEIVER_EVENT_NERR           1
+#define TRANSCEIVER_EVENT_REMOVED        2
+#define TRANSCEIVER_EVENT_DETECTED       3
+
+// type
+#define TRANSCEIVER_TYPE_NONE     0
+#define TRANSCEIVER_TYPE_251      1
+#define TRANSCEIVER_TYPE_252      2
+#define TRANSCEIVER_TYPE_DNOPTO   3
+#define TRANSCEIVER_TYPE_W210     4
+#define TRANSCEIVER_TYPE_SWC_PROTO       5  // Prototype. Driver may latch-up.
+#define TRANSCEIVER_TYPE_SWC             6
+
+
+// lineMode
+#define TRANSCEIVER_LINEMODE_NA       0
+#define TRANSCEIVER_LINEMODE_TWO_LINE 1
+#define TRANSCEIVER_LINEMODE_CAN_H    2
+#define TRANSCEIVER_LINEMODE_CAN_L    3
+#define TRANSCEIVER_LINEMODE_SWC_SLEEP   4  // SWC Sleep Mode.
+#define TRANSCEIVER_LINEMODE_SWC_NORMAL  5  // SWC Normal Mode.
+#define TRANSCEIVER_LINEMODE_SWC_FAST    6  // SWC High-Speed Mode.
+#define TRANSCEIVER_LINEMODE_SWC_WAKEUP  7  // SWC Wakeup Mode.
+#define TRANSCEIVER_LINEMODE_SLEEP    8
+#define TRANSCEIVER_LINEMODE_NORMAL   9
+#define TRANSCEIVER_LINEMODE_STDBY      10  // Standby for those who support it
+#define TRANSCEIVER_LINEMODE_TT_CAN_H   11  // Truck & Trailer: operating mode single wire using CAN high
+#define TRANSCEIVER_LINEMODE_TT_CAN_L   12  // Truck & Trailer: operating mode single wire using CAN low
+#define TRANSCEIVER_LINEMODE_OEM1       13  // Reserved for OEM apps
+#define TRANSCEIVER_LINEMODE_OEM2       14  // Reserved for OEM apps
+#define TRANSCEIVER_LINEMODE_OEM3       15  // Reserved for OEM apps
+#define TRANSCEIVER_LINEMODE_OEM4       16  // Reserved for OEM apps
+
+
+// resNet
+#define TRANSCEIVER_RESNET_NA          0
+#define TRANSCEIVER_RESNET_MASTER      1
+#define TRANSCEIVER_RESNET_MASTER_STBY 2
+#define TRANSCEIVER_RESNET_SLAVE       3
+
+#endif
+
+typedef struct {
+  unsigned char event;       // TRANSCEIVER_EVENT_xxx
+} CanEventTransceiver;
+
+typedef struct {
+  unsigned char type;        // TRANSCEIVER_TYPE_xxx
+  unsigned char lineMode;    // TRANSCEIVER_LINEMODE_xxx
+  unsigned char resNet;      // TRANSCEIVER_RESNET_xxx
+} CanEventGetTransceiverResponse;
+
+typedef struct {
+  unsigned char type;       // TRANSCEIVER_TYPE_xxx
+  unsigned char lineMode;   // TRANSCEIVER_LINEMODE_xxx
+  unsigned char resNet;     // TRANSCEIVER_RESNET_xxx
+} CanEventSetTransceiver;
+
+
+typedef union {
+    CanEventMessage                 canEventMessage;
+    CanEventChipState               canEventChipState;
+    CanEventStatisticsStd           canEventStatisticsStd;
+    CanEventStatisticsExt           canEventStatisticsExt;
+    CanEventErrorCode               canEventErrorCode;
+    CanEventAcceptanceFilter        canEventAcceptanceFilter;
+    CanEventDriverMode              canEventDriverMode;
+    CanEventSetTimer                canEventSetTimer;
+    CanEventSetDebugLevel           canEventSetDebugLevel;
+    CanEventSetOutputMode           canEventSetOutputMode;
+    CanEventFunction                canEventFunction;
+    CanEventTransceiver             canEventTransceiver;
+    CanEventGetTransceiverResponse  canEventGetTransceiverResponse;
+    CanEventSetTransceiver          canEventSetTransceiver;
+} CanEventUnion;
+    
+
+typedef struct {
+  unsigned char tag;
+  unsigned char chanIndex;
+  unsigned char _internal1;
+  unsigned char _internal2;
+  unsigned long timeStamp;
+  CanEventUnion x;
+} CanEvent, *PCanEvent;
+
+
+#include <poppack.h>
+
+#endif
+
Index: trunk/CanGateway/driver/kvaser/windows/canlib.h
===================================================================
--- trunk/CanGateway/driver/kvaser/windows/canlib.h	(revision 93)
+++ trunk/CanGateway/driver/kvaser/windows/canlib.h	(revision 93)
@@ -0,0 +1,5233 @@
+/**
+ * \section LICENSE
+ *                   Copyright 1994-2015 by KVASER AB, SWEDEN
+ *
+ *                        WWW: http://www.kvaser.com
+ *
+ * This software is furnished under a license and may be used and copied
+ * only in accordance with the terms of such license.
+ *
+ * \section DESCRIPTION
+ *
+ *   Definitions for the CANLIB API.
+ *
+ * \file canlib.h
+ * \author Kvaser AB
+ *
+ * \note MATLAB users on Windows: if you define WIN32_LEAN_AND_MEAN before
+ * including this file, you will see a lot less warnings.
+ *
+ * \defgroup General                 General
+ * \defgroup CAN                     CAN
+ * \defgroup ObjectBuffers           Object buffers
+ * \win_start
+ * \defgroup TimeDomainHandling      Time Domain Handling
+ * \defgroup NamedParameterSettings  Named Parameter Settings
+ * \defgroup tScript                 t-script
+ * \win_end
+ */
+
+#ifndef _CANLIB_H_
+#define _CANLIB_H_
+
+#include <stdlib.h>
+
+# include <windows.h>
+# include "predef.h"
+# include "canevt.h"
+# define CANLIB_DECLARE_ALL
+#include "canstat.h"
+
+/** Handle to an opened circuit. */
+typedef int canHandle;
+/** Handle to an opened circuit, created with \ref canOpenChannel(). */
+# define CanHandle int
+/** Denotes an invalid circuit handle. */
+# define canINVALID_HANDLE      (-1)
+
+/** Notify message sent to the application window */
+# define WM__CANLIB              (WM_USER+16354)
+
+/**
+ * \name canOPEN_xxx
+ * \anchor canOPEN_xxx
+ *
+ * These defines are used in \ref canOpenChannel().
+ *
+ * @{
+ */
+
+
+/**
+ * Don't allow sharing of this circuit between applications.
+ *
+ * This define is used in \ref canOpenChannel()
+ */
+#define canOPEN_EXCLUSIVE               0x0008
+
+/**
+ * This flag causes two things to happen:
+ *
+ * \li The call will fail if the specified circuit doesn't allow extended CAN
+ *     (CAN 2.0B).
+ *
+ * \li If no frame-type flag is specified in a call to \ref canWrite, it is assumed
+ *     that extended CAN should be used.
+ *
+ * This define is used in \ref canOpenChannel().
+ */
+#define canOPEN_REQUIRE_EXTENDED        0x0010
+
+/**
+ * Allow opening of virtual channels as well as physical channels.
+ *
+ * This define is used in \ref canOpenChannel().
+ *
+ * \sa \ref page_user_guide_virtual_info
+ */
+# define canOPEN_ACCEPT_VIRTUAL         0x0020
+
+/**
+ * Open the channel even if it is opened for exclusive
+ * access already.
+ *
+ * \warning Use this flag with caution.
+ *
+ * This define is used in \ref canOpenChannel().
+ */
+# define canOPEN_OVERRIDE_EXCLUSIVE     0x0040
+
+/**
+ * Fail the call if the channel cannot be opened with init access.
+ *
+ * Init access means that the thread that owns the handle can set bit rate and
+ * CAN driver mode. Init access is the default. At most one thread can have
+ * init access to any given channel. If you try to set the bit rate or CAN
+ * driver mode for a handle to which you don't have init access, the call will
+ * silently fail (i.e. \ref canOK is returned although the call had no effect),
+ * unless you enable "access error reporting" by calling \ref canIoCtl(). Access
+ * error reporting is by default off.
+ *
+ * This define is used in \ref canOpenChannel().
+ *
+ * \sa \ref canOPEN_NO_INIT_ACCESS
+ */
+# define canOPEN_REQUIRE_INIT_ACCESS    0x0080
+
+/**
+ * Don't open the handle with init access.
+ *
+ * This define is used in \ref canOpenChannel().
+ *
+ * \sa \ref canOPEN_REQUIRE_INIT_ACCESS
+ */
+# define canOPEN_NO_INIT_ACCESS         0x0100
+
+/**
+ * The channel will accept messages with DLC (Data Length Code) greater than
+ * 8. If this flag is not used, a message with DLC > 8 will always be
+ * reported or transmitted as a message with DLC = 8. If the
+ * \ref canOPEN_ACCEPT_LARGE_DLC flag is used, the message will be sent and/or
+ * received with the true DLC, which can be at most 15.
+ *
+ * \note The length of the message is always at most 8.
+ *
+ * This define is used in \ref canOpenChannel().
+ */
+# define canOPEN_ACCEPT_LARGE_DLC       0x0200  // DLC can be greater than 8
+
+/**
+ * The channel will use the CAN FD protocol.
+ *
+ * This define is used in \ref canOpenChannel().
+ */
+# define canOPEN_CAN_FD                 0x0400
+
+/**
+ * The channel will use the CAN FD NON-ISO protocol.
+ *
+ * This define is used in \ref canOpenChannel().
+ */
+# define canOPEN_CAN_FD_NONISO          0x0800
+/** @} */
+
+/**
+ * \ingroup CAN
+ * \name canFILTER_xxx
+ * \anchor canFILTER_xxx
+ *
+ * Flags for \ref canAccept().
+ *
+ * @{
+ */
+#define canFILTER_ACCEPT        1
+#define canFILTER_REJECT        2
+/** Sets the code for standard (11-bit) identifiers. */
+#define canFILTER_SET_CODE_STD  3
+/** Sets the mask for standard (11-bit) identifiers. */
+#define canFILTER_SET_MASK_STD  4
+/** Sets the code for extended (29-bit) identifiers. */
+#define canFILTER_SET_CODE_EXT  5
+/** Sets the mask for extended (29-bit) identifiers. */
+#define canFILTER_SET_MASK_EXT  6
+
+#define canFILTER_NULL_MASK     0L
+/** @} */
+
+
+/**
+ * \ingroup CAN
+ * \name canDRIVER_xxx
+ * \anchor canDRIVER_xxx
+ *
+ * CAN driver types - not all are supported on all cards.
+ *
+ * @{
+ */
+
+/**
+ * The "normal" driver type (push-pull). This is the default.
+ */
+#define canDRIVER_NORMAL           4
+
+/**
+ * Sets the CAN controller in Silent Mode; that is, it doesn't send anything,
+ * not even ACK bits, on the bus.  Reception works as usual.
+ *
+ * \note The values 2,3,5,6,7 are reserved values for compatibility reasons.
+ */
+#define canDRIVER_SILENT           1
+
+/**
+ * Self-reception. Not implemented.
+ */
+#define canDRIVER_SELFRECEPTION    8
+
+/**
+ * The driver is turned off. Not implemented in all types of hardware.
+ */
+#define canDRIVER_OFF              0
+
+/** @} */
+
+
+/**
+ * \ingroup CAN
+ * \anchor BAUD_xxx
+ * \anchor canBITRATE_xxx
+ * \name canBITRATE_xxx
+ *
+ * Common bus speeds. Used in \ref canSetBusParams() and \ref canSetBusParamsC200().
+ * The values are translated in canlib, \ref canTranslateBaud().
+ *
+ * \note The \ref BAUD_xxx names are only retained for compability.
+ *
+ * \sa \ref page_user_guide_misc_bitrate
+ *
+ * @{
+ */
+
+
+/** Used in \ref canSetBusParams() and \ref canSetBusParamsC200(). Indicate a bitrate of 1 Mbit/s. */
+#define canBITRATE_1M        (-1)
+/** Used in \ref canSetBusParams() and \ref canSetBusParamsC200(). Indicate a bitrate of 500 kbit/s. */
+#define canBITRATE_500K      (-2)
+/** Used in \ref canSetBusParams() and \ref canSetBusParamsC200(). Indicate a bitrate of 250 kbit/s. */
+#define canBITRATE_250K      (-3)
+/** Used in \ref canSetBusParams() and \ref canSetBusParamsC200(). Indicate a bitrate of 125 kbit/s. */
+#define canBITRATE_125K      (-4)
+/** Used in \ref canSetBusParams() and \ref canSetBusParamsC200(). Indicate a bitrate of 100 kbit/s. */
+#define canBITRATE_100K      (-5)
+/** Used in \ref canSetBusParams() and \ref canSetBusParamsC200(). Indicate a bitrate of 62 kbit/s. */
+#define canBITRATE_62K       (-6)
+/** Used in \ref canSetBusParams() and \ref canSetBusParamsC200(). Indicate a bitrate of 50 kbit/s. */
+#define canBITRATE_50K       (-7)
+/** Used in \ref canSetBusParams() and \ref canSetBusParamsC200(). Indicate a bitrate of 83 kbit/s. */
+#define canBITRATE_83K       (-8)
+/** Used in \ref canSetBusParams() and \ref canSetBusParamsC200(). Indicate a bitrate of 10 kbit/s. */
+#define canBITRATE_10K       (-9)
+
+// CAN FD Bit Rates
+/** Used in \ref canSetBusParamsFd(). Indicates a bitrate of 0.5 Mbit/s and sampling point at 80%. */
+#define canFD_BITRATE_500K_80P     (-1001)
+/** Used in \ref canSetBusParamsFd(). Indicates a bitrate of 1.0 Mbit/s and sampling point at 80%. */
+#define canFD_BITRATE_1M_80P     (-1002)
+/** Used in \ref canSetBusParamsFd(). Indicates a bitrate of 2.0 Mbit/s and sampling point at 80%. */
+#define canFD_BITRATE_2M_80P     (-1003)
+
+/** The \ref BAUD_xxx names are deprecated, use \ref canBITRATE_1M instead. */
+#define BAUD_1M              (-1)
+/** The \ref BAUD_xxx names are deprecated, use \ref canBITRATE_500K instead. */
+#define BAUD_500K            (-2)
+/** The \ref BAUD_xxx names are deprecated, use \ref canBITRATE_250K instead. */
+#define BAUD_250K            (-3)
+/** The \ref BAUD_xxx names are deprecated, use \ref canBITRATE_125K instead. */
+#define BAUD_125K            (-4)
+/** The \ref BAUD_xxx names are deprecated, use \ref canBITRATE_100K instead. */
+#define BAUD_100K            (-5)
+/** The \ref BAUD_xxx names are deprecated, use \ref canBITRATE_62K instead. */
+#define BAUD_62K             (-6)
+/** The \ref BAUD_xxx names are deprecated, use \ref canBITRATE_50K instead. */
+#define BAUD_50K             (-7)
+/** The \ref BAUD_xxx names are deprecated, use \ref canBITRATE_83K instead. */
+#define BAUD_83K             (-8)
+/** @} */
+
+
+//
+// Define CANLIBAPI unless it's done already.
+// (canlib.c provides its own definitions of CANLIBAPI, DLLIMPORT
+// and DLLEXPORT before including this file.)
+//
+#ifndef CANLIBAPI
+#   define CANLIBAPI __stdcall
+#   define DLLIMPORT __declspec(dllimport)
+#   define DLLEXPORT __declspec(dllexport)
+#endif
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * \ingroup General
+ *
+ * \source_cs       <b>static void canInitializeLibrary(void);</b>
+ *
+ * \source_delphi   <b>procedure canInitializeLibrary;    </b>
+ * \source_end
+ * This function must be called before any other functions is used.  It will
+ * initialize the driver.
+ *
+ * You may call \ref canInitializeLibrary() more than once. The actual
+ * initialization will take place only once.
+ *
+ * Any errors encountered during library initialization will be "silent" and an
+ * appropriate \ref canERR_xxx error code will be returned later on when
+ * \ref canOpenChannel() (or any other API call that requires initialization) is
+ * called.
+ *
+ * \note This call replaces the \ref canLocateHardware() API call and serves the
+ *  same purpose.
+ *
+ * \sa \ref page_code_snippets_examples
+ *
+ */
+void CANLIBAPI canInitializeLibrary (void);
+
+/**
+ * \ingroup CAN
+ *
+ * \source_cs       <b>static Canlib.canStatus canClose(int handle);</b>
+ *
+ * \source_delphi   <b>function canClose(handle: canHandle): canStatus;</b>
+ * \source_end
+ *
+ * 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.
+ *
+ * \ref canClose() will almost always return \ref canOK; the specified handle is closed
+ * on an best-effort basis.
+ *
+ * \param[in]  hnd  An open handle to a CAN channel.
+ *
+ * \return \ref canOK (zero) if success
+ * \return \ref canERR_xxx (negative) if failure
+ *
+ * \sa \ref page_code_snippets_examples
+ * \sa \ref canOpenChannel(), \ref canBusOn(), \ref canBusOff()
+ */
+canStatus CANLIBAPI canClose (const CanHandle hnd);
+
+/**
+ * \ingroup CAN
+ *
+ * \source_cs       <b>static Canlib.canStatus canBusOn(int handle);</b>
+ *
+ * \source_delphi   <b>function canBusOn(handle: canHandle): canStatus;    </b>
+ * \source_end
+ *
+ * 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 \ref canBusOn() once for
+ * each handle. The same applies to \ref canBusOff() - the physical channel will not
+ * go off bus until the last handle to the channel goes off bus.
+ *
+ * \param[in]  hnd  An open handle to a CAN channel.
+ *
+ * \return \ref canOK (zero) if success
+ * \return \ref canERR_xxx (negative) if failure
+ *
+ * \sa \ref page_code_snippets_examples
+ * \sa \ref canBusOff(), \ref canResetBus()
+ *
+ */
+canStatus CANLIBAPI canBusOn (const CanHandle hnd);
+
+/**
+ * \ingroup CAN
+ *
+ * \source_cs       <b>static Canlib.canStatus canBusOff(int handle);</b>
+ *
+ * \source_delphi   <b>function canBusOff(handle: canHandle): canStatus; </b>
+ * \source_end
+ *
+ * Takes the specified channel off-bus.
+ *
+ * \param[in]  hnd  An open handle to a CAN channel.
+ *
+ * \return \ref canOK (zero) if success
+ * \return \ref canERR_xxx (negative) if failure
+ *
+ * \sa \ref page_code_snippets_examples
+ * \sa \ref canBusOn(), \ref canResetBus()
+ *
+ */
+canStatus CANLIBAPI canBusOff (const CanHandle hnd);
+
+/**
+ * \ingroup CAN
+ *
+ * \source_cs       <b>static Canlib.canStatus canSetBusParams(int handle, int freq, int tseg1, int tseg2, int sjw, int noSamp, int syncmode); </b>
+ *
+ * \source_delphi   <b>function canSetBusParams(handle: canHandle; freq: Longint; tseg1, tseg2, sjw, noSamp, syncmode: Cardinal): canStatus;     </b>
+ * \source_end
+ *
+ * This function sets the bus timing parameters for the specified CAN controller.
+ *
+ * The library provides default values for \a tseg1, \a tseg2, \a sjw and \a
+ * noSamp when \a freq is specified to one of the
+ * pre-defined constants, \ref canBITRATE_xxx.
+ *
+ * If \a 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 \ref canBusOff() once
+ * for each handle. The same applies to \ref canBusOn() - the physical channel will
+ * not go off bus until the last handle to the channel goes off bus.
+ *
+ * \note Use \ref canSetBusParamsC200() to set the bus timing parameters in the
+ *  ubiquitous 82c200 bit-timing register format.
+ *
+ * \param[in]  hnd       An open handle to a CAN controller.
+ * \param[in]  freq      Bit rate (measured in bits per second); or one of the
+ *                       predefined constants \ref canBITRATE_xxx, which are described below.
+ * \param[in]  tseg1     Time segment 1, that is, the number of quanta from (but not
+ *                       including) the Sync Segment to the sampling point.
+ * \param[in]  tseg2     Time segment 2, that is, the number of quanta from the sampling
+ *                       point to the end of the bit.
+ * \param[in]  sjw       The Synchronization Jump Width; can be 1,2,3, or 4.
+ * \param[in]  noSamp    The number of sampling points; can be 1 or 3.
+ * \param[in]  syncmode  Unsupported and ignored.
+ *
+ * \return \ref canOK (zero) if success
+ * \return \ref canERR_xxx (negative) if failure
+ *
+ * \sa \ref page_code_snippets_bit_rate, \ref page_user_guide_misc_bitrate,
+ * \ref page_user_guide_init_bit_rate, \ref page_code_snippets_examples
+ * \sa \ref canSetBusParamsC200(), \ref canGetBusParams()
+ *
+ */
+canStatus CANLIBAPI canSetBusParams (const CanHandle hnd,
+                                     long freq,
+                                     unsigned int tseg1,
+                                     unsigned int tseg2,
+                                     unsigned int sjw,
+                                     unsigned int noSamp,
+                                     unsigned int syncmode);
+
+/**
+ * \ingroup CAN
+ *
+ * \source_cs       <b>static Canlib.canStatus canSetBusParamsFd(int hnd, int freq_brs, int tseg1_brs, int tseg2_brs, int sjw_brs);</b>
+ *
+ * \source_delphi   <b>function canSetBusParamsFd(hnd: canHandle; freq_brs: Longint; tseg1_brs, tseg2_brs, sjw_brs): canStatus;</b>
+ * \source_end
+ *
+ * This function sets the bus timing parameters for the specified
+ * CAN FD controller.
+ *
+ * The library provides default values for \a tseg1_brs, \a tseg2_brs,
+ * \a sjw_brs and \a freq_brs is specified to one of the pre-defined
+ * constants, \ref canBITRATE_xxx.
+ *
+ * If \a freq_brs is any other value, no default values are supplied
+ * by the library.
+ *
+ * \param[in]  hnd        An open handle to a CAN controller.
+ * \param[in]  freq_brs   Bit rate (measured in bits per second); or one of the
+ *                        predefined constants \ref canBITRATE_xxx, which are described below.
+ * \param[in]  tseg1_brs  Time segment 1, that is, the number of quanta from (but not
+ *                        including) the Sync Segment to the sampling point.
+ * \param[in]  tseg2_brs  Time segment 2, that is, the number of quanta from the sampling
+ *                        point to the end of the bit.
+ * \param[in]  sjw_brs    The Synchronization Jump Width; can be 1,2,3, or 4.
+ *
+ * \return \ref canOK (zero) if success
+ * \return \ref canERR_xxx (negative) if failure
+ */
+canStatus CANLIBAPI canSetBusParamsFd(const CanHandle hnd,
+                                      long freq_brs,
+                                      unsigned int tseg1_brs,
+                                      unsigned int tseg2_brs,
+                                      unsigned int sjw_brs);
+
+/**
+ * \ingroup CAN
+ * \name canFD_SSP_xxx
+ * \anchor canFD_SSP_xxx
+ *
+ * Flags for \ref canFdSecondarySamplePoint().
+ *
+ * @{
+ */
+/** Secondary sample point is automatically adjusted dynamically. */
+#define canFD_SSP_AUTO   0
+/** Set secondary sample point. */
+#define canFD_SSP_SET    1
+/** Get secondary sample point. */
+#define canFD_SSP_GET    2
+/** @} */
+
+/**
+ * \ingroup CAN
+ *
+ * \source_cs       <b>static Canlib.canStatus canFdSecondarySamplePoint(int hnd, ref int ns, int mode);</b>
+ *
+ * \source_delphi   <b>function canFdSecondarySamplePoint(hnd: canHandle; var ns: Cardinal; mode: Cardinal): canStatus;</b>
+ * \source_end
+ *
+ * This function sets or retrieves the secondary sampling point for
+ * the specified CAN FD controller.
+ *
+ * If \a mode is canFD_SSP_AUTO, the \a ns argument is ignored, and
+ * the secondary sampling point is automatically adjusted dynamically.
+ * If \a mode is canFD_SSP_SET, the secondary sampling point is set to
+ * \a ns, and if \a mode is canFD_SSP_GET, it is retrived and stored
+ * in \a ns.
+ *
+ * \param[in]     hnd     An open handle to a CAN controller.
+ * \param[in,out] ns      Secondary sampling point delay, in nanoseconds.
+ * \param[in]     mode    One of canFD_SSP_AUTO, canFD_SSP_GET, or
+ *                        canFD_SSP_SET.
+ *
+ * \return \ref canOK (zero) if success
+ * \return \ref canERR_xxx (negative) if failure
+ */
+canStatus CANLIBAPI canFdSecondarySamplePoint(const CanHandle hnd,
+                                              unsigned int *ns,
+                                              int mode);
+
+/**
+ * \ingroup CAN
+ *
+ * \source_cs       <b>static Canlib.canStatus canGetBusParams(int handle, out long freq, out int tseg1, out int tseg2, out int sjw, out int noSamp, out int syncmode);</b>
+ *
+ * \source_delphi   <b>function canGetBusParams(handle: canHandle; var freq: Longint; var tseg1, tseg2, sjw, noSamp, syncmode: Cardinal): canStatus;     </b>
+ * \source_end
+ *
+ * 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 <a href="http://www.kvaser.com">www.kvaser.com</a>.
+ *
+ * \param[in]  hnd       An open handle to a CAN controller.
+ * \param[out] freq      Bit rate (bits per second).
+ * \param[out] tseg1     Time segment 1, that is, the number of quanta from (but not
+ *                       including) the Sync Segment to the sampling point.
+ * \param[out] tseg2     Time segment 2, that is, the number of quanta from the sampling
+ *                       point to the end of the bit.
+ * \param[out] sjw       The Synchronization Jump Width; can be 1,2,3, or 4.
+ * \param[out] noSamp    The number of sampling points; can be 1 or 3.
+ * \param[out] syncmode  Unsupported, always read as zero.
+ *
+ * \return \ref canOK (zero) if success
+ * \return \ref canERR_xxx (negative) if failure
+ *
+ * \sa \ref page_code_snippets_bit_rate, \ref page_user_guide_init_bit_rate
+ * \sa \ref canSetBusParams(), \ref canSetBusParamsC200()
+ *
+ */
+canStatus CANLIBAPI canGetBusParams (const CanHandle hnd,
+                                     long  *freq,
+                                     unsigned int *tseg1,
+                                     unsigned int *tseg2,
+                                     unsigned int *sjw,
+                                     unsigned int *noSamp,
+                                     unsigned int *syncmode);
+
+
+/**
+ * \ingroup CAN
+ *
+ * \source_cs       <b>static Canlib.canStatus canGetBusParamsFd(int hnd, out long freq_brs, out int tseg1_brs, out int tseg2_brs, out int sjw_brs);</b>
+ *
+ * \source_delphi   <b>function canGetBusParamsFd(hnd: canHandle; var freq_brs: Longint; var tseg1_brs, tseg2_brs, sjw_brs): canStatus;</b>
+ * \source_end
+ *
+ * This function retrieves the current bus parameters for the specified
+ * CAN FD channel.
+ *
+ * \param[in]  hnd         An open handle to a CAN FD controller.
+ * \param[out] freq_brs    Bit rate (bits per second).
+ * \param[out] tseg1_brs   Time segment 1, that is, the number of quanta from (but not
+ *                         including) the Sync Segment to the sampling point.
+ * \param[out] tseg2_brs   Time segment 2, that is, the number of quanta from the sampling
+ *                         point to the end of the bit.
+ * \param[out] sjw_brs     The Synchronization Jump Width; can be 1,2,3, or 4.
+ *
+ * \return \ref canOK (zero) if success
+ * \return \ref canERR_xxx (negative) if failure
+ */
+canStatus CANLIBAPI canGetBusParamsFd(const CanHandle hnd,
+                                      long  *freq_brs,
+                                      unsigned int *tseg1_brs,
+                                      unsigned int *tseg2_brs,
+                                      unsigned int *sjw_brs);
+/**
+ * \ingroup CAN
+ *
+ * \source_cs       <b>static Canlib.canStatus canSetBusOutputControl(int handle, int drivertype);</b>
+ *
+ * \source_delphi   <b>function canSetBusOutputControl(handle: canHandle; drivertype: Cardinal): canStatus;     </b>
+ * \source_end
+ *
+ * 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.
+ *
+ * \param[in]  hnd         A handle to an open circuit.
+ * \param[out] drivertype  Can driver type, \ref canDRIVER_xxx)
+ *
+ * \return \ref canOK (zero) if success
+ * \return \ref canERR_xxx (negative) if failure
+ *
+ * \sa \ref canGetBusOutputControl()
+ */
+canStatus CANLIBAPI canSetBusOutputControl (const CanHandle hnd,
+                                            const unsigned int drivertype);
+
+/**
+ * \ingroup CAN
+ *
+ * \source_cs       <b>static Canlib.canStatus canGetBusOutputControl(int handle, out int drivertype);</b>
+ *
+ * \source_delphi   <b>function canGetBusOutputControl(handle: canHandle; var drivertype: Cardinal): canStatus;  </b>
+ * \source_end
+ *
+ * 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.
+ *
+ * \note Silent Mode is not supported by all CAN controllers.
+ *
+ * \param[in] hnd         An open handle to a CAN circuit.
+ * \param[in] drivertype  A pointer to an unsigned int which receives the
+ *                        current driver type. The driver type can be either
+ *                        \ref canDRIVER_NORMAL or \ref canDRIVER_SILENT.
+ *
+ * \return \ref canOK (zero) if success
+ * \return \ref canERR_xxx (negative) if failure
+ *
+ * \sa \ref canSetBusOutputControl()
+ */
+canStatus CANLIBAPI canGetBusOutputControl (const CanHandle hnd,
+                                            unsigned int *drivertype);
+
+/**
+ * \ingroup CAN
+ *
+ * \source_cs       <b>static Canlib.canStatus canAccept(int handle, int envelope, int flag);</b>
+ *
+ * \source_delphi   <b>function canAccept(handle: canHandle; envelope: Longint; flag: Cardinal): canStatus;     </b>
+ * \source_end
+ *
+ * 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. \ref canAccept() behaves in the same way for all
+ * boards, however.
+ *
+ * \ref canSetAcceptanceFilter() and \ref 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 \ref canAccept() with the mask set to 0.
+ *
+ * \note You can set the extended code and mask only on CAN boards that support
+ *       extended identifiers.
+ *
+ * \note Not all CAN boards support different masks for standard and extended
+ *       CAN identifiers.
+ *
+ * \param[in]  hnd       An open handle to a CAN circuit.
+ * \param[in]  envelope  The mask or code to set.
+ * \param[in]  flag      Any of \ref canFILTER_SET_CODE_STD,
+ *                       \ref canFILTER_SET_MASK_STD,
+ *                       \ref canFILTER_SET_CODE_EXT or
+ *                       \ref canFILTER_SET_MASK_EXT
+ *
+ * \return \ref canOK (zero) if success
+ * \return \ref canERR_xxx (negative) if failure
+ *
+ * \sa \ref page_user_guide_misc_code_and_mask,
+ *     \ref page_user_guide_send_recv_filters,
+ *     \ref page_code_snippets_examples
+ */
+canStatus CANLIBAPI canAccept (const CanHandle hnd,
+                               const long envelope,
+                               const unsigned int flag);
+
+/**
+ * \ingroup CAN
+ *
+ * \source_cs       <b>static Canlib.canStatus canReadStatus(int handle, out long flags);</b>
+ *
+ * \source_delphi   <b>function canReadStatus(handle: canHandle; var flags: Longint): canStatus;     </b>
+ * \source_end
+ *
+ * Returns the status for the specified circuit. flags points to a longword
+ * which receives a combination of the \ref canSTAT_xxx flags.
+ *
+ * \note \ref canReadStatus() returns the latest known status of the specified
+ *       circuit. If a status change happens precisely when \ref canReadStatus() is
+ *       called, it may not be reflected in the returned result.
+ *
+ * \param[in]  hnd    A handle to an open circuit.
+ * \param[out] flags  Pointer to a \c DWORD which receives the status flags;
+ *                    this is a combination of any of the \ref canSTAT_xxx.
+ *
+ * \return \ref canOK (zero) if success
+ * \return \ref canERR_xxx (negative) if failure
+ *
+ */
+canStatus CANLIBAPI canReadStatus (const CanHandle hnd,
+                                   unsigned long *const flags);
+
+/**
+ * \ingroup CAN
+ *
+ * \source_cs       <b>static Canlib.canStatus canReadErrorCounters(int handle, out int txErr, out int rxErr, out int ovErr);</b>
+ *
+ * \source_delphi   <b>function canReadErrorCounters(handle: canHandle; var txErr, rxErr, ovErr: Cardinal): canStatus;     </b>
+ * \source_end
+ *
+ * Reads the error counters of the CAN controller.
+ *
+ * \ref canReadErrorCounters() returns the latest known values of the error counters
+ * in the specified circuit. If the error counters change values precisely when
+ * \ref canReadErrorCounters() is called, it may not be reflected in the returned
+ * result.
+ *
+ * It is allowed to pass \c NULL as the value of the \a txErr, \a rxErr, and \a
+ * ovErr parameters.
+ *
+ * Use \ref canIoCtl() to clear the counters.
+ *
+ * \note Not all CAN controllers provide access to the error counters;
+ *       in this case, an educated guess is returned.
+ *
+ * \param[in]  hnd    A handle to an open circuit.
+ * \param[out] txErr  A pointer to a \c DWORD which receives the transmit error
+ *                    counter.
+ * \param[out] rxErr  A pointer to a \c DWORD which receives the receive error
+ *                    counter.
+ * \param[out] ovErr  A pointer to a \c DWORD which receives the number of
+ *                    overrun errors.
+ *
+ * \return \ref canOK (zero) if success
+ * \return \ref canERR_xxx (negative) if failure
+ *
+ * \sa \ref canIoCtl()
+ */
+canStatus CANLIBAPI canReadErrorCounters (const CanHandle hnd,
+                                          unsigned int *txErr,
+                                          unsigned int *rxErr,
+                                          unsigned int *ovErr);
+
+/**
+ * \ingroup CAN
+ *
+ * \source_cs       <b>static Canlib.canStatus canWrite(int handle, int id, byte[] msg, int dlc, int flag);</b>
+ *
+ * \source_delphi   <b>function canWrite(handle: canHandle; id: Longint; msg: Pointer; dlc: Cardinal; flag: Cardinal): canStatus;     </b>
+ * \source_end
+ *
+ * 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 \ref canIOCTL_SET_LOCAL_TXECHO.
+ *
+ * \note The message has been queued for transmission when this calls return.
+ *       It has not necessarily been sent.
+ *
+ * \param[in]  hnd       A handle to an open CAN circuit.
+ * \param[in]  id        The identifier of the CAN message to send.
+ * \param[in]  msg       A pointer to the message data, or \c NULL.
+ * \param[in]  dlc       The length of the message. Can be at most 8.
+ * \param[in]  flag      A combination of message flags, \ref canMSG_xxx.
+ *                       Use this parameter to send extended (29-bit) frames
+ *                       and/or remote frames. Use \ref canMSG_EXT and/or
+ *                       \ref canMSG_RTR for this purpose.
+ *
+ * \return \ref canOK (zero) if success
+ * \return \ref canERR_xxx (negative) if failure
+ *
+ * \sa \ref page_user_guide_send_recv_sending, \ref page_code_snippets_examples
+ * \sa \ref canWriteSync(), \ref canWriteWait()
+ *
+ */
+canStatus CANLIBAPI canWrite (const CanHandle hnd,
+                              long id,
+                              void *msg,
+                              unsigned int dlc,
+                              unsigned int flag);
+
+/**
+ * \ingroup CAN
+ *
+ * \source_cs       <b>static Canlib.canStatus canWriteSync(int handle, long timeout);</b>
+ *
+ * \source_delphi   <b>function canWriteSync(handle: canHandle; timeout: Longint): canStatus;     </b>
+ * \source_end
+ *
+ * Waits until all CAN messages for the specified handle are sent, or the
+ * timeout period expires.
+ *
+ * \param[in]  hnd       A handle to an open CAN circuit.
+ * \param[in]  timeout   The timeout in milliseconds. 0xFFFFFFFF gives an
+ *                       infinite timeout.
+ *
+ * \return \ref canOK (zero) if the queue emptied before the timeout period came to
+ *         its end.
+ * \return \ref canERR_TIMEOUT (negative) not all messages were transmitted when
+ *         the timeout occurred.
+ * \return \ref canERR_PARAM (negative) This could be caused by an erroneous
+ *         parameter, or if you have turned TXACKs off (by using \ref canIoCtl())
+ *         because if you do you can't use this call. The driver simply doesn't
+ *         know when all the messages are sent!
+ * \return \ref canERR_xxx (negative) if failure
+ *
+ * \sa \ref canWrite(), \ref canWriteWait()
+ */
+canStatus CANLIBAPI canWriteSync (const CanHandle hnd, unsigned long timeout);
+
+/**
+ * \ingroup CAN
+ *
+ * \source_cs       <b>static Canlib.canStatus canRead(int handle, out int id, byte[] msg, out int dlc, out int flag, out long time);</b>
+ *
+ * \source_delphi   <b>function canRead(handle: canHandle; var id: Longint; msg: Pointer; var dlc: Cardinal; var flag: Cardinal; var time: Longint): canStatus;     </b>
+ * \source_end
+ *
+ * Reads a message from the receive buffer. If no message is available, the
+ * function returns immediately with return code \ref 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 \ref canIOCTL_SET_LOCAL_TXECHO.
+ *
+ * It is allowed to pass \c NULL as the value of \a id, \a msg, \a dlc, \a
+ * flag, and \a time.
+ *
+ * \param[in]  hnd   A handle to an open circuit.
+ * \param[out] id    Pointer 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.
+ * \param[out] msg   Pointer 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.
+ * \param[out] dlc   Pointer to a buffer which receives the message length.
+ * \param[out] flag  Pointer to a buffer which receives the message flags,
+ *                   which is a combination of the \ref canMSG_xxx and
+ *                   \ref canMSGERR_xxx values.
+ * \param[out] time  Pointer to a buffer which receives the message time stamp.
+ *
+ * \return \ref canOK (zero) if a message was read.
+ * \return \ref canERR_NOMSG (negative) if there was no message available.
+ * \return \ref canERR_xxx (negative) if failure
+ *
+ * \sa \ref page_user_guide_send_recv_reading, \ref
+ * page_user_guide_send_recv_mailboxes, \ref page_code_snippets_examples,
+ * \ref page_user_guide_time_accuracy_and_resolution
+ * \sa \ref canReadSpecific(), \ref canReadSpecificSkip(), \ref canReadSync(),
+ *     \ref canReadSyncSpecific(), \ref canReadWait()
+ *
+ */
+canStatus CANLIBAPI canRead (const CanHandle hnd,
+                             long *id,
+                             void *msg,
+                             unsigned int *dlc,
+                             unsigned int *flag,
+                             unsigned long *time);
+
+/**
+ * \ingroup CAN
+ *
+ * \source_cs       <b>static Canlib.canStatus canReadWait(int handle, out int id, byte[] msg, out int dlc, out int flag, out long time, long timeout);</b>
+ *
+ * \source_delphi   <b>function canReadWait(handle: canHandle; var id: Longint; msg: Pointer; var dlc: Cardinal; var flag: Cardinal; var time: Longint; timeout: Longint): canStatus;     </b>
+ * \source_end
+ *
+ * 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 \ref canIOCTL_SET_LOCAL_TXECHO.
+ *
+ * It is allowed to pass \c NULL as the value of \a id, \a msg, \a dlc, \a
+ * flag, and \a time.
+ *
+ * \param[in]   hnd    A handle to an open circuit.
+ * \param[out]  id     Pointer 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.
+ * \param[out]  msg    Pointer to the buffer which receives the message data.
+ *                     This buffer must be large enough (i.e. 8 bytes.).
+ * \param[out]  dlc    Pointer to a buffer which receives the message length.
+ * \param[out]  flag   Pointer to a buffer which receives the message flags,
+ *                     which is a combination of the \ref canMSG_xxx and
+ *                     \ref canMSGERR_xxx values.
+ * \param[out] time    Pointer to a buffer which receives the message time stamp.
+ * \param[in]  timeout If no message is immediately available, this parameter
+ *                     gives the number of milliseconds to wait for a message
+ *                     before returning. 0xFFFFFFFF gives an infinite timeout.
+ *
+ * \return \ref canOK (zero) if a message was read.
+ * \return \ref canERR_NOMSG (negative) if there was no message available.
+ * \return \ref canERR_xxx (negative) if failure
+ *
+ * \sa \ref canRead(),\win_start \ref canReadSpecific(), \ref canReadSpecificSkip(),
+ *  \ref canReadSyncSpecific(),\win_end \ref canReadSync()
+ *
+ * \sa \ref page_user_guide_time_accuracy_and_resolution
+ */
+canStatus CANLIBAPI canReadWait (const CanHandle hnd,
+                                 long *id,
+                                 void *msg,
+                                 unsigned int  *dlc,
+                                 unsigned int  *flag,
+                                 unsigned long *time,
+                                 unsigned long timeout);
+
+#if defined(CANLIB_DECLARE_ALL)
+/**
+ * \ingroup CAN
+ *
+ * \source_cs       <b>static Canlib.canStatus canReadSpecific(int handle, int id, byte[] msg, out int dlc, out int flag, out long time);</b>
+ *
+ * \source_delphi   <b>function canReadSpecific(handle: canHandle; id: Longint; msg: Pointer; var dlc: Cardinal; var flag: Cardinal; var time: Longint): canStatus;     </b>
+ * \source_end
+ *
+ * Reads a message with a specified identifier from the receive buffer. Any
+ * preceding message not matching the specified identifier will be kept
+ * in the receive buffer. If no message with the specified identifier is
+ * available, the function returns immediately with an error code.
+ *
+ * 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 \ref canIOCTL_SET_LOCAL_TXECHO.
+ *
+ * It is allowed to pass \c NULL as the value of \a id, \a msg, \a dlc, \a
+ * flag, and \a time.
+ *
+ * \note Use \ref canReadSpecific only if you for some reason must keep the unread
+ *       messages in the queue. If this is not the case, consider using
+ *       \ref canReadSpecificSkip() or \ref canRead() for better performance.
+ *
+ * \param[in]   hnd    A handle to an open circuit.
+ * \param[out]  id     The desired CAN identifier.
+ * \param[out]  msg    Pointer to the buffer which receives the message data.
+ *                     This buffer must be large enough (i.e. 8 bytes.).
+ * \param[out]  dlc    Pointer to a buffer which receives the message length.
+ * \param[out]  flag   Pointer to a buffer which receives the message flags,
+ *                     which is a combination of the \ref canMSG_xxx and
+ *                     \ref canMSGERR_xxx values.
+ * \param[out] time    Pointer to a buffer which receives the message time stamp.
+ *
+ * \return \ref canOK (zero) if a message was read.
+ * \return \ref canERR_NOMSG (negative) if a matching message was not found.
+ *         There might be other messages in the queue, though.
+ * \return \ref canERR_xxx (negative) if failure
+ *
+ * \sa \ref page_user_guide_send_recv_mailboxes \ref
+ * page_user_guide_send_recv_reading \ref
+ * page_user_guide_time_accuracy_and_resolution
+ * \sa \ref canRead(), \ref canReadSpecificSkip(), \ref canReadSync(), \ref canReadSyncSpecific(),
+ * \ref canReadWait()
+ *
+ */
+canStatus CANLIBAPI canReadSpecific (const CanHandle hnd, long id, void * msg,
+                                     unsigned int * dlc, unsigned int * flag,
+                                     unsigned long * time);
+
+/**
+ * \ingroup CAN
+ *
+ * \source_cs       <b>static Canlib.canStatus canReadSync(int handle, long timeout);</b>
+ *
+ * \source_delphi   <b>function canReadSync(handle: canHandle; timeout: Longint): canStatus;     </b>
+ * \source_end
+ *
+ * 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 \ref canIOCTL_SET_LOCAL_TXECHO.
+ *
+ * \param[in]  hnd      A handle to an open circuit.
+ * \param[in]  timeout  The timeout in milliseconds. 0xFFFFFFFF gives an
+ *                      infinite timeout.
+ *
+ * \return \ref canOK (zero) if the queue contains the desired message.
+ * \return \ref canERR_TIMEOUT (negative) if a timeout occurs before a message
+ *         arrived.
+ * \return \ref canERR_xxx (negative) if the call fails.
+ *
+ * \sa \ref canRead(), \win_start \ref canReadSpecific(), \ref canReadSpecificSkip(),
+ * \ref canReadSyncSpecific(),\win_end \ref canReadWait()
+ */
+canStatus CANLIBAPI canReadSync (const CanHandle hnd, unsigned long timeout);
+
+/**
+ * \ingroup CAN
+ *
+ * \source_cs       <b>static Canlib.canStatus canReadSyncSpecific(int handle, int id, long timeout);</b>
+ *
+ * \source_delphi   <b>function canReadSyncSpecific(handle: canHandle; id, timeout: Longint): canStatus;  </b>
+ * \source_end
+ *
+ * Waits until the receive queue contains a message with the specified id, 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 \ref canIOCTL_SET_LOCAL_TXECHO.
+ *
+ * \param[in]  hnd      A handle to an open circuit.
+ * \param[in]  id       The desired message identifier.
+ * \param[in]  timeout  The timeout in milliseconds. 0xFFFFFFFF gives an
+ *                      infinite timeout.
+ *
+ * \return \ref canOK (zero) if the queue contains the desired message.
+ * \return \ref canERR_TIMEOUT (negative) if a timeout occurs before the specified
+ *         message arrived.
+ * \return \ref canERR_xxx (negative) if the call fails.
+ *
+ * \sa \ref canRead(), \ref canReadSpecific(), \ref canReadSpecificSkip(),
+ * \ref canReadSync(), \ref canReadWait()
+ */
+canStatus CANLIBAPI canReadSyncSpecific (const CanHandle hnd,
+                                         long id,
+                                         unsigned long timeout);
+
+/**
+ * \ingroup CAN
+ *
+ * \source_cs       <b>static Canlib.canStatus canReadSpecificSkip(int hnd, int id, byte[] msg, out int dlc, out int flag, out long time);</b>
+ *
+ * \source_delphi   <b>function canReadSpecificSkip(handle: canHandle; id: Longint; msg: Pointer; var dlc: Cardinal; var flag: Cardinal; var time: Longint): canStatus;     </b>
+ * \source_end
+ *
+ * Reads a message with a specified identifier from the receive buffer. Any
+ * preceding message not matching the specified identifier will be removed
+ * in the receive buffer. If no message with the specified identifier is
+ * available, the function returns immediately with an error code.
+ *
+ * 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 \ref canIOCTL_SET_LOCAL_TXECHO.
+ *
+ * It is allowed to pass \c NULL as the value of \a id, \a msg, \a dlc, \a
+ * flag, and \a time.
+ *
+ * \param[in]   hnd    A handle to an open circuit.
+ * \param[out]  id     The desired CAN identifier.
+ * \param[out]  msg    Pointer to the buffer which receives the message data.
+ *                     This buffer must be large enough (i.e. 8 bytes.).
+ * \param[out]  dlc    Pointer to a buffer which receives the message length.
+ * \param[out]  flag   Pointer to a buffer which receives the message flags,
+ *                     which is a combination of the \ref canMSG_xxx and
+ *                     \ref canMSGERR_xxx values.
+ * \param[out] time    Pointer to a buffer which receives the message time stamp.
+ *
+ * \return \ref canOK (zero) if a matching message was found.
+ * \return \ref canERR_NOMSG if there was no matching message available. All other
+           messages (if any!) were discarded.
+ * \return \ref canERR_xxx (negative) if failure
+ *
+ * \sa \ref page_user_guide_send_recv_reading, \ref
+ * page_user_guide_time_accuracy_and_resolution
+ * \sa \ref canRead(), \ref canReadSpecific(), \ref canReadSync(),
+ * \ref canReadSyncSpecific(), \ref canReadWait()
+ */
+canStatus CANLIBAPI canReadSpecificSkip (const CanHandle hnd,
+                                         long id,
+                                         void * msg,
+                                         unsigned int * dlc,
+                                         unsigned int * flag,
+                                         unsigned long * time);
+#endif
+
+
+/**
+ * \ingroup CAN
+ *
+ * \source_cs       <b>static Canlib.canStatus canSetNotify(int handle, IntPtr win_handle, int aNotifyFlags);</b>
+ *
+ * \source_delphi   <b>function canSetNotify(handle: canHandle; aHWnd: HWND; aNotifyFlags: Cardinal): canStatus;     </b>
+ * \source_end
+ *
+ * This function associates a window handle with the CAN circuit. A
+ * \c WM__CANLIB message is sent to that window when certain events
+ * (specified by the \ref canNOTIFY_xxx flags) occur.
+ *
+ * When an event take place, a \c WM__CANLIB message will be sent to the window
+ * whose handle is aHWnd. This \c WM__CANLIB message will have:
+ *
+ * \li \c WPARAM handle to the circuit where the event occurred
+ * \li \c HIWORD(LPARAM) 0
+ * \li \c LOWORD(LPARAM) \ref canEVENT_xxx
+ *
+ * In the routine that handles \c WM__CANLIB, you can call the CANLIB API
+ * functions (for example, \ref canRead()) using the handle found in \c wParam.
+ *
+ * \param[in]  hnd          A handle to an open CAN circuit.
+ * \param[in] aHWnd         Handle of the window which will receive the
+ *                          notification messages.
+ * \param[in] aNotifyFlags  The events specified with \ref canNOTIFY_xxx, for
+ *                          which callback should be called.
+ *
+ * \return \ref canOK (zero) if success
+ * \return \ref canERR_xxx (negative) if failure
+ *
+ * \n In the routine that handles \c WM__CANLIB, you must call \ref canRead() repeatedly
+ *    until it returns \ref canERR_NOMSG, regardless of the \c LPARAM value. This will
+ *    flush the driver's internal event queues. If you fail to do this, no more
+ *    events will be reported.
+ *
+ * \sa \ref page_code_snippets_examples
+ */
+canStatus CANLIBAPI canSetNotify (const CanHandle hnd,
+                                  HWND aHWnd,
+                                  unsigned int aNotifyFlags);
+
+
+/**
+ * \ingroup CAN
+ *
+ * \source_cs       <b>static Canlib.canStatus canTranslateBaud(ref int freq, out int tseg1, out int tseg2, out int sjw, out int nosamp, out int syncMode);</b>
+ *
+ * \source_delphi   <b>function canTranslateBaud(var freq: longint; var tseg1, tseg2, sjw, noSamp, syncMode: Cardinal): canStatus;     </b>
+ * \source_end
+ *
+ * This function translates the \ref canBITRATE_xxx constants to their corresponding
+ * bus parameter values. At return, this \a freq contains the actual bit rate
+ * (in bits per second). \a TSeg1 is the number of quanta (less one) in a bit
+ * before the sampling point. \a TSeg2 is the number of quanta after the
+ * sampling point.
+ *
+ * \param[in]  freq      A pointer to a \c DWORD which contains the \ref canBITRATE_xxx
+ *                       constant to translate
+ * \param[in]  tseg1     A 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.
+ * \param[in]  tseg2     A 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.
+ * \param[in]  sjw       A pointer to a buffer which receives the Synchronization
+ *                       Jump Width; can be 1,2,3, or 4.
+ * \param[in]  nosamp    A pointer to a buffer which receives the number of
+ *                       sampling points; can be 1 or 3.
+ * \param[in]  syncMode  Unsupported, always read as zero.
+ *
+ * \return \ref canOK (zero) if success
+ * \return \ref canERR_xxx (negative) if failure
+ *
+ * \sa \ref canSetBusParams()
+ */
+canStatus CANLIBAPI canTranslateBaud (long *const freq,
+                                      unsigned int *const tseg1,
+                                      unsigned int *const tseg2,
+                                      unsigned int *const sjw,
+                                      unsigned int *const nosamp,
+                                      unsigned int *const syncMode);
+
+/**
+ * \ingroup General
+ *
+ * \source_cs       <b>static Canlib.canStatus canGetErrorText(Canlib.canStatus err, out string buf_str);</b>
+ *
+ * \source_delphi   <b>function canGetErrorText(err: canStatus; buf: PChar; bufsiz: Cardinal): canStatus;     </b>
+ * \source_end
+ *
+ * This function translates an error code (\ref canERR_xxx)
+ * to a human-readable, English text.
+ *
+ * \param[in]     err     The error code.
+ * \param[in,out] buf     The buffer which is to receive the text, which is a
+ *                        zero-terminated string (provided the buffer is large enough.)
+ * \param[in]     bufsiz  The length of the input buffer.
+ *
+ * \return \ref canOK (zero) if success
+ * \return \ref canERR_xxx (negative) if failure
+ *
+ * \sa \ref page_code_snippets_examples
+ *
+ */
+canStatus CANLIBAPI canGetErrorText (canStatus err, char *buf, unsigned int bufsiz);
+
+/**
+ * \ingroup  General
+ *
+ * \source_cs       <b>static short canGetVersion();</b>
+ *
+ * \source_delphi   <b>function canGetVersion: Word;     </b>
+ * \source_end
+ *
+ * \win_start
+ * This API call returns the version of the CANLIB API DLL (canlib32.dll).  The
+ * most significant byte is the major version number and the least significant
+ * byte is the minor version number.
+ *
+ * The actual version of the different driver files can be obtained by studying
+ * the version resources in each of the files.
+ *
+ * \note The version number of the canlib32.dll file is not related to the
+ *       product version of CANLIB you are using. CANLIB consists of several
+ *       driver and DLL files. To obtain the product version, use
+ *       \ref canGetVersionEx().
+ *
+ * \return version number of canlib32.dll
+ *
+ * \sa \ref page_user_guide_build_driver_version
+ * \sa \ref canGetVersionEx(), \ref canProbeVersion()
+ *
+ * \win_end
+ *
+ * \linux_start
+ * 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.
+ *
+ * \return version number of libcanlib.so.x.y
+ *
+ * \linux_end
+ *
+ *
+ */
+unsigned short CANLIBAPI canGetVersion (void);
+
+/**
+ * \ingroup General
+ *
+ * \source_cs       <b>static Canlib.canStatus canIoCtl(int handle, int func, int val);<br>
+      static Canlib.canStatus canIoCtl(int handle, int func, out int val);<br>
+      static Canlib.canStatus canIoCtl(int handle, int func, out string str_buf);<br>
+      static Canlib.canStatus canIoCtl(int handle, int func, ref object obj_buf);</b>
+ *
+ * \source_delphi   <b>function canIoCtl(handle: canHandle; func: Cardinal; buf: Pointer; buflen: Cardinal): canStatus;     </b>
+ * \source_end
+ *
+ * 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 \ref canIoCtl(), whereas other open
+ * handles will remain unaffected.  The contents of \a buf after the call is
+ * dependent on the function code you specified.
+ *
+ * \param[in]     hnd     A handle to an open circuit.
+ * \param[in]     func    A \ref canIOCTL_xxx function code
+ * \param[in,out] buf     Pointer to a buffer containing function-dependent data;
+                          or a \c NULL pointer for certain function codes. The
+                          buffer can be used for both input and output
+                          depending on the function code. See \ref canIOCTL_xxx.
+ * \param[in]     buflen  The length of the buffer.
+ *
+ * \return \ref canOK (zero) if success
+ * \return \ref canERR_xxx (negative) if failure
+ *
+ */
+canStatus CANLIBAPI canIoCtl (const CanHandle hnd,
+                              unsigned int func,
+                              void *buf,
+                              unsigned int buflen);
+
+/* Note the difference from the windows version */
+
+/**
+ * \ingroup CAN
+ *
+ * \source_cs       <b>static long canReadTimer(int hnd);</b>
+ *
+ * \source_delphi   <b>function canReadTimer(handle: canHandle): longint;     </b>
+ * \source_end
+ *
+ * Reads the current time from the clock used to timestamp the
+ * messages for the indicated circuit.
+ *
+ * This API may return \ref canERR_INVHANDLE and/or \ref canERR_NOTINITIALIZED!
+ * This happens if \a hnd is invalid, or if the library was not initialized.
+ *
+ * \note \ref kvReadTimer() should be used instead since it separates the returned
+ * time from the error code.
+ *
+ * \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.
+ *
+ * \param[in]  hnd  A handle to an open circuit.
+ *
+ * \return The current time, with the prevailing time resolution (milliseconds
+ *         by default).
+ *
+ * \sa \ref page_user_guide_time_accuracy_and_resolution
+ * \sa \ref kvReadTimer()
+ */
+unsigned long CANLIBAPI canReadTimer (const CanHandle hnd);
+
+/**
+ * \ingroup CAN
+ *
+ * \source_cs       <b>static int canOpenChannel(int channel, int flags);</b>
+ *
+ * \source_delphi   <b>function canOpenChannel(channel: Integer; flags: Integer): canHandle;     </b>
+ * \source_end
+ *
+ * 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,
+ *
+ * \li If you have a single LAPcan, the channels are numbered 0 and 1.
+ *
+ * \li If you have a USBcan Professional, the channels are numbered 0-1
+ *     according to the labels on the cables.
+ *
+ * \li 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
+ * \ref 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 \ref 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 \ref canIOCTL_SET_LOCAL_TXECHO.
+ *
+ * \note The handle returned may be zero which is perfectly valid.
+ *
+ * \note This call replaces the \ref canOpen() API call and serves the same purpose.
+ *
+ * \param[in]  channel  The number of the channel. Channel numbering is hardware
+ *                      dependent.
+ * \param[in]  flags    A combination of \ref canOPEN_xxx flags
+ *
+ * \return Returns a handle to the opened circuit, or \ref canERR_xxx
+ *         (negative) if the call failed.
+ *
+ * \sa \ref page_code_snippets_examples,  \ref page_user_guide_virtual_info
+ * \sa \ref canGetNumberOfChannels(), \ref canGetChannelData(), \ref canIoCtl()
+ *
+ */
+CanHandle CANLIBAPI canOpenChannel (int channel, int flags);
+
+/**
+ * \ingroup General
+ *
+ * \source_cs       <b>static Canlib.canStatus canGetNumberOfChannels(out int channelCount);</b>
+ *
+ * \source_delphi   <b>function canGetNumberOfChannels(var channelCount: Integer): canStatus;     </b>
+ * \source_end
+ *
+ * This function returns the number of available CAN channels in the
+ * computer. The virtual channels are included in this number.
+ *
+ * \param[out] channelCount  A pointer to a \c DWORD which will receive the current
+ *                           number of channels.
+ *
+ * \return \ref canOK (zero) if success
+ * \return \ref canERR_xxx (negative) if failure
+ *
+ * \sa \ref page_code_snippets_examples, \ref page_user_guide_virtual_info
+ * \sa \ref canGetChannelData()
+ */
+canStatus CANLIBAPI canGetNumberOfChannels (int *channelCount);
+
+/**
+ * \ingroup General
+ *
+ * \source_cs       <b>static Canlib.canStatus canGetChannelData(int channel, int item, out object buffer);</b>
+ *
+ * \source_delphi   <b>function canGetChannelData(channel, item: Integer; var buffer; bufsize: Cardinal): canStatus;     </b>
+ * \source_end
+ *
+ * This function can be used to retrieve certain pieces of information about a channel.
+ *
+ * \note You must pass a channel number and not a channel handle.
+ *
+ * \param[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
+ *                        \ref canGetNumberOfChannels() minus 1.
+ * \param[in]  item  This parameter specifies what data to obtain for the
+ *                        specified channel. The value is one of the constants
+ *                        \ref canCHANNELDATA_xxx.
+ * \param[in,out] buffer  The address of a buffer which is to receive the data.
+ * \param[in]  bufsize    The size of the buffer to which the buffer parameter
+ *                        points.
+ *
+ * \return \ref canOK (zero) if success
+ * \return \ref canERR_xxx (negative) if failure
+ *
+ * \sa \ref page_code_snippets_examples
+ * \sa \ref canGetNumberOfChannels()
+ */
+canStatus CANLIBAPI canGetChannelData (int channel,
+                                       int item,
+                                       void *buffer,
+                                       size_t bufsize);
+
+/**
+ * \ingroup General
+ * \anchor canCHANNELDATA_xxx
+ * \name canCHANNELDATA_xxx
+ *
+ * These defines are used in \ref canGetChannelData().
+ *
+ *  @{
+ */
+
+  /**
+   * This define is used in \ref canGetChannelData(), \a buffer
+   * mentioned below refers to this functions argument.
+   *
+   * \a buffer points to a 32-bit unsigned integer that receives the
+   * capabilities of the CAN controller; this is a combination of the \ref
+   * canCHANNEL_CAP_xxx flags.
+   */
+#define canCHANNELDATA_CHANNEL_CAP                1
+
+  /**
+   * This define is used in \ref canGetChannelData(), \a buffer
+   * mentioned below refers to this functions argument.
+   *
+   * \a buffer points to a 32-bit unsigned integer that receives the
+   * capabilities of the CAN transceiver; this is a combination of the
+   * \ref canDRIVER_CAP_xxx flags.
+   */
+#define canCHANNELDATA_TRANS_CAP                  2
+
+  /**
+   * This define is used in \ref canGetChannelData(), \a buffer
+   * mentioned below refers to this functions argument.
+   *
+   * \note Currently not implemented.
+   */
+#define canCHANNELDATA_CHANNEL_FLAGS              3   // available, etc
+
+  /**
+   * This define is used in \ref canGetChannelData(), \a buffer
+   * mentioned below refers to this functions argument.
+   *
+   * \a buffer points to a 32-bit unsigned integer that receives the hardware
+   * type of the card. This value is any one of the \ref canHWTYPE_xxx
+   * constants.
+   */
+#define canCHANNELDATA_CARD_TYPE                  4
+
+  /**
+   * This define is used in \ref canGetChannelData(), \a buffer
+   * mentioned below refers to this functions argument.
+   *
+   * \a buffer points to a 32-bit unsigned integer that receives the card's
+   * number in the computer. Each card type is numbered separately. For
+   * example, the first LAPcan card in a machine will have number 0, the second
+   * LAPcan number 1, etc.
+   */
+#define canCHANNELDATA_CARD_NUMBER                5
+
+  /**
+   * This define is used in \ref canGetChannelData(), \a buffer
+   * mentioned below refers to this functions argument.
+   *
+   * \a buffer points to a 32-bit unsigned integer which receives the channel
+   * number on the card.
+   */
+#define canCHANNELDATA_CHAN_NO_ON_CARD            6
+
+  /**
+   * This define is used in \ref canGetChannelData(), \a buffer
+   * mentioned below refers to this functions argument.
+   *
+   * \a buffer points to a 64-bit (8 bytes) area which receives the serial
+   * number of the card. If the card doesn't have a serial number, 0 is
+   * returned. The serial number is an 8-byte unsigned integer. Currently, no
+   * products are using all 8 bytes; at most 4 bytes are used.
+   */
+#define canCHANNELDATA_CARD_SERIAL_NO             7
+
+  /**
+   * This define is used in \ref canGetChannelData(), \a buffer
+   * mentioned below refers to this functions argument.
+   *
+   * \a buffer points to a 64-bit (8 bytes) area which receives the serial
+   * number of the transceiver. The serial number is an 8-byte unsigned
+   * integer. If the transceiver doesn't have a serial number, 0 is returned.
+   */
+#define canCHANNELDATA_TRANS_SERIAL_NO            8
+
+  /**
+   * This define is used in \ref canGetChannelData(), \a buffer
+   * mentioned below refers to this functions argument.
+   *
+   * \a buffer points to a 64-bit (8 bytes) area which receives the firmware
+   * revision number on the card. This number consists of four 16-bit words:
+   * the major revision, the minor revision, the release number and the build
+   * number, listed in order from the most significant to the least
+   * significant.
+   */
+#define canCHANNELDATA_CARD_FIRMWARE_REV          9
+
+  /**
+   * This define is used in \ref canGetChannelData(), \a buffer
+   * mentioned below refers to this functions argument.
+   *
+   * \a buffer points to a 64-bit (8 bytes) area which receives the hardware
+   * revision number on the card. This number consists of four 16-bit words;
+   * the two most significant are always 0, and the two least significant are
+   * the major revision and the minor revision, listed in order from the most
+   * significant to the least significant.
+   */
+#define canCHANNELDATA_CARD_HARDWARE_REV          10
+
+  /**
+   * This define is used in \ref canGetChannelData(), \a buffer
+   * mentioned below refers to this functions argument.
+   *
+   * \a buffer points to a 8-byte area which receives the UPC (EAN) number for
+   * the card. If there is no UPC number, the buffer is filled with zeros. The
+   * UPC (EAN) number is coded as a BCD string with the LSB first, so
+   * e.g. 733-0130-00122-0 is coded as 0x30001220 0x00073301.
+   */
+#define canCHANNELDATA_CARD_UPC_NO                11
+
+  /**
+   * This define is used in \ref canGetChannelData(), \a buffer
+   * mentioned below refers to this functions argument.
+   *
+   * \a buffer points to a 8-byte area which receives the UPC (EAN) number for
+   * the transceiver. If there is no UPC number, the buffer is filled with
+   * zeros. The UPC (EAN) number is coded as a BCD string with the LSB first,
+   * so e.g. 733-0130-00122-0 is coded as 0x30001220 0x00073301.
+   */
+#define canCHANNELDATA_TRANS_UPC_NO               12
+
+  /**
+   * This define is used in \ref canGetChannelData(), \a buffer
+   * mentioned below refers to this functions argument.
+   *
+   * \a buffer points to an area which receives a zero-terminated string with a
+   * clear-text name of the channel.
+   *
+   * \note Use of this item code is no longer recommended. The returned
+   * channel name doesn't contain the exact hardware type (it just contains
+   * the device family) and uses zero-based channel numbering, which is not
+   * user friendly.  Instead, use e.g. \ref canCHANNELDATA_DEVDESCR_ASCII and
+   * \ref canCHANNELDATA_CHAN_NO_ON_CARD to build your own channel name.
+   *
+   *\win_start
+   * \sa \ref canCHANNELDATA_DEVNAME_ASCII
+   *\win_end
+   */
+#define canCHANNELDATA_CHANNEL_NAME               13
+#if defined(CANLIB_DECLARE_ALL)
+
+  /**
+   * This define is used in \ref canGetChannelData(), \a buffer
+   * mentioned below refers to this functions argument.
+   *
+   * \a buffer points to an array of 4 16-bit unsigned integers which receives
+   * the file version number of the second-level DLL driver file, i.e. the DLL
+   * that interfaces between CANLIB32.DLL and the driver proper.
+   *
+   * Contents depening on index:
+   *
+   * \li 0: 0
+   * \li 1: The build number
+   * \li 2: The minor revision number
+   * \li 3: The major revision number
+   */
+# define canCHANNELDATA_DLL_FILE_VERSION          14
+
+  /**
+   * This define is used in \ref canGetChannelData(), \a buffer
+   * mentioned below refers to this functions argument.
+   *
+   * \a buffer points to an array of 4 16-bit unsigned integers which receives
+   * the product version number of the second-level DLL driver file, i.e. the
+   * DLL that interfaces between CANLIB32.DLL and the driver proper.
+   *
+   * Contents depening on index:
+   *
+   * \li 0: 0
+   * \li 1: 1
+   * \li 2: The minor revision number
+   * \li 3: The major revision number
+   */
+# define canCHANNELDATA_DLL_PRODUCT_VERSION       15
+
+  /**
+   * This define is used in \ref canGetChannelData(), \a buffer
+   * mentioned below refers to this functions argument.
+   *
+   * \a buffer points to a 32-bit unsigned integer which receives a number that
+   * identifies the second-level DLL driver file, i.e. the DLL that interfaces
+   * between CANLIB32.DLL and the driver proper.
+   *
+   * Values:
+   *
+   * \li 1: kvalapw.dll - used with CANLIB up to 2.29.
+   *
+   * \li 2: kvalapw2.dll - used with CANLIB from 3.0 and on.
+   */
+# define canCHANNELDATA_DLL_FILETYPE              16
+
+  /**
+   * This define is used in \ref canGetChannelData(), \a buffer
+   * mentioned below refers to this functions argument.
+   *
+   * \a buffer points to a 32-bit unsigned integer which receives the CAN
+   * transceiver type of the specified channel.  This value is one of the
+   * \ref canTRANSCEIVER_TYPE_xxx
+   */
+# define canCHANNELDATA_TRANS_TYPE                17
+
+  /**
+   * This define is used in \ref canGetChannelData(), \a buffer
+   * mentioned below refers to this functions argument.
+   *
+   * \a buffer points to a 32-bit unsigned integer which receives an address
+   * indicating where the device is located on its underlying bus. The
+   * interpretation of this number is bus-specific. If the address is unknown
+   * or the bus driver does not support an address, the bus driver leaves this
+   * member at its default value of 0xFFFFFFFF.
+   *
+   * The following list describes the information certain bus drivers store in
+   * the Address field for their child devices:
+   *
+   * \li ISA: Does not supply an address. Defaults to 0xFFFFFFFF.
+   *
+   * \li PC Card (PCMCIA): The socket number (typically 0x00 or 0x40)
+   *
+   * \li PCI: The device number in the high word and the function number in the
+   *          low word.
+   *
+   * \li USB: The port number.
+   */
+# define canCHANNELDATA_DEVICE_PHYSICAL_POSITION  18
+
+  /**
+   * This define is used in \ref canGetChannelData(), \a buffer
+   * mentioned below refers to this functions argument.
+   *
+   * \a buffer points to a 32-bit unsigned integer which receives a number
+   * associated with the device that can be displayed in the user
+   * interface. This number is typically a user-perceived slot number, such as
+   * a number printed next to the slot on the board, or some other number that
+   * makes locating the physical device easier for the user. For buses with no
+   * such convention, or when the UI number is unknown, 0xFFFFFFFF is returned.
+   */
+# define canCHANNELDATA_UI_NUMBER                 19
+
+  /**
+   * This define is used in \ref canGetChannelData(), \a buffer
+   * mentioned below refers to this functions argument.
+   *
+   * \a buffer points to a 32-bit unsigned integer which is set to 0, if the
+   * legacy time synchronization is not currently enabled for the specified
+   * channel, and 1, if the legacy time synchronization is currently enabled
+   * for the specified channel.
+   *
+   * Legacy time synchronization is a mechanism that will keep the PC and CAN
+   * channel clocks in sync. The synchronization is done in the driver, which
+   * periodically calculates the difference between the PC clock and the CAN
+   * device clock and compensates for the clock drift by recalculating the CAN
+   * message time stamps. You need to enable clock synchronization in the
+   * Control Panel using the Kvaser Hardware applet.
+   *
+   * \note Legacy time synchronization is implemented only on LAPcan and LAPcan
+   * II. It is not related to Kvaser MagiSync&tm; which is implemented in the
+   * high-end members of the Kvaser Leaf family. Kvaser MagiSync&tm; is always
+   * enabled and allows for much more accurate time synchronization.
+   *
+   */
+# define canCHANNELDATA_TIMESYNC_ENABLED          20
+
+  /**
+   * This define is used in \ref canGetChannelData(), \a buffer
+   * mentioned below refers to this functions argument.
+   *
+   * \a buffer points to an array of four 16-bit unsigned integers which
+   * receives the file version number of the kernel-mode driver.
+   *
+   * Contents depening on index:
+   *
+   * \li 0: The build number
+   * \li 1: 0
+   * \li 2: The minor revision number
+   * \li 3: The major revision number
+   */
+# define canCHANNELDATA_DRIVER_FILE_VERSION       21
+
+  /**
+   * This define is used in \ref canGetChannelData(), \a buffer
+   * mentioned below refers to this functions argument.
+   *
+   *  \a buffer points to an array of four 16-bit unsigned integers which
+   *  receives the product version number of the kernel-mode driver.
+   *
+   * Contents depening on index:
+   *
+   * \li 0: 0
+   * \li 1: 0
+   * \li 2: The minor revision number
+   * \li 3: The major revision number
+   */
+# define canCHANNELDATA_DRIVER_PRODUCT_VERSION    22
+
+  /**
+   * This define is used in \ref canGetChannelData(), \a buffer
+   * mentioned below refers to this functions argument.
+   *
+   * \a buffer points to a buffer which receives the device manufacturer's name
+   * as a zero-terminated Unicode string.
+   */
+# define canCHANNELDATA_MFGNAME_UNICODE           23
+
+  /**
+   * This define is used in \ref canGetChannelData(), \a buffer
+   * mentioned below refers to this functions argument.
+   *
+   * \a buffer points to a buffer which receives the device manufacturer's name
+   * as a zero-terminated ASCII string.
+   */
+# define canCHANNELDATA_MFGNAME_ASCII             24
+
+  /**
+   * This define is used in \ref canGetChannelData(), \a buffer
+   * mentioned below refers to this functions argument.
+   *
+   * \a buffer points to a buffer which receives the product name of the device
+   * as a zero-terminated Unicode string.
+   */
+# define canCHANNELDATA_DEVDESCR_UNICODE          25
+
+  /**
+   * This define is used in \ref canGetChannelData(), \a buffer
+   * mentioned below refers to this functions argument.
+   *
+   * \a buffer points to a buffer which receives the product name of the device
+   * as a zero-terminated ASCII string.
+   */
+# define canCHANNELDATA_DEVDESCR_ASCII            26
+
+ /**
+   * This define is used in \ref canGetChannelData(), \a buffer
+   * mentioned below refers to this functions argument.
+   *
+   * \a buffer points to a buffer which receives the name of the device
+   * driver (e.g. "kcans") as a zero-terminated ASCII string.
+   *
+   * \note The device driver names have no special meanings and may change
+   * from a release to another.
+   */
+# define canCHANNELDATA_DRIVER_NAME               27
+
+  /**
+   * This define is used in \ref canGetChannelData(), \a buffer
+   * mentioned below refers to this functions argument.
+   *
+   * \a buffer points to a 32-bit unsigned integer that receives the quality of
+   * the channel, where the quality is measured in percent of optimal quality.
+   *
+   * For WLAN, -90 dBm and -35 dBm are considered 0% and 100%, respectively.
+   *
+   * The quality is 100% for any directly connected channel (USB, PCI etc.).
+   */
+#  define canCHANNELDATA_CHANNEL_QUALITY           28
+
+  /**
+   * This define is used in \ref canGetChannelData(), \a buffer
+   * mentioned below refers to this functions argument.
+   *
+   * \a buffer point to a 32-bit unsigned integer that receives the roundtrip
+   * time which is measured in milliseconds.
+   */
+#  define canCHANNELDATA_ROUNDTRIP_TIME            29
+
+  /**
+   * This define is used in \ref canGetChannelData(), \a buffer
+   * mentioned below refers to this functions argument.
+   *
+   * \a buffer points to a 32-bit unsigned integer that receives the
+   * \ref kvBUSTYPE_GROUP_xxx bus type.
+   */
+#  define canCHANNELDATA_BUS_TYPE                  30
+
+  /**
+   * This define is used in \ref canGetChannelData(), \a buffer
+   * mentioned below refers to this functions argument.
+   *
+   * \a buffer points to a CHAR array of at least 32 characters which receives
+   * the current device name as a \c NULL terminated ASCII string.
+   *
+   * If device name is not set or the device does not support this
+   * functionality, an error will be returned.
+   */
+#  define canCHANNELDATA_DEVNAME_ASCII             31
+
+  /**
+   * This define is used in \ref canGetChannelData(), \a buffer
+   * mentioned below refers to this functions argument.
+   *
+   * \a buffer points to a 32-bit unsigned integer that contains the time in
+   * milliseconds since the last communication occured.
+   *
+   * For WLAN devices, this is the time since the last keep-alive message.
+   */
+#  define canCHANNELDATA_TIME_SINCE_LAST_SEEN      32
+
+  /**
+   * This define is used in \ref canGetChannelData(), \a buffer
+   * mentioned below refers to this functions argument.
+   *
+   * \a buffer points to a 32-bit unsigned integer that receives the
+   * current WLAN operational mode of the remote capable device;
+   * \ref canCHANNEL_OPMODE_xxx.
+   */
+#  define canCHANNELDATA_REMOTE_OPERATIONAL_MODE   33
+
+  /**
+   * This define is used in \ref canGetChannelData(), \a buffer
+   * mentioned below refers to this functions argument.
+   *
+   * \a buffer points to a buffer which receives the remote profile name
+   * of the device as a zero-terminated ASCII string.
+   */
+#  define canCHANNELDATA_REMOTE_PROFILE_NAME   34
+
+  /**
+   * This define is used in \ref canGetChannelData(), \a buffer
+   * mentioned below refers to this functions argument.
+   *
+   * \a buffer points to a buffer which receives the remote host name
+   * of the device as a zero-terminated ASCII string.
+   */
+#  define canCHANNELDATA_REMOTE_HOST_NAME   35
+
+  /**
+   * This define is used in \ref canGetChannelData(), \a buffer
+   * mentioned below refers to this functions argument.
+   *
+   * \a buffer points to a buffer which receives the mac address
+   * of the device as a zero-terminated ASCII string.
+   */
+#  define canCHANNELDATA_REMOTE_MAC   36
+
+  /**
+   * This define is used in \ref canGetChannelData(), \a buffer
+   * mentioned below refers to this functions argument.
+   *
+   * \a buffer points to a 32-bit unsigned integer which receives 
+   * maximum bitrate of the device. Zero value means no limit on
+   * bitrate.
+   */
+#  define canCHANNELDATA_MAX_BITRATE   37
+
+
+#endif
+
+ /** @} */
+
+
+/**
+ * \name canCHANNEL_IS_xxx
+ * \anchor canCHANNEL_IS_xxx
+ *
+ * These channelFlags are used in \ref canGetChannelData() and in conjunction with \ref
+ * canCHANNELDATA_CHANNEL_FLAGS.
+ *  @{
+ */
+/** Used with \ref canCHANNELDATA_CHANNEL_FLAGS, indicates that the channel is
+    opened exclusively. */
+#define canCHANNEL_IS_EXCLUSIVE         0x0001
+/** Used with \ref canCHANNELDATA_CHANNEL_FLAGS, indicates that the channel is
+    opened. */
+#define canCHANNEL_IS_OPEN              0x0002
+
+/** Used with \ref canCHANNELDATA_CHANNEL_FLAGS, indicates that the channel is
+ *  opened as CAN FD.  */
+
+#define canCHANNEL_IS_CANFD             0x0004
+ /** @} */
+
+
+/**
+ * \name canHWTYPE_xxx
+ * \anchor canHWTYPE_xxx
+ *
+ * The following constants can be returned from \ref canGetChannelData(), using the
+ * \ref canCHANNELDATA_CARD_TYPE item code. They identify the hardware type for
+ * the channel specified in the call to \ref canGetChannelData().
+ *
+ * \note They indicate a hardware type, but not necessarily a specific
+ * product. For example, \ref canHWTYPE_LAPCAN is returned both for LAPcan and
+ * LAPcan II. (You can use \ref canGetChannelData() to obtain the UPC/EAN code for
+ * the device. This number uniquely identifies the product.)
+ *
+ *  @{
+ */
+#define canHWTYPE_NONE                0  ///< Unknown or undefined
+#define canHWTYPE_VIRTUAL             1  ///< The virtual CAN bus
+#define canHWTYPE_LAPCAN              2  ///< LAPcan Family
+#define canHWTYPE_CANPARI             3  ///< CANpari (obsolete).
+#define canHWTYPE_PCCAN               8  ///< PCcan Family
+#define canHWTYPE_PCICAN              9  ///< PCIcan Family
+#define canHWTYPE_USBCAN             11  ///< USBcan (obsolete).
+#define canHWTYPE_PCICAN_II          40  ///< PCIcan II family
+#define canHWTYPE_USBCAN_II          42  ///< USBcan II, USBcan Rugged, Kvaser Memorator
+#define canHWTYPE_SIMULATED          44  ///< Simulated CAN bus for Kvaser Creator (obsolete).
+#define canHWTYPE_ACQUISITOR         46  ///< Kvaser Acquisitor (obsolete).
+#define canHWTYPE_LEAF               48  ///< Kvaser Leaf Family
+#define canHWTYPE_PC104_PLUS         50  ///< Kvaser PC104+
+#define canHWTYPE_PCICANX_II         52  ///< Kvaser PCIcanx II
+#define canHWTYPE_MEMORATOR_II       54  ///< Kvaser Memorator Professional family
+#define canHWTYPE_MEMORATOR_PRO      54  ///< Kvaser Memorator Professional family
+#define canHWTYPE_USBCAN_PRO         56  ///< Kvaser USBcan Professional
+#define canHWTYPE_IRIS               58  ///< Obsolete name, use canHWTYPE_BLACKBIRD instead
+#define canHWTYPE_BLACKBIRD          58  ///< Kvaser BlackBird
+#define canHWTYPE_MEMORATOR_LIGHT    60  ///< Kvaser Memorator Light
+#define canHWTYPE_MINIHYDRA          62  ///< Obsolete name, use canHWTYPE_EAGLE instead
+#define canHWTYPE_EAGLE              62  ///< Kvaser Eagle family
+#define canHWTYPE_BAGEL              64  ///< Obsolete name, use canHWTYPE_BLACKBIRD_V2 instead
+#define canHWTYPE_BLACKBIRD_V2       64  ///< Kvaser BlackBird v2
+#define canHWTYPE_MINIPCIE           66  ///< Kvaser Mini PCI Express
+#define canHWTYPE_USBCAN_KLINE       68  ///< USBcan Pro HS/K-Line
+#define canHWTYPE_ETHERCAN           70  ///< Kvaser Ethercan
+#define canHWTYPE_USBCAN_LIGHT       72  ///< Kvaser USBcan Light
+#define canHWTYPE_USBCAN_PRO2        74  ///< Kvaser USBcan Pro 5xHS and variants
+#define canHWTYPE_PCIE_V2            76  ///< Kvaser PCIEcan 4xHS and variants
+#define canHWTYPE_MEMORATOR_PRO2     78  ///< Kvaser Memorator Pro 5xHS and variants
+#define canHWTYPE_LEAF2              80  ///< Kvaser Leaf Pro HS v2 and variants
+#define canHWTYPE_MEMORATOR_LIGHT2   82  ///< Kvaser Memorator Light (2nd generation)
+
+
+/** @} */
+
+/**
+ * \name canCHANNEL_CAP_xxx
+ * \anchor canCHANNEL_CAP_xxx
+ *
+ * Channel capabilities.
+ */
+#define canCHANNEL_CAP_EXTENDED_CAN      0x00000001L ///< Can use extended identifiers
+#define canCHANNEL_CAP_BUS_STATISTICS    0x00000002L ///< Can report busload etc
+#define canCHANNEL_CAP_ERROR_COUNTERS    0x00000004L ///< Can return error counters
+#define canCHANNEL_CAP_CAN_DIAGNOSTICS   0x00000008L ///< Can report CAN diagnostics
+#define canCHANNEL_CAP_GENERATE_ERROR    0x00000010L ///< Can send error frames
+#define canCHANNEL_CAP_GENERATE_OVERLOAD 0x00000020L ///< Can send CAN overload frame
+#define canCHANNEL_CAP_TXREQUEST         0x00000040L ///< Can report when a CAN messsage transmission is initiated
+#define canCHANNEL_CAP_TXACKNOWLEDGE     0x00000080L ///< Can report when a CAN messages has been transmitted
+#define canCHANNEL_CAP_VIRTUAL           0x00010000L ///< Virtual CAN channel
+#define canCHANNEL_CAP_SIMULATED         0x00020000L ///< Simulated CAN channel
+#define canCHANNEL_CAP_REMOTE            0x00040000L ///< Remote CAN channel (e.g. BlackBird).
+#define canCHANNEL_CAP_CAN_FD            0x00080000L ///< CAN-FD channel
+#define canCHANNEL_CAP_CAN_FD_NONISO     0x00100000L ///< Supports Non-ISO CAN-FD channel
+
+/**
+ * \name canCHANNEL_OPMODE_xxx
+ * \anchor canCHANNEL_OPMODE_xxx
+ *
+ * Current WLAN operational mode.
+ *
+ *  @{
+ */
+#define canCHANNEL_OPMODE_NONE                 1  ///< Not applicable, or unknown
+#define canCHANNEL_OPMODE_INFRASTRUCTURE       2  ///< Infrastructure mode
+#define canCHANNEL_OPMODE_RESERVED             3  ///< Reserved value, do not use
+#define canCHANNEL_OPMODE_ADHOC                4  ///< Adhoc mode
+/** @} */
+
+/**
+ *  \name canDRIVER_CAP_xxx
+ *  \anchor canDRIVER_CAP_xxx
+ *
+ *  Driver (transceiver) capabilities.
+ *  @{
+ */
+/** Used with \ref canCHANNELDATA_TRANS_CAP */
+#define canDRIVER_CAP_HIGHSPEED             0x00000001L
+/** @} */
+
+/**
+ * \ingroup General
+ * \name canIOCTL_xxx
+ * \anchor canIOCTL_xxx
+ *
+ * These defines are used in \ref canIoCtl().
+ *
+ * @{
+ */
+
+
+  /**
+   * This define is used in \ref canIoCtl(), \a buf and \a buflen refers to this
+   * functions arguments.
+   *
+   * Tells CANLIB to "prefer" extended identifiers; that is, if you send a
+   * message with \ref canWrite() and don't specify \ref canMSG_EXT nor \ref canMSG_STD,
+   * \ref canMSG_EXT will be assumed. The contents of \a buf and \a buflen are
+   * ignored. \ref canRead() et al will set \ref canMSG_EXT and/or \ref canMSG_STD as usual
+   * and are not affected by this call.
+   */
+#define canIOCTL_PREFER_EXT             1
+
+  /**
+   * This define is used in \ref canIoCtl(), \a buf and \a buflen refers to this
+   * functions arguments.
+   *
+   * Tells CANLIB to "prefer" standard identifiers; that is, if you send a
+   * message with \ref canWrite() and don't specify \ref canMSG_EXT nor \ref canMSG_STD,
+   * \ref canMSG_STD will be assumed. The contents of \a buf and \a buflen are
+   * ignored. \ref canRead() et al will set \ref canMSG_EXT and/or \ref canMSG_STD as usual
+   * and are not affected by this call.
+   */
+#define canIOCTL_PREFER_STD             2
+// 3,4 reserved.
+
+  /**
+   * This define is used in \ref canIoCtl(), \a buf and \a buflen refers to this
+   * functions arguments.
+   *
+   * Tells CANLIB to clear the CAN error counters. The contents of \a buf and \a
+   * buflen are ignored.
+   *
+   * \note Not all CAN controllers support this operation (and if they don't,
+   * nothing will happen.)
+   */
+#define canIOCTL_CLEAR_ERROR_COUNTERS   5
+
+  /**
+   * This define is used in \ref canIoCtl(), \a buf mentioned below refers to this
+   * functions argument.
+   *
+   * \a buf points to a DWORD which contains the desired time-stamp clock
+   * resolution in microseconds. The default value is 1000 microseconds, i.e.
+   * one millisecond.
+   *
+   * \note The accuracy of the clock isn't affected.
+   */
+#define canIOCTL_SET_TIMER_SCALE        6
+
+  /**
+   * This define is used in \ref canIoCtl(), \a buf mentioned below refers to this
+   * functions argument.
+   *
+   * \a buf points to a DWORD which contains
+   *
+   * \li 0: to turn Transmit Acknowledges off.
+   * \li 1: to turn Transmit Acknowledges on.
+   * \li 2: to turn Transmit Acknowledges off, even for the driver's internal
+   * usage. This might enhance performance but will cause some other APIs to
+   * stop working (for example, the current size of the transmit queue can not
+   * be read when this mode is active.)
+   *
+   * The default value is 0, Transmit Acknowledge is off.
+   */
+#define canIOCTL_SET_TXACK              7
+
+  /**
+   * This define is used in \ref canIoCtl(), \a buf mentioned below refers to this
+   * functions argument.
+   *
+   * \a buf points at a \c DWORD which receives the current RX queue level. The
+   * returned value is approximative (this is because not all hardware supports
+   * retrieving the queue levels. In that case a best-effort guess is
+   * returned. Also note that a device with embedded CPU will report its queue
+   * levels to the host computer after a short delay that depends on the bus
+   * traffic intensity, and consequently the value returned by the call to
+   * \ref canIoCtl() might be a few milliseconds old.)
+   */
+#define canIOCTL_GET_RX_BUFFER_LEVEL              8
+
+  /**
+   * This define is used in \ref canIoCtl(), \a buf mentioned below refers to this
+   * functions argument.
+   *
+   * \a buf points at a \c DWORD which receives the current TX queue level. The
+   * returned value is approximative (this is because not all hardware supports
+   * retrieving the queue levels. In that case a best-effort guess is
+   * returned. Also note that a device with embedded CPU will report its queue
+   * levels to the host computer after a short delay that depends on the bus
+   * traffic intensity, and consequently the value returned by the call to
+   * \ref canIoCtl() might be a few milliseconds old.)
+   */
+#define canIOCTL_GET_TX_BUFFER_LEVEL              9
+
+  /**
+   * This define is used in \ref canIoCtl(), \a buf and \a buflen refers to this
+   * functions arguments.
+   *
+   * Discard the current contents of the RX queue. The values of \a buf and \a
+   * buflen are ignored.
+   *
+   * \note This is the same thing as calling \ref canFlushReceiveQueue()
+   */
+#define canIOCTL_FLUSH_RX_BUFFER                  10
+
+  /**
+   * This define is used in \ref canIoCtl(), \a buf and \a buflen refers to this
+   * functions arguments.
+   *
+   * Discard the current contents of the TX queue. The values of \a buf and \a
+   * buflen are ignored.
+   *
+   * \note This is the same thing as calling \ref canFlushTransmitQueue().
+   */
+#define canIOCTL_FLUSH_TX_BUFFER                  11
+
+  /**
+   * This define is used in \ref canIoCtl(), \a buf mentioned below refers to this
+   * functions argument.
+   *
+   * \a buf points to a \c DWORD which contains the desired time-stamp clock
+   * resolution in microseconds. Note that the accuracy of the clock isn't
+   * affected. The default value is 1000 microseconds, i.e. one millisecond.
+   */
+#define canIOCTL_GET_TIMER_SCALE                  12
+
+  /**
+   * This define is used in \ref canIoCtl(), \a buf mentioned below refers to this
+   * functions argument.
+   *
+   * \a buf points to a \c DWORD which contains
+   *
+   * \li \c 0 to turn Transmit Requests off.
+   * \li \c 1 to turn Transmit Requests on.
+   *
+   * Default value is \c 0, Transmit Requests off.
+   */
+#define canIOCTL_SET_TXRQ                         13
+
+  /**
+   * This define is used in \ref canIoCtl(), \a buf mentioned below refers to this
+   * functions argument.
+   *
+   * \a buf points at a \c DWORD which receives a Windows Event handle which can
+   * be passed to the Win32 API \c WaitForSingleObject. The event is signaled
+   * when "something" (typically that a CAN message has been received or
+   * transmitted) happens in the driver.
+   *
+   * \note There is no more information available as to what happened when this
+   * call returns. The call may return on an "internal" event in CANLIB and your
+   * application must be prepared to handle this (i.e. go to sleep again.)
+   * \note If \ref canWaitForEvent() returns with success status (\ref canOK), you must call
+   * \ref canRead() repeatedly until it returns \ref canERR_NOMSG, before calling
+   * \ref canWaitForEvent() again. This will flush the driver's internal event queues.
+   * Failure to call \ref canRead() can cause \ref canWaitForEvent() to get stuck in a state
+   * where it always sleeps for the specified timeout and then returns with
+   * \ref canERR_TIMEOUT.
+   *
+   * \sa \ref canWaitForEvent()
+   *
+   * \note You must not set, reset, nor close this handle.  Waiting on it is
+   *       the only supported operation.
+   */
+#define canIOCTL_GET_EVENTHANDLE                  14
+
+  /**
+   * This define is used in \ref canIoCtl(), \a buf mentioned below refers to this
+   * functions argument.
+   *
+   * \note Not yet implemented.
+   */
+#define canIOCTL_SET_BYPASS_MODE                  15
+
+  /**
+   * This define is used in \ref canIoCtl().
+   *
+   * This is only intended for internal use.
+   */
+#define canIOCTL_SET_WAKEUP                       16
+
+#if defined(CANLIB_DECLARE_ALL)
+
+  /**
+   * This define is used in \ref canIoCtl(), \a buf mentioned below refers to this
+   * functions argument.
+   *
+   * \a buf points to a HANDLE which receives the Windows handle related to the
+   * CANLIB handle.
+   */
+# define canIOCTL_GET_DRIVERHANDLE                17
+
+  /**
+   * This define is used in \ref canIoCtl().
+   *
+   * This is only intended for internal use.
+   */
+# define canIOCTL_MAP_RXQUEUE                     18
+
+  /**
+   * This define is used in \ref canIoCtl().
+   *
+   *  This is only intended for internal use.
+   */
+# define canIOCTL_GET_WAKEUP                      19
+
+  /**
+   * This define is used in \ref canIoCtl(), \a buf mentioned below refers to this
+   * functions argument.
+   *
+   * \a buf points to a BYTE which contains
+   *
+   * \li \c 0 to turn access error reporting off, and
+   * \li \c 1 to turn access error reporting on.
+   *
+   * Default value is \c 0, access error reporting off.
+   */
+# define canIOCTL_SET_REPORT_ACCESS_ERRORS        20
+
+  /**
+   * This define is used in \ref canIoCtl(), \a buf mentioned below refers to this
+   * functions argument.
+   *
+   * \a buf points to a BYTE which receives the current setting of the access
+   * error reporting (0 or 1.)
+   */
+# define canIOCTL_GET_REPORT_ACCESS_ERRORS        21
+
+  /**
+   * This define is used in \ref canIoCtl(), \a buf mentioned below refers to this
+   * functions argument.
+   *
+   * Connects the handle to the virtual bus number (0..31) which the \a buf
+   * points to.
+   */
+# define canIOCTL_CONNECT_TO_VIRTUAL_BUS          22
+
+  /**
+   * This define is used in \ref canIoCtl(), \a buf mentioned below refers to this
+   * functions argument.
+   *
+   * Disonnects the handle from the virtual bus number (0..31) which the \a buf
+   * points to.
+   */
+# define canIOCTL_DISCONNECT_FROM_VIRTUAL_BUS     23
+
+  /**
+   * This define is used in \ref canIoCtl(), \a buf mentioned below refers to this
+   * functions argument.
+   *
+   * \a buf points to a \ref canUserIoPortData struct that contains a port number
+   * and a port value to set. This is used by special hardware only.
+   */
+# define canIOCTL_SET_USER_IOPORT                 24
+
+  /**
+   * This define is used in \ref canIoCtl(), \a buf mentioned below refers to this
+   * functions argument.
+   *
+   * \a buf points to a \ref canUserIoPortData struct that contains a port
+   *  number. After the call, the struct will contain the current value of the
+   *  I/O port. This is used by special hardware only.
+   */
+# define canIOCTL_GET_USER_IOPORT                 25
+
+  /**
+   * This define is used in \ref canIoCtl().
+   *
+   *  This is only intended for internal use.
+   */
+# define canIOCTL_SET_BUFFER_WRAPAROUND_MODE      26
+
+  /**
+   * This define is used in \ref canIoCtl(), \a buf mentioned below refers to this
+   * functions argument.
+   *
+   * Use this function code to set the size of the receive buffer for a
+   * specific handle. \a buf points to an unsigned integer which contains the
+   * new size (number of messages) of the receive buffer.
+   *
+   * \note The receive buffer consumes system nonpaged pool memory, which is a
+   *       limited resource. Do not increase the receive buffer size unless you
+   *       have good reasons to do so.
+   *
+   * \note You can't use this function code when the channel is on bus.
+   */
+# define canIOCTL_SET_RX_QUEUE_SIZE               27
+
+  /**
+   * This define is used in \ref canIoCtl().
+   *
+   *  This is only intended for internal use.
+   */
+# define canIOCTL_SET_USB_THROTTLE                28
+
+  /**
+   * This define is used in \ref canIoCtl().
+   *
+   *  This is only intended for internal use.
+   */
+# define canIOCTL_GET_USB_THROTTLE                29
+
+  /**
+   * This define is used in \ref canIoCtl(), \a buf mentioned below refers to this
+   * functions argument.
+   *
+   * \a buf points to a DWORD. If the value is zero, the CAN clock will not be
+   * reset at buson for the handle. Otherwise, the CAN clock will be reset at
+   * buson.
+   *
+   * Default value is \c 1, the CAN clock will be reset at buson.
+   */
+# define canIOCTL_SET_BUSON_TIME_AUTO_RESET       30
+
+  /**
+   * This define is used in \ref canIoCtl(), \a buf mentioned below refers to this
+   * functions argument.
+   *
+   * Returns the state of the Transmit Acknowledge as a DWORD in \a buf:
+   *
+   * \li 0: Transmit Acknowledges is turned off.
+   * \li 1: Transmit Acknowledges is turned on.
+   * \li 2: Transmit Acknowledges is turned off, even for the driver's internal
+   *        usage.
+   */
+# define canIOCTL_GET_TXACK                       31
+
+  /**
+   * This define is used in \ref canIoCtl(), \a buf mentioned below refers to this
+   * functions argument.
+   *
+   * \a buf points to an unsigned byte. If the value is zero, the local transmit
+   * echo is turned off for the handle. Otherwise, local transmit echo is turned
+   * on.
+   *
+   * Local transmit echo is turned on by default on all handles.  This means
+   * that if two handles are open on the same channel, and a message is
+   * transmitted on the first handle, it will be received as a normal message
+   * on the second handle. Use the \ref canIOCTL_SET_LOCAL_TXECHO function code to
+   * turn this function off, if it is not desired on a certain handle.
+   */
+# define canIOCTL_SET_LOCAL_TXECHO                32
+
+  /**
+   * This define is used in \ref canIoCtl(), \a buf mentioned below refers to this
+   * functions argument.
+   *
+   * \a buf points to an unsigned byte. If the value is zero, the reporting of
+   * error frames is turned off for the handle. Otherwise, error frame reporting
+   * is turned on.
+   *
+   * Default value is \c 1, error frame reporting is turned on.
+   */
+#  define canIOCTL_SET_ERROR_FRAMES_REPORTING      33
+
+  /**
+   * This define is used in \ref canIoCtl(), \a buf mentioned below refers to this
+   * functions argument.
+   *
+   * \a buf points to a 32-bit unsigned integer that receives the quality of
+   * the channel, where the quality is measured in percent of optimal quality.
+   *
+   * For a WLAN, -90 dBm and -35 dBm are considered 0% and 100%, respectively.
+   *
+   * The quality is 100% for any directly connected channel (USB, PCI etc.).
+   */
+# define canIOCTL_GET_CHANNEL_QUALITY             34
+
+  /**
+   * This define is used in \ref canIoCtl(), \a buf mentioned below refers to this
+   * functions argument.
+   *
+   * \a buf points to a \c DWORD that contains the roundtrip time measured in
+   * milliseconds.
+   */
+#  define canIOCTL_GET_ROUNDTRIP_TIME              35
+
+  /**
+   * This define is used in \ref canIoCtl(), \a buf mentioned below refers to this
+   * functions argument.
+   *
+   * \a buf points to a \c DWORD that contains the \ref kvBUSTYPE_GROUP_xxx bus type.
+   */
+#  define canIOCTL_GET_BUS_TYPE                    36
+
+  /**
+   * This define is used in \ref canIoCtl(), \a buf mentioned below refers to this
+   * functions argument.
+   *
+   * \a buf points to a CHAR array of at least 32 characters which receives the
+   * current device name as a \c NULL terminated ASCII string.
+   *
+   * If device name is not set or the device does not support this
+   * functionality, an error will be returned.
+   */
+#  define canIOCTL_GET_DEVNAME_ASCII               37
+
+  /**
+   * This define is used in \ref canIoCtl(), \a buf mentioned below refers to this
+   * functions argument.
+   *
+   * \a buf points to a \c DWORD that contains the time in milliseconds since the last
+   * communication occured.
+   *
+   * For WLAN devices, this is the time since the last keep-alive message.
+   */
+#  define canIOCTL_GET_TIME_SINCE_LAST_SEEN        38
+
+
+  /**
+   * This define is used in \ref canIoCtl(), \a buf mentioned below refers to this
+   * functions argument.
+   *
+   * Obtain the time reference list for MagiSync devices.
+   *
+   * \a buf points to an array of pairs of 64-bit ints, one of which
+   * will contain the reference number and the other one the timestamp
+   * in nanoseconds.
+   *
+   * \note This function is subject to change in future releases and is
+   * not supported by Kvaser.
+   */
+#  define canIOCTL_GET_TREF_LIST                   39
+
+  /**
+   * This define is used in \ref canIoCtl(), \a buf mentioned below refers to this
+   * functions argument.
+   *
+   * \a buf points to a \c DWORD that contains the number of microseconds
+   * the minimum CAN message transmit interval should be set to, or 0xffffffff
+   * to fetch the current setting.
+   * The minimum interval can not be set to more than one second.
+   *
+   * When a CAN channel goes bus on, the minimum interval is set to zero.
+   * I.e. CAN transmissions happen at the maximum speed the device is capable of.
+   *
+   * If the device does not support this functionality, or if an invalid
+   * minimum interval is requested, an error will be returned.
+   *
+   * \note The minimum CAN messages transmit interval applies to the physical CAN
+   * channel. It will thus affect all messages transmitted, even those sent
+   * using other CANlib handles to the same physical channel. The interval
+   * is defined as the time from the successful completion of one transmit
+   * to the beginning of the next one.
+   */
+#  define canIOCTL_TX_INTERVAL                     40
+
+  /**
+   * Obsolete, use \ref canIOCTL_SET_THROTTLE_SCALED instead
+   */
+#  define canIOCTL_SET_USB_THROTTLE_SCALED                41
+
+  /**
+   * This define is used in \ref canIoCtl(), \a buf mentioned below refers to this
+   * functions argument.
+   *
+   * This ioctl can be used to set the responsitivity of some devices.
+   * \a buf points to a \c DWORD that should contain a value between 0 and 100.
+   * A value of 0 means that the device should be very responsive and a value
+   * of 100 means that the device generates less cpu load or requires more bandwidth.
+   * Note that not all
+   * devices support this. Some hardware will accept this command but neglect it.
+   * This can be found out by reading the scaled throttle.
+   */
+#  define canIOCTL_SET_THROTTLE_SCALED                    41
+
+  /**
+   * Obsolete, use \ref canIOCTL_GET_THROTTLE_SCALED instead
+   */
+#  define canIOCTL_GET_USB_THROTTLE_SCALED                42
+
+  /**
+   * This define is used in \ref canIoCtl(), \a buf mentioned below refers to this
+   * functions argument.
+   *
+   * This ioctl can be used to set the responsitivity of some devices.
+   * \a buf points to a \c DWORD that should contain a value between 0 and 100.
+   * A value of 0 means that the device should be very responsive and a value
+   * of 100 means that the device generates less cpu load or requires more bandwidth.
+   * Note that not all
+   * devices support this. Some hardware will accept this command but neglect it.
+   * This can be found out by reading the scaled throttle.
+   */
+#  define canIOCTL_GET_THROTTLE_SCALED                    42
+
+   /**
+   * This define is used in \ref canIoCtl(), \a buf mentioned below refers to this
+   * functions argument.
+   *
+   * Some hardware have bitrate limits, which must be met when using any of \a canSetBusParams(),
+   * \a canSetBusParamsC200(), \a canGetBusParams() functions
+   * which can be overriden with this IOCTL.
+   * \a buf points to a \c long value that contains a user defined bitrate.
+   * A value of 0 means that the device should use its own default bitrate limit.
+   */
+#  define canIOCTL_SET_BRLIMIT                            43
+
+#endif
+ /** @} */
+
+#if defined(CANLIB_DECLARE_ALL)
+/** Used in \ref canIOCTL_SET_USER_IOPORT and \ref canIOCTL_GET_USER_IOPORT. */
+typedef struct {
+  unsigned int portNo;     ///< Port number used in e.g. \ref canIOCTL_SET_USER_IOPORT
+  unsigned int portValue;  ///< Port value used in e.g. \ref canIOCTL_SET_USER_IOPORT
+} canUserIoPortData;
+
+#endif
+
+#if defined(CANLIB_DECLARE_ALL)
+/**
+ * \ingroup Notification and Waiting
+ *
+ * \source_cs       <b>static Canlib.canStatus canWaitForEvent(int hnd, ulong timeout);</b>
+ *
+ * \source_delphi   <b>function canWaitForEvent(hnd: canHandle; timeout: Cardinal): canStatus;     </b>
+ * \source_end
+ *
+ * Waits for an event (of any kind) to happen at the specified CAN circuit, or
+ * a timeout to occur. An event in this context means for example the arrival
+ * of a CAN message or a CAN bus status change, but it can also be an event
+ * internal to the driver.
+ *
+ * \param[in] hnd      A handle to an open CAN circuit.
+ * \param[in] timeout  The number of milliseconds to wait before the call
+ *                     returns, if no event occurs. 0xFFFFFFFF gives an
+ *                     infinite timeout.
+ *
+ * \return \ref canOK (zero) if an event happened during the specified time
+ *         period.
+ * \return \ref canERR_TIMEOUT (negative) if nothing happened during the specified
+ *         time period.
+ * \return \ref canERR_xxx (negative) if failure.
+ *
+ * \sa \ref page_code_snippets_examples,
+ * \ref page_user_guide_send_recv_asynch_not
+ * \sa \ref canRead()
+ */
+canStatus CANLIBAPI canWaitForEvent (const CanHandle hnd, DWORD timeout);
+#endif
+
+/**
+ * \ingroup CAN
+ *
+ * \source_cs       <b>static Canlib.canStatus canSetBusParamsC200(int hnd, byte btr0, byte btr1);</b>
+ *
+ * \source_delphi   <b>function canSetBusParamsC200(hnd: canHandle; btr0, btr1: byte): canStatus;     </b>
+ * \source_end
+ *
+ * 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
+ *
+ * \li \a btr0 [b7..b6]: SJW - 1
+ * \li \a btr0 [b5..b0]: Prescaler -1
+ * \li \a btr1 [b7]: \c 1: 3 samples, \c 0: 1 samples
+ * \li \a btr1 [b6..b4]: tseg2 - 1
+ * \li \a 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.
+ *
+ * \param[in] hnd   A handle to an open CAN circuit.
+ * \param[in] btr0  The desired bit timing, formatted as the contents of the
+ *                  BTR0 register in the 82c200.
+ * \param[in] btr1  The desired bit timing, formatted as the contents of the
+ *                  BTR1 register in the 82c200.
+ *
+ * \return \ref canOK (zero) if success
+ * \return \ref canERR_xxx (negative) if failure
+ *
+ *
+ * \sa \ref page_code_snippets_bit_rate, \ref page_user_guide_misc_bitrate
+ * \sa \ref canSetBusParams()
+ */
+canStatus CANLIBAPI canSetBusParamsC200 (const CanHandle hnd, BYTE btr0, BYTE btr1);
+
+#if defined(CANLIB_DECLARE_ALL)
+
+/**
+ * \ingroup CAN
+ *
+ * \win_start
+ * \source_cs       <b>static Canlib.canStatus canSetDriverMode(int hnd, int lineMode, int resNet);</b>
+ *
+ * \source_delphi   <b>function canSetDriverMode(hnd: canHandle; lineMode, resNet: Integer): canStatus;     </b>
+ * \source_end
+ *
+ * This function sets the current CAN bus driver mode. This is
+ * typically a mode like sleep, wakeup, standby, fast mode, etc. The
+ * different modes are almost always hardware dependent and requires
+ * special DRVcan cables. As an example, the DRVcan S implements J2411
+ * compliant single-wire CAN and supports four line modes, namely
+ * Normal, Sleep, Fast and Wakeup.
+ *
+ * Standard ISO 11898 CAN do not support any of these bus driver modes.
+ *
+ * \note The bus driver mode is typically used to control things like one- or
+ * two-wire mode, sleep mode, and so on. It requires special support in the CAN
+ * driver circuit.
+ *
+ * \param[in] hnd       An open handle to a CAN circuit.
+ * \param[in] lineMode  An int which defines the line mode,
+ *                      \ref canTRANSCEIVER_LINEMODE_xxx.
+ * \param[in] resNet    An int which defines the resnet mode. Set this parameter to
+ *                      \ref canTRANSCEIVER_RESNET_NA unless you have good reasons to set it
+ *                      to something else.
+ *
+ * \return \ref canOK (zero) if success
+ * \return \ref canERR_xxx (negative) if failure
+ *
+ * \sa \ref canGetDriverMode()
+ * \win_end
+ * \linux_start
+ * Not implemented.
+ * \linux_end
+ */
+canStatus CANLIBAPI canSetDriverMode (const CanHandle hnd, int lineMode, int resNet);
+
+/**
+ * \ingroup CAN
+ *
+ * \win_start
+ * \source_cs       <b>static Canlib.canStatus canGetDriverMode(int hnd, out int lineMode, out int resNet);</b>
+ *
+ * \source_delphi   <b>function canGetDriverMode(hnd: canHandle; var lineMode: Integer; var resNet: Integer): canStatus;     </b>
+ * \source_end
+ *
+ * This function retrieves the current CAN bus driver mode. This is typically a
+ * mode like sleep, wakeup, standby, fast mode, etc. The different modes are
+ * almost always hardware dependent and requires special DRVcan cables. As an
+ * example, the DRVcan S implements J2411 compliant single-wire CAN and
+ * supports four line modes, namely Normal, Sleep, Fast and Wakeup.
+ *
+ * Standard ISO 11898 CAN do not support any of these bus driver modes.
+ *
+ * \note The bus driver mode is typically used to control things like one- or
+ * two-wire mode, sleep mode, and so on. It requires special support in the CAN
+ * driver circuit.
+ *
+ * \param[in]  hnd       An open handle to a CAN circuit.
+ * \param[out] lineMode  A pointer to an int which receives the current line
+ *                       mode (\ref canTRANSCEIVER_LINEMODE_xxx).
+ * \param[out] resNet    A pointer to an int which receives the current resnet
+ *                       mode.  This value is usually
+ *                       \ref canTRANSCEIVER_RESNET_NA except for special DRVcan
+ *                       cables.
+ *
+ * \return \ref canOK (zero) if success
+ * \return \ref canERR_xxx (negative) if failure
+ *
+ * \sa \ref canSetDriverMode()
+ * \win_end
+ * \linux_start
+ * Not implemented.
+ * \linux_end
+ *
+ */
+canStatus CANLIBAPI canGetDriverMode (const CanHandle hnd, int *lineMode, int *resNet);
+#endif
+
+/**
+ * \name canVERSION_CANLIB32_xxx
+ * \anchor canVERSION_CANLIB32_xxx
+ * @{
+ * Item codes for canGetVersionEx().
+ */
+
+  /**
+   * This define is used in \ref canGetVersionEx() and controls which version number
+   * that returned.
+   *
+   * Version number of the canlib32.dll file coded as an unsigned 16-bit word
+   * with the major version number in the upper byte and the minor version
+   * number in the lower byte. This version number is not related to the
+   * product version number of the whole CANLIB.  For example, canlib32.dll
+   * belonging to CANLIB 2.27 would return 0x305.
+   */
+#define canVERSION_CANLIB32_VERSION     0
+
+  /**
+   * This define is used in \ref canGetVersionEx() and controls what type of version
+   * number that is returned.
+   *
+   * Product version number of canlib32.dll coded as an unsigned 16-bit word
+   * with the major version number in the upper byte and the minor version
+   * number in the lower byte. The product version number corresponds to the
+   * version number of the whole CANLIB. For example, canlib32.dll belonging to
+   * CANLIB 2.27 would return 0x21B.
+   */
+#define canVERSION_CANLIB32_PRODVER     1
+
+  /**
+   * This define is used in \ref canGetVersionEx() and controls what type of version
+   * number that is returned.
+   *
+   * Product version number of canlib32.dll coded as an unsigned 32-bit word
+   * where the bytes contain (in order from the most significant to the least
+   * significant byte) 0, major version number, minor version number, and the
+   * minor version letter. (The minor version letter is the ASCII code for the
+   * letter, or 0 (zero) if no letter). For example, CANLIB 3.8 would return
+   * 0x00030800 and CANLIB 3.8a would return 0x00030861.
+   */
+#define canVERSION_CANLIB32_PRODVER32   2
+
+  /**
+   * This define is used in \ref canGetVersionEx() and controls what type of version
+   * number that is returned.
+   *
+   * Returns 1 if the present version is a beta (preview) release, or 0 if it
+   * is an official release.
+   */
+#define canVERSION_CANLIB32_BETA        3
+/** @} */
+
+#if defined(CANLIB_DECLARE_ALL)
+
+/**
+ * \ingroup Information Services
+ *
+ * \source_cs       <b>static int canGetVersionEx(int itemCode);</b>
+ *
+ * \source_delphi   <b>function canGetVersionEx(itemCode: Cardinal): Cardinal;     </b>
+ * \source_end
+ *
+ * This function returns various version numbers from the driver routines.
+ *
+ * \param[in] itemCode  Specifies which version number to retrieve. See
+ *                      \ref canVERSION_CANLIB32_xxx
+ *
+ * \return The return value is desired version number.
+ *
+ * \sa \ref page_user_guide_build_driver_version
+ */
+unsigned int CANLIBAPI canGetVersionEx (unsigned int itemCode);
+
+/**
+ * \ingroup NamedParameterSettings
+ *
+ * \source_cs       <b>static Canlib.canStatus canParamGetCount();</b>
+ *
+ * \source_delphi   <b>function canParamGetCount(): canStatus;     </b>
+ * \source_end
+ *
+ * This function returns the number of entries in the table of named
+ * channels.
+ *
+ * \return The number of channels (zero or positive)
+ * \return \ref canERR_xxx (negative) if failure
+ *
+ * \sa \ref page_user_guide_misc_named_parameters
+ *
+ */
+canStatus CANLIBAPI canParamGetCount (void);
+
+/**
+ * \ingroup NamedParameterSettings
+ *
+ * \source_cs       <b>static Canlib.canStatus canParamCommitChanges();</b>
+ *
+ * \source_delphi   <b>function canParamCommitChanges(): canStatus;   </b>
+ * \source_end
+ *
+ * This function writes the current set of named parameters to the
+ * Registry. Previous entries are erased.
+ *
+ * The named parameters are stored in the
+ * \c HKEY_LOCAL_MACHINE\\SOFTWARE\\KVASER \c AB\\CANLIB32\\PredefinedBitrates
+ * key in the Registry.
+ *
+ * \note You must have Administrator's rights to write to the Registry.
+ *
+ * \return \ref canOK (zero) if success
+ * \return \ref canERR_xxx (negative) if failure
+ *
+ * \sa \ref page_user_guide_misc_named_parameters
+ *
+ */
+canStatus CANLIBAPI canParamCommitChanges (void);
+
+/**
+ * \ingroup NamedParameterSettings
+ *
+ * \source_cs       <b>static Canlib.canStatus canParamDeleteEntry(int index);</b>
+ *
+ * \source_delphi   <b>function canParamDeleteEntry(index: Integer): canStatus;      </b>
+ * \source_end
+ *
+ * This function deletes the entry in the table of named parameter settings
+ * with the given index. The entries below (i.e. with higher indices) the
+ * deleted entry are moved up one step in the table.
+ *
+ * The named parameters are stored in the
+ * \c HKEY_LOCAL_MACHINE\\SOFTWARE\\KVASER \c AB\\CANLIB32\\PredefinedBitrates
+ * key in the Registry.
+ *
+ * \param[in]  index  The index of the entry to delete.
+ *
+ * \return \ref canOK (zero) if success
+ * \return \ref canERR_xxx (negative) if failure
+ *
+ * \sa \ref page_user_guide_misc_named_parameters
+ * \sa \ref canParamCreateNewEntry(), \ref canParamCommitChanges()
+ */
+canStatus CANLIBAPI canParamDeleteEntry (int index);
+
+/**
+ * \ingroup NamedParameterSettings
+ *
+ * \source_cs       <b>static int canParamCreateNewEntry();</b>
+ *
+ * \source_delphi   <b>function canParamCreateNewEntry(): canStatus;     </b>
+ * \source_end
+ *
+ * This function creates a new entry in the table of named parameter
+ * settings.
+ *
+ * The named parameters are stored in the
+ * \c HKEY_LOCAL_MACHINE\\SOFTWARE\\KVASER \c AB\\CANLIB32\\PredefinedBitrates
+ * key in the Registry.
+ *
+ * \return The index of the created entry (zero or positive) if success
+ * \return \ref canERR_xxx (negative) if failure
+ *
+ * \sa \ref page_user_guide_misc_named_parameters
+ * \sa \ref canParamCommitChanges(), \ref canParamDeleteEntry()
+ *
+ */
+canStatus CANLIBAPI canParamCreateNewEntry (void);
+
+/**
+ * \ingroup NamedParameterSettings
+ *
+ * \source_cs       <b>static Canlib.canStatus canParamSwapEntries(int index1, int index2);</b>
+ *
+ * \source_delphi   <b>function canParamSwapEntries(index1, index2: Integer): canStatus;      </b>
+ * \source_end
+ *
+ * This function swaps two entries in the list of named
+ * parameters.
+ *
+ * The named parameters are stored in the
+ * \c HKEY_LOCAL_MACHINE\\SOFTWARE\\KVASER \c AB\\CANLIB32\\PredefinedBitrates
+ * key in the Registry.
+ *
+ * \param[in]  index1  The first of the two entries that are to be swapped in the
+ *                     named parameters list.
+ * \param[in]  index2  The second of the two entries that are to be swapped in the
+ *                     named parameters list.
+ *
+ * \return \ref canOK (zero) if success
+ * \return \ref canERR_xxx (negative) if failure
+ *
+ * \sa \ref page_user_guide_misc_named_parameters
+ * \sa \ref canParamCommitChanges()
+ *
+ */
+canStatus CANLIBAPI canParamSwapEntries (int index1, int index2);
+
+/**
+ * \ingroup NamedParameterSettings
+ *
+ * \source_cs       <b>static Canlib.canStatus canParamGetName(int index, ref string str_buf);</b>
+ *
+ * \source_delphi   <b>function canParamGetName(index: Integer; buffer: PChar; maxlen: Integer): canStatus;      </b>
+ * \source_end
+ *
+ * This function returns the name of a given entry in the list of
+ * named parameters.
+ *
+ * The named parameters are stored in the
+ * \c HKEY_LOCAL_MACHINE\\SOFTWARE\\KVASER \c AB\\CANLIB32\\PredefinedBitrates
+ * key in the Registry.
+ *
+ * \param[in]  index   The index of the entry in the named parameters list, whose
+ *                     name is to be returned.
+ * \param[out] buffer  A pointer to a buffer that is to receive a
+ *                     \c NULL terminated string which contains the name. The
+ *                     buffer is allocated and deallocated by the user.
+ * \param[in]  maxlen  The length of the buffer.
+ *
+ * \return \ref canOK (zero) if success
+ * \return \ref canERR_xxx (negative) if failure
+ *
+ * \sa \ref page_user_guide_misc_named_parameters
+ * \sa \ref canParamSetName(), \ref canParamCommitChanges()
+ */
+canStatus CANLIBAPI canParamGetName (int index, char *buffer, int maxlen);
+
+/**
+ * \ingroup NamedParameterSettings
+ *
+ * \source_cs       <b>static int canParamGetChannelNumber(int index);</b>
+ *
+ * \source_delphi   <b>function canParamGetChannelNumber(index: Integer): canStatus;     </b>
+ * \source_end
+ *
+ * This function returns the channel number of the entry with the
+ * given index in the table of named parameter settings.
+ *
+ * \param[in] index The index of the entry in the table of named parameter
+ *                  settings.
+ *
+ * \return The channel number of the entry in question (zero or positive)
+ * \return \ref canERR_xxx (negative) if failure
+ *
+ * \sa \ref page_user_guide_misc_named_parameters
+ * \sa \ref canParamCommitChanges(), \ref canParamGetChannelNumber()
+ */
+canStatus CANLIBAPI canParamGetChannelNumber (int index);
+
+/**
+ * \ingroup NamedParameterSettings
+ *
+ * \source_cs       <b>static Canlib.canStatus canParamGetBusParams(int index, out int bitrate, out int tseg1, out int tseg2, out int sjw, out int noSamp);</b>
+ *
+ * \source_delphi   <b>function canParamGetBusParams(index: Integer; var bitrate: LongInt; var tseg1: Cardinal; var tseg2: Cardinal; var sjw: Cardinal; var nosamp: Cardinal): canStatus;    </b>
+ * \source_end
+ *
+ * This function retrieves the bus parameters associated with the
+ * entry with the given index in the table of named parameter
+ *   settings.
+ *
+ * \param[in] index     The index of the entry in the table of named parameter
+ *                      settings.
+ * \param[out] bitrate  Bit rate (bits per second).
+ * \param[out] tseg1    Time segment 1, that is, the number of quanta from (but
+ *                      not including) the Sync Segment to the sampling point.
+ * \param[out] tseg2    Time segment 2, that is, the number of quanta from the
+ *                      sampling point to the end of the bit.
+ * \param[out] sjw      The Synchronization Jump Width; can be 1,2,3, or 4.
+ * \param[out] noSamp   The number of sampling points; can be 1 or 3.
+ *
+ * \return \ref canOK (zero) if success
+ * \return \ref canERR_xxx (negative) if failure
+ *
+ * \sa \ref page_user_guide_misc_named_parameters
+ * \sa \ref canParamCommitChanges(), \ref canParamSetBusParams()
+ */
+canStatus CANLIBAPI canParamGetBusParams (int index,
+                                          long* bitrate,
+                                          unsigned int *tseg1,
+                                          unsigned int *tseg2,
+                                          unsigned int *sjw,
+                                          unsigned int *noSamp);
+
+/**
+ * \ingroup NamedParameterSettings
+ *
+ * \source_cs       <b>static Canlib.canStatus canParamSetName(int index, string str_buf);</b>
+ *
+ * \source_delphi   <b>function canParamSetName(index: Integer; buffer:  PChar): canStatus;    </b>
+ * \source_end
+ *
+ * This function sets or changes the name of a named parameter.
+ *
+ * \param[in]  index  The index of the named parameter whose name is to be
+ *                    changed or set.
+ * \param[out] buffer A pointer to a \c NULL terminated string that contains the
+ *                    new name. If the string is longer than the maximum
+ *                    allowed name length, it is truncated.
+ *
+ * \return \ref canOK (zero) if success
+ * \return \ref canERR_xxx (negative) if failure
+ *
+ * \sa \ref page_user_guide_misc_named_parameters
+ * \sa \ref canParamCommitChanges(), \ref canParamGetName()
+ */
+canStatus CANLIBAPI canParamSetName (int index, const char *buffer);
+
+/**
+ * \ingroup NamedParameterSettings
+ *
+ * \source_cs       <b>static Canlib.canStatus canParamSetChannelNumber(int index, int channel);</b>
+ *
+ * \source_delphi   <b>function canParamSetChannelNumber(index, channel: Integer): canStatus;     </b>
+ * \source_end
+ *
+ * This function sets the channel number for a specified entry in the list of
+ * named parameters. Channels are numbered from 0 and up.
+ *
+ * \param[in] index    The index of the entry in the named parameter list whose
+ *                     channel number is to be set.
+ * \param[in] channel  The channel number.
+ *
+ * \return \ref canOK (zero) if success
+ * \return \ref canERR_xxx (negative) if failure
+ *
+ * \sa \ref page_user_guide_misc_named_parameters
+ * \sa \ref canParamCommitChanges(), \ref canParamGetChannelNumber()
+ */
+canStatus CANLIBAPI canParamSetChannelNumber (int index, int channel);
+
+/**
+ * \ingroup NamedParameterSettings
+ *
+ * \source_cs       <b>static Canlib.canStatus canParamSetBusParams(int index, int bitrate, int tseg1, int tseg2, int sjw, int noSamp);</b>
+ *
+ * \source_delphi   <b>function canParamSetBusParams(index: Integer; bitrate: longint; tseq1, tseq2, sjw, noSamp: Cardinal): canStatus;     </b>
+ * \source_end
+ *
+ * This function sets or changes the bus parameters for a given entry in the
+ * list of named parameters.
+ *
+ * \note The bus parameters are not checked for validity.
+ *
+ * \param[in]  index   The index of the entry in the named parameter list whose
+ *                     parameters are to be set or changed.
+ * \param[in] bitrate  Bit rate (measured in bits per second); or one of the
+ *                     predefined constants \ref canBITRATE_xxx.
+
+ * \param[in] tseg1    Time segment 1, that is, the number of quanta from (but not
+ *                     including) the Sync Segment to the sampling point.
+ * \param[in] tseg2    Time segment 2, that is, the number of quanta from the
+ *                     sampling point to the end of the bit.
+
+ * \param[in]  sjw     The Synchronization Jump Width; can be 1,2,3, or 4.
+ * \param[in]  noSamp  The number of sampling points; can be 1 or 3.
+ *
+ * \return \ref canOK (zero) if success
+ * \return \ref canERR_xxx (negative) if failure
+ *
+ * \sa \ref page_user_guide_misc_named_parameters
+ * \sa \ref canParamCommitChanges(), \ref canParamGetBusParams()
+ */
+canStatus CANLIBAPI canParamSetBusParams (int index,
+                                          long bitrate,
+                                          unsigned int tseg1,
+                                          unsigned int tseg2,
+                                          unsigned int sjw,
+                                          unsigned int noSamp);
+
+/**
+ * \ingroup NamedParameterSettings
+ *
+ * \source_cs       <b>static Canlib.canStatus canParamFindByName(string str_name);</b>
+ *
+ * \source_delphi   <b>function canParamFindByName(const Name: PChar):canStatus;     </b>
+ * \source_end
+ *
+ * This function returns the index of the parameter setting with the
+ * given name.
+ *
+ * \param[in] name A pointer to a string containing the name of the setting.
+ *
+ * \return The index of the setting (zero or positive) if success.
+ * \return \ref canERR_xxx (negative) if failure
+ *
+ * \sa \ref page_user_guide_misc_named_parameters
+ * \sa \ref canParamCommitChanges()
+ */
+canStatus CANLIBAPI canParamFindByName (const char *name);
+/**
+ * \ingroup ObjectBuffers
+ *
+ * \source_cs       <b>static Canlib.canStatus canObjBufFreeAll(int handle);</b>
+ *
+ * \source_delphi   <b>function canObjBufFreeAll(handle: canHandle): canStatus;     </b>
+ * \source_end
+ *
+ * Deallocates all object buffers on the specified handle. The
+ * buffers cannot be referenced after this operation.
+ *
+ * \param[in]  hnd  An open handle to a CAN circuit.
+ *
+ * \return \ref canOK (zero) if success
+ * \return \ref canERR_xxx (negative) if failure
+ *
+ * \sa \ref page_user_guide_send_recv_obj_buf
+ * \sa \ref canObjBufFree(), \ref canObjBufAllocate()
+ */
+canStatus CANLIBAPI canObjBufFreeAll (const CanHandle hnd);
+
+/**
+ * \ingroup ObjectBuffers
+ *
+ * \source_cs       <b>static Canlib.canStatus canObjBufAllocate(int handle, int type);</b>
+ *
+ * \source_delphi   <b>function canObjBufAllocate(handle: canHandle; tp: Integer): canStatus;     </b>
+ * \source_end
+ *
+ * Allocates an object buffer associated with a handle to a CAN
+ * circuit.
+ *
+ * \param[in] hnd   An open handle to a CAN circuit.
+ * \param[in] type  The type of the buffer. Must be one of \ref canOBJBUF_TYPE_xxx
+ *
+ * \return A buffer index (zero or positive) if success.
+ * \return \ref canERR_xxx (negative) if failure
+ *
+ * \sa \ref page_user_guide_send_recv_obj_buf
+ * \sa \ref canObjBufFree(), \ref canObjBufFreeAll()
+ */
+canStatus CANLIBAPI canObjBufAllocate (const CanHandle hnd, int type);
+
+ /**
+  * \name canOBJBUF_TYPE_xxx
+  * \anchor canOBJBUF_TYPE_xxx
+  *
+  * Used in \ref canObjBufAllocate().
+  *
+  * @{
+  */
+#define canOBJBUF_TYPE_AUTO_RESPONSE            0x01 ///< The buffer is an auto-response buffer.
+#define canOBJBUF_TYPE_PERIODIC_TX              0x02 ///< The buffer is an auto-transmit buffer.
+ /** @} */
+
+/**
+ * \ingroup ObjectBuffers
+ *
+ * \source_cs       <b>static Canlib.canStatus canObjBufFree(int handle, int idx);</b>
+ *
+ * \source_delphi   <b>function canObjBufFree(handle: canHandle; idx: Integer): canStatus;      </b>
+ * \source_end
+ *
+ * Deallocates the object buffer with the specified index. The buffer
+ * can not be referenced after this operation.
+ *
+ * \param[in] hnd  An open handle to a CAN circuit.
+ * \param[in] idx  The object buffer to deallocate.
+ *
+ * \return \ref canOK (zero) if success
+ * \return \ref canERR_xxx (negative) if failure
+ *
+ * \sa \ref page_user_guide_send_recv_obj_buf
+ * \sa \ref canObjBufFreeAll(), \ref canObjBufAllocate(),
+ */
+canStatus CANLIBAPI canObjBufFree (const CanHandle hnd, int idx);
+
+// Writes CAN data to the object buffer with the specified index.
+
+/**
+ * \ingroup ObjectBuffers
+ *
+ * \source_cs       <b>static Canlib.canStatus canObjBufWrite(int handle, int idx, int id, byte[] msg, int dlc, int flags);</b>
+ *
+ * \source_delphi   <b>function canObjBufWrite(handle: canHandle; idx, id: Integer; var msg; dlc, flags: cardinal): canStatus;     </b>
+ * \source_end
+ *
+ * Defines the contents of a specific object buffer.
+ *
+ * \param[in] hnd   An open handle to a CAN circuit.
+ * \param[in] idx   The index of the object buffer whose contents is to be
+ *                  defined.
+ * \param[in] id    The CAN identifier of the message.
+ * \param[in] msg   Points to the contents of the message.
+ * \param[in] dlc   The length of the message. Must be at least 0 and at most 8
+ *                  bytes.
+ * \param[in] flags Message flags; a combination of the \ref canMSG_xxx flags.
+ *
+ * \return \ref canOK (zero) if success
+ * \return \ref canERR_xxx (negative) if failure
+ *
+ * \sa \ref page_user_guide_send_recv_obj_buf
+ */
+canStatus CANLIBAPI canObjBufWrite (const CanHandle hnd,
+                                    int idx,
+                                    int id,
+                                    void* msg,
+                                    unsigned int dlc,
+                                    unsigned int flags);
+
+/**
+ * \ingroup ObjectBuffers
+ *
+ * \source_cs       <b>static Canlib.canStatus canObjBufSetFilter(int handle, int idx, int code, int mask);</b>
+ *
+ * \source_delphi   <b>function canObjBufSetFilter(handle: canHandle; idx: Integer; code, mask: Cardinal): canStatus;      </b>
+ * \source_end
+ *
+ * Defines a message reception filter on the specified object buffer.
+ * Messages not matching the filter are discarded.
+ *
+ * \note For an auto response buffer, set the code and mask that together define
+ * the identifier(s) that trigger(s) the automatic response.
+ *
+ * \param[in] hnd   An open handle to a CAN circuit.
+ * \param[in] idx   The index of the object buffer on which the filter is to be
+ *                  set.
+ * \param[in] code  The acceptance code in the filter.
+ * \param[in] mask  The acceptance mask in the filter.
+ *
+ * \return \ref canOK (zero) if success
+ * \return \ref canERR_xxx (negative) if failure
+ *
+ * \sa \ref page_user_guide_misc_code_and_mask,
+ *     \ref page_user_guide_send_recv_obj_buf
+ */
+canStatus CANLIBAPI canObjBufSetFilter (const CanHandle hnd,
+                                        int idx,
+                                        unsigned int code,
+                                        unsigned int mask);
+
+/**
+ * \ingroup ObjectBuffers
+ *
+ * \source_cs       <b>static Canlib.canStatus canObjBufSetFlags(int handle, int idx, int flags);</b>
+ *
+ * \source_delphi   <b>function canObjBufSetFlags(handle: canHandle; idx: Integer; flags: Cardinal): canStatus;     </b>
+ * \source_end
+ *
+ * Sets object buffer flags on a specified object buffer.
+ *
+ * \param[in] hnd    An open handle to a CAN circuit.
+ * \param[in] idx    The buffer on which the flags are to be set.
+ * \param[in] flags  Specifies a combination of zero or more of the
+ *                   \ref canOBJBUF_AUTO_RESPONSE_xxx flag values
+ *
+ * \return \ref canOK (zero) if success
+ * \return \ref canERR_xxx (negative) if failure
+ *
+ * \sa \ref page_user_guide_send_recv_obj_buf
+ */
+canStatus CANLIBAPI canObjBufSetFlags (const CanHandle hnd,
+                                       int idx,
+                                       unsigned int flags);
+
+/**
+ * \name canOBJBUF_AUTO_RESPONSE_xxx
+ * \anchor canOBJBUF_AUTO_RESPONSE_xxx
+ *
+ * These defines are used in \ref canObjBufSetFlags().
+ *
+ * @{
+ */
+ /**
+  * This define is used in \ref canObjBufSetFlags().
+  *
+  * For auto-response buffers only. When this flag is in effect, the buffer
+  * will auto-respond to remote requests only.  If this flag is not in effect,
+  * the buffer will auto-respond to both remote requests and ordinary data
+  * frames.
+  *
+  */
+# define canOBJBUF_AUTO_RESPONSE_RTR_ONLY        0x01
+ /** @} */
+
+/**
+ * \ingroup ObjectBuffers
+ *
+ * \source_cs       <b>static Canlib.canStatus canObjBufSetPeriod(int hnd, int idx, int period);</b>
+ *
+ * \source_delphi   <b>function canObjBufSetPeriod(handle: canHandle; idx: Integer; period: Cardinal): canStatus;     </b>
+ * \source_end
+ *
+ * The \ref canObjBufSetPeriod function sets the transmission period for an auto
+ * transmission object buffer.
+ *
+ * \param[in] hnd     An open handle to a CAN channel.
+ * \param[in] idx     The index of a CAN object buffer.
+ * \param[in] period  The transmission interval, in microseconds.
+ *
+ * \return \ref canOK (zero) if success
+ * \return \ref canERR_xxx (negative) if failure
+ *
+ * \sa \ref page_user_guide_send_recv_obj_buf
+ */
+canStatus CANLIBAPI canObjBufSetPeriod (const CanHandle hnd,
+                                        int idx,
+                                        unsigned int period);
+
+/**
+ * \ingroup ObjectBuffers
+ *
+ * \source_cs       <b>static Canlib.canStatus canObjBufSetMsgCount(int hnd, int idx, int count);</b>
+ *
+ * \source_delphi   <b>function canObjBufSetMsgCount(handle: canHandle; idx: Integer; count: Cardinal): canStatus;     </b>
+ * \source_end
+ *
+ * The \ref canObjBufSetMsgCount function sets the message count for an auto
+ * transmit object buffer.
+ *
+ * \param[in] hnd    An open handle to a CAN channel.
+ * \param[in] idx    The index of a CAN object buffer.
+ * \param[in] count  The message count.
+ *
+ * \return \ref canOK (zero) if success
+ * \return \ref canERR_xxx (negative) if failure
+ *
+ * \sa \ref page_user_guide_send_recv_obj_buf
+ */
+canStatus CANLIBAPI canObjBufSetMsgCount (const CanHandle hnd,
+                                          int idx,
+                                          unsigned int count);
+
+/**
+ * \ingroup ObjectBuffers
+ *
+ * \source_cs       <b>static Canlib.canStatus canObjBufEnable(int handle, int idx);</b>
+ *
+ * \source_delphi   <b>function canObjBufEnable(handle: canHandle; idx: Integer): canStatus;     </b>
+ * \source_end
+ *
+ * Enables the object buffer with the specified index.
+ *
+ * \param[in] hnd  An open handle to a CAN circuit.
+ * \param[in] idx  The index of the object buffer to enable.
+ *
+ * \return \ref canOK (zero) if success
+ * \return \ref canERR_xxx (negative) if failure
+ *
+ * \sa \ref page_user_guide_send_recv_obj_buf
+ * \sa \ref canObjBufDisable()
+ */
+canStatus CANLIBAPI canObjBufEnable (const CanHandle hnd, int idx);
+
+/**
+ * \ingroup ObjectBuffers
+ *
+ * \source_cs       <b>static Canlib.canStatus canObjBufDisable(int handle, int idx);</b>
+ *
+ * \source_delphi   <b>function canObjBufDisable(handle: canHandle; idx: Integer): canStatus;     </b>
+ * \source_end
+ *
+ * Disables the object buffer with the specified index.
+ *
+ * \param[in] hnd  An open handle to a CAN circuit.
+ * \param[in] idx  The index of the buffer.
+ *
+ * \return \ref canOK (zero) if success
+ * \return \ref canERR_xxx (negative) if failure
+ *
+ * \sa \ref page_user_guide_send_recv_obj_buf
+ * \sa \ref canObjBufEnable()
+ */
+canStatus CANLIBAPI canObjBufDisable (const CanHandle hnd, int idx);
+
+/**
+ * \ingroup ObjectBuffers
+ *
+ * \source_cs       <b>static Canlib.canStatus canObjBufSendBurst(int hnd, int idx, int burstlen);</b>
+ *
+ * \source_delphi   <b>function canObjBufSendBurst(handle: canHandle; idx: Integer; burstLen: Cardinal): canStatus;      </b>
+ * \source_end
+ *
+ * The canObjBufSendBurst function sends a burst of CAN messages. You have to
+ * set up an object buffer first with the message to send. The messages will be
+ * sent as fast as possible from the hardware.
+ *
+ * This function is inteneded for certain diagnostic applications.
+ *
+ * \param[in] hnd       An open handle to a CAN channel.
+ * \param[in] idx       The index of a CAN object buffer.
+ * \param[in] burstlen  The number of messages to send.
+ *
+ * \return \ref canOK (zero) if success
+ * \return \ref canERR_xxx (negative) if failure
+ *
+ * \sa \ref page_user_guide_send_recv_obj_buf
+ */
+canStatus CANLIBAPI canObjBufSendBurst (const CanHandle hnd,
+                                        int idx,
+                                        unsigned int burstlen);
+
+/**
+ * \name canVERSION_xxx
+ * \anchor canVERSION_xxx
+ *
+ * These defines are used in \ref canProbeVersion().
+ *
+ * @{
+ */
+  /**
+   * This define is used in \ref canProbeVersion(), \a major and \a minor refer to
+   * this functions arguments.
+   *
+   * Require that exactly the version specified by \a major and \a minor be
+   * present. Earlier and later versions are not accepted. This flag does not
+   * affect the acceptance of beta versions.
+   */
+#define canVERSION_DONT_ACCEPT_LATER      0x01
+  /**
+   * This define is used in \ref canProbeVersion(), \a major and \a minor refer to
+   * this functions arguments.
+   *
+   * Return FALSE if a beta version (preview version) of CANLIB is installed,
+   * regardless of its version number.
+   */
+#define canVERSION_DONT_ACCEPT_BETAS      0x02
+ /** @} */
+
+/**
+ * \ingroup General
+ *
+ * \source_cs       <b>static bool canProbeVersion(int hnd, int major, int minor, int oem_id, int flags);</b>
+ *
+ * \source_delphi   <b>function canProbeVersion(handle: canHandle; major, minor, oem_id: Integer; flags: Cardinal): Boolean;     </b>
+ * \source_end
+ *
+ * This function checks whether a specific version of CANLIB is installed on
+ * the system.
+ *
+ * The default behaviour of \ref canProbeVersion is to accept
+ *
+ * \li the version specified by \a major and \a minor, and
+ * \li any later version, and
+ * \li all beta versions.
+ *
+ * You get the default behaviour by setting \a flags to 0. Use any
+ * combination of the \ref canVERSION_xxx flags to modify the behaviour.
+ *
+ * \note Different handles might have different driver versions installed. This
+ * should not normally be the case but it might happen anyway. You should check
+ * the version for each handle you open, e.g. directly after calling
+ * \ref canOpenChannel().
+ *
+ * \param[in] hnd     A handle to an open circuit.
+ * \param[in] major   The major version number of the version to test for.
+ * \param[in] minor   The minor version number of the version to test for.
+ * \param[in] oem_id  Reserved, must be zero.
+ * \param[in] flags   Any combination of the \ref canVERSION_xxx flags, or 0.
+ *
+ * \return TRUE if the specified version of CANLIB is installed on the system.
+ *
+ * \sa \ref page_user_guide_build_driver_version
+ * \sa \ref page_code_snippets_examples
+ * \sa \ref canGetVersion(), \ref canGetVersionEx(), \ref canGetChannelData()
+ */
+BOOL CANLIBAPI canProbeVersion (const CanHandle hnd,
+                                int major,
+                                int minor,
+                                int oem_id,
+                                unsigned int flags);
+#endif
+
+/**
+ * \ingroup CAN
+ *
+ * \source_cs       <b>static Canlib.canStatus canResetBus(int handle);</b>
+ *
+ * \source_delphi   <b>function canResetBus(handle: canHandle): canStatus;     </b>
+ * \source_end
+ *
+ * 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 \ref canResetBus().)
+ *
+ * This function will affect the hardware (and cause a real reset of the CAN
+ * chip) only if \a hnd is the only handle open on the channel. If there
+ * are other open handles, this operation will not affect the hardware.
+ *
+ * \param[in] hnd  A handle to an open circuit.
+ *
+ * \return \ref canOK (zero) if success
+ * \return \ref canERR_xxx (negative) if failure
+ *
+ * \sa \ref canBusOn(), \ref canBusOff()
+ */
+canStatus CANLIBAPI canResetBus (const CanHandle hnd);
+
+/**
+ * \ingroup CAN
+ *
+ * \source_cs       <b>static Canlib.canStatus canWriteWait(int handle, int id, byte[] msg, int dlc, int flag, long timeout);</b>
+ *
+ * \source_delphi   <b>function canWriteWait(handle: canHandle; id: longint; var msg; dlc, flag, timeout : Cardinal): canStatus;     </b>
+ * \source_end
+ *
+ * This function sends a CAN message. It returns when the message is sent, or
+ * the timeout expires.
+ *
+ * This is a convenience function that combines \ref canWrite() and \ref 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 \ref canIOCTL_SET_LOCAL_TXECHO.
+ *
+ * \param[in]  hnd       A handle to an open CAN circuit.
+ * \param[in]  id        The identifier of the CAN message to send.
+ * \param[in]  msg       A pointer to the message data, or \c NULL.
+ * \param[in]  dlc       The length of the message. Can be at most 8.
+ * \param[in]  flag      A combination of message flags, \ref canMSG_xxx.
+ *                       Use this parameter to send extended (29-bit) frames
+ *                       and/or remote frames. Use \ref canMSG_EXT and/or
+ *                       \ref canMSG_RTR for this purpose.
+ * \param[in] timeout    The timeout, in milliseconds. 0xFFFFFFFF gives an
+ *                       infinite timeout.
+ *
+ * \return \ref canOK (zero) if success
+ * \return \ref canERR_xxx (negative) if failure
+ */
+canStatus CANLIBAPI canWriteWait (const CanHandle hnd,
+                                  long id,
+                                  void *msg,
+                                  unsigned int dlc,
+                                  unsigned int flag,
+                                  unsigned long timeout);
+
+
+#if defined(CANLIB_DECLARE_ALL)
+
+/**
+ * \ingroup General
+ *
+ * \source_cs       <b>static Canlib.canStatus canUnloadLibrary();</b>
+ *
+ * \source_delphi   <b>function canUnloadLibrary: Integer;     </b>
+ * \source_end
+ *
+ * Use this function if you are loading CANLIB32.DLL dynamically (that is,
+ * using the Win32 API \c LoadLibrary) and need to unload it using the Win32
+ * API \c FreeLibrary. \ref canUnloadLibrary() will free allocated memory, unload
+ * the DLLs canlib32.dll has loaded and de-initialize data structures. You must
+ * call \ref canInitializeLibrary() again to use the API functions in canlib32.dll.
+ *
+ * \return \ref canOK (zero) if success
+ * \return \ref canERR_xxx (negative) if failure
+ *
+ * \sa \ref canInitializeLibrary()
+ */
+canStatus CANLIBAPI canUnloadLibrary (void);
+
+/**
+ * \ingroup CAN
+ *
+ * \source_cs       <b>static Canlib.canStatus canSetAcceptanceFilter(int hnd, int code, int mask, int is_extended);</b>
+ *
+ * \source_delphi   <b>function canSetAcceptanceFilter(handle: canHandle; code, mask: Cardinal; is_extended: Integer): canStatus;     </b>
+ * \source_end
+ *
+ * This routine sets the message acceptance filters on a CAN channel.
+ *
+ * Format of \a code and \a mask:
+ *
+ * \li A binary 1 in a mask means "the corresponding bit in the code is
+ *     relevant"
+ * \li A binary 0 in a mask means "the corresponding bit in the code is not
+ *     relevant"
+ * \li A relevant binary 1 in a code means "the corresponding bit in the
+ *     identifier must be 1"
+ * \li A relevant binary 1 in a code means "the corresponding bit in the
+ *     identifier must be 1"
+ *
+ * In other words, the message is accepted if ((code XOR id) AND mask) == 0.
+ *
+ * \a extended should be set to:
+ *
+ * \li \c 0 (FALSE): if the code and mask shall apply to 11-bit CAN identifiers.
+ * \li \c 1 (TRUE): if the code and mask shall apply to 29-bit CAN identifiers.
+ *
+ * If you want to remove a filter, call \ref canSetAcceptanceFilter() with the mask
+ * set to \c 0.
+ *
+ * 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.  \ref canSetAcceptanceFilter() behaves in the same
+ * way for all boards, however.
+ *
+ * \ref canSetAcceptanceFilter() and \ref canAccept() both serve the same purpose but the
+ * former can set the code and mask in just one call.
+ *
+ * \note You can set the extended code and mask only on CAN boards that support
+ *       extended identifiers.
+ *
+ * \note Not all CAN boards support different masks for standard and
+ *       extended CAN identifiers.
+ *
+ * \param[in] hnd          An open handle to a CAN circuit.
+ * \param[in] code         The acceptance code to set.
+ * \param[in] mask         The acceptance mask to set.
+ * \param[in] is_extended  Select 29-bit CAN identifiers.
+ *
+ * \return \ref canOK (zero) if success
+ * \return \ref canERR_xxx (negative) if failure
+ *
+ * \sa \ref page_code_snippets_examples,
+ *     \ref page_user_guide_misc_code_and_mask
+ * \sa  \ref canAccept()
+ */
+canStatus CANLIBAPI canSetAcceptanceFilter (const CanHandle hnd,
+                                            unsigned int code,
+                                            unsigned int mask,
+                                            int is_extended);
+
+/**
+ * \ingroup CAN
+ *
+ * \source_cs       <b>static Canlib.canStatus canFlushReceiveQueue(int hnd);</b>
+ *
+ * \source_delphi   <b>function canFlushReceiveQueue(handle: canHandle): canStatus;     </b>
+ * \source_end
+ *
+ * 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 \ref canFlushReceiveQueue are discarded.
+ *
+ * \note This call has the same effect as calling \ref canIoCtl() with a function
+ * code of \ref canIOCTL_FLUSH_RX_BUFFER.
+ *
+ * \param[in] hnd  A handle to an open circuit.
+ *
+ * \return \ref canOK (zero) if success
+ * \return \ref canERR_xxx (negative) if failure
+ *
+ * \sa \ref canFlushTransmitQueue()
+ */
+canStatus CANLIBAPI canFlushReceiveQueue (const CanHandle hnd);
+
+/**
+ * \ingroup CAN
+ *
+ * \source_cs       <b>static Canlib.canStatus canFlushTransmitQueue(int hnd);</b>
+ *
+ * \source_delphi   <b>function canFlushTransmitQueue(handle: canHandle): canStatus;     </b>
+ * \source_end
+ *
+ * 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.
+ *
+ * \note This call has the same effect as calling \ref canIoCtl() with a function
+ * code of \ref canIOCTL_FLUSH_TX_BUFFER.
+ *
+ * \param[in] hnd  A handle to an open circuit.
+ *
+ * \return \ref canOK (zero) if success
+ * \return \ref canERR_xxx (negative) if failure
+ *
+ * \sa \ref canFlushReceiveQueue()
+ */
+canStatus CANLIBAPI canFlushTransmitQueue (const CanHandle hnd);
+
+/**
+ * \ingroup General
+ *
+ * \source_cs       <b>static Canlib.canStatus kvGetApplicationMapping(int busType, string appName, int appChannel, out int resultingChannel);</b>
+ *
+ * \source_delphi   <b>function kvGetApplicationMapping(busType: Integer; appName: PChar; appChannel: Integer; var resultingChannel: Integer): canStatus;     </b>
+ * \source_end
+ *
+ * \note The \ref kvGetApplicationMapping function is presently not implemented.
+ *
+ * \param busType
+ * \param appName
+ * \param appChannel
+ * \param resultingChannel
+ *
+ * \return \ref canOK (zero) if success
+ * \return \ref canERR_xxx (negative) if failure
+ *
+ */
+canStatus CANLIBAPI kvGetApplicationMapping (int busType,
+                                             char *appName,
+                                             int appChannel,
+                                             int *resultingChannel);
+
+/**
+ * \ingroup General
+ *
+ * \source_cs       <b>static Canlib.canStatus kvBeep(int hnd, int freq, int duration);</b>
+ *
+ * \source_delphi   <b>function kvBeep(handle: canHandle; freq: Integer; duration: Cardinal): canStatus;     </b>
+ * \source_end
+ *
+ * The \ref kvBeep function emits a sound of a specific frequency and duration from
+ * the loudspeaker on the device.
+ *
+ * \note This function requires that a loudspeaker be present on the hardware.
+ *
+ * \param[in] hnd       An open handle to a CAN channel.
+ * \param[in] freq      The frequency (in Hertz) of the sound.
+ * \param[in] duration  The duration of the sound, in milliseconds.
+ *
+ * \return \ref canOK (zero) if success
+ * \return \ref canERR_xxx (negative) if failure
+ *
+ */
+canStatus CANLIBAPI kvBeep (const CanHandle hnd,
+                            int freq,
+                            unsigned int duration);
+
+/**
+ * \ingroup General
+ *
+ * \source_cs       <b>static Canlib.canStatus kvSelfTest(int hnd, out int presults);</b>
+ *
+ * \source_delphi   <b>function kvSelfTest(handle: canHandle; var presults: Cardinal): canStatus;     </b>
+ * \source_end
+ *
+ * The \ref kvSelfTest function runs a built-in self test in the device. Note that
+ * not all devices supports built-in self tests.
+ *
+ * \param[in]  hnd       An open hnd to a CAN channel.
+ * \param[out] presults  A pointer to a 32-bit unsigned integer where the
+ *                       resuls of the self test will be placed.
+ *
+ * \return \ref canOK (zero) if success
+ * \return \ref canERR_xxx (negative) if failure
+ *
+ */
+canStatus CANLIBAPI kvSelfTest (const CanHandle hnd, unsigned long *presults);
+
+  /**
+   * \anchor kvLED_ACTION_xxx
+   * \name kvLED_ACTION_xxx
+   *
+   * The following constants can be used together with the \ref kvFlashLeds() function.
+   *
+   * @{
+   */
+#define kvLED_ACTION_ALL_LEDS_ON    0 ///< Turn all LEDs on.
+#define kvLED_ACTION_ALL_LEDS_OFF   1 ///< Turn all LEDs off.
+#define kvLED_ACTION_LED_0_ON       2 ///< Turn LED 0 on.
+#define kvLED_ACTION_LED_0_OFF      3 ///< Turn LED 0 off.
+#define kvLED_ACTION_LED_1_ON       4 ///< Turn LED 1 on.
+#define kvLED_ACTION_LED_1_OFF      5 ///< Turn LED 1 off.
+#define kvLED_ACTION_LED_2_ON       6 ///< Turn LED 2 on.
+#define kvLED_ACTION_LED_2_OFF      7 ///< Turn LED 2 off.
+#define kvLED_ACTION_LED_3_ON       8 ///< Turn LED 3 on.
+#define kvLED_ACTION_LED_3_OFF      9 ///< Turn LED 3 off.
+  /** @} */
+
+/**
+ * \ingroup General
+ *
+ * \source_cs       <b>static Canlib.canStatus kvFlashLeds(int hnd, int action, int timeout);</b>
+ *
+ * \source_delphi   <b>function kvFlashLeds(handle: canHandle; action: Integer; timeout: Integer): canStatus;     </b>
+ * \source_end
+ *
+ * The \ref kvFlashLeds function will turn the LEDs on the device on or off.
+ *
+ * \param[in] hnd
+ * \param[in] action   One of the \ref kvLED_ACTION_xxx constants, defining
+ *                     which LED to turn on or off.
+ * \param[in] timeout  Specifies the time, in milliseconds, during which the
+ *                     action is to be carried out. When the timeout expires,
+ *                     the LED(s) will return to its ordinary function.
+ *
+ * \return \ref canOK (zero) if success
+ * \return \ref canERR_xxx (negative) if failure
+ *
+ */
+canStatus CANLIBAPI kvFlashLeds (const CanHandle hnd, int action, int timeout);
+
+/**
+ * \ingroup CAN
+ *
+ * \source_cs       <b>static Canlib.canStatus canRequestChipStatus(int hnd);</b>
+ *
+ * \source_delphi   <b>function canRequestChipStatus(handle: canHandle): canStatus;     </b>
+ * \source_end
+ *
+ * The canRequestChipStatus function requests that the hardware report the chip
+ * status (bus on/error passive status etc.) to the driver. The chip status can
+ * later be retrieved using the \ref canReadStatus() function.
+ *
+ * \note The \ref canRequestChipStatus() function is asynchronous, that is, it
+ * completes before the answer is returned from the hardware.  The time between
+ * a call to \ref canRequestChipStatus() and the point in time where the chip status
+ * is actually available via a call to \ref canReadStatus() is not
+ * defined. \ref canReadStatus() always returns the latest data reported by the
+ * hardware.
+ *
+ * \param[in] hnd An open handle to a CAN channel.
+ *
+ * \return \ref canOK (zero) if success
+ * \return \ref canERR_xxx (negative) if failure
+ *
+ * \sa \ref canReadStatus()
+ */
+canStatus CANLIBAPI canRequestChipStatus (const CanHandle hnd);
+
+/**
+ * \ingroup CAN
+ *
+ * \source_cs       <b>static Canlib.canStatus canRequestBusStatistics(int hnd);</b>
+ *
+ * \source_delphi   <b>function canRequestBusStatistics(handle: canHandle): canStatus;     </b>
+ * \source_end
+ *
+ * The \ref canRequestBusStatistics function requests bus statistics from the
+ * hardware. The bus statistics figures can be retrieved later by a call to the
+ * \ref canGetBusStatistics function.
+ *
+ * \note The time between a call to \ref canRequestBusStatistics() and the point in
+ * time where the bus statistics is actually available via a call to
+ * \ref canGetBusStatistics() is not defined. Typically, you would call
+ * \ref canRequestBusStatistics() from your application periodically (for example,
+ * once per second) to request the data from the driver and then call
+ * \ref canGetBusStatistics() with the same rate to obtain the latest reported data.
+ *
+ * \param[in] hnd   An open handle to a CAN channel.
+ *
+ * \return \ref canOK (zero) if success
+ * \return \ref canERR_xxx (negative) if failure
+ *
+ * \sa \ref canGetBusStatistics()
+ */
+canStatus CANLIBAPI canRequestBusStatistics (const CanHandle hnd);
+
+  /**
+   * \ingroup CAN
+   * This struct is returned by \ref canGetBusStatistics()
+   *
+   * The values are cleared when the corresponding channel goes on bus.
+   */
+typedef struct canBusStatistics_s {
+  unsigned long  stdData;   ///< Number of received standard (11-bit identifiers) data frames.
+  unsigned long  stdRemote; ///< Number of received standard (11-bit identifiers) remote frames.
+  unsigned long  extData;   ///< Number of received extended (29-bit identifiers) data frames.
+  unsigned long  extRemote; ///< Number of received extended (29-bit identifiers) remote frames.
+  unsigned long  errFrame;  ///< Number of error frames
+
+  /**
+   * The bus load, expressed as an integer in the interval 0 - 10000
+   * representing 0.00% - 100.00% bus load.
+   */
+  unsigned long  busLoad;
+  unsigned long  overruns;  ///< The number of overruns detected by the hardware, firmware or driver.
+} canBusStatistics;
+
+/**
+ * \ingroup CAN
+ *
+ * \source_cs       <b>static Canlib.canStatus canGetBusStatistics(int hnd, out Canlib.canBusStatistics stat);</b>
+ *
+ * \source_delphi   <b>function canGetBusStatistics(handle: canHandle; var stat: canBusStatistics; bufsiz: Cardinal): canStatus;     </b>
+ * \source_end
+ *
+ * The \ref canGetBusStatistics() function retrieves the latest bus statistics
+ * figures reported by the driver.  You request the bus statistics from the
+ * driver by calling the \ref canRequestBusStatistics() function.
+ *
+ * \param[in]  hnd     An open handle to a CAN channel.
+ * \param[out] stat    A pointer to a \ref canBusStatistics struct that will receive
+ *                     the bus statistics figures.
+ * \param[in]  bufsiz  The size, in bytes, of the stat buffer.
+ *
+ * \return \ref canOK (zero) if success
+ * \return \ref canERR_xxx (negative) if failure
+ *
+ * \sa \ref canRequestBusStatistics()
+ */
+canStatus CANLIBAPI canGetBusStatistics (const CanHandle hnd,
+                                         canBusStatistics *stat,
+                                         size_t bufsiz);
+
+/**
+ * \ingroup CAN
+ *
+ * \source_cs       <b>static Canlib.canStatus canSetBitrate(int hnd, int bitrate);</b>
+ *
+ * \source_delphi   <b>function canSetBitrate(handle: canHandle; bitrate: Integer): canStatus;     </b>
+ * \source_end
+ *
+ * The \ref canSetBitrate() function sets the bit rate of the specified CAN
+ * channel. The SJW is left unchanged.  The sampling point is recalculated and
+ * kept as close as possible to the value before the call.
+ *
+ * \param[in] hnd      An open handle to a CAN channel.
+ * \param[in] bitrate  The new bit rate, in bits/second.
+ *
+ * \return \ref canOK (zero) if success
+ * \return \ref canERR_xxx (negative) if failure
+ *
+ * \sa \ref canSetBusParamsC200(), \ref canSetBusParams(), \ref canGetBusParams()
+ */
+canStatus CANLIBAPI canSetBitrate (const CanHandle hnd, int bitrate);
+
+/**
+ * \ingroup General
+ *
+ * \source_cs       <b>static Canlib.canStatus kvAnnounceIdentity(int hnd, object buffer);</b>
+ *
+ * \source_delphi   <b>function kvAnnounceIdentity(handle: canHandle; var buf; bufsiz: Cardinal): canStatus;     </b>
+ * \source_end
+ *
+ * The \ref kvAnnounceIdentity function is used by certain OEM applications.
+ *
+ * \param[in]  hnd     An open handle to a CAN channel.
+ * \param[out] buf     A pointer to the data to be sent to the driver.
+ * \param[in]  bufsiz  The size, in bytes, of the buffer that buf points to.
+ *
+ * \return \ref canOK (zero) if success
+ * \return \ref canERR_xxx (negative) if failure
+ */
+canStatus CANLIBAPI kvAnnounceIdentity (const CanHandle hnd,
+                                        void *buf,
+                                        size_t bufsiz);
+/**
+ * \ingroup General
+ *
+ * The \ref kvAnnounceIdentityEx function is used by certain OEM applications.
+ *
+ * \param[in]  hnd     An open handle to a CAN channel.
+ * \param[in]  type    Type of announcement.
+ * \param[out] buf     A pointer to the data to be sent to the driver.
+ * \param[in]  bufsiz  The size, in bytes, of the buffer that buf points to.
+ *
+ * \return \ref canOK (zero) if success
+ * \return \ref canERR_xxx (negative) if failure
+ */
+canStatus CANLIBAPI kvAnnounceIdentityEx (const CanHandle hnd,
+                                          int type,
+                                          void *buf,
+                                          size_t bufsiz);
+
+/**
+ * \ingroup CAN
+ *
+ * \source_cs       <b>static Canlib.canStatus canGetHandleData(int hnd, int item, out object buffer);</b>
+ *
+ * \source_delphi   <b>function canGetHandleData(handle: canHandle; item: Integer; var Buffer; bufsize: Cardinal): canStatus;     </b>
+ * \source_end
+ *
+ * \note This function can be used to retrieve certain pieces of information about an open handle to a CANlib channel.
+ *
+ * \param[in]  hnd      An open handle to a CAN channel.
+ * \param[in]  item     This parameter specifies what data to obtain for the specified handle. The value is one of the constants \ref canCHANNELDATA_xxx
+ * \param[out] buffer   The address of a buffer which is to receive the data.
+ * \param[in]  bufsize  The size of the buffer to which the buffer parameter points.
+ *
+ * \return \ref canOK (zero) if success
+ * \return \ref canERR_xxx (negative) if failure
+ *
+ * \sa \ref canGetChannelData()
+ */
+canStatus CANLIBAPI canGetHandleData (const CanHandle hnd,
+                                      int item,
+                                      void *buffer,
+                                      size_t bufsize);
+
+/** Used for time domain handling. */
+typedef void *kvTimeDomain;
+
+/** Contains status codes according to \ref canSTAT_xxx. */
+typedef canStatus kvStatus;
+
+/**
+ * \ingroup TimeDomainHandling
+ *
+ * Used for time domain handling.
+ */
+typedef struct kvTimeDomainData_s {
+  int nMagiSyncGroups;        ///< number of MagiSync&tm; groups
+  int nMagiSyncedMembers;     ///< number of MagiSync&tm; members
+  int nNonMagiSyncCards;      ///< number of non MagiSync&tm; interfaces
+  int nNonMagiSyncedMembers;  ///< number of non MagiSync&tm; members
+} kvTimeDomainData;
+
+/**
+ * \ingroup TimeDomainHandling
+ *
+ * \source_cs       <b>static Canlib.canStatus kvTimeDomainCreate(out object domain);</b>
+ *
+ * \source_delphi   <b>function kvTimeDomainCreate(var domain: kvTimeDomain): kvStatus;     </b>
+ * \source_end
+ *
+ * This routine creates an empty time domain.
+ *
+ * The variable is set by this function and then used in later calls to
+ * other functions using a \ref kvTimeDomain.
+ *
+ * Time domains created by \ref kvTimeDomainCreate() can be destroyed with a
+ * call to \ref kvTimeDomainDelete().
+ *
+ * \note A time domain is a set of channels with a common time base.
+ *
+ * \param[in] domain  A pointer to a caller allocated, opaque variable of type
+ *                    \ref kvTimeDomain that holds data to identify a particlar
+ *                    time domain.
+ *
+ * \return \ref canOK (zero) if success
+ * \return \ref canERR_xxx (negative) if failure
+ *
+ * \sa \ref page_code_snippets_examples
+ * \sa \ref kvTimeDomainDelete()
+ */
+kvStatus CANLIBAPI kvTimeDomainCreate (kvTimeDomain *domain);
+
+/**
+ * \ingroup TimeDomainHandling
+ *
+ * \source_cs       <b>static Canlib.canStatus kvTimeDomainDelete(object domain);</b>
+ *
+ * \source_delphi   <b>function kvTimeDomainDelete(domain: kvTimeDomain): kvStatus;     </b>
+ * \source_end
+ *
+ * This is a cleanup routine that deletes all members of a domain and then
+ * deletes the domain itself.
+ *
+ * \note A time domain is a set of channels with a common time base.
+ *
+ * \param[in] domain  An opaque variable set by \ref kvTimeDomainCreate() that
+ *                    identifies the domain to be deleted.
+ *
+ * \return \ref canOK (zero) if success
+ * \return \ref canERR_xxx (negative) if failure
+ *
+ * \sa \ref page_code_snippets_examples
+ * \sa \ref kvTimeDomainCreate()
+ */
+kvStatus CANLIBAPI kvTimeDomainDelete (kvTimeDomain domain);
+
+/**
+ * \ingroup TimeDomainHandling
+ *
+ * \source_cs       <b>static Canlib.canStatus kvTimeDomainResetTime(object domain);</b>
+ *
+ * \source_delphi   <b>function kvTimeDomainResetTime(domain: kvTimeDomain): kvStatus;     </b>
+ * \source_end
+ *
+ * This routine resets the time on all members of a time domain.
+ *
+ * After a call to this routine timestamps from all channels with MagiSync&tm;
+ * running have no offset at all any longer. The same applies for channels that
+ * reside on the same physical interface.
+ *
+ * \note A time domain is a set of channels with a common time base.
+ *
+ * \param[in] domain  An opaque variable set by \ref kvTimeDomainCreate() that
+ *                    identifies the domain to reset the time on.
+ *
+ * \return \ref canOK (zero) if success
+ * \return \ref canERR_xxx (negative) if failure
+ *
+ * \sa \ref page_code_snippets_examples
+ * \sa \ref kvTimeDomainCreate()
+ */
+kvStatus CANLIBAPI kvTimeDomainResetTime (kvTimeDomain domain);
+
+/**
+ * \ingroup TimeDomainHandling
+ *
+ * \source_cs       <b>static Canlib.canStatus kvTimeDomainGetData(object domain, Canlib.kvTimeDomainData data);</b>
+ *
+ * \source_delphi   <b>function kvTimeDomainGetData(domain: kvTimeDomain; var data: kvTimeDomainData; bufsiz: Cardinal): kvStatus;     </b>
+ * \source_end
+ *
+ * This routine collects some data on a time domain.
+ *
+ * \note A time domain is a set of channels with a common time base.
+ *
+ * \param[in]  domain  An opaque variable set by \ref kvTimeDomainCreate() that
+ *                     identifies the domain to add a handle to.
+ * \param[out] data    A pointer to a \ref kvTimeDomainData that is to be filled by
+ *                     the function.
+ * \param[in]  bufsiz  The size in bytes of the \ref kvTimeDomainData struct.
+ *
+ * \return \ref canOK (zero) if success
+ * \return \ref canERR_xxx (negative) if failure
+ *
+ * \sa \ref page_code_snippets_examples
+ * \sa \ref kvTimeDomainCreate()
+ */
+kvStatus CANLIBAPI kvTimeDomainGetData (kvTimeDomain domain,
+                                        kvTimeDomainData *data,
+                                        size_t bufsiz);
+
+/**
+ * \ingroup TimeDomainHandling
+ *
+ * \source_cs       <b>static Canlib.canStatus kvTimeDomainAddHandle(object domain, int handle);</b>
+ *
+ * \source_delphi   <b>function kvTimeDomainAddHandle(domain: kvTimeDomain; handle: canHandle): kvStatus;     </b>
+ * \source_end
+ *
+ * This routine adds an open channel handle to a domain.
+ *
+ * \note A time domain is a set of channels with a common time base.
+ *
+ * \param[in] domain  An opaque variable set by \ref kvTimeDomainCreate()
+ *                    that identifies the domain to add a handle to.
+ * \param[in] hnd     A handle to an open channel.
+ *
+ * \return \ref canOK (zero) if success
+ * \return \ref canERR_xxx (negative) if failure
+ *
+ * \sa \ref page_code_snippets_examples
+ * \sa \ref kvTimeDomainCreate(), \ref kvTimeDomainRemoveHandle()
+ */
+kvStatus CANLIBAPI kvTimeDomainAddHandle(kvTimeDomain domain,
+                                         const CanHandle hnd);
+
+/**
+ * \ingroup TimeDomainHandling
+ *
+ * \source_cs       <b>static Canlib.canStatus kvTimeDomainRemoveHandle(object domain, int handle);</b>
+ *
+ * \source_delphi   <b>function kvTimeDomainRemoveHandle(domain: kvTimeDomain; handle: canHandle): kvStatus;     </b>
+ * \source_end
+ *
+ * This routine removes an open channel handle from a domain.
+ *
+ * \note A time domain is a set of channels with a common time base.
+ *
+ * \param[in] domain  An opaque variable set by \ref kvTimeDomainCreate()
+ *                    that identifies the domain to remove a handle from.
+ * \param[in] hnd     A handle to an open channel.
+ *
+ * \return \ref canOK (zero) if success
+ * \return \ref canERR_xxx (negative) if failure
+ *
+ * \sa \ref kvTimeDomainCreate(), \ref kvTimeDomainAddHandle()
+ */
+kvStatus CANLIBAPI kvTimeDomainRemoveHandle (kvTimeDomain domain,
+                                             const CanHandle hnd);
+/**
+ * \name kvCallback_t
+ * \anchor kvCallback_t
+ * \ref kvCallback_t is used by the function \ref kvSetNotifyCallback()
+ *
+ * The callback function is called with the following arguments:
+ * \li hnd - the handle of the CAN channel where the event happened.
+ * \li context - the context pointer you passed to \ref kvSetNotifyCallback().
+ * \li notifyEvent - one of the \ref canNOTIFY_xxx notification codes.
+ *
+ * \note It is really the \ref canNOTIFY_xxx codes, and not the \ref
+ *  \ref canEVENT_xxx codes that the \ref canSetNotify() API is using.
+ *
+ * \param[in] hnd          An open handle to a CAN channel.
+ * \param[in] context      Arbitrary user-defined context data which
+ *                         is passed to the callback function.
+ * \param[in] notifyEvent  One or more of the \ref canEVENT_xxx flags.
+ *
+ */
+typedef void (CANLIBAPI *kvCallback_t) (CanHandle hnd, void* context, unsigned int notifyEvent);
+
+/**
+ * \ingroup General
+ *
+ * \source_cs       <b>static Canlib.canStatus kvSetNotifyCallback(int hnd, Canlib.kvCallbackDelegate callback, IntPtr context, uint notifyFlags);</b>
+ *
+ * \source_delphi   <b>function kvSetNotifyCallback(handle: canHandle; callback: kvCallback_t; context: Pointer; notifyFlags: Cardinal): canStatus;     </b>
+ * \source_end
+ *
+ * The \ref 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 \ref kvSetNotifyCallback() with a \c NULL pointer in
+ * the callback argument.
+ *
+ * \note The callback function is called in the context of a high-priority
+ * thread created by CANLIB. You should take precaution not to do any time
+ * consuming tasks in the callback.  You must also arrange the synchronization
+ * between the callback and your other threads yourself.
+ *
+ * \param[in] hnd          An open handle to a CAN channel.
+ * \param[in] callback     A pointer to a callback function of type
+ *                         \ref kvCallback_t
+ * \param[in] context      A pointer to arbitrary user-defined context data which
+ *                         is passed to the callback function.
+ * \param[in] notifyFlags  One or more of the \ref canNOTIFY_xxx flags.
+ *
+ * \return \ref canOK (zero) if success
+ * \return \ref canERR_xxx (negative) if failure
+ *
+ * \sa \ref canSetNotify()
+ */
+kvStatus CANLIBAPI kvSetNotifyCallback (const CanHandle hnd,
+                                        kvCallback_t callback,
+                                        void* context,
+                                        unsigned int notifyFlags);
+
+/**
+ * \name kvBUSTYPE_xxx
+ * \anchor kvBUSTYPE_xxx
+ *
+ *  Bus types, returned by \ref kvGetSupportedInterfaceInfo().
+ * @{
+ */
+#define kvBUSTYPE_NONE          0   ///< Unkown bus type.
+#define kvBUSTYPE_PCI           1   ///< Bus of type PCI.
+#define kvBUSTYPE_PCMCIA        2   ///< Bus of type PCMCIA
+#define kvBUSTYPE_USB           3   ///< Bus of type USB
+#define kvBUSTYPE_WLAN          4   ///< Bus of type WLAN
+#define kvBUSTYPE_PCI_EXPRESS   5   ///< Bus of type PCI Express
+#define kvBUSTYPE_ISA           6   ///< Bus of type ISA
+#define kvBUSTYPE_VIRTUAL       7   ///< Bus of type virtual
+#define kvBUSTYPE_PC104_PLUS    8   ///< Bus of type PC104+
+#define kvBUSTYPE_LAN           9   ///< Bus of type LAN
+/** @} */
+
+/**
+ * \name kvBUSTYPE_GROUP_xxx
+ * \anchor kvBUSTYPE_GROUP_xxx
+ *
+ * Bus type group, returned when using \ref canCHANNELDATA_BUS_TYPE
+ * This is a grouping of the individual \ref kvBUSTYPE_xxx.
+ * @{
+ */
+#define kvBUSTYPE_GROUP_VIRTUAL  1 ///< \ref kvBUSTYPE_VIRTUAL
+#define kvBUSTYPE_GROUP_LOCAL    2 ///< \ref kvBUSTYPE_USB
+#define kvBUSTYPE_GROUP_REMOTE   3 ///< \ref kvBUSTYPE_WLAN, \ref kvBUSTYPE_LAN
+#define kvBUSTYPE_GROUP_INTERNAL 4 ///< \ref kvBUSTYPE_PCI, \ref kvBUSTYPE_PCMCIA, ...
+/** @} */
+
+/**
+ * \ingroup General
+ *
+ * \source_cs       <b>static Canlib.canStatus kvGetSupportedInterfaceInfo(int index, out string hwName, out int hwType, out int hwBusType);</b>
+ *
+ * \source_delphi   <b>function kvGetSupportedInterfaceInfo(index: Integer; hwName: PChar; nameLen: Cardinal; var hwType: Integer; var hwBusType: Integer): kvStatus;     </b>
+ * \source_end
+ *
+ * The \ref kvGetSupportedInterfaceInfo function returns information about the
+ * different supported hardware types in the installed version of CANLIB.
+ *
+ * This function is used to enumerate all the supported hardware types in the
+ * installed version of CANLIB. It does not return a complete list of all
+ * supported devices, nor does it return a list of the presently installed
+ * hardware. The returned data indicates which device families are supported.
+ *
+ * For example, a returned set of data might be:
+ * \li \a hwType = \ref canHWTYPE_MEMORATOR_PRO
+ * \li \a hwBusType = \ref kvBUSTYPE_USB
+ * \li \a hwName = \c "Kvaser Memorator Professional"
+ *
+ * This means that
+ * \li the presently installed version of CANLIB supports members in the Kvaser
+ *     Memorator Pro family (e.g. the HS/HS and the HS/LS),
+ * \li the members of the Kvaser Memorator Pro family are USB devices,
+ * \li the members of the Kvaser Memorator Pro family use the
+ *     \ref canHWTYPE_MEMORATOR_PRO hardware type.
+ *
+ * The \ref kvGetSupportedInterfaceInfo() function is intended to help
+ * application designers build a bus-oriented display of the different
+ * installed and/or supported Kvaser devices in the computer.
+ *
+ * \param[in] index       Use this parameter to enumerate the different supported
+ *                        hardware types. Start with index = 0, and then call
+ *                        \ref kvGetSupportedInterfaceInfo again() with index =
+ *                        1,2,3,... until the function returns an error code.
+ * \param[out] hwName     A pointer to a buffer that will receive the name of the
+ *                        hardware family, as a zero-terminated ASCII string.
+ * \param[in]  nameLen    The length of the hwName buffer.
+ * \param[out] hwType     Pointer to a 32-bit integer that will receive the
+ *                        hardware type (one of the \ref canHWTYPE_xxx
+ *                        constants.)
+ * \param[out] hwBusType  Pointer to a 32-bit integer that will receive the bus
+ *                        type (one of the \ref kvBUSTYPE_xxx constants.)
+ *
+ * \return \ref canOK (zero) if success
+ * \return \ref canERR_xxx (negative) if failure
+ *
+ * \sa \ref canBusOn(), \ref canResetBus()
+ */
+kvStatus CANLIBAPI kvGetSupportedInterfaceInfo (int index,
+                                                char *hwName,
+                                                size_t nameLen,
+                                                int *hwType,
+                                                int *hwBusType);
+
+/**
+ * \ingroup General
+ *
+ * \source_cs       <b>static Canlib.canStatus kvReadTimer(int hnd, out int time);</b>
+ *
+ * \source_delphi   <b>function kvReadTimer(handle: canHandle; var time: Cardinal): kvStatus;     </b>
+ * \source_end
+ *
+ * The \ref kvReadTimer reads the hardware clock on the specified device and returns
+ * the value.
+ *
+ * When the call to \ref kvReadTimer() returns, the time value is already
+ * obsolete. The time required for the device firmware, any intermediary buses
+ * (like USB,) and the operating system to return the time value is not
+ * defined.
+ *
+ * This call should be used instead of \ref canReadTimer() because it can return an
+ * error code if it fails.
+ *
+ * \param[in]  hnd   An open handle to a CAN channel.
+ * \param[out] time  A pointer to a 32-bit unsigned integer that will receive
+ *                   the time value.
+ *
+ * \return \ref canOK (zero) if success
+ * \return \ref canERR_xxx (negative) if failure
+ *
+ * \sa \ref canReadTimer(), \ref kvReadTimer64()
+ */
+kvStatus CANLIBAPI kvReadTimer (const CanHandle hnd, unsigned int *time);
+
+#if defined(KVINT64)
+/**
+ * \ingroup General
+ *
+ * \source_cs       <b>static Canlib.canStatus kvReadTimer64(int hnd, out long time);</b>
+ *
+ * \source_delphi   <b>function kvReadTimer64(handle: canHandle; var time: Int64): kvStatus;     </b>
+ * \source_end
+ *
+ * The \ref kvReadTimer64 reads the hardware clock on the specified device and
+ * returns the value.
+ *
+ * When the call to \ref kvReadTimer64() returns, the time value is already
+ * obsolete. The time required for the device firmware, any intermediary buses
+ * (like USB,) and the operating system to return the time value is not
+ * defined.
+ *
+ * This call should be used instead of \ref canReadTimer() because it can return an
+ * error code if it fails.
+ *
+ * \param[in]  hnd   An open handle to a CAN channel.
+ * \param[out] time  A pointer to a 64-bit signed integer that will receive the
+ *                   time value.
+ *
+ * \return \ref canOK (zero) if success
+ * \return \ref canERR_xxx (negative) if failure
+ *
+ * \sa \ref kvReadTimer(), \ref canReadTimer()
+ */
+kvStatus CANLIBAPI kvReadTimer64 (const CanHandle hnd, KVINT64 *time);
+#endif
+
+/**
+ * \ingroup General
+ *
+ * \source_cs       <b>static Canlib.canStatus kvReadDeviceCustomerData(int hnd, int userNumber, int itemNumber, byte[] data, int bufsize);</b>
+ *
+ * \source_delphi   <b>function kvReadDeviceCustomerData(hnd: canHandle;userNumber, itemNumber: Integer; var data; bufsize: Cardinal): kvStatus;     </b>
+ * \source_end
+ *
+ * Reading customer data works with Kvaser Leaf (of all
+ * types), Kvaser USBcan Professional, Kvaser Memorator Professional, Kvaser Eagle and
+ * Kvaser Memorator Light. To write customer data use external tools.
+ *
+ * \param[in]  hnd        An open handle to a CAN channel.
+ * \param[in]  userNumber Assigned by Kvaser.
+ * \param[in]  itemNumber Must be zero (reserved)
+ * \param[out] data       A pointer to a buffer of up to 8 bytes where
+ *                        the result will be placed.
+ * \param[in]  bufsiz     The size of the buffer that data points at.
+ *
+ * \return \ref canOK (zero) if success
+ * \return \ref canERR_xxx (negative) if failure
+ */
+kvStatus CANLIBAPI kvReadDeviceCustomerData (const CanHandle hnd,
+                                             int userNumber,
+                                             int itemNumber,
+                                             void *data,
+                                             size_t bufsiz);
+
+//ĤĤĤĤĤĤĤĤĤĤĤĤĤĤĤĤĤĤĤĤĤĤĤĤĤĤĤĤĤĤĤĤĤĤĤĤĤĤč
+//
+// APIs for t-script
+//
+
+/**
+ * \ingroup tScript
+ * \name kvENVVAR_TYPE_xxx
+ * \anchor kvENVVAR_TYPE_xxx
+ *
+ * These defines are used in \ref kvScriptEnvvarOpen().
+ *  @{
+ */
+  /**
+   * This define is used in \ref kvScriptEnvvarOpen().
+   *
+   * It defines the type of the envvar as \c int.
+   */
+#define kvENVVAR_TYPE_INT       1
+
+  /**
+   * This define is used in \ref kvScriptEnvvarOpen().
+   *
+   * It defines the type of the envvar as \c float.
+   */
+#define kvENVVAR_TYPE_FLOAT     2
+
+  /**
+   * This define is used in \ref kvScriptEnvvarOpen().
+   *
+   * It defines the type of the envvar as \c string.
+   */
+#define kvENVVAR_TYPE_STRING    3
+ /** @} */
+/**
+ * \ingroup tScript
+ * \name kvEVENT_xxx
+ * \anchor kvEVENT_xxx
+ *
+ * These defines are used in \ref kvScriptSendEvent().
+ *  @{
+ */
+
+  /**
+   * This define is used in  \ref kvScriptSendEvent().
+   *
+   * It defines an event of type "key pressed".
+   */
+#define kvEVENT_TYPE_KEY        1
+ /** @} */
+  /**
+   * \ingroup tScript
+   *
+   * A handle to a t-script envvar.
+   * Returned by the function \ref kvScriptEnvvarOpen().
+   */
+typedef __int64 kvEnvHandle;
+
+/**
+ * \ingroup tScript
+ *
+ * \source_cs       <b>static Canlib.canStatus kvScriptStart(int hnd, int slotNo);</b>
+ *
+ * \source_delphi   <b>function kvScriptStart(const hnd: canHandle; slotNo: integer): kvStatus;     </b>
+ * \source_end
+ *
+ * The \ref kvScriptStart() function starts a loaded script.
+ *
+ * \param[in] hnd     An open handle to a CAN channel.
+ * \param[in] slotNo  The slot with the loaded script we want to start.
+ *
+ * \return \ref canOK (zero) if success
+ * \return \ref canERR_xxx (negative) if failure
+ *
+ * \sa \ref page_code_snippets_examples
+ * \sa \ref kvScriptLoadFile(), \ref kvScriptStop()
+ */
+kvStatus CANLIBAPI kvScriptStart (const CanHandle hnd, int slotNo);
+
+/**
+ * Script stop modes. Used by \ref kvScriptStop().
+ * \anchor kvSCRIPT_STOP_xxx
+ * \name kvSCRIPT_STOP_xxx
+ * @{
+ */
+#define kvSCRIPT_STOP_NORMAL         0 /**< Stop a running script */
+#define kvSCRIPT_STOP_FORCED        -9 /**< Request termination of a hanged script */
+/** @} */
+
+
+/**
+ * \ingroup tScript
+ *
+ * \source_cs       <b>static Canlib.canStatus kvScriptStop(int hnd, int slotNo, int mode);</b>
+ *
+ * \source_delphi   <b>function kvScriptStop(const hnd: canHandle; slotNo: integer; mode: integer): kvStatus;     </b>
+ * \source_end
+ *
+ *  The \ref kvScriptStop() function stops a started script.
+ *
+ * \param[in] hnd     An open handle to a CAN channel.
+ * \param[in] slotNo  The slot with the loaded and running script we want to stop.
+ * \param[in] mode    Stop mode of type \ref kvSCRIPT_STOP_xxx
+ *
+ * \return \ref canOK (zero) if success
+ * \return \ref canERR_xxx (negative) if failure
+ *
+ * \sa \ref page_code_snippets_examples
+ * \sa \ref kvScriptLoadFile(), \ref kvScriptStart()
+ */
+kvStatus CANLIBAPI kvScriptStop (const CanHandle hnd, int slotNo, int mode);
+
+/**
+ * \ingroup tScript
+ *
+ * \source_cs       <b>static Canlib.canStatus kvScriptUnload(int hnd, int slotNo);</b>
+ *
+ * \source_delphi   <b>function kvScriptUnload(const hnd: canHandle; slotNo: integer): kvStatus;     </b>
+ * \source_end
+ *
+ *  The \ref kvScriptUnload() function unloads a stopped script.
+ *
+ * \param[in] hnd     An open handle to a CAN channel.
+ * \param[in] slotNo  The slot with the loaded and stopped script we want to unload.
+ *
+ * \return \ref canOK (zero) if success
+ * \return \ref canERR_xxx (negative) if failure
+ *
+ * \sa \ref page_code_snippets_examples
+ * \sa \ref kvScriptLoadFile(), \ref kvScriptStop()
+ */
+kvStatus CANLIBAPI kvScriptUnload (const CanHandle hnd, int slotNo);
+
+/**
+ * \ingroup tScript
+ *
+ * \source_cs       <b>static Canlib.canStatus kvScriptSendEvent(int hnd, int slotNo, int eventType, int eventNo, uint data);</b>
+ *
+ * \source_delphi   <b>function kvScriptSendEvent(const hnd: canHandle; slotNo: integer; eventType: integer; eventNo: integer; data: Cardinal): kvStatus;     </b>
+ * \source_end
+ *
+ * The \ref kvScriptSendEvent() function sends an event of a type, and an event
+ * number and associated data to a script running in a specific slot.
+ *
+ * \param[in] hnd        An open handle to a CAN channel.
+ * \param[in] slotNo     The slot where the script was loaded and is running.
+ * \param[in] eventType  The event to send, of type \ref kvEVENT_xxx
+ * \param[in] eventNo    The event's number.
+ * \param[in] data       The event's data.
+ *
+ * \return \ref canOK (zero) if success
+ * \return \ref canERR_xxx (negative) if failure
+ *
+ * \sa \ref page_code_snippets_examples
+ */
+kvStatus CANLIBAPI kvScriptSendEvent (const CanHandle hnd,
+                                      int slotNo,
+                                      int eventType,
+                                      int eventNo,
+                                      unsigned int data);
+
+/**
+ * \ingroup tScript
+ *
+ * \source_cs       <b>static long kvScriptEnvvarOpen(int hnd, string envvarName, out int envvarType, out int envvarSize);</b>
+ *
+ * \source_delphi   <b>function kvScriptEnvvarOpen(const hnd: canHandle; envvarName: PChar; var envvarType: Integer; var envvarSize: Integer): \ref kvEnvHandle;     </b>
+ * \source_end
+ *
+ * The \ref kvScriptEnvvarOpen() opens an existing envvar and returns a handle to it.
+ *
+ * \param[in]  hnd         An open handle to a CAN channel.
+ * \param[in]  envvarName  The envvar's name; a pointer to a \c NULL terminated
+ *                         array of chars.
+ * \param[out] envvarType  A pointer to a 32-bit integer that will receive the
+ *                         \ref kvENVVAR_TYPE_xxx type.
+ * \param[out] envvarSize  A pointer to a 32-bit integer that will receive the
+ *                         size of the envvar in bytes.
+ *
+ * \return A \ref kvEnvHandle handle (positive) to an envvar if success
+ * \return \ref canERR_xxx (negative) if failure
+ *
+ * \sa \ref page_code_snippets_examples
+ * \sa \ref kvScriptEnvvarClose()
+ */
+kvEnvHandle CANLIBAPI kvScriptEnvvarOpen (const CanHandle hnd,
+                                          char* envvarName,
+                                          int *envvarType,
+                                          int *envvarSize); // returns scriptHandle
+
+/**
+ * \ingroup tScript
+ *
+ * \source_cs       <b>static Canlib.canStatus kvScriptEnvvarClose(long eHnd);</b>
+ *
+ * \source_delphi   <b>function kvScriptEnvvarClose(const eHnd: kvEnvHandle): kvStatus;     </b>
+ * \source_end
+ *
+ * The \ref kvScriptEnvvarClose() function closes an open envvar.
+ *
+ * \param[in] eHnd  An open handle to an envvar.
+ *
+ * \return \ref canOK (zero) if success
+ * \return \ref canERR_xxx (negative) if failure
+ *
+ * \sa \ref kvScriptEnvvarOpen()
+ */
+kvStatus CANLIBAPI kvScriptEnvvarClose (kvEnvHandle eHnd);
+
+/**
+ * \ingroup tScript
+ *
+ * \source_cs       <b>static Canlib.canStatus kvScriptEnvvarSetInt(long eHnd, int val);</b>
+ *
+ * \source_delphi   <b>function kvScriptEnvvarSetInt(const eHnd: kvEnvHandle; val: Integer): kvStatus;     </b>
+ * \source_end
+ *
+ * The \ref kvScriptEnvvarSetInt() sets the value of an \c int envvar.
+ *
+ * \param[in] eHnd  An open handle to an envvar.
+ * \param[in] val   The new value.
+ *
+ * \return \ref canOK (zero) if success
+ * \return \ref canERR_xxx (negative) if failure
+ *
+ * \sa \ref page_code_snippets_examples
+ * \sa \ref kvScriptEnvvarOpen(), \ref kvScriptEnvvarGetInt(), \ref kvScriptEnvvarSetFloat(),
+ * \ref kvScriptEnvvarSetData()
+ */
+kvStatus CANLIBAPI kvScriptEnvvarSetInt (kvEnvHandle eHnd, int val);
+
+/**
+ * \ingroup tScript
+ *
+ * \source_cs       <b>static Canlib.canStatus kvScriptEnvvarGetInt(long eHnd, out int val);</b>
+ *
+ * \source_delphi   <b>function kvScriptEnvvarGetInt(const eHnd: kvEnvHandle; var val: Integer): kvStatus;     </b>
+ * \source_end
+ *
+ * The \ref kvScriptEnvvarGetInt() function retrieves the value of an \c int envvar.
+ *
+ * \param[in]  eHnd An open handle to an envvar.
+ * \param[out] val  The current value.
+ *
+ * \return \ref canOK (zero) if success
+ * \return \ref canERR_xxx (negative) if failure
+ *
+ * \sa \ref page_code_snippets_examples
+ * \sa \ref kvScriptEnvvarOpen(), \ref kvScriptEnvvarSetInt(), \ref kvScriptEnvvarGetFloat(),
+ * \ref kvScriptEnvvarGetData()
+ *
+ */
+kvStatus CANLIBAPI kvScriptEnvvarGetInt (kvEnvHandle eHnd, int *val);
+
+/**
+ * \ingroup tScript
+ *
+ * \source_cs       <b>static Canlib.canStatus kvScriptEnvvarSetFloat(long eHnd, float val);</b>
+ *
+ * \source_delphi   <b>function kvScriptEnvvarSetFloat(const eHnd: kvEnvHandle; val: Single): kvStatus;     </b>
+ * \source_end
+ *
+ * The \ref kvScriptEnvvarSetFloat() sets the value of a \c float envvar.
+ *
+ * \param[in] eHnd  An open handle to an envvar.
+ * \param[in] val   The new value.
+ *
+ * \return \ref canOK (zero) if success
+ * \return \ref canERR_xxx (negative) if failure
+ *
+ * \sa \ref page_code_snippets_examples
+ * \sa \ref kvScriptEnvvarOpen(), \ref kvScriptEnvvarGetFloat(), \ref kvScriptEnvvarSetInt(),
+ * \ref kvScriptEnvvarSetData()
+ */
+kvStatus CANLIBAPI kvScriptEnvvarSetFloat (kvEnvHandle eHnd, float val);
+
+/**
+ * \ingroup tScript
+ *
+ * \source_cs       <b>static Canlib.canStatus kvScriptEnvvarGetFloat(long eHnd, out float val);</b>
+ *
+ * \source_delphi   <b>function kvScriptEnvvarGetFloat(const eHnd: kvEnvHandle; var val: Single): kvStatus;     </b>
+ * \source_end
+ *
+ * The \ref kvScriptEnvvarGetFloat() function retrieves the value of a \c float envvar.
+ *
+ * \param[in]  eHnd  An open handle to an envvar.
+ * \param[out] val   A pointer to a \c float where the retrieved result should be
+ *                   stored.
+ *
+ * \return \ref canOK (zero) if success
+ * \return \ref canERR_xxx (negative) if failure
+ *
+ * \sa \ref page_code_snippets_examples
+ * \sa \ref kvScriptEnvvarOpen(), \ref kvScriptEnvvarSetFloat(), \ref kvScriptEnvvarGetInt(),
+ * \ref kvScriptEnvvarGetData()
+ */
+kvStatus CANLIBAPI kvScriptEnvvarGetFloat (kvEnvHandle eHnd, float *val);
+
+/**
+ * \ingroup tScript
+ *
+ * \source_cs       <b>static Canlib.canStatus kvScriptEnvvarSetData(long eHnd, byte[] buf, int start_index, int data_len);</b>
+ *
+ * \source_delphi   <b>function kvScriptEnvvarSetData(const eHnd: kvEnvHandle; var buf; start_index: Integer; data_len: Integer): kvStatus;     </b>
+ * \source_end
+ *
+ * The \ref kvScriptEnvvarSetData() function sets a range of data bytes in an envvar.
+ *
+ * \param[in] eHnd         An open handle to an envvar.
+ * \param[in] buf          A pointer to a data area with the new values.
+ * \param[in] start_index  The start index of the envvar's data range that we
+ *                         want to update.
+ * \param[in] data_len     The length in bytes of the envvar's data range that
+ *                         we want to update.
+ *
+ * \return \ref canOK (zero) if success
+ * \return \ref canERR_xxx (negative) if failure
+ *
+ * \sa \ref page_code_snippets_examples
+ * \sa \ref kvScriptEnvvarOpen(), \ref kvScriptEnvvarGetData(), \ref kvScriptEnvvarSetInt(),
+ * \ref kvScriptEnvvarSetFloat()
+ */
+kvStatus CANLIBAPI kvScriptEnvvarSetData (kvEnvHandle eHnd,
+                                          void *buf,
+                                          int start_index,
+                                          int data_len);
+
+/**
+ * \ingroup tScript
+ *
+ * \source_cs       <b>static Canlib.canStatus kvScriptEnvvarGetData(long eHnd, out byte[] buf, int start_index, int data_len);</b>
+ *
+ * \source_delphi   <b>function kvScriptEnvvarGetData(const eHnd: kvEnvHandle; var buf; start_index: Integer; data_len: Integer): kvStatus;     </b>
+ * \source_end
+ *
+ * The \ref kvScriptEnvvarGetData() function retrieves a range of data bytes from an envvar.
+ *
+ * \param[in]  eHnd         An open handle to an envvar.
+ * \param[out] buf          A pointer to a data area where the retrieved data
+ *                          range should be stored.
+ * \param[in]  start_index  The start index of the data range.
+ * \param[in]  data_len     The length in bytes of the data range.
+ *
+ * \return \ref canOK (zero) if success
+ * \return \ref canERR_xxx (negative) if failure
+ *
+ * \sa \ref page_code_snippets_examples
+ * \sa \ref kvScriptEnvvarOpen(), \ref kvScriptEnvvarSetData(), \ref kvScriptEnvvarGetInt(),
+ * \ref kvScriptEnvvarGetFloat()
+ */
+kvStatus CANLIBAPI kvScriptEnvvarGetData (kvEnvHandle eHnd,
+                                          void *buf,
+                                          int start_index,
+                                          int data_len);
+
+/**
+ * \ingroup tScript
+ *
+ * \source_cs       <b>static Canlib.canStatus kvScriptLoadFileOnDevice(int hnd, int slotNo, ref string localFile);</b>
+ *
+ * \source_delphi   <b>function kvScriptLoadFileOnDevice(hnd: canHandle; slotNo: Integer; localFile: PChar): kvStatus;     </b>
+ * \source_end
+ *
+ * The \ref kvScriptLoadFileOnDevice() function loads a compiled script file (.txe)
+ * stored on the device (SD card) into a script slot on the device.
+ *
+ * \param[in] hnd        An open handle to a CAN channel.
+ * \param[in] slotNo     The slot where to load the script.
+ * \param[in] localFile  The script file name; a pointer to a \c NULL terminated
+ *                       array of chars.
+ *
+ * \return \ref canOK (zero) if success
+ * \return \ref canERR_xxx (negative) if failure
+ *
+ * \sa \ref page_code_snippets_examples
+ * \sa \ref kvScriptLoadFile(), \ref kvFileCopyToDevice(), \ref kvScriptStart(),
+ * \ref kvScriptStop()
+ */
+kvStatus CANLIBAPI kvScriptLoadFileOnDevice (const CanHandle hnd,
+                                             int slotNo,
+                                             char *localFile);
+
+/**
+ * \ingroup tScript
+ *
+ * \source_cs       <b>static Canlib.canStatus kvScriptLoadFile(int hnd, int slotNo, ref string filePathOnPC);</b>
+ *
+ * \source_delphi   <b>function kvScriptLoadFile(hnd: canHandle; slotNo: Integer; filePathOnPC: PChar): kvStatus;     </b>
+ * \source_end
+ *
+ * The \ref kvScriptLoadFile() function loads a compiled script file (.txe) stored
+ * on the host (PC) into a script slot on the device.
+ *
+ * \param[in] hnd           An open handle to a CAN channel.
+ * \param[in] slotNo        The slot where to load the script.
+ * \param[in] filePathOnPC  The script file name; a pointer to a \c NULL
+ *                          terminated array of chars.
+ *
+ * \return \ref canOK (zero) if success
+ * \return \ref canERR_xxx (negative) if failure
+ *
+ * \sa \ref page_code_snippets_examples
+ * \sa \ref kvScriptLoadFileOnDevice(), \ref kvFileCopyToDevice(), \ref kvScriptStart(),
+ * \ref kvScriptStop()
+ */
+kvStatus CANLIBAPI kvScriptLoadFile (const CanHandle hnd,
+                                     int slotNo,
+                                     char *filePathOnPC);
+
+
+
+
+/**
+ * \ingroup General
+ * \name kvSCRIPT_REQUEST_TEXT_xxx
+ * \anchor kvSCRIPT_REQUEST_TEXT_xxx
+ *
+ * These defines are used in \ref kvScriptRequestText() for printf message subscribe/unsubscribe.
+ *
+ * @{
+ */
+
+/**
+ *  Cancel subscription of printf messages from script slots.
+ */
+#define kvSCRIPT_REQUEST_TEXT_UNSUBSCRIBE  1
+
+/**
+ *  Subscribe to printf messages from script slots.
+ */
+#define kvSCRIPT_REQUEST_TEXT_SUBSCRIBE    2
+
+/**
+ *  Select all script slots.
+ */
+#define kvSCRIPT_REQUEST_TEXT_ALL_SLOTS    255
+
+/** @} */
+
+
+/**
+ * \ingroup tScript
+ *
+ * \source_cs       <b>static Canlib.canStatus kvScriptRequestText(int hnd, int slot, int request);</b>
+ *
+ * \source_delphi   <b>function kvScriptRequestText(hnd: canHandle; slotNo: cardinal; request: cardinal): kvStatus;     </b>
+ * \source_end
+ *
+ * The \ref kvScriptRequestText() Sets up a printf subscription to a
+ * selected script slot.
+ * Read the printf messages with \ref kvScriptGetText().
+ *
+ * \param[in] hnd          An open handle to a CAN channel.
+ * \param[in] slot         The slot to subscribe to.
+ * \param[in] request      Subscription request i.e. \ref kvSCRIPT_REQUEST_TEXT_xxx.
+ *
+ * \return \ref canOK (zero) if success
+ * \return \ref canERR_xxx (negative) if failure
+ *
+ */
+kvStatus CANLIBAPI kvScriptRequestText(const CanHandle hnd,
+                                       unsigned int slot,
+                                       unsigned int request);
+
+
+
+/**
+ * \ingroup tScript
+ *
+ * \source_cs       <b>static Canlib.canStatus kvScriptGetText(int hnd, out int slot, out ulong time, out int flags, out string buf);</b>
+ *
+ * \source_delphi   <b>function kvScriptGetText(hnd: canHandle; var slot: integer; var time: Cardinal; var flags: Cardinal; buf: PChar; bufsize: Cardinal): kvStatus;     </b>
+ * \source_end
+ *
+ * The \ref kvScriptGetText() Reads a printf from a subscribed script slot.
+ * Set up a subscription with \ref kvScriptRequestText().
+ *
+ * \param[in] hnd           An open handle to a CAN channel.
+ * \param[out] slot         The slot where the printf originated.
+ * \param[out] time         The printf timestamp.
+ * \param[out] flags        Printf flags. A combination of \ref canSTAT_xxx flags.
+ * \param[out] buf          Buffer to hold the printf string.
+ * \param[in] bufsize       Size of the buffer.
+ *
+ * \return \ref canOK (zero) if success
+ * \return \ref canERR_xxx (negative) if failure
+ *
+ */
+kvStatus CANLIBAPI kvScriptGetText(const CanHandle hnd,
+                                        int  *slot,
+                                        unsigned long *time,
+                                        unsigned int  *flags,
+                                        char *buf,
+                                        size_t bufsize
+                                        );
+
+
+
+/**
+ * Script status flag bits. Used by \ref kvScriptStatus().
+ * \anchor kvSCRIPT_STATUS_xxx
+ * \name kvSCRIPT_STATUS_xxx
+ * @{
+ */
+#define kvSCRIPT_STATUS_LOADED      1 /**< The slot is loaded with a script */
+#define kvSCRIPT_STATUS_RUNNING     2 /**< The slot is running a script. */
+/** @} */
+
+
+/**
+ * \ingroup tScript
+ *
+ * \source_cs       <b>static Canlib.canStatus kvScriptStatus(int hnd, int slot, out unsigned int status);</b>
+ * \source_delphi   <b>function kvScriptStatus(hnd: canHandle; var slot: integer; var time: integer): kvStatus;</b>
+ * \source_end
+ *
+ * The \ref kvScriptStatus() function reads the current status of a script slot.
+ *
+ * \param[in] hnd           An open handle to a CAN channel.
+ * \param[in] slot          The slot which status we want.
+ * \param[out] status       The script status, as \ref kvSCRIPT_STATUS_xxx flag bits
+ *
+ * \return \ref canOK (zero) if success
+ * \return \ref canERR_xxx (negative) if failure
+ */
+kvStatus CANLIBAPI kvScriptStatus(const CanHandle hnd,
+                                  int  slot,
+                                  unsigned int *status);
+
+
+
+
+/**
+ * \ingroup tScript
+ *
+ * \source_cs       <b>static Canlib.canStatus kvFileCopyToDevice(int hnd, string hostFileName, string deviceFileName);</b>
+ *
+ * \source_delphi   <b>function kvFileCopyToDevice(hnd: canHandle; hostFileName: PChar; deviceFileName: PChar): kvStatus;     </b>
+ * \source_end
+ *
+ * The \ref kvFileCopyToDevice() function copies an arbitrary file from the host to
+ * the device.
+ *
+ * \param[in] hnd             An open handle to a CAN channel.
+ * \param[in] hostFileName    The host file name; a pointer to a \c NULL terminated
+ *                            array of chars.
+ * \param[in] deviceFileName  The target device file name; a pointer to a \c NULL
+ *                            terminated array of chars.
+ *
+ * \return \ref canOK (zero) if success
+ * \return \ref canERR_xxx (negative) if failure
+ *
+ * \sa \ref kvFileCopyFromDevice(), \ref kvFileDelete()
+ */
+kvStatus CANLIBAPI kvFileCopyToDevice (const CanHandle hnd,
+                                       char *hostFileName,
+                                       char *deviceFileName);
+
+/**
+ * \ingroup tScript
+ *
+ * \source_cs       <b>static Canlib.canStatus kvFileCopyFromDevice(int hnd, string deviceFileName, string hostFileName);</b>
+ *
+ * \source_delphi   <b>function kvFileCopyFromDevice(hnd: canHandle; deviceFileName: PChar; hostFileName: PChar): kvStatus;     </b>
+ * \source_end
+ *
+ * The \ref kvFileCopyFromDevice() function copies an arbitrary file from the device
+ * to the host.
+ *
+ * \param[in] hnd             An open handle to a CAN channel.
+ * \param[in] deviceFileName  The device file name; a pointer to a \c NULL
+ *                            terminated array of chars.
+ * \param[in] hostFileName    The target host file name; a pointer to a \c NULL terminated
+ *                            array of chars.
+ *
+ * \return \ref canOK (zero) if success
+ * \return \ref canERR_xxx (negative) if failure
+ *
+ * \sa \ref kvFileCopyToDevice()
+ */
+kvStatus CANLIBAPI kvFileCopyFromDevice (const CanHandle hnd,
+                                         char *deviceFileName,
+                                         char *hostFileName);
+
+/**
+ * \ingroup tScript
+ *
+ * \source_cs       <b>static Canlib.canStatus kvFileDelete(int hnd, string deviceFileName);</b>
+ *
+ * \source_delphi   <b>function kvFileDelete(hnd: canHandle; deviceFileName: PChar): kvStatus;     </b>
+ * \source_end
+ *
+ * The \ref kvFileDelete() function deletes a file on the device.
+ *
+ * \note Deleting system files is not recommended.
+ *
+ * \param[in] hnd             An open handle to a CAN channel.
+ * \param[in] deviceFileName  The file on the device to delete; a pointer
+ *                            to a \c NULL terminated array of chars.
+ *
+ * \return \ref canOK (zero) if success
+ * \return \ref canERR_xxx (negative) if failure
+ *
+ * \sa \ref kvFileCopyToDevice()
+ */
+kvStatus CANLIBAPI kvFileDelete (const CanHandle hnd, char *deviceFileName);
+
+/**
+ * \ingroup tScript
+ *
+ * \source_cs       <b>static Canlib.canStatus kvFileGetName(int hnd, int fileNo, out string name);</b>
+ *
+ * \source_delphi   <b>function kvFileGetName(hnd: canHandle; fileNo: Integer; name: PChar; namelen: Integer): kvStatus;     </b>
+ * \source_end
+ *
+ * The \ref kvFileGetName() function returns the name of the file with
+ *   number \a fileNo.
+ *
+ * \param[in]  hnd      An open handle to a CAN channel.
+ * \param[in]  fileNo   The number of the file.
+ * \param[out] name     A buffer that will contain the name of the
+ *                      file. The name is a zero-terminated ASCII string.
+ * \param[in]  namelen  The length, in bytes, of the \a name buffer.
+ *
+ * \return \ref canOK (zero) if success
+ * \return \ref canERR_xxx (negative) if failure
+ *
+ * \sa \ref kvFileGetCount(), \ref kvFileGetSystemData()
+ */
+kvStatus CANLIBAPI kvFileGetName (const CanHandle hnd,
+                                  int fileNo,
+                                  char *name,
+                                  int namelen);
+
+/**
+ * \ingroup tScript
+ *
+ * \source_cs       <b>static Canlib.canStatus kvFileGetCount(int hnd, out int count);</b>
+ *
+ * \source_delphi   <b>function kvFileGetCount(hnd: canHandle; var count: Integer): kvStatus;     </b>
+ * \source_end
+ *
+ * The \ref kvFileGetCount() function returns the number of files.
+ *
+ * \param[in]  hnd    An open handle to a CAN channel.
+ * \param[out] count  A pointer to a 32-bit integer that will receive
+ *                    the file count.
+ *
+ * \return \ref canOK (zero) if success
+ * \return \ref canERR_xxx (negative) if failure
+ *
+ * \sa \ref kvFileGetName(), \ref kvFileGetSystemData()
+ */
+kvStatus CANLIBAPI kvFileGetCount (const CanHandle hnd, int *count);
+
+/**
+ * \ingroup tScript
+ *
+ * \source_cs       <b>static Canlib.canStatus kvFileGetSystemData(int hnd, int itemCode, out int result);</b>
+ *
+ * \source_delphi   <b>function kvFileGetSystemData(hnd: canHandle; itemCode: Integer; var result: Integer): kvStatus;     </b>
+ * \source_end
+ *
+ * The \ref kvFileGetSystemData() function is used for reading disk parameters,
+ * e.g. size, max number of (user) files, etc.
+ *
+ * \note Not yet implemented
+ *
+ * \param[in]  hnd       An open handle to a CAN channel.
+ * \param[in]  itemCode  The item we want information on.
+ * \param[out] result    A pointer to a 32-bit integer that will
+ *                       receive the result.
+ *
+ * \return \ref canOK (zero) if success
+ * \return \ref canERR_xxx (negative) if failure
+ *
+ */
+kvStatus CANLIBAPI kvFileGetSystemData (const CanHandle hnd,
+                                        int itemCode,
+                                        int *result);
+
+/**
+ * \ingroup General
+ * \anchor kvDEVICE_MODE_xxx
+ * \name kvDEVICE_MODE_xxx
+ *
+ * These defines are used in \ref kvDeviceSetMode() and \ref kvDeviceGetMode().
+ *
+ * \note The mode is device specific, which means that not all modes are
+ * implemented in all products.
+ *
+ *  @{
+ */
+   /**
+   * This define is used in \ref kvDeviceSetMode() and \ref kvDeviceGetMode().
+   *
+   * Device is running or should be running in interface mode.
+   */
+#define kvDEVICE_MODE_INTERFACE      0x00
+  /**
+   * This define is used in \ref kvDeviceSetMode() and \ref kvDeviceGetMode().
+   *
+   * Device is running or should be running in logger mode.
+   */
+#define kvDEVICE_MODE_LOGGER      0x01
+ /** @} */
+
+
+/**
+ * \ingroup General
+ *
+ * \source_cs       <b>static Canlib.canStatus kvDeviceSetMode(int hnd, int mode);</b>
+ *
+ * \source_delphi   <b>function kvDeviceSetMode(hnd: canHandle; mode: Integer): kvStatus;     </b>
+ * \source_end
+ *
+ * The \ref kvDeviceSetMode() sets the mode.
+ *
+ * \note The mode is device specific, which means that not all modes are
+ * implemented in all products.
+ *
+ * \param[in] hnd   An open handle to a CAN channel.
+ * \param[in] mode  One of the \ref kvDEVICE_MODE_xxx constants,
+ *                  defining which mode to use.
+ *
+ * \return \ref canOK (zero) if success
+ * \return \ref canERR_xxx (negative) if failure
+ *
+ * \sa \ref kvDeviceGetMode()
+ */
+kvStatus CANLIBAPI kvDeviceSetMode (const CanHandle hnd, int mode);
+
+/**
+ * \ingroup General
+ *
+ * \source_cs       <b>static Canlib.canStatus kvDeviceGetMode(int hnd, out int result);</b>
+ *
+ * \source_delphi   <b>function kvDeviceGetMode(hnd: canHandle; var mode: Integer): kvStatus;     </b>
+ * \source_end
+ *
+ * The \ref kvDeviceGetMode() reads the current device's specific mode.
+ *
+ * \note The mode is device specific, which means that not all modes are
+ * implemented in all products.
+ *
+ * \param[in]  hnd     An open handle to a CAN channel.
+ * \param[out] result  A pointer to a 32-bit integer that will receive the
+ *                     \ref kvDEVICE_MODE_xxx value.
+ *
+ * \return \ref canOK (zero) if success
+ * \return \ref canERR_xxx (negative) if failure
+ *
+ * \sa \ref kvDeviceSetMode()
+ */
+kvStatus CANLIBAPI kvDeviceGetMode (const CanHandle hnd, int *result);
+
+
+/**
+ * \ingroup General
+ *
+ * \source_cs       <b>static Canlib.canStatus kvPingRequest(int hnd, out uint requestTime);</b>
+ *
+ * \source_delphi   <b>function kvPingRequest(hnd: canHandle; var requestTime: Cardinal): kvStatus;     </b>
+ * \source_end
+ *
+ * This function sends an active ping to a device. The ping time can later be
+ * retrieved using \ref kvPingGetLatest().
+ *
+ * \param[in]  hnd          A handle to an open circuit.
+ * \param[out] requestTime  Time of request in microseconds. Used for matching answer to request.
+ *
+ * \return \ref canOK (zero) if success
+ * \return \ref canERR_xxx (negative) if failure
+ */
+kvStatus CANLIBAPI kvPingRequest (const CanHandle hnd,
+                                  unsigned int *requestTime);
+
+/**
+ * \ingroup General
+ *
+ * \source_cs       <b>static Canlib.canStatus kvPingGetLatest(int hnd, out uint requestTime, out uint pingTime);</b>
+ *
+ * \source_delphi   <b>function kvPingGetLatest(hnd: canHandle; var requestTime: Cardinal; var pingTime: Cardinal): kvStatus;     </b>
+ * \source_end
+ *
+ * This retrieves the latest ping time issued by an earlier call to \ref kvPingRequest()
+ *
+ * \param[in]  hnd         A handle to an open circuit.
+ * \param[out] requestTime Time of request in microseconds. Used for matching answer to request.
+ * \param[out] pingTime    Latest value of ping time in milliseconds.
+ *
+ * \return \ref canOK (zero) if success
+ * \return \ref canERR_xxx (negative) if failure
+ */
+ kvStatus CANLIBAPI kvPingGetLatest (const CanHandle hnd,
+                                     unsigned int *requestTime,
+                                     unsigned int *pingTime);
+
+
+/**
+ * \ingroup Internal
+ * \anchor Internal
+ * \name Unimplemented internal
+ *
+ * The following are not yet implemented. Do not use it.
+ *
+ *  @{
+ */
+//
+//
+//
+#if defined(_CANEVT_H_)
+canStatus CANLIBAPI canReadEvent (const CanHandle hnd, CanEvent *event);
+#endif
+
+/** This function is not implemented, do not use it. */
+void CANLIBAPI canSetDebug(int d);
+/** This function is not implemented, do not use it. */
+canStatus CANLIBAPI canSetNotifyEx (const CanHandle hnd,
+                                    HANDLE event,
+                                    unsigned int flags);
+/** This function is not implemented, do not use it. */
+canStatus CANLIBAPI canSetTimer (const CanHandle hnd,
+                                 DWORD interval,
+                                 DWORD flags);
+/** This is reserved for \ref canSetTimer() but not implemented, do not use it. */
+#define canTIMER_CYCLIC             0x01
+/** This is reserved for \ref canSetTimer() but not implemented, do not use it. */
+#define canTIMER_EXPENSIVE          0x02
+/** This function is not implemented, do not use it. */
+int CANLIBAPI canSplitHandle (CanHandle hnd, int channel);
+/** This function is not implemented, do not use it. */
+int CANLIBAPI canOpenMultiple (DWORD bitmask, int flags);
+/** @} */
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+# include "obsolete.h"
+
+#endif
Index: trunk/CanGateway/driver/kvaser/windows/canstat.h
===================================================================
--- trunk/CanGateway/driver/kvaser/windows/canstat.h	(revision 93)
+++ trunk/CanGateway/driver/kvaser/windows/canstat.h	(revision 93)
@@ -0,0 +1,472 @@
+/**
+ * \section LICENSE
+ *                   Copyright 1994-2013 by KVASER AB, SWEDEN
+ *
+ *                        WWW: http://www.kvaser.com
+ *
+ * This software is furnished under a license and may be used and copied
+ * only in accordance with the terms of such license.
+ *
+ * \section DESCRIPTION
+ *
+ *   Definitions for the CANLIB API.
+ *
+ * \file canlib.h
+ * \author Kvaser AB
+ *
+ * \note MATLAB users on Windows: if you define WIN32_LEAN_AND_MEAN before
+ * including this file, you will see a lot less warnings.
+ *
+ * \defgroup General                 General
+ * \defgroup CAN                     CAN
+ * \defgroup ObjectBuffers           Object buffers
+ * \win_start
+ * \defgroup TimeDomainHandling      Time Domain Handling
+ * \defgroup NamedParameterSettings  Named Parameter Settings
+ * \defgroup tScript                 t-script
+ * \win_end
+ */
+#ifndef _CANSTAT_H_
+#define _CANSTAT_H_
+
+//
+// Don't forget to update canGetErrorText in canlib.c if this is changed!
+//
+
+/**
+ * \name canERR_xxx
+ * \anchor canERR_xxx
+ *
+ * Generally, a return code greater than or equal to zero means success. A
+ * value less than zero means failure.
+ *
+ * You should avoid testing for a specific error code unless it is explicitly
+ * stated in the documentation for the API in question that this specific error
+ * code is returned. Instead, check if the error code is less than zero. Use
+ * \ref canGetErrorText() to obtain an error message suitable for a message to the
+ * user, or for a line in an error log file.
+ */
+typedef enum {
+  /**
+   * <b>Normal successful completion</b>; The driver is just fine, and really
+   * believes it carried out your command to everyone's satisfaction.
+   */
+    canOK                  = 0,
+  /**
+   * <b>Error in one or more parameters</b>; a parameter \ref canERR_xxx
+   * specified in the call was invalid, out of range, or so. This status code
+   * will also be returned when the call is not implemented.
+   */
+    canERR_PARAM           = -1,
+  /**
+   * <b>There were no messages to read</b>; A function tried to read a message,
+   * but there was no message to read.
+   */
+    canERR_NOMSG           = -2,
+  /**
+   * <b>Specified device or channel not found.</b> There is no hardware
+   * available that matches the given search criteria. For example, you may
+   * have specified \ref canOPEN_REQUIRE_EXTENDED but there's no controller
+   * capable of extended CAN. You may have specified a channel number that is
+   * out of the range for the hardware in question. You may have requested
+   * exclusive access to a channel, but the channel is already occupied.
+   */
+    canERR_NOTFOUND        = -3,
+  /**
+   * <b>Out of memory</b>; A memory allocation failed.
+   */
+    canERR_NOMEM           = -4,
+  /**
+   * <b>No channels available</b>; There is indeed hardware matching the
+   * criteria you specified, but there are no channels available, or the
+   * channel you specified is already occupied.
+   */
+    canERR_NOCHANNELS      = -5,
+
+    canERR_INTERRUPTED     = -6,    ///< Interrupted by signals
+  /**
+   * <b>Timeout occurred</b>; A function waited for something to happen (for
+   * example, the arrival of a message), but that something didn't happen.
+   */
+    canERR_TIMEOUT         = -7,
+  /**
+   * <b>The library is not initialized</b>; The driver is not
+   * initialized. \ref canInitializeLibrary() was probably not called?
+   */
+    canERR_NOTINITIALIZED  = -8,
+  /**
+   * <b>Out of handles</b>; No handles are available inside canlib32. The
+   * application has too many handles open (i.e. has called \ref canOpenChannel() too
+   * many times, or there's a memory leak somewhere.)
+   *
+   * \note We are not talking about Windows handles here, it's CANLIB's own
+   * internal handles.
+   */
+    canERR_NOHANDLES       = -9,
+  /**
+   * <b>Handle is invalid</b>; The CANLIB handle you specified (if the API call
+   * includes a handle) is not valid. Ensure you are passing the handle and
+   * not, for example, a channel number.
+   */
+    canERR_INVHANDLE       = -10,
+    canERR_INIFILE         = -11,    ///< Error in the ini-file (16-bit only)
+  /**
+   * <b>Driver type not supported</b>; CAN driver mode is not supported by the
+   * present hardware.
+   */
+    canERR_DRIVER          = -12,
+  /**
+   * <b>Transmit buffer overflow</b>; The transmit queue was full, so the
+   * message was dropped.
+   */
+    canERR_TXBUFOFL        = -13,
+    canERR_RESERVED_1      = -14,    ///< Reserved
+  /**
+   * <b>A hardware error has occurred</b>; Something probably related to the
+   * hardware happened. This could mean that the device does not respond (IRQ
+   * or address conflict?), or that the response was invalid or unexpected
+   * (faulty card?).
+   */
+    canERR_HARDWARE        = -15,
+  /**
+   * <b>A driver DLL can't be found or loaded</b>; (One of) the DLL(s)
+   * specified in the registry failed to load. This could be a driver
+   * installation problem.
+   */
+    canERR_DYNALOAD        = -16,
+  /**
+   * <b>A DLL seems to have wrong version</b>; DLL version mismatch. (One of)
+   * the DLL(s) specified in the registry is - probably - too old, or - less
+   * likely - too new.
+   */
+    canERR_DYNALIB         = -17,
+  /**
+   * <b>Error when initializing a DLL</b>; Something failed when a device
+   * driver was being initialized. In other words, we can open the driver but
+   * it makes a lot of fuss about something we don't understand.
+   */
+    canERR_DYNAINIT        = -18,
+    canERR_NOT_SUPPORTED   = -19,    ///< Operation not supported by hardware or firmware
+    canERR_RESERVED_5      = -20,    ///< Reserved
+    canERR_RESERVED_6      = -21,    ///< Reserved
+    canERR_RESERVED_2      = -22,    ///< Reserved
+  /**
+   * <b>Can't find or load kernel driver</b>; A device driver (kernel mode
+   * driver for NT, VxD for W95/98) failed to load; or the DLL could not open
+   * the device. Privileges? Driver file missing?
+   */
+    canERR_DRIVERLOAD      = -23,
+  /**
+   * <b>DeviceIOControl failed</b>; Use Win32 GetLastError() to learn what
+   * really happened.
+   */
+    canERR_DRIVERFAILED    = -24,
+    canERR_NOCONFIGMGR     = -25,    ///< Can't find req'd config s/w (e.g. CS/SS)
+    canERR_NOCARD          = -26,    ///< The card was removed or not inserted
+    canERR_RESERVED_7      = -27,    ///< Reserved
+  /**
+   * <b>Error (missing data) in the Registry</b>; A registry key is missing,
+   * invalid, malformed, has gone for lunch or what not. can_verify.exe might
+   * provide some insight.
+   */
+    canERR_REGISTRY        = -28,
+    canERR_LICENSE         = -29,    ///< The license is not valid.
+  /**
+   * <b>Internal error in the driver</b>; Indicates an error condition in the
+   * driver or DLL, which couldn't be properly handled. Please contact the
+   * friendly support at support@kvaser.com.
+   */
+    canERR_INTERNAL        = -30,
+  /**
+   * <b>Access denied</b>; This means that you tried to set the bit rate on a
+   * handle to which you haven't got init access or you tried to open a channel
+   * that already is open with init access. See \ref canOpenChannel() for more
+   * information about init access.
+   */
+    canERR_NO_ACCESS       = -31,
+  /**
+   * <b>Not implemented</b>; The requested feature or function is not
+   * implemented in the device you are trying to use it on.
+   */
+    canERR_NOT_IMPLEMENTED = -32,
+  /**
+   * <b>Device File error</b>; An error has occured when trying to access a
+   * file on the device.
+   */
+    canERR_DEVICE_FILE     = -33,
+  /**
+   * <b>Host File error</b>; An error has occured when trying to access a file on the host.
+   *
+   */
+    canERR_HOST_FILE       = -34,
+  /**
+   * <b>Disk error</b>; A disk error has occurred. Verify that the disk is
+   * initialized.
+   */
+    canERR_DISK            = -35,
+  /**
+   * <b>CRC error</b>; The CRC calculation did not match the expected result.
+   */
+    canERR_CRC             = -36,
+  /**
+   * <b>Configuration Error</b>; The configuration is corrupt.
+   */
+    canERR_CONFIG          = -37,
+  /**
+   * <b>Memo Error</b>; Other configuration error.
+   */
+    canERR_MEMO_FAIL       = -38,
+  /**
+   * <b>Script Fail</b>; A script has failed.
+   *
+   * \note This code represents several different failures, for example:
+   * - Trying to load a corrupt file or not a .txe file
+   * - Trying to start a t script that has not been loaded
+   * - Trying to load a t script compiled with the wrong version of the t compiler
+   * - Trying to unload a t script that has not been stopped
+   * - Trying to use an envvar that does not exist
+   */
+    canERR_SCRIPT_FAIL     = -39,
+
+  /**
+   * <b>The t script version dosen't match the version(s) that the device firmware supports.</b>;
+   */
+    canERR_SCRIPT_WRONG_VERSION = -40,
+
+
+  // The last entry - a dummy so we know where NOT to place a comma.
+    canERR__RESERVED       = -41    ///< Reserved
+} canStatus;
+
+
+/**
+ * \name Convenience
+ * @{
+ */
+#define CANSTATUS_SUCCESS(X) ((X) == canOK)
+#define CANSTATUS_FAILURE(X) ((X) != canOK)
+/** @} */
+
+/**
+ * \name canEVENT_xxx WM__CANLIB notification codes
+ * \anchor canEVENT_xxx
+ * Appears in the notification \c WM__CANLIB message.
+ * @{
+ */
+#define canEVENT_RX             32000       ///< when the queue of received CAN messages goes from empty to non-empty
+#define canEVENT_TX             32001       ///< when a CAN message has been transmitted
+#define canEVENT_ERROR          32002       ///< when a CAN bus error is reported by the CAN controller
+#define canEVENT_STATUS         32003       ///< when the CAN controller changes state
+#define canEVENT_ENVVAR         32004       ///< An envvar changed
+# define canEVENT_BUSONOFF       32005       ///< Bus on/off status changed
+# define canEVENT_REMOVED        32006       ///< Device removed
+/** @} */
+
+/**
+ * \name canNOTIFY_xxx
+ * \anchor canNOTIFY_xxx
+ *
+ * These are notification codes used in calls to \ref canSetNotify() and \ref kvSetNotifyCallback().
+ *
+ * This can be \ref canNOTIFY_NONE (zero), meaning that no event notification is to
+ * occur, or a combination of any of the following constants
+ *
+ * @{
+ */
+#define canNOTIFY_NONE          0           ///< Turn notifications off.
+#define canNOTIFY_RX            0x0001      ///< CAN message reception notification
+#define canNOTIFY_TX            0x0002      ///< CAN message transmission notification
+#define canNOTIFY_ERROR         0x0004      ///< CAN bus error notification
+#define canNOTIFY_STATUS        0x0008      ///< CAN chip status change
+#define canNOTIFY_ENVVAR        0x0010      ///< An environment variable was changed by a script
+# define canNOTIFY_BUSONOFF      0x0020      ///< Notify on bus on/off status changed
+# define canNOTIFY_REMOVED       0x0040      ///< Notify on device removed
+/** @} */
+
+
+/**
+ * \ingroup InformationServices
+ * \name canSTAT_xxx
+ * \anchor canSTAT_xxx
+ *
+ * The following circuit status flags are returned by \ref canReadStatus(). Note
+ * that more than one flag might be set at any one time.
+ *
+ * \note Usually both \ref canSTAT_HW_OVERRUN and \ref canSTAT_SW_OVERRUN are set
+ * when overrun has occurred. This is because the kernel driver can't see the
+ * difference between a software overrun and a hardware overrun. So the code
+ * should always test for both types of overrun using the \ref canSTAT_OVERRUN
+ * "flag".
+ *
+ * @{
+ */
+#define canSTAT_ERROR_PASSIVE   0x00000001  ///< The circuit is error passive
+#define canSTAT_BUS_OFF         0x00000002  ///< The circuit is Off Bus
+#define canSTAT_ERROR_WARNING   0x00000004  ///< At least one error counter > 96
+#define canSTAT_ERROR_ACTIVE    0x00000008  ///< The circuit is error active.
+#define canSTAT_TX_PENDING      0x00000010  ///< There are messages pending transmission
+#define canSTAT_RX_PENDING      0x00000020  ///< There are messages in the receive buffer
+#define canSTAT_RESERVED_1      0x00000040
+#define canSTAT_TXERR           0x00000080  ///< There has been at least one TX error
+#define canSTAT_RXERR           0x00000100  ///< There has been at least one RX error of some sort
+#define canSTAT_HW_OVERRUN      0x00000200  ///< The has been at least one HW buffer overflow
+#define canSTAT_SW_OVERRUN      0x00000400  ///< The has been at least one SW buffer overflow
+#define canSTAT_OVERRUN         (canSTAT_HW_OVERRUN | canSTAT_SW_OVERRUN) ///< For convenience.
+/** @} */
+
+/**
+ * \name Message information flags, < 0x100
+ * \anchor canMSG_xxx
+ *
+ * The following flags can be returned from \ref canRead() et al, or passed to
+ * \ref canWrite().
+ *
+ * All flags and/or combinations of them are meaningful for received messages.
+ *
+ * \ref canMSG_RTR, \ref canMSG_STD, \ref canMSG_EXT, \ref canMSG_WAKEUP and
+ * \ref canMSG_ERROR_FRAME are meaningful also for transmitted messages.
+ *
+ * @{
+ */
+#define canMSG_MASK             0x00ff      ///< Used to mask the non-info bits
+#define canMSG_RTR              0x0001      ///< Message is a remote request
+#define canMSG_STD              0x0002      ///< Message has a standard ID
+#define canMSG_EXT              0x0004      ///< Message has an extended ID
+#define canMSG_WAKEUP           0x0008      ///< Message to be sent / was received in wakeup mode
+
+/**
+ * NERR was active during the message
+ *
+ * The NERR flag is set by the CAN transceiver when certain CAN bus wire faults
+ * occur, namely:
+ * \li CANH wire interrupted
+ * \li CANL wire interrupted
+ * \li CANH short-circuited to battery
+ * \li CANH short-circuited to VCC
+ * \li CANL short-circuited to ground
+ * \li CANH short-circuited to ground
+ * \li CANL short-circuited to battery
+ * \li CANL short-circuited to VCC
+ * \li CANL and CANH mutually short-circuited
+ *
+ * See the TJA1054 data sheet (available from Philips) for more detailed
+ * information.
+ */
+#define canMSG_NERR             0x0010
+#define canMSG_ERROR_FRAME      0x0020      ///< Message is an error frame
+#define canMSG_TXACK            0x0040      ///< Message is a TX ACK (msg is really sent)
+#define canMSG_TXRQ             0x0080      ///< Message is a TX REQUEST (msg is transfered to the chip)
+
+// qqq add documentation
+#define canFDMSG_MASK            0xff0000
+#define canFDMSG_EDL             0x010000    ///< Message is an FD message (CAN FD)
+#define canFDMSG_BRS             0x020000    ///< Message is sent/received with bit rate switch (CAN FD)
+#define canFDMSG_ESI             0x040000    ///< Sender of the message is in error passive mode (CAN FD)
+
+/** @} */
+
+/**
+ * \name Message error flags, >= 0x0100
+ * \anchor canMSGERR_xxx
+ *
+ * \note Not all hardware platforms can detect the difference between hardware
+ * overruns and software overruns, so your application should test for both
+ * conditions. You can use the symbol \ref canMSGERR_OVERRUN for this purpose.
+ *
+ * @{
+ */
+#define canMSGERR_MASK          0xff00      ///< Used to mask the non-error bits
+// 0x0100 reserved
+#define canMSGERR_HW_OVERRUN    0x0200      ///< HW buffer overrun
+#define canMSGERR_SW_OVERRUN    0x0400      ///< SW buffer overrun
+#define canMSGERR_STUFF         0x0800      ///< Stuff error
+#define canMSGERR_FORM          0x1000      ///< Form error
+#define canMSGERR_CRC           0x2000      ///< CRC error
+#define canMSGERR_BIT0          0x4000      ///< Sent dom, read rec
+#define canMSGERR_BIT1          0x8000      ///< Sent rec, read dom
+
+// Convenience values for the message error flags.
+#define canMSGERR_OVERRUN       0x0600      ///< Any overrun condition.
+#define canMSGERR_BIT           0xC000      ///< Any bit error.
+#define canMSGERR_BUSERR        0xF800      ///< Any RX error
+/** @} */
+
+/**
+ * \name canTRANSCEIVER_LINEMODE_xxx
+ * \anchor canTRANSCEIVER_LINEMODE_xxx
+ *
+ * The following values can be used with \ref canSetDriverMode() to set different
+ * driver (i.e. transceiver) modes. Use \ref canGetDriverMode() to obtain the
+ * current driver mode for a particular CAN channel.
+ * @{
+ */
+#define canTRANSCEIVER_LINEMODE_NA          0  ///< Not Affected/Not available.
+#define canTRANSCEIVER_LINEMODE_SWC_SLEEP   4  ///< SWC Sleep Mode.
+#define canTRANSCEIVER_LINEMODE_SWC_NORMAL  5  ///< SWC Normal Mode.
+#define canTRANSCEIVER_LINEMODE_SWC_FAST    6  ///< SWC High-Speed Mode.
+#define canTRANSCEIVER_LINEMODE_SWC_WAKEUP  7  ///< SWC Wakeup Mode.
+#define canTRANSCEIVER_LINEMODE_SLEEP       8  ///< Sleep mode for those supporting it.
+#define canTRANSCEIVER_LINEMODE_NORMAL      9  ///< Normal mode (the inverse of sleep mode) for those supporting it.
+#define canTRANSCEIVER_LINEMODE_STDBY      10  ///< Standby for those who support it
+#define canTRANSCEIVER_LINEMODE_TT_CAN_H   11  ///< Truck & Trailer: operating mode single wire using CAN high
+#define canTRANSCEIVER_LINEMODE_TT_CAN_L   12  ///< Truck & Trailer: operating mode single wire using CAN low
+#define canTRANSCEIVER_LINEMODE_OEM1       13  ///< Reserved for OEM apps
+#define canTRANSCEIVER_LINEMODE_OEM2       14  ///< Reserved for OEM apps
+#define canTRANSCEIVER_LINEMODE_OEM3       15  ///< Reserved for OEM apps
+#define canTRANSCEIVER_LINEMODE_OEM4       16  ///< Reserved for OEM apps
+
+/** @} */
+
+/**
+ * \anchor canTRANSCEIVER_RESNET_xxx
+ *
+ */
+#define canTRANSCEIVER_RESNET_NA            0
+#define canTRANSCEIVER_RESNET_MASTER        1
+#define canTRANSCEIVER_RESNET_MASTER_STBY   2
+#define canTRANSCEIVER_RESNET_SLAVE         3
+
+/**
+ * \name Transceiver (logical) types
+ * \anchor canTRANSCEIVER_TYPE_xxx
+ *
+ * The following constants can be returned from \ref canGetChannelData(), using the
+ * \ref canCHANNELDATA_TRANS_TYPE item code. They identify the bus transceiver
+ * type for the channel specified in the call to \ref canGetChannelData.
+ *
+ * \note They indicate a hardware type, but not necessarily a specific circuit
+ * or product.
+ *
+ * @{
+ */
+// Also see src\include\hwnames.h and registered document 048.
+#define canTRANSCEIVER_TYPE_UNKNOWN         0  ///< Unknown or undefined
+#define canTRANSCEIVER_TYPE_251             1  ///< 82c251
+#define canTRANSCEIVER_TYPE_252             2  ///< 82c252, TJA1053, TJA1054
+#define canTRANSCEIVER_TYPE_DNOPTO          3  ///< Optoisolated 82C251
+#define canTRANSCEIVER_TYPE_W210            4  ///<
+#define canTRANSCEIVER_TYPE_SWC_PROTO       5  ///< AU5790 prototype
+#define canTRANSCEIVER_TYPE_SWC             6  ///< AU5790
+#define canTRANSCEIVER_TYPE_EVA             7  ///<
+#define canTRANSCEIVER_TYPE_FIBER           8  ///< 82c251 with fibre extension
+#define canTRANSCEIVER_TYPE_K251            9  ///< K-line + 82c251
+#define canTRANSCEIVER_TYPE_K              10  ///< K-line, without CAN
+#define canTRANSCEIVER_TYPE_1054_OPTO      11  ///< TJA1054 with optical isolation
+#define canTRANSCEIVER_TYPE_SWC_OPTO       12  ///< AU5790 with optical isolation
+#define canTRANSCEIVER_TYPE_TT             13  ///< B10011S Truck-And-Trailer
+#define canTRANSCEIVER_TYPE_1050           14  ///< TJA1050
+#define canTRANSCEIVER_TYPE_1050_OPTO      15  ///< TJA1050 with optical isolation
+#define canTRANSCEIVER_TYPE_1041           16  ///< TJA1041
+#define canTRANSCEIVER_TYPE_1041_OPTO      17  ///< TJA1041 with optical isolation
+#define canTRANSCEIVER_TYPE_RS485          18  ///< RS485 (i.e. J1708)
+#define canTRANSCEIVER_TYPE_LIN            19  ///< LIN
+#define canTRANSCEIVER_TYPE_KONE           20  ///< KONE
+#define canTRANSCEIVER_TYPE_CANFD          22  ///< CAN-FD
+#define canTRANSCEIVER_TYPE_LINX_LIN       64
+#define canTRANSCEIVER_TYPE_LINX_J1708     66
+#define canTRANSCEIVER_TYPE_LINX_K         68
+#define canTRANSCEIVER_TYPE_LINX_SWC       70
+#define canTRANSCEIVER_TYPE_LINX_LS        72
+/** @} */
+
+#endif
Index: trunk/CanGateway/driver/kvaser/windows/extras/poppack.h
===================================================================
--- trunk/CanGateway/driver/kvaser/windows/extras/poppack.h	(revision 93)
+++ trunk/CanGateway/driver/kvaser/windows/extras/poppack.h	(revision 93)
@@ -0,0 +1,43 @@
+/*
+**                   Copyright 2005 by KVASER AB, SWEDEN      
+**                        WWW: http://www.kvaser.com
+**
+**
+** Description:
+**   This file resets the struct alignment to the value
+**   prevalent before pshpackN.h was included.  Many compilers provide a
+**   file similar to this one.
+** ---------------------------------------------------------------------------
+*/
+#if ! (defined(lint) || defined(_lint) || defined(RC_INVOKED))
+#  if defined(_MSC_VER)
+#    if ( _MSC_VER > 800 ) || defined(_PUSHPOP_SUPPORTED)
+#      pragma warning(disable:4103)
+#      if !(defined( MIDL_PASS )) || defined( __midl )
+#        pragma pack(pop)
+#      else
+#        pragma pack()
+#      endif
+#    else
+#      pragma warning(disable:4103)
+#      pragma pack()
+#    endif
+#  elif defined(__C166__)
+#    pragma pack()
+#  elif defined(__GCC__)
+#    pragma pack(pop)
+#  elif defined(__LCC__)
+#    pragma pack(pop)
+#  elif defined(__MWERKS__)
+#    pragma pack(pop)
+#  elif defined(__BORLANDC__)
+#    if (__BORLANDC__ >= 0x460)
+#       pragma nopackwarning
+#       pragma pack(pop)
+#    else
+#       pragma option -a.
+#    endif
+#  else
+#    error Unsupported compiler.
+#  endif
+#endif /* ! (defined(lint) || defined(_lint) || defined(RC_INVOKED)) */
Index: trunk/CanGateway/driver/kvaser/windows/extras/pshpack1.h
===================================================================
--- trunk/CanGateway/driver/kvaser/windows/extras/pshpack1.h	(revision 93)
+++ trunk/CanGateway/driver/kvaser/windows/extras/pshpack1.h	(revision 93)
@@ -0,0 +1,41 @@
+/*
+**                   Copyright 2005 by KVASER AB, SWEDEN      
+**                        WWW: http://www.kvaser.com
+**
+**
+** Description:
+**   This file sets the struct alignment to 1 byte and saves the old
+**   alignment.  Many compilers provide a file similar to this one.
+** ---------------------------------------------------------------------------
+*/
+#if ! (defined(lint) || defined(_lint) || defined(RC_INVOKED))
+#  if defined(_MSC_VER)
+#    if ( _MSC_VER > 800 ) || defined(_PUSHPOP_SUPPORTED)
+#      pragma warning(disable:4103)
+#      if !(defined( MIDL_PASS )) || defined( __midl )
+#        pragma pack(push)
+#      endif
+#      pragma pack(1)
+#    else
+#      pragma warning(disable:4103)
+#      pragma pack(1)
+#    endif
+#  elif defined(__C166__)
+#     pragma pack(1)
+#  elif defined(__GCC__)
+#     pragma pack(push, 1)
+#  elif defined(__LCC__)
+#     pragma pack(push, 1)
+#  elif defined(__MWERKS__)
+#     pragma pack(push, 1)
+#  elif defined(__BORLANDC__)
+#    if (__BORLANDC__ >= 0x460)
+#       pragma nopackwarning
+#       pragma pack(push, 1)
+#    else
+#       pragma option -a1
+#    endif
+#  else
+#    error Unsupported compiler. See the compiler docs for more info on its alignment pragmas.
+#  endif
+#endif /* ! (defined(lint) || defined(_lint) || defined(RC_INVOKED)) */
Index: trunk/CanGateway/driver/kvaser/windows/j1587lib.h
===================================================================
--- trunk/CanGateway/driver/kvaser/windows/j1587lib.h	(revision 93)
+++ trunk/CanGateway/driver/kvaser/windows/j1587lib.h	(revision 93)
@@ -0,0 +1,440 @@
+/**
+ * \section LICENSE
+ *                   Copyright 2007-2011 by KVASER AB, SWEDEN
+ *
+ *                        WWW: http://www.kvaser.com
+ *
+ * This software is furnished under a license and may be used and copied
+ * only in accordance with the terms of such license.
+ *
+ * \section DESCRIPTION
+ *
+ *   Definitions for the J1587lib API.
+ *
+ * \file j1587lib.h
+ * \author Kvaser AB
+ */
+ 
+ 
+#ifndef __J1587LIB_H
+#define __J1587LIB_H
+
+/**
+ * \defgroup J1587 J1587
+ * @{
+ */
+
+#include <windows.h>
+
+/**
+ * J1587 handle
+ */
+typedef int J1587Handle;
+
+/**
+ * Invalid J1587 handle
+ */
+#define j1587INVALID_HANDLE      ((J1587Handle)(-1))
+
+/**
+ * \name Linx tranceiver types
+ * \anchor canTRANSCEIVER_TYPE_LINX_xxx
+ * @{
+ */
+#define canTRANSCEIVER_TYPE_LINX_LIN       64
+#define canTRANSCEIVER_TYPE_LINX_J1708     66
+#define canTRANSCEIVER_TYPE_LINX_K         68
+#define canTRANSCEIVER_TYPE_LINX_SWC       70
+#define canTRANSCEIVER_TYPE_LINX_LS        72
+/** @} */
+
+/**
+ * \name Operation modes
+ * \anchor EEPROM_OP_MODE_xxx
+ * @{
+ */
+#define EEPROM_OP_MODE_NONE             0x00
+#define EEPROM_OP_MODE_J1587_NORMAL     0x01
+#define EEPROM_OP_MODE_J1587_NODE       0x02
+/** @} */
+
+/**
+ * \name Flags for J1587MessageInfo
+ * \anchor j1587FLAG_xxx
+ * @{
+ */
+#define j1587FLAG_CHECKSUM              0x80
+#define j1587FLAG_FRAMEDELAY            0x40
+#define j1587FLAG_BYTEDELAY             0x20
+#define j1587FLAG_STOPBIT               0x10
+#define j1587FLAG_OVERRUN               0x08
+/** @} */
+
+/**
+ * \name Return codes from the J1587lib functions
+ * \anchor j1587ERR_xxx
+ * @{
+ */
+typedef enum {
+  j1587OK                  = 0,      ///< OK - no error
+  j1587ERR_NOMSG           = -1,     ///< No messages available
+  j1587ERR_NOTRUNNING      = -3,
+  j1587ERR_RUNNING         = -4,
+  j1587ERR_NORMALONLY      = -5,
+  j1587ERR_NODEONLY        = -6,
+  j1587ERR_PARAM           = -7,     ///< Error in parameter
+  j1587ERR_NOTFOUND        = -8,     ///< Specified hw not found.
+  j1587ERR_NOMEM           = -9,     ///< Out of memory
+  j1587ERR_NOCHANNELS      = -10,    ///< No channels avaliable
+  j1587ERR_TIMEOUT         = -11,    ///< Timeout occurred
+  j1587ERR_NOTINITIALIZED  = -12,    ///< Library not initialized
+  j1587ERR_NOHANDLES       = -13,    ///< Can't get handle
+  j1587ERR_INVHANDLE       = -14,    ///< Handle is invalid
+  j1587ERR_CANERROR        = -15,
+  j1587ERR_ERRRESP         = -16,    ///< There was an error response from the J1587 interface
+  j1587ERR_WRONGRESP       = -17,    ///< The J1587 interface response wasn't the expected one
+  j1587ERR_DRIVER          = -18,    ///< CAN driver type not supported
+  j1587ERR_DRIVERFAILED    = -19,    ///< DeviceIOControl failed; use Win32 GetLastError()
+  j1587ERR_NOCARD          = -20,    ///< The card was removed or not inserted
+  j1587ERR_LICENSE         = -21,    ///< The license is not valid.
+  j1587ERR_INTERNAL        = -22,    ///< Internal error in the driver.
+  j1587ERR_NO_ACCESS       = -23,    ///< Access denied
+  j1587ERR_VERSION         = -24     ///< Function not supported in this version.
+} J1587Status;
+/** @} */
+
+/**
+ * J1587 library version definition
+ */
+#define J1587LIB_VERSION  1
+
+// sizeof(J1587MessageInfo) should be 16
+#include <pshpack1.h>
+
+
+
+/**
+ * \name J1587MessageInfo
+ * \anchor J1587MessageInfo
+ *
+ * In certain J1587 bus API calls, the following structure is used to provide 
+ * more information about the J1587 messages.
+ */
+typedef struct {
+  /**
+   * To enable future extensions of this structure (see J1587LIB_VERSION).
+   */
+  unsigned char version;
+
+  /**
+   * Miscellaneous flags
+   */
+  unsigned char flags;
+
+  /**
+   * Frame delay in bit times (up to 255).
+   * - Read:  Length of inter-frame delay.
+   * - Write: Delay before message transmission could begin.
+   */
+  unsigned char frameDelay;
+
+  union {
+    /**
+     * Checksum as read from the J1587 bus. Might not
+     * match the data in case of J1587_CSUM_ERROR.
+     */
+    unsigned char checkSum;
+    /**
+     * Number of retries before message could be transmitted.
+     */
+    unsigned char retries;
+  };
+
+  /**
+   * Timestamp in ms of the reception/transmission completion
+   * of the checksum. Uses the canlib CAN timer.
+   */
+  unsigned long timestamp;
+
+  /**
+   * Total frame length in microseconds;
+   * from the first start bit to the end of the checksum.
+   */
+  unsigned long frameLength;
+
+  /**
+   * Bitrate of the message in bits per second.
+   * Range [1000 .. 60000] (plus some margin)
+   */
+  unsigned short bitrate;
+
+  /**
+   * Reserved
+   */
+  unsigned short reserved;
+} J1587MessageInfo;
+#include <poppack.h>
+
+
+// Define J1587LIBAPI unless it's done already.
+// (j1587lib.c provides its own definition of J1587LIBAPI before including this file.)
+//
+#ifndef J1587LIBAPI
+#   if defined(__BORLANDC__)
+#      define J1587LIBAPI __stdcall
+#   elif defined(_MSC_VER) || defined(__MWERKS__) || defined(__GNUC__)
+#      define J1587LIBAPI __stdcall
+#   endif
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/** 
+ * To be called before the library is used.
+ */
+void J1587LIBAPI j1587InitializeLibrary(void);
+
+
+/** 
+ * Open a channel to a J1587 interface.
+ * 
+ * \note The J1587 cable must be powered.
+ * 
+ * The channel number is the same that
+ * is used by \ref canOpenChannel() to access the LAPcan channel.
+ *
+ * \param[in] channel  The number of the channel. This is the same as used 
+ *                     by \ref canOpenChannel() to access the LAPcan channel. 
+ * \param[in] flags    Flags of type \ref J1587_xxx
+ *
+ * \return If the call succeeds, a handle to the opened channel is returned. 
+ * The handle is an integer greater than or equal to zero.
+ *
+ * \return If the call fails, the return value is a negative integer indicating 
+ * an error code. See \ref j1587ERR_xxx for a list of possible error codes.
+ *
+ * \sa \ref j1587Close()
+ */
+J1587Handle J1587LIBAPI j1587OpenChannel(int channel, int flags);
+
+/**
+ * \name Flags for j1587OpenChannel()
+ * \anchor J1587_xxx
+ * @{
+ */
+#define J1587_NORMAL 1
+#define J1587_NODE   2
+#define J1587_READ   4
+#define J1587_WRITE  8
+/** @} */
+
+/** 
+ * Closes an open handle to a J1587 channel. The handle becomes invalid and can 
+ * not be used in subsequent calls to the J1587 functions.
+ *
+ * \param[in] h        A handle to an open J1587 channel.
+ *
+ * \return \ref j1587OK (zero) if success
+ * \return \ref j1587ERR_xxx (negative) if failure
+ *
+ * \sa \ref j1587OpenChannel()
+ */
+J1587Status J1587LIBAPI j1587Close(J1587Handle h);
+
+/**
+ * This function retrieves the firmware version from the J1587 interface.
+ *
+ * 
+ * \note The version numbers aren't valid until \ref j1587BusOn() has been called.
+ *
+ * \note The firmware in the J1587 interface is divided into two parts, the boot 
+ * code and the application. The boot code is used only when reprogramming 
+ * (reflashing) the J1597 interface. The application handles all J1587 communication.
+ *
+ * \note Version numbers are, since the precambric era, divided into a major 
+ * version number, a minor version number and a build number. These are usually 
+ * written like, for example, 3.2.12. Here the major number is 3, the minor 
+ * number 2 and the build number 12.
+ *
+ * \param[in]  h             A handle to an open J1587 channel.
+ * \param[out] bootVerMajor  A pointer to a byte where the major version number 
+ *                           of the boot code is stored. 
+ * \param[out] bootVerMinor  A pointer to a byte where the minor version number 
+ *                           of the boot code is stored. 
+ * \param[out] bootVerBuild  A pointer to a byte where the build number of the 
+ *                           boot code is stored. 
+ * \param[out] appVerMajor   A pointer to a byte where the major version number 
+ *                           of the application code is stored.
+ * \param[out] appVerMinor   A pointer to a byte where the minor version number 
+ *                           of the application code is stored. 
+ * \param[out] appVerBuild   A pointer to a byte where the build number of the application is stored. 
+ *
+ * \return \ref j1587OK (zero) if success
+ * \return \ref j1587ERR_xxx (negative) if failure
+ */
+J1587Status J1587LIBAPI j1587GetFirmwareVersion(J1587Handle h,
+                                          unsigned char *bootVerMajor,
+                                          unsigned char *bootVerMinor,
+                                          unsigned char *bootVerBuild,
+                                          unsigned char *appVerMajor,
+                                          unsigned char *appVerMinor,
+                                          unsigned char *appVerBuild);
+
+/** 
+ * This function sets the bit rate 
+ *
+ * \note The J1587 Interface should not be on bus.
+ *
+ * \param[in] h   A handle to an open J1587 channel.
+ * \param[in] bps Bit rate in bits per second.
+ *
+ * \return \ref j1587OK (zero) if success
+ * \return \ref j1587ERR_xxx (negative) if failure
+ */
+J1587Status J1587LIBAPI j1587SetBitrate(J1587Handle h, unsigned int bps);
+
+/** 
+ * This function activates the J1587 interface.
+ * \note It will be reset, so any setups done earlier will be lost.
+ *
+ * \param[in] h   A handle to an open J1587 channel.
+ *
+ * \return \ref j1587OK (zero) if success
+ * \return \ref j1587ERR_xxx (negative) if failure
+ */
+J1587Status J1587LIBAPI j1587BusOn(J1587Handle h);
+
+/** 
+ * This function deactivates the J1587 interface. It will be reset clearing any 
+ * settings such as J1587 data buffers active.
+ *
+ * \param[in] h   A handle to an open J1587 channel.
+ *
+ * \return \ref j1587OK (zero) if success
+ * \return \ref j1587ERR_xxx (negative) if failure
+ */
+J1587Status J1587LIBAPI j1587BusOff(J1587Handle h);
+
+/** 
+ * Return the current timer value (used for timestamps)
+ *
+ * \note For convenience, this call returns the timer value instead of passing 
+ * it in a parameter. This means that if the call fails, it will still return 
+ * a value (which then is the error code, type casted to a long unsigned 
+ * integer - e.g. 0xFFFFFFF2 for \ref j1587ERR_INVHANDLE. Watch out. 
+ *
+ * \param[in] h        A handle to an open J1587 channel.
+ * \return If the call succeeds, the present timer value is returned.
+ */
+unsigned long J1587LIBAPI j1587ReadTimer(J1587Handle h);
+
+/**
+ * Write a J1587 message. Times out after timeout ms.
+ *
+ * \param[in] h        A handle to an open J1587 channel.
+ * \param[in] msg      A pointer to a buffer containing the J1587 message.
+ * \param[in] length   Length of message, max 0xFFF
+ * \param[in] priority Priority of message, max 0xFF
+ * \param[in] timeout  Times out after \a timeout milliseconds
+ *
+ * \return \ref j1587OK (zero) if success
+ * \return \ref j1587ERR_xxx (negative) if failure
+ */
+J1587Status J1587LIBAPI j1587WriteMessageWait(J1587Handle h, const void *msg,
+                                              unsigned int length,
+                                              unsigned int priority,
+                                              DWORD timeout);
+
+/** 
+ * Read a J1587 message.
+ *
+ * \param[in] h           A handle to an open J1587 channel.
+ * \param[out] msg        A pointer to a buffer where the J1587 message will be 
+ *                        stored. 
+ * \param[out] msgLength  A pointer to an integer where the length of the  
+ *                        received J1587 message will be stored. 
+ * \param[out] msgInfo    A pointer a \ref J1587MessageInfo structure where the 
+ *                        message information will be stored. 
+ * \param[in] timeout     Times out after \a timeout milliseconds
+ * 
+ * \return \ref j1587OK (zero) if success
+ * \return \ref j1587ERR_NOMSG if nothing is received
+ * \return \ref j1587ERR_xxx (negative) if failure
+ */
+J1587Status J1587LIBAPI j1587ReadMessageWait(J1587Handle h, void *msg,
+                                             unsigned int *msgLength,
+                                             J1587MessageInfo *msgInfo,
+                                             DWORD timeout);
+
+/** 
+ * Call this function to make sure all messages transmitted to the
+ * J1587 Interface have been received by it.
+ *
+ * When messages are transmitted to the J1587 Interface, they are queued by
+ * Windows before appearing on the CAN bus.
+ *
+ * \param[in] h           A handle to an open J1587 channel.
+ * \param[out] msgInfo    A pointer a \ref J1587MessageInfo structure where the 
+ *                        message information will be stored. 
+ * \param[in] timeout     Times out after \a timeout milliseconds
+ *
+ * \return \ref j1587OK (zero) if all writes are done
+ * \return \ref j1587ERR_xxx (negative) if failure
+ */
+J1587Status J1587LIBAPI j1587WriteSync (J1587Handle h,
+                                        J1587MessageInfo *msgInfo,
+                                        DWORD timeout);
+
+/**
+ * With this function, it is possible to change settings on a J1587 Interface
+ * that is on-bus.
+ * When going on-bus, the bitrate and the flag values \ref J1587_REPORT_xxx are set 
+ * to the default value (either as hard-coded in the firmware, or as stored in the
+ * non-volatile memory of the J1587 Interface).
+ *
+ * \note The J1587 Interface must be on bus for this command to work.
+ *
+ * \param[in] h           A handle to an open J1587 channel.
+ * \param[in] flags       Flags, see \ref J1587_REPORT_xxx
+ *
+ * \todo Describe how to use J1587_INTER_CHAR_DELAY_MASK
+ *
+ * \return \ref j1587OK (zero) if all writes are done
+ * \return \ref j1587ERR_xxx (negative) if failure
+ */
+J1587Status J1587LIBAPI j1587Configure(J1587Handle h, unsigned int flags);
+
+
+
+/**
+ * \name Flags for j1587Configure()
+ * \anchor J1587_REPORT_xxx
+ * @{
+ */
+#define J1587_INTER_CHAR_DELAY_MASK 0x0f ///< Inter character delay mask
+#define J1587_REPORT_BAD_CHECKSUM   0x10 ///< Default off
+#define J1587_REPORT_FRAME_DELAY    0x20 ///< Default off
+#define J1587_REPORT_CHAR_DELAY     0x40 ///< Default off
+/** @} */
+
+/**
+ * Return the CAN handle given an open J1587 handle
+ *
+ * \param[in]  h          A handle to an open J1587 channel.
+ * \param[out] canHandle  A pointer to an integer where the CAN handle will be 
+ *                        stored. 
+ *
+ * \return \ref j1587OK (zero) if success
+ * \return \ref j1587ERR_xxx (negative) if failure
+ */
+J1587Status J1587LIBAPI j1587GetCanHandle(J1587Handle h, unsigned int *canHandle);
+
+#ifdef __cplusplus
+}
+#endif
+
+/** @} */
+
+#endif // __J1587LIB_H
Index: trunk/CanGateway/driver/kvaser/windows/kvadblib.h
===================================================================
--- trunk/CanGateway/driver/kvaser/windows/kvadblib.h	(revision 93)
+++ trunk/CanGateway/driver/kvaser/windows/kvadblib.h	(revision 93)
@@ -0,0 +1,1512 @@
+/**
+ * \section LICENSE
+ *                   Copyright 2002-2011 by KVASER AB, SWEDEN
+ *
+ *                        WWW: http://www.kvaser.com
+ *
+ * This software is furnished under a license and may be used and copied
+ * only in accordance with the terms of such license.
+ *
+ * \section DESCRIPTION
+ *
+ *   Definitions for the CAN Database API.
+ *
+ * \file kvaDBlib.h
+ * \author Kvaser AB
+ *
+ */
+
+#ifndef KVADBLIB_H
+#define KVADBLIB_H
+
+/**
+ * \defgroup CANDB  CAN Database
+ * @{
+ */
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/**
+ *
+ * \name kvaDbErr_xxx
+ * \anchor kvaDbErr_xxx
+ *
+ * The following codes are returned by most CANDB API calls.
+ *
+ * \note Error codes are always negative.
+ * @{
+ */
+typedef enum {
+    kvaDbOK                      =  0,  ///< OK - no error
+    kvaDbErr_Fail                = -1,  ///< General failure
+    kvaDbErr_NoDatabase          = -2,  ///< No database was found
+    kvaDbErr_Param               = -3,  ///< One or more of the parameters in call is erronous
+    kvaDbErr_NoMsg               = -4,  ///< No message was found
+    kvaDbErr_NoSignal            = -5,  ///< No signal was found
+    kvaDbErr_Internal            = -6,  ///< An internal error occured in the library
+    kvaDbErr_DbFileOpen          = -7,  ///< Could not open the database file
+    kvaDbErr_DatabaseInternal    = -8,  ///< An internal error occured in the database handler
+    kvaDbErr_NoNode              = -9,  ///< Could not find the database node
+    kvaDbErr_NoAttrib            = -10, ///< No attribute found
+    kvaDbErr_OnlyOneAllowed      = -11, ///< Only one CANdb structure is allowed
+} KvaDbStatus;
+/** @} */
+
+/**
+ * \name Kvaser Database Message Flags
+ * \anchor KVADB_MESSAGE_xxx
+ *
+ * The following flags are never used.
+ *
+ * \todo Why are they never used?
+ * @{
+ */
+#define KVADB_MESSAGE_EXT      0x80000000  ///< Message is an extended CAN message
+#define KVADB_MESSAGE_J1939    0x00000001  ///< Message uses J1939 protocol
+#define KVADB_MESSAGE_WAKEUP   0x00000002  ///< Message is a wake-up frame, Id/msg/dlc are undefined
+/** @} */
+
+/**
+ * \name CANDBSignalEncoding API Signal Encoding
+ * 
+ * The following values are used by kvaDbGetSignalEncoding() and
+ * kvaDbSetSignalEncoding()
+ * @{
+ */
+typedef enum {
+  kvaDb_Intel     = 0, ///< Intel
+  kvaDb_Motorola  = 1, ///< kvaDb_Motorola
+} KvaDbSignalEncoding;
+/** @} */
+
+/**
+ * \name CANDBSignalRepresentation API Signal Representation
+ * 
+ * The type ::KvaDbSignalType is used by e.g. kvaDbGetSignalRepresentationType().
+ * @{
+ */
+typedef enum  {
+   kvaDb_Invalid,   ///< Invalid representation
+   kvaDb_Signed,    ///< Signed integer
+   kvaDb_Unsigned,  ///< Unsigned integer
+   kvaDb_Float,     ///< Float
+   kvaDb_Double     ///< Double
+} KvaDbSignalType;
+/** @} */
+
+/**
+ * \name CANDBAttributeRepresentation API Attribute Representation
+ *
+ * The type ::KvaDbAttributeType is used by e.g. kvaDbGetAttributeDefinitionType()
+ * and kvaDbGetAttributeType().
+ * @{
+ */
+typedef enum {
+   kvaDb_AttributeInvalid       = 0,  ///< Invalid attribute
+   kvaDb_AttributeInteger       = 1,  ///< Integer attribute
+   kvaDb_AttributeFloat         = 3,  ///< Float attribute
+   kvaDb_AttributeEnumeration   = 4,  ///< Enumeration attribute
+   kvaDb_AttributeString        = 5,  ///< String attribute
+} KvaDbAttributeType;
+/** @} */
+
+/**
+ * \name CANDBAttributeOwner API Attribute Owner
+ *
+ * The type ::KvaDbAttributeOwnerType is used by e.g. kvaDbGetAttributeDefinitionOwner(),
+ * @{
+ */
+typedef enum {
+   kvaDb_AttributeOwnerInvalid  = 0,  ///< Invalid owner
+   kvaDb_AttributeOwnerDb       = 1,  ///< Database owner
+   kvaDb_AttributeOwnerMessage  = 2,  ///< Message owner
+   kvaDb_AttributeOwnerNode     = 3,  ///< Node owner
+   kvaDb_AttributeOwnerSignal   = 4,  ///< Signal owner
+   kvaDb_AttributeOwnerEnv      = 5,  ///< Environment owner
+} KvaDbAttributeOwner;
+/** @} */
+
+// Database flags
+
+/**
+ * \name CANDBDatabaseFlags API Database Flags
+ * \anchor KVADB_DATABASE_xxx
+ * 
+ * The following value is used by kvaDbGetFlags().
+ * @{
+ */
+#define KVADB_DATABASE_J1939   0x0001  ///< The database uses the J1939 protocol
+
+typedef void* KvaDbHnd;              ///< Database handle
+typedef void* KvaDbMessageHnd;       ///< Message handle
+typedef void* KvaDbSignalHnd;        ///< Signal handle
+typedef void* KvaDbNodeHnd;          ///< Node handle
+typedef void* KvaDbAttributeHnd;     ///< Attribute handle
+typedef void* KvaDbAttributeDefHnd;  ///< Attribute definition handle
+/** @} */
+
+/**
+ * \name Kvaser Database Multiplexer Mode values
+ * \anchor KVADB_MUX_xxx
+ * @{ 
+*/
+#define KVADB_MUX_SIGNAL -2  ///< Multiplex mode value of a multiplexer signal
+#define KVADB_MUX_INDEPENDENT -1 ///< Miltiplex mode value of an independent signal
+/** @} */
+
+/**
+ * This function creates a new database handle.
+ * 
+ * \param[out] dh  A handle to a new database
+ * 
+ * \return ::kvaDbOK (zero) if success
+ * \return \ref kvaDbErr_xxx (negative) if failure
+ * 
+ * \sa kvaDbClose()
+ */
+KvaDbStatus WINAPI kvaDbOpen(KvaDbHnd *dh);
+
+/**
+ * This loads a database file into a handle created with kvaDbOpen().
+ * 
+ * \note This function is deprecated and will be replaced by kvaDbCreate()
+ *
+ * \param[in] dh        A handle database handle
+ * \param[in] filename  A database file
+ * 
+ * \return ::kvaDbOK (zero) if success
+ * \return \ref kvaDbErr_xxx (negative) if failure
+ * 
+ * \sa kvaDbCreate()
+ */
+KvaDbStatus WINAPI kvaDbAddFile(KvaDbHnd dh, const char *filename);
+
+/**
+ * This function creates a new database in a handle created with
+ * kvaDbOpen(). It is used when there is no file to read data from.
+ *
+ * \note This function is deprecated and will be replaced by kvaDbCreate().
+ * 
+ * \param[in] dh        A database handle
+ * \param[in] filename  The the dummy filename to use for this database
+ * 
+ * \return ::kvaDbOK (zero) if success
+ * \return \ref kvaDbErr_xxx (negative) if failure
+ * 
+ * \sa kvaDbCreate()
+ */
+KvaDbStatus WINAPI kvaDbSetDummyFileName(KvaDbHnd dh, const char *filename);
+
+/**
+ * This function creates a new database in a handle created with
+ * kvaDbOpen(). There are three ways to call this function:
+ *   
+ * \li To load data from an existing database file, set \a localName to \c NULL
+ * and set \a filename to the database file.
+ *   
+ * \li To add an empty database, set \a localName to any name and set \a
+ * filename to \c NULL.
+ *   
+ * \li To load data from an existing database file and give it a new name, set
+ * \a localName to the new name and set \a filename to the database file.
+ * 
+ * \param[in] dh         A database handle
+ * \param[in] localName  The name of the database or \c NULL
+ * \param[in] filename   The database file or \c NULL
+ * 
+ * \return ::kvaDbOK (zero) if success
+ * \return \ref kvaDbErr_xxx (negative) if failure
+ * 
+ * \sa kvaDbOpen()
+ */
+KvaDbStatus WINAPI kvaDbCreate(KvaDbHnd dh, const char *localName, const char *filename);
+
+/**
+ * This function closes an open database handle.
+ * 
+ * \param[in] dh  A handle to a database
+ * 
+ * \return ::kvaDbOK (zero) if success
+ * \return \ref kvaDbErr_xxx (negative) if failure
+ * 
+ * \sa kvaDbOpen()
+ */
+KvaDbStatus WINAPI kvaDbClose(KvaDbHnd dh);
+
+/**
+ * Write a database to file.
+ * 
+ * \param[in] dh        A handle to a database
+ * \param[in] filename  The name of the database file
+ * 
+ * \return ::kvaDbOK (zero) if success
+ * \return \ref kvaDbErr_xxx (negative) if failure
+ * 
+ * \sa kvaDbReadFile()
+ */
+KvaDbStatus WINAPI kvaDbWriteFile(KvaDbHnd dh, char* filename);
+
+/**
+ * Load a database from file into a handle created with kvaDbOpen().
+ * 
+ * \param[out]  dh        A handle to a database
+ * \param[in]   filename  The name of the database file.
+ * 
+ * \return ::kvaDbOK (zero) if success
+ * \return \ref kvaDbErr_xxx (negative) if failure
+ * 
+ * \sa kvaDbCreate()
+ */
+KvaDbStatus WINAPI kvaDbReadFile(KvaDbHnd dh, char* filename);
+
+/**
+ * Get the database flags.
+ * 
+ * \param[in]  dh     A handle to a database
+ * \param[out] flags  The database flags, \ref KVADB_DATABASE_xxx
+ * 
+ * \return ::kvaDbOK (zero) if success
+ * \return \ref kvaDbErr_xxx (negative) if failure
+ * 
+ * \sa kvaDbReadFile()
+ *
+ * \todo check kvaDbReadFile(), we should perhaps link to kvaDbCreate()?
+ */
+KvaDbStatus WINAPI kvaDbGetFlags(KvaDbHnd dh, unsigned int *flags);
+
+/**
+ * Get the first message in a database.
+ * 
+ * \param[in]  dh  A handle to a database
+ * \param[out] mh  A handle to the first message
+ * 
+ * \return ::kvaDbOK (zero) if success
+ * \return \ref kvaDbErr_xxx (negative) if failure
+ * 
+ * \sa kvaDbGetNextMsg()
+ */
+KvaDbStatus WINAPI kvaDbGetFirstMsg(KvaDbHnd dh, KvaDbMessageHnd *mh);
+
+/**
+ * Get a handle to the next message in a database. Should be called after
+ * kvaDbGetFirstMsg().
+ * 
+ * \param[in]  dh  A database handle
+ * \param[out] mh  A message handle
+ * 
+ * \return ::kvaDbOK (zero) if success
+ * \return \ref kvaDbErr_xxx (negative) if failure
+ * 
+ * \sa kvaDbGetFirstMsg()
+ */
+KvaDbStatus WINAPI kvaDbGetNextMsg(KvaDbHnd dh, KvaDbMessageHnd *mh);
+
+/**
+ * Get a handle to a message with a specific identifier.
+ * 
+ * \param[in]  dh  A database handle
+ * \param[in]  id  The selected message identifier
+ * \param[out] mh  A message handle
+ * 
+ * \return ::kvaDbOK (zero) if success
+ * \return \ref kvaDbErr_xxx (negative) if failure
+ * 
+ * \sa kvaDbGetMsgByName()
+ */
+KvaDbStatus WINAPI kvaDbGetMsgById(KvaDbHnd dh, 
+                                   unsigned int id, 
+                                   KvaDbMessageHnd *mh);
+
+/**
+ * Get a handle to a message with a specific name.
+ * 
+ * \param[in]  dh        A databse handle
+ * \param[in]  msg_name  The message name to search for
+ * \param[out] mh        A message handle
+ * 
+ * \return ::kvaDbOK (zero) if success
+ * \return \ref kvaDbErr_xxx (negative) if failure
+ * 
+ * \sa kvaDbGetMsgById()
+ */
+KvaDbStatus WINAPI kvaDbGetMsgByName(KvaDbHnd dh, 
+                                     const char *msg_name, 
+                                     KvaDbMessageHnd *mh);
+
+/**
+ * Get the message name.
+ * 
+ * \param[in]  mh      A message handle
+ * \param[out] buf     The buffer that will hold the message name
+ * \param[in]  buflen  The length of the buffer.
+ * 
+ * \return ::kvaDbOK (zero) if success
+ * \return \ref kvaDbErr_xxx (negative) if failure
+ * 
+ * \sa kvaDbSetMsgName(), kvaDbGetMsgQualifiedName()
+ */
+KvaDbStatus WINAPI kvaDbGetMsgName(KvaDbMessageHnd mh, char *buf, size_t buflen);
+
+/**
+ * Get the qualified message name, which is the database name and the message
+ * name separated by a dot.
+ * 
+ * \param[in]  mh      A message handle
+ * \param[out] buf     The buffer that will hold the qualified message name
+ * \param[in]  buflen  The length of the buffer
+ * 
+ * \return ::kvaDbOK (zero) if success
+ * \return \ref kvaDbErr_xxx (negative) if failure
+ * 
+ * \sa kvaDbGetMsgName()
+ */
+KvaDbStatus WINAPI kvaDbGetMsgQualifiedName(KvaDbMessageHnd mh, char *buf, size_t buflen);
+
+/**
+ * Get the message comment.
+ * 
+ * \param[in]  mh      A message handle
+ * \param[out] buf     The buffer that will hold the message comment
+ * \param[in]  buflen  The length of the buffer
+ * 
+ * \return ::kvaDbOK (zero) if success
+ * \return \ref kvaDbErr_xxx (negative) if failure
+ * 
+ * \sa kvaDbSetMsgComment()
+ */
+KvaDbStatus WINAPI kvaDbGetMsgComment(KvaDbMessageHnd mh, char *buf, size_t buflen);
+
+/**
+ * Get message identifier and flags.
+ * 
+ * \param[in]  mh     A message handle.
+ * \param[out] id     The identifier.
+ * \param[out] flags  The flags, \ref KVADB_MESSAGE_xxx
+ * 
+ * \return ::kvaDbOK (zero) if success
+ * \return \ref kvaDbErr_xxx (negative) if failure
+ * 
+ * \todo "flags" contains extended? or use 0x80000000 convention?
+ *       could also contain J1939 flag, wakeup etc. qqq
+ *
+ * \sa kvaDbSetMsgId()
+ */
+KvaDbStatus WINAPI kvaDbGetMsgId(KvaDbMessageHnd mh, 
+                                 unsigned int *id, 
+                                 unsigned int *flags);
+
+/**
+ * Get the data length code for a message.
+ * 
+ * \param[in]  mh   A message handle
+ * \param[out] dlc  The data length code
+ * 
+ * \return ::kvaDbOK (zero) if success
+ * \return \ref kvaDbErr_xxx (negative) if failure
+ * 
+ * \sa kvaDbSetMsgDlc()
+ */
+KvaDbStatus WINAPI kvaDbGetMsgDlc(KvaDbMessageHnd mh, int *dlc);
+
+/**
+ * Add a new message to a database.
+ * 
+ * \param[in]  dh  A database handle
+ * \param[out] mh  A handle to the new message
+ * 
+ * \return ::kvaDbOK (zero) if success
+ * \return \ref kvaDbErr_xxx (negative) if failure
+ * 
+ * \sa kvaDbDeleteMsg()
+ */
+KvaDbStatus WINAPI kvaDbAddMsg(KvaDbHnd dh, KvaDbMessageHnd *mh);
+
+/**
+ * Delete a message from a database.
+ * 
+ * \param[in] dh  A database handle
+ * \param[in] mh  A handle to the message that will be deleted
+ * 
+ * \return ::kvaDbOK (zero) if success
+ * \return \ref kvaDbErr_xxx (negative) if failure
+ * 
+ * \sa kvaDbAddMsg()
+ */
+KvaDbStatus WINAPI kvaDbDeleteMsg(KvaDbHnd dh, KvaDbMessageHnd mh);
+
+/**
+ * Set the database flags.
+ *
+ * \note This feature is currently not enabled.
+ * 
+ * \param[in] dh     A database handle
+ * \param[in] flags  The flags to set, \ref KVADB_MESSAGE_xxx
+ * 
+ * \return ::kvaDbOK (zero) if success
+ * \return \ref kvaDbErr_xxx (negative) if failure
+ * 
+ * \sa kvaDbGetFlags()
+ */
+KvaDbStatus WINAPI kvaDbSetFlags(KvaDbHnd dh, unsigned int flags);
+
+/**
+ * Set the message name.
+ * 
+ * \param[in] mh   A message handle
+ * \param[in] buf  The buffer that contains the message name.
+ * 
+ * \return ::kvaDbOK (zero) if success
+ * \return \ref kvaDbErr_xxx (negative) if failure
+ * 
+ * \sa kvaDbGetMsgName()
+ */
+KvaDbStatus WINAPI kvaDbSetMsgName(KvaDbMessageHnd mh, char *buf);
+
+/**
+ * Set the message comment.
+ * 
+ * \param[in] mh   A message handle
+ * \param[in] buf The buffer that contains the message comment
+ * 
+ * \return ::kvaDbOK (zero) if success
+ * \return \ref kvaDbErr_xxx (negative) if failure
+ * 
+ * \sa kvaDbGetMsgComment()
+ */
+KvaDbStatus WINAPI kvaDbSetMsgComment(KvaDbMessageHnd mh, char *buf);
+
+/**
+ * Set the message identifier and flags.
+ * 
+ * \param[in] mh     A message handle
+ * \param[in] id     The message identifier
+ * \param[in] flags  The message flags, \ref KVADB_MESSAGE_xxx
+ * 
+ * \return ::kvaDbOK (zero) if success
+ * \return \ref kvaDbErr_xxx (negative) if failure
+ * 
+ * \todo "flags" contains extended? or use 0x80000000 convention?
+ *       could also contain J1939 flag, wakeup etc. qqq
+ *
+ * \sa kvaDbGetMsgId()
+ */
+KvaDbStatus WINAPI kvaDbSetMsgId(KvaDbMessageHnd mh, unsigned int id, unsigned int flags);
+
+/**
+ * Set the data length code for a message.
+ * 
+ * \param[in] mh   A message handle
+ * \param[in] dlc  The data length code
+ * 
+ * \return ::kvaDbOK (zero) if success
+ * \return \ref kvaDbErr_xxx (negative) if failure
+ * 
+ * \sa kvaDbGetMsgDlc()
+ */
+KvaDbStatus WINAPI kvaDbSetMsgDlc(KvaDbMessageHnd mh, int dlc);
+
+// qqq pragma för att sätta sizeof(enum) till 4? annars skippa enum...
+
+// J1939 fungerar hur? Helt enkelt genom att id == PGN?  Hur hantera
+// SA, DA, etc? qqq
+
+/**
+ * Returns handle to a multiplexer signal of a given message
+ *
+ * \param[in]  mh     A message handle
+ * \param[out] shh    Multiplexer signal handle
+ *
+ * \return ::kvaDbOK (zero if success
+ * \return \ref kvaDbErr_xxx (negative) if failure
+ */ 
+
+KvaDbStatus WINAPI kvaDbGetMsgMux(KvaDbMessageHnd mh, KvaDbSignalHnd *shh); 
+
+/**
+ * Get the first signal in a message.
+ * 
+ * \param[in]  mh  A message handle
+ * \param[out] sh  A handle to the first signal
+ * 
+ * \return ::kvaDbOK (zero) if success
+ * \return \ref kvaDbErr_xxx (negative) if failure
+ * 
+ * \sa kvaDbGetNextSignal()
+ */
+ 
+KvaDbStatus WINAPI kvaDbGetFirstSignal(KvaDbMessageHnd mh, KvaDbSignalHnd *sh);
+
+/**
+ * Get the next signal in a message. Should be called after
+ * kvaDbGetFirstSignal().
+ * 
+ * \param[in]  mh  A message handle
+ * \param[out] sh  A handle to the next signal
+ * 
+ * \return ::kvaDbOK (zero) if success
+ * \return \ref kvaDbErr_xxx (negative) if failure
+ * 
+ * \sa kvaDbGetFirstSignal
+ */
+KvaDbStatus WINAPI kvaDbGetNextSignal(KvaDbMessageHnd mh, KvaDbSignalHnd *sh);
+
+/**
+ * Get a signal handle by seaching for the signals's name.
+ * 
+ * \param[in]  mh   A message handle
+ * \param[in]  buf  The buffer that contains the name of the signal to search for
+ * \param[out] sh   A handle to the signal
+ * 
+ * \return ::kvaDbOK (zero) if success
+ * \return \ref kvaDbErr_xxx (negative) if failure
+ * 
+ * \sa kvaDbGetFirstMsg()
+ */
+KvaDbStatus WINAPI kvaDbGetSignalByName(KvaDbMessageHnd mh, char *buf, KvaDbSignalHnd *sh);
+
+/**
+ * Sets signal's multiplex mode. If value is equal to KVADB_MUX_SIGNAL, marks signal as a multiplexer.
+ *
+ * \param[in]  sh     A signal handle
+ * \param[in] mux   Signal's multiplex mode
+ *
+ * \return ::kvaDbOK (zero if success
+ * \return \ref kvaDbErr_xxx (negative) if failure
+ * \sa \ref KVADB_MUX_xxx
+ */ 
+  
+KvaDbStatus WINAPI kvaDbSetSignalMode(KvaDbSignalHnd sh, int mux);
+
+/**
+ * Sets mux to multiplexer mode value of given signal. 
+ * See \ref KVADB_MUX_xxx for special (negative) values of multiplexer mode.
+ *
+ * \param[in]  sh     A signal handle
+ * \param[out] mux   Signal's multiplex mode
+ *
+ * \return ::kvaDbOK (zero if success
+ * \return \ref kvaDbErr_xxx (negative) if failure
+ * \sa \ref KVADB_MUX_xxx
+*/ 
+
+KvaDbStatus WINAPI kvaDbGetSignalMode(KvaDbSignalHnd sh, int *mux);
+
+/**
+ * Convert data to a signal's physical (floating-point) value.
+ * 
+ * \param[in]  sh    A signal handle
+ * \param[out] f     The converted value
+ * \param[in]  data  The data buffer to be converted
+ * \param[in]  len   The length of the data buffer
+ * 
+ * \return ::kvaDbOK (zero) if success
+ * \return \ref kvaDbErr_xxx (negative) if failure
+ * 
+ * \sa kvaDbStoreSignalValuePhys()
+ */
+
+KvaDbStatus WINAPI kvaDbGetSignalValueFloat(KvaDbSignalHnd sh, double *f, void *data, size_t len);
+
+/**
+ * Convert data to a signal's raw (integer) value.
+ * 
+ * \param[in]  sh    A signal handle
+ * \param[out] f     The converted value
+ * \param[in]  data  The data buffer to be converted
+ * \param[in]  len   The length of the data buffer
+ * 
+ * \return ::kvaDbOK (zero) if success
+ * \return \ref kvaDbErr_xxx (negative) if failure
+ * 
+ * \sa kvaDbStoreSignalValueRaw()
+ */
+ 
+KvaDbStatus WINAPI kvaDbGetSignalValueInteger(KvaDbSignalHnd sh, int *f, void *data, size_t len);
+
+/**
+ * Get the minimum and maximum values from a signal.
+ * 
+ * \param[in]  sh      A signal handle
+ * \param[out] minval  The minimum value
+ * \param[out] maxval  The maximum value
+ * 
+ * \return ::kvaDbOK (zero) if success
+ * \return \ref kvaDbErr_xxx (negative) if failure
+ * 
+ * \sa kvaDbSetSignalValueLimits()
+ */
+KvaDbStatus WINAPI kvaDbGetSignalValueLimits(KvaDbSignalHnd sh, double *minval, double *maxval);
+
+/**
+ * Get the scale factor and offset from a signal.
+ * 
+ * \param[in]  sh      A signal handle
+ * \param[out] factor  The signal scale factor
+ * \param[out] offset  The signal offset
+ * 
+ * \return ::kvaDbOK (zero) if success
+ * \return \ref kvaDbErr_xxx (negative) if failure
+ * 
+ * \sa kvaDbSetSignalValueScaling()
+ */
+KvaDbStatus WINAPI kvaDbGetSignalValueScaling(KvaDbSignalHnd sh, double *factor, double *offset);
+
+/**
+ * Get the size and position of the signal value.
+ * 
+ * \param[in]  sh        A signal handle
+ * \param[out] startbit  The bit where the signal value starts
+ * \param[out] length    The length of the signal value in bits
+ * 
+ * \return ::kvaDbOK (zero) if success
+ * \return \ref kvaDbErr_xxx (negative) if failure
+ * 
+ * \sa kvaDbSetSignalValueSize()
+ */
+KvaDbStatus WINAPI kvaDbGetSignalValueSize(KvaDbSignalHnd sh, int *startbit, int *length);
+
+/**
+ * Get the signal name.
+ * 
+ * \param[in]  sh      A signal handle
+ * \param[out] buf     The signal name
+ * \param[in]  buflen  The length of the buffer that will hold the signal name
+ * 
+ * \return ::kvaDbOK (zero) if success
+ * \return \ref kvaDbErr_xxx (negative) if failure
+ * 
+ * \sa kvaDbSetSignalName()
+ */
+KvaDbStatus WINAPI kvaDbGetSignalName(KvaDbSignalHnd sh, char *buf, size_t buflen);
+
+/**
+ * Get the qualified signal name. which is the database, message ans signal
+ * names separated by dots.
+ * 
+ * \param[in]  sh      A signal handle
+ * \param[out] buf     The qualified signal name
+ * \param[in]  buflen  The length of the buffer that will hold the qualified
+ *                     signal name
+ * 
+ * \return ::kvaDbOK (zero) if success
+ * \return \ref kvaDbErr_xxx (negative) if failure
+ * 
+ * \sa kvaDbGetSignalName()
+ */
+KvaDbStatus WINAPI kvaDbGetSignalQualifiedName(KvaDbSignalHnd sh, char *buf, size_t buflen);
+
+/**
+ * Get the signal comment.
+ * 
+ * \param[in]  sh      A signal handle
+ * \param[out] buf     The signal comment
+ * \param[in]  buflen  The length of the buffer that will hold the signal comment
+ * 
+ * \return ::kvaDbOK (zero) if success
+ * \return \ref kvaDbErr_xxx (negative) if failure
+ * 
+ * \sa kvaDbSetSignalComment()
+ */
+KvaDbStatus WINAPI kvaDbGetSignalComment(KvaDbSignalHnd sh, char *buf, size_t buflen);
+
+/**
+ * Get the signal unit.
+ * 
+ * \param[in]  sh      A signal handle
+ * \param[out] buf     The signal unit
+ * \param[in]  buflen  The length of the buffer that will hold the signal unit
+ * 
+ * \return ::kvaDbOK (zero) if success
+ * \return \ref kvaDbErr_xxx (negative) if failure
+ * 
+ * \sa kvaDbSetSignalUnit()
+ */
+KvaDbStatus WINAPI kvaDbGetSignalUnit(KvaDbSignalHnd sh, char *buf, size_t buflen);
+
+/**
+ * Get the signal encoding.
+ * 
+ * \param[in]  sh  A signal handle
+ * \param[out] e   The signal encoding, Intel or Motorola, ::KvaDbSignalEncoding
+ * 
+ * \return ::kvaDbOK (zero) if success
+ * \return \ref kvaDbErr_xxx (negative) if failure
+ * 
+ * \sa kvaDbSetSignalEncoding()
+ */
+KvaDbStatus WINAPI kvaDbGetSignalEncoding(KvaDbSignalHnd sh, KvaDbSignalEncoding *e);
+
+/**
+ * Get the signal representation type.
+ * 
+ * \param[in]  sh  A signal handle
+ * \param[out] t   The signal representation type, ::KvaDbSignalType
+ * 
+ * \return ::kvaDbOK (zero) if success
+ * \return \ref kvaDbErr_xxx (negative) if failure
+ * 
+ * \sa kvaDbSetSignalRepresentationType()
+ */
+KvaDbStatus WINAPI kvaDbGetSignalRepresentationType(KvaDbSignalHnd sh, KvaDbSignalType *t);
+
+/**
+ * Get the signal representation type.
+ * 
+ * \note This function is deprecated and will be replaced by
+ * kvaDbGetSignalRepresentationType()
+ * 
+ * \param[in]  sh
+ * \param[out] t   The signal representation type, ::KvaDbSignalType
+ * 
+ * \return ::kvaDbOK (zero) if success
+ * \return \ref kvaDbErr_xxx (negative) if failure
+ * 
+ * \sa kvaDbSetSignalRepresentationType()
+ */
+KvaDbStatus WINAPI kvaDbGetSignalPresentationType(KvaDbSignalHnd sh, KvaDbSignalType *t);
+
+/**
+ * Add a new signal to a message.
+ * 
+ * \param[in]  mh  A message handle
+ * \param[out] sh  A handle to the new signal
+ * 
+ * \return ::kvaDbOK (zero) if success
+ * \return \ref kvaDbErr_xxx (negative) if failure
+ * 
+ * \sa kvaDbDeleteSignal()
+ */
+KvaDbStatus WINAPI kvaDbAddSignal(KvaDbMessageHnd mh, KvaDbSignalHnd *sh);
+
+/**
+ * Delete a signal from a message.
+ * 
+ * \param[in] mh  A message handle
+ * \param[in] sh  A handle to the signal to delete
+ * 
+ * \return ::kvaDbOK (zero) if success
+ * \return \ref kvaDbErr_xxx (negative) if failure
+ * 
+ * \sa kvaDbAddSignal()
+ */
+KvaDbStatus WINAPI kvaDbDeleteSignal(KvaDbMessageHnd mh, KvaDbSignalHnd sh);
+
+/**
+ * Set the value limits for a signal.
+ * 
+ * \param[in] sh      A signal handle
+ * \param[in] minval  The minimum signal value
+ * \param[in] maxval  The maximum signal value
+ * 
+ * \return ::kvaDbOK (zero) if success
+ * \return \ref kvaDbErr_xxx (negative) if failure
+ * 
+ * \sa kvaDbGetSignalValueLimits()
+ */
+KvaDbStatus WINAPI kvaDbSetSignalValueLimits(KvaDbSignalHnd sh, 
+                                             double minval, 
+                                             double maxval);
+
+/**
+ * Set the scale factor and offset for a signal.
+ * 
+ * \param[in] sh      A signal handle
+ * \param[in] factor  The scale factor for the signal value
+ * \param[in] offset  The offset for the signal value
+ * 
+ * \return ::kvaDbOK (zero) if success
+ * \return \ref kvaDbErr_xxx (negative) if failure
+ * 
+ * \sa kvaDbGetSignalValueScaling()
+ */
+KvaDbStatus WINAPI kvaDbSetSignalValueScaling(KvaDbSignalHnd sh, 
+                                              double factor, 
+                                              double offset);
+
+/**
+ * Set the value position and size for a signal.
+ * 
+ * \param[in] sh        A signal handle
+ * \param[in] startbit  The starting bit of the signal's value
+ * \param[in] length    The length of the value in bits
+ * 
+ * \return ::kvaDbOK (zero) if success
+ * \return \ref kvaDbErr_xxx (negative) if failure
+ * 
+ * \sa kvaDbGetSignalValueSize()
+ */
+KvaDbStatus WINAPI kvaDbSetSignalValueSize(KvaDbSignalHnd sh, 
+                                           int startbit, 
+                                           int length);
+
+/**
+ * Set the signal name.
+ * 
+ * \param[in] sh   A signal handle
+ * \param[in] buf  The buffer that contains the signal name
+ * 
+ * \return ::kvaDbOK (zero) if success
+ * \return \ref kvaDbErr_xxx (negative) if failure
+ * 
+ * \sa kvaDbGetSignalName()
+ */
+KvaDbStatus WINAPI kvaDbSetSignalName(KvaDbSignalHnd sh, char *buf);
+
+/**
+ * Set the signal comment.
+ * 
+ * \param[in] sh   A signal handle
+ * \param[in] buf  The buffer that contains the signal comment
+ * 
+ * \return ::kvaDbOK (zero) if success
+ * \return \ref kvaDbErr_xxx (negative) if failure
+ * 
+ * \sa kvaDbGetSignalComment()
+ */
+KvaDbStatus WINAPI kvaDbSetSignalComment(KvaDbSignalHnd sh, char *buf);
+
+/**
+ * Set the signal unit.
+ * 
+ * \param[in] sh   A signal handle
+ * \param[in] buf  The buffer that contains the unit for the signal
+ * 
+ * \return ::kvaDbOK (zero) if success
+ * \return \ref kvaDbErr_xxx (negative) if failure
+ * 
+ * \sa kvaDbGetSignalUnit()
+ */
+KvaDbStatus WINAPI kvaDbSetSignalUnit(KvaDbSignalHnd sh, char *buf);
+
+/**
+ * Set the signal encoding.
+ * 
+ * \param[in] sh  A signal handle
+ * \param[in] e   The signal encoding, Intel or Motorola, ::KvaDbSignalEncoding
+ * 
+ * \return ::kvaDbOK (zero) if success
+ * \return \ref kvaDbErr_xxx (negative) if failure
+ * 
+ * \sa kvaDbGetSignalEncoding()
+ */
+KvaDbStatus WINAPI kvaDbSetSignalEncoding(KvaDbSignalHnd sh, KvaDbSignalEncoding e);
+
+/**
+ * Set the signal representation type.
+ * 
+ * \param[in] sh  A signal handle
+ * \param[in] t   The signal representation type, ::KvaDbSignalType
+ * 
+ * \return ::kvaDbOK (zero) if success
+ * \return \ref kvaDbErr_xxx (negative) if failure
+ * 
+ * \sa kvaDbGetSignalRepresentationType()
+ */
+KvaDbStatus WINAPI kvaDbSetSignalRepresentationType(KvaDbSignalHnd sh, KvaDbSignalType t);
+
+/**
+ * Get the first node.
+ * 
+ * \param[in]  dh  A database handle
+ * \param[out] nh  A node handle
+ * 
+ * \return ::kvaDbOK (zero) if success
+ * \return \ref kvaDbErr_xxx (negative) if failure
+ * 
+ * \sa kvaDbGetNextNode()
+ */
+KvaDbStatus WINAPI kvaDbGetFirstNode(KvaDbHnd dh, KvaDbNodeHnd *nh);
+
+/**
+ * Get the next node. Should be called after kvaDbGetFirstNode().
+ * 
+ * \param[in]  dh  A database handle
+ * \param[out] nh  A handle to the next node
+ * 
+ * \return ::kvaDbOK (zero) if success
+ * \return \ref kvaDbErr_xxx (negative) if failure
+ * 
+ * \sa kvaDbGetNodeByName()
+ */
+KvaDbStatus WINAPI kvaDbGetNextNode(KvaDbHnd dh, KvaDbNodeHnd *nh);
+
+/**
+ * Get a node by seaching for the node's name.
+ * 
+ * \param[in]  dh         A database handle
+ * \param[in]  node_name  The buffer that contains the node name to search for
+ * \param[out] nh         A node handle
+ * 
+ * \return ::kvaDbOK (zero) if success
+ * \return \ref kvaDbErr_xxx (negative) if failure
+ * 
+ * \sa kvaDbGetNodeAttributeIntByName()
+ */
+KvaDbStatus WINAPI kvaDbGetNodeByName(KvaDbHnd dh, const char *node_name, KvaDbNodeHnd *nh);
+
+/**
+ * Get the value of a node attribute as an integer.
+ * 
+ * \param[in]  nh        A node handle
+ * \param[in]  attrName  The buffer that contains the attribute name
+ * \param[out] val       The value of the attribute
+ * 
+ * \return ::kvaDbOK (zero) if success
+ * \return \ref kvaDbErr_xxx (negative) if failure
+ * 
+ * \sa kvaDbGetFirstNode()
+ */
+KvaDbStatus WINAPI kvaDbGetNodeAttributeIntByName(KvaDbNodeHnd nh, const char *attrName, int *val);
+
+/**
+ * Add a new node to a database.
+ * 
+ * \param[in]  dh  A database handle
+ * \param[out] nh  A handle to the new node
+ * 
+ * \return ::kvaDbOK (zero) if success
+ * \return \ref kvaDbErr_xxx (negative) if failure
+ */
+KvaDbStatus WINAPI kvaDbAddNode(KvaDbHnd dh, KvaDbNodeHnd *nh);
+
+/**
+ * Delete a node from a database.
+ * 
+ * \param[in] dh  A database handle
+ * \param[in] nh  A handle to the node that will be deleted
+ * 
+ * \return ::kvaDbOK (zero) if success
+ * \return \ref kvaDbErr_xxx (negative) if failure
+ */
+KvaDbStatus WINAPI kvaDbDeleteNode(KvaDbHnd dh, KvaDbNodeHnd nh);
+
+/**
+ * Set the node name.
+ * 
+ * \param[in] nh   A node handle
+ * \param[in] buf  The buffer that contains the node name
+ * 
+ * \return ::kvaDbOK (zero) if success
+ * \return \ref kvaDbErr_xxx (negative) if failure
+ */
+KvaDbStatus WINAPI kvaDbSetNodeName(KvaDbNodeHnd nh, char *buf);
+
+/**
+ * Get the node name.
+ * 
+ * \param[in] nh   A node handle
+ * \param[out] buf  The buffer that will contain the node name
+ * \param[in] buflen  The length of the data buffer
+ * 
+ * \return ::kvaDbOK (zero) if success
+ * \return \ref kvaDbErr_xxx (negative) if failure
+ */
+KvaDbStatus WINAPI kvaDbGetNodeName(KvaDbNodeHnd nh, char *buf, size_t buflen);
+
+/**
+ * Set the node comment.
+ * 
+ * \param[in] nh   A node handle
+ * \param[in] buf  The buffer that contains the node comment
+ * 
+ * \return ::kvaDbOK (zero) if success
+ * \return \ref kvaDbErr_xxx (negative) if failure
+ */
+KvaDbStatus WINAPI kvaDbSetNodeComment(KvaDbNodeHnd nh, char *buf);
+
+/**
+ * Add a receiving node to a signal.
+ * 
+ * \param[in] sh   A signal handle
+ * \param[in] nh   A node handle
+ * 
+ * \return ::kvaDbOK (zero) if success
+ * \return \ref kvaDbErr_xxx (negative) if failure
+ */
+KvaDbStatus WINAPI kvaDbAddReceiveNodeToSignal(KvaDbSignalHnd sh, KvaDbNodeHnd nh);
+
+/**
+ * Remove a receiving node from a signal.
+ * 
+ * \param[in] sh   A signal handle
+ * \param[in] nh   A node handle
+ * 
+ * \return ::kvaDbOK (zero) if success
+ * \return \ref kvaDbErr_xxx (negative) if failure
+ */
+KvaDbStatus WINAPI kvaDbRemoveReceiveNodeFromSignal(KvaDbSignalHnd sh, KvaDbNodeHnd nh);
+
+/**
+ * Convert a physical signal value to data bytes.
+ * 
+ * \param[in]  sh        A signal handle
+ * \param[out] can_data  The buffer that will hold the converted value
+ * \param[in]  dlc       The length of the data buffer
+ * \param[in]  value     The physical signal value to convert
+ * 
+ * \return ::kvaDbOK (zero) if success
+ * \return \ref kvaDbErr_xxx (negative) if failure
+ * 
+ * \sa kvaDbGetSignalValueFloat()
+ */
+KvaDbStatus WINAPI kvaDbStoreSignalValuePhys(KvaDbSignalHnd sh, unsigned char *can_data, int dlc, double value);
+
+/**
+ * Convert a raw signal value to data bytes.
+ * 
+ * \param[in]  sh        A signal handle
+ * \param[out] can_data  The buffer that will hold the converted value
+ * \param[in]  dlc       The length of the data buffer
+ * \param[in]  value     The raw signal value to convert
+ * 
+ * \return ::kvaDbOK (zero) if success
+ * \return \ref kvaDbErr_xxx (negative) if failure
+ * 
+ * \sa kvaDbGetSignalValueInteger()
+ */
+KvaDbStatus WINAPI kvaDbStoreSignalValueRaw(KvaDbSignalHnd sh, unsigned char *can_data, int dlc, int value);
+
+/**
+ * Get a handle to the first attribute defined in the database.
+ *
+ * \param[in]  dh   A handle to a database
+ * \param[out] adh  An attribute definition handle
+ *
+ * \return ::kvaDbOK (zero) if success
+ * \return \ref kvaDbErr_xxx (negative) if failure
+ *
+ * \sa kvaDbGetNextAttributeDefinition()
+ */
+KvaDbStatus WINAPI kvaDbGetFirstAttributeDefinition(KvaDbHnd dh, KvaDbAttributeDefHnd *adh);
+
+/**
+ * Get a handle to an attribute definition with specified name.
+ *
+ * \param[in]  dh   A handle to a database
+ * \param[in]  attrName  The attribute name to search for
+ * \param[out] adh  An attribute definition handle
+ *
+ * \return ::kvaDbOK (zero) if success
+ * \return \ref kvaDbErr_xxx (negative) if failure
+ */
+KvaDbStatus WINAPI kvaDbGetAttributeDefinitionByName(KvaDbHnd dh, const char *attrName, KvaDbAttributeDefHnd *adh);
+
+/**
+ * Get a handle to the following attribute defined.
+ *
+ * \param[in]  adh   A handle to an attribute definition database
+ * \param[out] nadh  An attribute definition handle
+ *
+ * \return ::kvaDbOK (zero) if success
+ * \return \ref kvaDbErr_xxx (negative) if failure
+ *
+ * \sa kvaDbGetFirstAttributeDefinition()
+ */
+KvaDbStatus WINAPI kvaDbGetNextAttributeDefinition(KvaDbAttributeDefHnd adh, KvaDbAttributeDefHnd *nadh);
+
+/**
+ * Get the type for an attribute definition.
+ *
+ * \param[in]  adh   A handle to an attribute definition
+ * \param[out] at    The type of the attribute definition
+ *
+ * \return ::kvaDbOK (zero) if success
+ * \return \ref kvaDbErr_xxx (negative) if failure
+ *
+ * \sa kvaDbGetAttributeDefinitionOwner()
+ */
+KvaDbStatus WINAPI kvaDbGetAttributeDefinitionType(KvaDbAttributeDefHnd adh, KvaDbAttributeType *at);
+
+/**
+ * Get the type for an attribute definition.
+ *
+ * \param[in]  adh   A handle to an attribute definition
+ * \param[out] ao    The owner of the attribute definition
+ *
+ * \return ::kvaDbOK (zero) if success
+ * \return \ref kvaDbErr_xxx (negative) if failure
+ *
+ * \sa kvaDbGetAttributeDefinitionType()
+ */
+KvaDbStatus WINAPI kvaDbGetAttributeDefinitionOwner(KvaDbAttributeDefHnd adh, KvaDbAttributeOwner *ao);
+
+/**
+ * Get the name for an attribute definition.
+ *
+ * \param[in]  adh     A handle to an attribute
+ * \param[out] buf     The buffer that will hold the attribute name
+ * \param[in]  buflen  The length of the buffer.
+ *
+ * \return ::kvaDbOK (zero) if success
+ * \return \ref kvaDbErr_xxx (negative) if failure
+ *
+ * \sa kvaDbGetAttributeDefinitionType()
+ */
+KvaDbStatus WINAPI kvaDbGetAttributeDefinitionName(KvaDbAttributeDefHnd adh, char *buf, size_t buflen);
+
+/**
+ * Get the values for an attribute definition of type integer.
+ *
+ * \param[in]  adh   A handle to an attribute definition
+ * \param[out] def   The default value of the attribute definition
+ * \param[out] min   The min value of the attribute definition
+ * \param[out] max   The max value of the attribute definition
+ *
+ * \return ::kvaDbOK (zero) if success
+ * \return \ref kvaDbErr_xxx (negative) if failure
+ */
+KvaDbStatus WINAPI kvaDbGetAttributeDefinitionInt(KvaDbAttributeDefHnd adh, int *def, int *min, int *max);
+
+/**
+ * Get the values for an attribute definition of type float.
+ *
+ * \param[in]  adh   A handle to an attribute definition
+ * \param[out] def   The default value of the attribute definition
+ * \param[out] min   The min value of the attribute definition
+ * \param[out] max   The max value of the attribute definition
+ *
+ * \return ::kvaDbOK (zero) if success
+ * \return \ref kvaDbErr_xxx (negative) if failure
+ */
+KvaDbStatus WINAPI kvaDbGetAttributeDefinitionFloat(KvaDbAttributeDefHnd adh, float *def, float *min, float *max);
+
+/**
+ * Get the value for an attribute definition of type string.
+ *
+ * \param[in]  adh     A handle to an attribute definition
+ * \param[out] buf     The buffer that holds the default value of the attribute
+ * \param[out] buflen  The length of the buffer.
+ *
+ * \return ::kvaDbOK (zero) if success
+ * \return \ref kvaDbErr_xxx (negative) if failure
+ */
+KvaDbStatus WINAPI kvaDbGetAttributeDefinitionString(KvaDbAttributeDefHnd adh, char *buf, int buflen);
+
+/**
+ * Get the value for an attribute definition of type enumeration.
+ *
+ * \param[in]  adh   A handle to an attribute definition
+ * \param[out] def   The default value of the attribute definition
+ *
+ * \return ::kvaDbOK (zero) if success
+ * \return \ref kvaDbErr_xxx (negative) if failure
+ */
+KvaDbStatus WINAPI kvaDbGetAttributeDefinitionEnumeration(KvaDbAttributeDefHnd adh, int *def);
+
+/**
+ * Add an attribute to a message.
+ *
+ * \param[in]  mh    A handle to a message
+ * \param[in]  adh   A handle to an attribute definition
+ * \param[out] ah    An attribute handle
+ *
+ * \return ::kvaDbOK (zero) if success
+ * \return \ref kvaDbErr_xxx (negative) if failure
+ *
+ * \sa kvaDbDeleteMsgAttribute()
+ */
+KvaDbStatus WINAPI kvaDbAddMsgAttribute(KvaDbMessageHnd mh, KvaDbAttributeDefHnd adh, KvaDbAttributeHnd *ah);
+
+/**
+ * Delete an attribute from a message.
+ *
+ * \param[in]  mh    A handle to a message
+ * \param[in]  ah    A handle to an attribute
+ *
+ * \return ::kvaDbOK (zero) if success
+ * \return \ref kvaDbErr_xxx (negative) if failure
+ *
+ * \sa kvaDbAddMsgAttribute()
+ */
+KvaDbStatus WINAPI kvaDbDeleteMsgAttribute(KvaDbMessageHnd mh, KvaDbAttributeHnd ah);
+
+/**
+ * Add an attribute to a signal.
+ *
+ * \param[in]  sh    A handle to a signal
+ * \param[in]  adh   A handle to an attribute definition
+ * \param[out] ah    An attribute handle
+ *
+ * \return ::kvaDbOK (zero) if success
+ * \return \ref kvaDbErr_xxx (negative) if failure
+ *
+ * \sa kvaDbDeleteSignalAttribute()
+ */
+KvaDbStatus WINAPI kvaDbAddSignalAttribute(KvaDbSignalHnd sh, KvaDbAttributeDefHnd adh, KvaDbAttributeHnd *ah);
+
+/**
+ * Delete an attribute from a signal.
+ *
+ * \param[in]  sh    A handle to a signal
+ * \param[in]  ah    A handle to an attribute
+ *
+ * \return ::kvaDbOK (zero) if success
+ * \return \ref kvaDbErr_xxx (negative) if failure
+ *
+ * \sa kvaDbAddSignalAttribute()
+ */
+KvaDbStatus WINAPI kvaDbDeleteSignalAttribute(KvaDbSignalHnd sh, KvaDbAttributeHnd ah);
+
+/**
+ * Add an attribute to a signal.
+ *
+ * \param[in]  nh    A handle to a node
+ * \param[in]  adh   A handle to an attribute definition
+ * \param[out] ah    An attribute handle
+ *
+ * \return ::kvaDbOK (zero) if success
+ * \return \ref kvaDbErr_xxx (negative) if failure
+ *
+ * \sa kvaDbDeleteNodeAttribute()
+ */
+KvaDbStatus WINAPI kvaDbAddNodeAttribute(KvaDbNodeHnd nh, KvaDbAttributeDefHnd adh, KvaDbAttributeHnd *ah);
+
+/**
+ * Delete an attribute from a signal.
+ *
+ * \param[in]  nh    A handle to a node
+ * \param[in]  ah    A handle to an attribute
+ *
+ * \return ::kvaDbOK (zero) if success
+ * \return \ref kvaDbErr_xxx (negative) if failure
+ *
+ * \sa kvaDbAddNodeAttribute()
+ */
+KvaDbStatus WINAPI kvaDbDeleteNodeAttribute(KvaDbNodeHnd nh, KvaDbAttributeHnd ah);
+
+/**
+ * Get a handle to the first attribute for a message.
+ *
+ * \param[in]  mh   A handle to a message
+ * \param[out] ah   An attribute definition handle
+ *
+ * \return ::kvaDbOK (zero) if success
+ * \return \ref kvaDbErr_xxx (negative) if failure
+ *
+ * \sa kvaDbGetNextAttribute()
+ */
+KvaDbStatus WINAPI kvaDbGetFirstMsgAttribute(KvaDbMessageHnd mh, KvaDbAttributeHnd *ah);
+
+/**
+ * Get a handle to an attribute with specified name for a message.
+ *
+ * \param[in]  mh   A handle to a message
+ * \param[in]  attrName  The attribute name to search for
+ * \param[out] ah  An attribute definition handle
+ *
+ * \return ::kvaDbOK (zero) if success
+ * \return \ref kvaDbErr_xxx (negative) if failure
+ */
+KvaDbStatus WINAPI kvaDbGetMsgAttributeByName(KvaDbMessageHnd mh, const char *attrName, KvaDbAttributeHnd *ah);
+
+/**
+ * Get a handle to the first attribute for a signal.
+ *
+ * \param[in]  sh   A handle to a signal
+ * \param[out] ah   An attribute definition handle
+ *
+ * \return ::kvaDbOK (zero) if success
+ * \return \ref kvaDbErr_xxx (negative) if failure
+ *
+ * \sa kvaDbGetNextAttribute()
+ */
+KvaDbStatus WINAPI kvaDbGetFirstSignalAttribute(KvaDbSignalHnd sh, KvaDbAttributeHnd *ah);
+
+/**
+ * Get a handle to an attribute with specified name for a signal.
+ *
+ * \param[in]  sh   A handle to a signal
+ * \param[in]  attrName  The attribute name to search for
+ * \param[out] ah  An attribute definition handle
+ *
+ * \return ::kvaDbOK (zero) if success
+ * \return \ref kvaDbErr_xxx (negative) if failure
+ */
+KvaDbStatus WINAPI kvaDbGetSignalAttributeByName(KvaDbSignalHnd sh, const char *attrName, KvaDbAttributeHnd *ah);
+
+/**
+ * Get a handle to the first attribute for a node.
+ *
+ * \param[in]  nh   A handle to a node
+ * \param[out] ah   An attribute definition handle
+ *
+ * \return ::kvaDbOK (zero) if success
+ * \return \ref kvaDbErr_xxx (negative) if failure
+ *
+ * \sa kvaDbGetNextAttribute()
+ */
+KvaDbStatus WINAPI kvaDbGetFirstNodeAttribute(KvaDbNodeHnd nh, KvaDbAttributeHnd *ah);
+
+/**
+ * Get a handle to an attribute with specified name for a node.
+ *
+ * \param[in]  nh   A handle to a node
+ * \param[in]  attrName  The attribute name to search for
+ * \param[out] ah  An attribute definition handle
+ *
+ * \return ::kvaDbOK (zero) if success
+ * \return \ref kvaDbErr_xxx (negative) if failure
+ */
+KvaDbStatus WINAPI kvaDbGetNodeAttributeByName(KvaDbNodeHnd nh, const char *attrName, KvaDbAttributeHnd *ah);
+
+/**
+ * Get a handle to the following attribute.
+ *
+ * \param[in]  ah    A handle to an attribute
+ * \param[out] nah   An attribute handle
+ *
+ * \return ::kvaDbOK (zero) if success
+ * \return \ref kvaDbErr_xxx (negative) if failure
+ *
+ * \sa kvaDbGetFirstMsgAttribute()
+ * \sa kvaDbGetFirstSignalAttribute()
+ * \sa kvaDbGetFirstNodeAttribute()
+ */
+KvaDbStatus WINAPI kvaDbGetNextAttribute(KvaDbAttributeHnd ah, KvaDbAttributeHnd *nah);
+
+/**
+ * Get the type for an attribute.
+ *
+ * \param[in]  ah   A handle to an attribute
+ * \param[out] at   The type of the attribute
+ *
+ * \return ::kvaDbOK (zero) if success
+ * \return \ref kvaDbErr_xxx (negative) if failure
+ *
+ * \sa kvaDbGetAttributeName()
+ */
+KvaDbStatus WINAPI kvaDbGetAttributeType(KvaDbAttributeHnd ah, KvaDbAttributeType *at);
+
+/**
+ * Get the name for an attribute.
+ *
+ * \param[in]  ah      A handle to an attribute
+ * \param[out] buf     The buffer that will hold the attribute name
+ * \param[in]  buflen  The length of the buffer.
+ *
+ * \return ::kvaDbOK (zero) if success
+ * \return \ref kvaDbErr_xxx (negative) if failure
+ *
+ * \sa kvaDbGetAttributeType()
+ */
+KvaDbStatus WINAPI kvaDbGetAttributeName(KvaDbAttributeHnd adh, char *buf, size_t buflen);
+
+/**
+ * Set the value for an attribute of type integer.
+ *
+ * \param[in]  ah   A handle to an attribute
+ * \param[in]  val  The value to set
+ *
+ * \return ::kvaDbOK (zero) if success
+ * \return \ref kvaDbErr_xxx (negative) if failure
+ *
+ * \sa kvaDbGetAttributeValueInt()
+ */
+KvaDbStatus WINAPI kvaDbSetAttributeValueInt(KvaDbAttributeHnd ah, int val);
+
+/**
+ * Get the value for an attribute of type integer.
+ *
+ * \param[in]  ah   A handle to an attribute
+ * \param[out] val  The value of the attribute
+ *
+ * \return ::kvaDbOK (zero) if success
+ * \return \ref kvaDbErr_xxx (negative) if failure
+ *
+ * \sa kvaDbSetAttributeValueInt()
+ */
+KvaDbStatus WINAPI kvaDbGetAttributeValueInt(KvaDbAttributeHnd ah, int *val);
+
+/**
+ * Set the value for an attribute of type float.
+ *
+ * \param[in]  ah   A handle to an attribute
+ * \param[in]  val  The value to set
+ *
+ * \return ::kvaDbOK (zero) if success
+ * \return \ref kvaDbErr_xxx (negative) if failure
+ *
+ * \sa kvaDbGetAttributeValueFloat()
+ */
+KvaDbStatus WINAPI kvaDbSetAttributeValueFloat(KvaDbAttributeHnd ah, float val);
+
+/**
+ * Get the value for an attribute of type float.
+ *
+ * \param[in]  ah   A handle to an attribute
+ * \param[out] val  The value of the attribute
+ *
+ * \return ::kvaDbOK (zero) if success
+ * \return \ref kvaDbErr_xxx (negative) if failure
+ *
+ * \sa kvaDbSetAttributeValueFloat()
+ */
+KvaDbStatus WINAPI kvaDbGetAttributeValueFloat(KvaDbAttributeHnd ah, float *val);
+
+/**
+ * Set the value for an attribute of type string.
+ *
+ * \param[in]  ah   A handle to an attribute
+ * \param[in] buf     The buffer that holds the attribute value
+ * \param[in]  buflen  The length of the buffer.
+ *
+ * \return ::kvaDbOK (zero) if success
+ * \return \ref kvaDbErr_xxx (negative) if failure
+ *
+ * \sa kvaDbGetAttributeValueString()
+ */
+KvaDbStatus WINAPI kvaDbSetAttributeValueString(KvaDbAttributeHnd ah, const char *buf, int buflen);
+
+/**
+ * Get the value for an attribute of type string.
+ *
+ * \param[in]  ah   A handle to an attribute
+ * \param[out] buf     The buffer that holds the attribute value
+ * \param[out]  buflen  The length of the buffer.
+ *
+ * \return ::kvaDbOK (zero) if success
+ * \return \ref kvaDbErr_xxx (negative) if failure
+ *
+ * \sa kvaDbSetAttributeValueString()
+ */
+KvaDbStatus WINAPI kvaDbGetAttributeValueString(KvaDbAttributeHnd ah, char *buf, size_t buflen);
+
+/**
+ * Set the value for an attribute of type enumeration.
+ *
+ * \param[in]  ah   A handle to an attribute
+ * \param[in]  val  The value to set
+ *
+ * \return ::kvaDbOK (zero) if success
+ * \return \ref kvaDbErr_xxx (negative) if failure
+ *
+ * \sa kvaDbGetAttributeValueEnumeration()
+ */
+KvaDbStatus WINAPI kvaDbSetAttributeValueEnumeration(KvaDbAttributeHnd ah, int val);
+
+/**
+ * Get the value for an attribute of type enumeration.
+ *
+ * \param[in]  ah   A handle to an attribute
+ * \param[out] val  The value of the attribute
+ *
+ * \return ::kvaDbOK (zero) if success
+ * \return \ref kvaDbErr_xxx (negative) if failure
+ *
+ * \sa kvaDbSetAttributeValueEnumeration()
+ */
+KvaDbStatus WINAPI kvaDbGetAttributeValueEnumeration(KvaDbAttributeHnd ah, int *val);
+
+
+
+#ifdef __cplusplus
+}
+#endif
+
+/** @} */
+
+#endif //KVADBLIB_H
Index: trunk/CanGateway/driver/kvaser/windows/kvaser_stdint.h
===================================================================
--- trunk/CanGateway/driver/kvaser/windows/kvaser_stdint.h	(revision 93)
+++ trunk/CanGateway/driver/kvaser/windows/kvaser_stdint.h	(revision 93)
@@ -0,0 +1,803 @@
+/*  A portable stdint.h
+ ****************************************************************************
+ *  BSD License:
+ ****************************************************************************
+ *
+ *  Copyright (c) 2005-2007 Paul Hsieh
+ *  All rights reserved.
+ *  
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions
+ *  are met:
+ *  
+ *  1. Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *  2. Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *  3. The name of the author may not be used to endorse or promote products
+ *     derived from this software without specific prior written permission.
+ *  
+ *  THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ *  IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ *  OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ *  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ *  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ *  THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ ****************************************************************************
+ *
+ *  Version 0.1.11
+ *
+ *  The ANSI C standard committee, for the C99 standard, specified the
+ *  inclusion of a new standard include file called stdint.h.  This is
+ *  a very useful and long desired include file which contains several
+ *  very precise definitions for integer scalar types that is
+ *  critically important for making portable several classes of
+ *  applications including cryptography, hashing, variable length
+ *  integer libraries and so on.  But for most developers its likely
+ *  useful just for programming sanity.
+ *
+ *  The problem is that most compiler vendors have decided not to
+ *  implement the C99 standard, and the next C++ language standard
+ *  (which has a lot more mindshare these days) will be a long time in
+ *  coming and its unknown whether or not it will include stdint.h or
+ *  how much adoption it will have.  Either way, it will be a long time
+ *  before all compilers come with a stdint.h and it also does nothing
+ *  for the extremely large number of compilers available today which
+ *  do not include this file, or anything comparable to it.
+ *
+ *  So that's what this file is all about.  Its an attempt to build a
+ *  single universal include file that works on as many platforms as
+ *  possible to deliver what stdint.h is supposed to.  A few things
+ *  that should be noted about this file:
+ *
+ *    1) It is not guaranteed to be portable and/or present an identical
+ *       interface on all platforms.  The extreme variability of the
+ *       ANSI C standard makes this an impossibility right from the
+ *       very get go. Its really only meant to be useful for the vast
+ *       majority of platforms that possess the capability of
+ *       implementing usefully and precisely defined, standard sized
+ *       integer scalars.  Systems which are not intrinsically 2s
+ *       complement may produce invalid constants.
+ *
+ *    2) There is an unavoidable use of non-reserved symbols.
+ *
+ *    3) Other standard include files are invoked.
+ *
+ *    4) This file may come in conflict with future platforms that do
+ *       include stdint.h.  The hope is that one or the other can be
+ *       used with no real difference.
+ *
+ *    5) In the current verison, if your platform can't represent
+ *       int32_t, int16_t and int8_t, it just dumps out with a compiler
+ *       error.
+ *
+ *    6) 64 bit integers may or may not be defined.  Test for their
+ *       presence with the test: #ifdef INT64_MAX or #ifdef UINT64_MAX.
+ *       Note that this is different from the C99 specification which
+ *       requires the existence of 64 bit support in the compiler.  If
+ *       this is not defined for your platform, yet it is capable of
+ *       dealing with 64 bits then it is because this file has not yet
+ *       been extended to cover all of your system's capabilities.
+ *
+ *    7) (u)intptr_t may or may not be defined.  Test for its presence
+ *       with the test: #ifdef PTRDIFF_MAX.  If this is not defined
+ *       for your platform, then it is because this file has not yet
+ *       been extended to cover all of your system's capabilities, not
+ *       because its optional.
+ *
+ *    8) The following might not been defined even if your platform is
+ *       capable of defining it:
+ *
+ *       WCHAR_MIN
+ *       WCHAR_MAX
+ *       (u)int64_t
+ *       PTRDIFF_MIN
+ *       PTRDIFF_MAX
+ *       (u)intptr_t
+ *
+ *    9) The following have not been defined:
+ *
+ *       WINT_MIN
+ *       WINT_MAX
+ *
+ *   10) The criteria for defining (u)int_least(*)_t isn't clear,
+ *       except for systems which don't have a type that precisely
+ *       defined 8, 16, or 32 bit types (which this include file does
+ *       not support anyways). Default definitions have been given.
+ *
+ *   11) The criteria for defining (u)int_fast(*)_t isn't something I
+ *       would trust to any particular compiler vendor or the ANSI C
+ *       committee.  It is well known that "compatible systems" are
+ *       commonly created that have very different performance
+ *       characteristics from the systems they are compatible with,
+ *       especially those whose vendors make both the compiler and the
+ *       system.  Default definitions have been given, but its strongly
+ *       recommended that users never use these definitions for any
+ *       reason (they do *NOT* deliver any serious guarantee of
+ *       improved performance -- not in this file, nor any vendor's
+ *       stdint.h).
+ *
+ *   12) The following macros:
+ *
+ *       PRINTF_INTMAX_MODIFIER
+ *       PRINTF_INT64_MODIFIER
+ *       PRINTF_INT32_MODIFIER
+ *       PRINTF_INT16_MODIFIER
+ *       PRINTF_LEAST64_MODIFIER
+ *       PRINTF_LEAST32_MODIFIER
+ *       PRINTF_LEAST16_MODIFIER
+ *       PRINTF_INTPTR_MODIFIER
+ *
+ *       are strings which have been defined as the modifiers required
+ *       for the "d", "u" and "x" printf formats to correctly output
+ *       (u)intmax_t, (u)int64_t, (u)int32_t, (u)int16_t, (u)least64_t,
+ *       (u)least32_t, (u)least16_t and (u)intptr_t types respectively.
+ *       PRINTF_INTPTR_MODIFIER is not defined for some systems which
+ *       provide their own stdint.h.  PRINTF_INT64_MODIFIER is not
+ *       defined if INT64_MAX is not defined.  These are an extension
+ *       beyond what C99 specifies must be in stdint.h.
+ *
+ *       In addition, the following macros are defined:
+ *
+ *       PRINTF_INTMAX_HEX_WIDTH
+ *       PRINTF_INT64_HEX_WIDTH
+ *       PRINTF_INT32_HEX_WIDTH
+ *       PRINTF_INT16_HEX_WIDTH
+ *       PRINTF_INT8_HEX_WIDTH
+ *       PRINTF_INTMAX_DEC_WIDTH
+ *       PRINTF_INT64_DEC_WIDTH
+ *       PRINTF_INT32_DEC_WIDTH
+ *       PRINTF_INT16_DEC_WIDTH
+ *       PRINTF_INT8_DEC_WIDTH
+ *
+ *       Which specifies the maximum number of characters required to
+ *       print the number of that type in either hexadecimal or decimal.
+ *       These are an extension beyond what C99 specifies must be in
+ *       stdint.h.
+ *
+ *  Compilers tested (all with 0 warnings at their highest respective
+ *  settings): Borland Turbo C 2.0, WATCOM C/C++ 11.0 (16 bits and 32
+ *  bits), Microsoft Visual C++ 6.0 (32 bit), Microsoft Visual Studio
+ *  .net (VC7), Intel C++ 4.0, GNU gcc v3.3.3
+ *
+ *  This file should be considered a work in progress.  Suggestions for
+ *  improvements, especially those which increase coverage are strongly
+ *  encouraged.
+ *
+ *  Acknowledgements
+ *
+ *  The following people have made significant contributions to the
+ *  development and testing of this file:
+ *
+ *  Chris Howie
+ *  John Steele Scott
+ *  Dave Thorup
+ *
+ */
+
+#ifdef WIN32 
+
+#include <stddef.h>
+#include <limits.h>
+#include <signal.h>
+
+/*
+ *  For gcc with _STDINT_H, fill in the PRINTF_INT*_MODIFIER macros, and
+ *  do nothing else.  On the Mac OS X version of gcc this is _STDINT_H_.
+ */
+
+#if ((defined(__STDC__) && __STDC__ && __STDC_VERSION__ >= 199901L) || (defined (__WATCOMC__) && (defined (_STDINT_H_INCLUDED) || __WATCOMC__ >= 1250)) || (defined(__GNUC__) && (defined(_STDINT_H) || defined(_STDINT_H_)) )) && !defined (_PSTDINT_H_INCLUDED)
+#include <stdint.h>
+#define _PSTDINT_H_INCLUDED
+# ifndef PRINTF_INT64_MODIFIER
+#  define PRINTF_INT64_MODIFIER "ll"
+# endif
+# ifndef PRINTF_INT32_MODIFIER
+#  define PRINTF_INT32_MODIFIER "l"
+# endif
+# ifndef PRINTF_INT16_MODIFIER
+#  define PRINTF_INT16_MODIFIER "h"
+# endif
+# ifndef PRINTF_INTMAX_MODIFIER
+#  define PRINTF_INTMAX_MODIFIER PRINTF_INT64_MODIFIER
+# endif
+# ifndef PRINTF_INT64_HEX_WIDTH
+#  define PRINTF_INT64_HEX_WIDTH "16"
+# endif
+# ifndef PRINTF_INT32_HEX_WIDTH
+#  define PRINTF_INT32_HEX_WIDTH "8"
+# endif
+# ifndef PRINTF_INT16_HEX_WIDTH
+#  define PRINTF_INT16_HEX_WIDTH "4"
+# endif
+# ifndef PRINTF_INT8_HEX_WIDTH
+#  define PRINTF_INT8_HEX_WIDTH "2"
+# endif
+# ifndef PRINTF_INT64_DEC_WIDTH
+#  define PRINTF_INT64_DEC_WIDTH "20"
+# endif
+# ifndef PRINTF_INT32_DEC_WIDTH
+#  define PRINTF_INT32_DEC_WIDTH "10"
+# endif
+# ifndef PRINTF_INT16_DEC_WIDTH
+#  define PRINTF_INT16_DEC_WIDTH "5"
+# endif
+# ifndef PRINTF_INT8_DEC_WIDTH
+#  define PRINTF_INT8_DEC_WIDTH "3"
+# endif
+# ifndef PRINTF_INTMAX_HEX_WIDTH
+#  define PRINTF_INTMAX_HEX_WIDTH PRINTF_INT64_HEX_WIDTH
+# endif
+# ifndef PRINTF_INTMAX_DEC_WIDTH
+#  define PRINTF_INTMAX_DEC_WIDTH PRINTF_INT64_DEC_WIDTH
+# endif
+
+/*
+ *  Something really weird is going on with Open Watcom.  Just pull some of
+ *  these duplicated definitions from Open Watcom's stdint.h file for now.
+ */
+
+# if defined (__WATCOMC__) && __WATCOMC__ >= 1250
+#  if !defined (INT64_C)
+#   define INT64_C(x)   (x + (INT64_MAX - INT64_MAX))
+#  endif
+#  if !defined (UINT64_C)
+#   define UINT64_C(x)  (x + (UINT64_MAX - UINT64_MAX))
+#  endif
+#  if !defined (INT32_C)
+#   define INT32_C(x)   (x + (INT32_MAX - INT32_MAX))
+#  endif
+#  if !defined (UINT32_C)
+#   define UINT32_C(x)  (x + (UINT32_MAX - UINT32_MAX))
+#  endif
+#  if !defined (INT16_C)
+#   define INT16_C(x)   (x)
+#  endif
+#  if !defined (UINT16_C)
+#   define UINT16_C(x)  (x)
+#  endif
+#  if !defined (INT8_C)
+#   define INT8_C(x)   (x)
+#  endif
+#  if !defined (UINT8_C)
+#   define UINT8_C(x)  (x)
+#  endif
+#  if !defined (UINT64_MAX)
+#   define UINT64_MAX  18446744073709551615ULL
+#  endif
+#  if !defined (INT64_MAX)
+#   define INT64_MAX  9223372036854775807LL
+#  endif
+#  if !defined (UINT32_MAX)
+#   define UINT32_MAX  4294967295UL
+#  endif
+#  if !defined (INT32_MAX)
+#   define INT32_MAX  2147483647L
+#  endif
+#  if !defined (INTMAX_MAX)
+#   define INTMAX_MAX INT64_MAX
+#  endif
+#  if !defined (INTMAX_MIN)
+#   define INTMAX_MIN INT64_MIN
+#  endif
+# endif
+#endif
+
+#ifndef _PSTDINT_H_INCLUDED
+#define _PSTDINT_H_INCLUDED
+
+#ifndef SIZE_MAX
+# define SIZE_MAX (~(size_t)0)
+#endif
+
+/*
+ *  Deduce the type assignments from limits.h under the assumption that
+ *  integer sizes in bits are powers of 2, and follow the ANSI
+ *  definitions.
+ */
+
+#ifndef UINT8_MAX
+# define UINT8_MAX 0xff
+#endif
+#ifndef uint8_t
+# if (UCHAR_MAX == UINT8_MAX) || defined (S_SPLINT_S)
+    typedef unsigned char uint8_t;
+#   define UINT8_C(v) ((uint8_t) v)
+# else
+#   error "Platform not supported"
+# endif
+#endif
+
+#ifndef INT8_MAX
+# define INT8_MAX 0x7f
+#endif
+#ifndef INT8_MIN
+# define INT8_MIN INT8_C(0x80)
+#endif
+#ifndef int8_t
+# if (SCHAR_MAX == INT8_MAX) || defined (S_SPLINT_S)
+    typedef signed char int8_t;
+#   define INT8_C(v) ((int8_t) v)
+# else
+#   error "Platform not supported"
+# endif
+#endif
+
+#ifndef UINT16_MAX
+# define UINT16_MAX 0xffff
+#endif
+#ifndef uint16_t
+#if (UINT_MAX == UINT16_MAX) || defined (S_SPLINT_S)
+  typedef unsigned int uint16_t;
+# ifndef PRINTF_INT16_MODIFIER
+#  define PRINTF_INT16_MODIFIER ""
+# endif
+# define UINT16_C(v) ((uint16_t) (v))
+#elif (USHRT_MAX == UINT16_MAX)
+  typedef unsigned short uint16_t;
+# define UINT16_C(v) ((uint16_t) (v))
+# ifndef PRINTF_INT16_MODIFIER
+#  define PRINTF_INT16_MODIFIER "h"
+# endif
+#else
+#error "Platform not supported"
+#endif
+#endif
+
+#ifndef INT16_MAX
+# define INT16_MAX 0x7fff
+#endif
+#ifndef INT16_MIN
+# define INT16_MIN INT16_C(0x8000)
+#endif
+#ifndef int16_t
+#if (INT_MAX == INT16_MAX) || defined (S_SPLINT_S)
+  typedef signed int int16_t;
+# define INT16_C(v) ((int16_t) (v))
+# ifndef PRINTF_INT16_MODIFIER
+#  define PRINTF_INT16_MODIFIER ""
+# endif
+#elif (SHRT_MAX == INT16_MAX)
+  typedef signed short int16_t;
+# define INT16_C(v) ((int16_t) (v))
+# ifndef PRINTF_INT16_MODIFIER
+#  define PRINTF_INT16_MODIFIER "h"
+# endif
+#else
+#error "Platform not supported"
+#endif
+#endif
+
+#ifndef UINT32_MAX
+# define UINT32_MAX (0xffffffffUL)
+#endif
+#ifndef uint32_t
+#if (ULONG_MAX == UINT32_MAX) || defined (S_SPLINT_S)
+  typedef unsigned long uint32_t;
+# define UINT32_C(v) v ## UL
+# ifndef PRINTF_INT32_MODIFIER
+#  define PRINTF_INT32_MODIFIER "l"
+# endif
+#elif (UINT_MAX == UINT32_MAX)
+  typedef unsigned int uint32_t;
+# ifndef PRINTF_INT32_MODIFIER
+#  define PRINTF_INT32_MODIFIER ""
+# endif
+# define UINT32_C(v) v ## U
+#elif (USHRT_MAX == UINT32_MAX)
+  typedef unsigned short uint32_t;
+# define UINT32_C(v) ((unsigned short) (v))
+# ifndef PRINTF_INT32_MODIFIER
+#  define PRINTF_INT32_MODIFIER ""
+# endif
+#else
+#error "Platform not supported"
+#endif
+#endif
+
+#ifndef INT32_MAX
+# define INT32_MAX (0x7fffffffL)
+#endif
+#ifndef INT32_MIN
+# define INT32_MIN INT32_C(0x80000000)
+#endif
+#ifndef int32_t
+#if (LONG_MAX == INT32_MAX) || defined (S_SPLINT_S)
+  typedef signed long int32_t;
+# define INT32_C(v) v ## L
+# ifndef PRINTF_INT32_MODIFIER
+#  define PRINTF_INT32_MODIFIER "l"
+# endif
+#elif (INT_MAX == INT32_MAX)
+  typedef signed int int32_t;
+# define INT32_C(v) v
+# ifndef PRINTF_INT32_MODIFIER
+#  define PRINTF_INT32_MODIFIER ""
+# endif
+#elif (SHRT_MAX == INT32_MAX)
+  typedef signed short int32_t;
+# define INT32_C(v) ((short) (v))
+# ifndef PRINTF_INT32_MODIFIER
+#  define PRINTF_INT32_MODIFIER ""
+# endif
+#else
+#error "Platform not supported"
+#endif
+#endif
+
+/*
+ *  The macro stdint_int64_defined is temporarily used to record
+ *  whether or not 64 integer support is available.  It must be
+ *  defined for any 64 integer extensions for new platforms that are
+ *  added.
+ */
+
+#undef stdint_int64_defined
+#if (defined(__STDC__) && defined(__STDC_VERSION__)) || defined (S_SPLINT_S)
+# if (__STDC__ && __STDC_VERSION >= 199901L) || defined (S_SPLINT_S)
+#  define stdint_int64_defined
+   typedef long long int64_t;
+   typedef unsigned long long uint64_t;
+#  define UINT64_C(v) v ## ULL
+#  define  INT64_C(v) v ## LL
+#  ifndef PRINTF_INT64_MODIFIER
+#   define PRINTF_INT64_MODIFIER "ll"
+#  endif
+# endif
+#endif
+
+#if !defined (stdint_int64_defined)
+# if defined(__GNUC__)
+#  define stdint_int64_defined
+   __extension__ typedef long long int64_t;
+   __extension__ typedef unsigned long long uint64_t;
+#  define UINT64_C(v) v ## ULL
+#  define  INT64_C(v) v ## LL
+#  ifndef PRINTF_INT64_MODIFIER
+#   define PRINTF_INT64_MODIFIER "ll"
+#  endif
+# elif defined(__MWERKS__) || defined (__SUNPRO_C) || defined (__SUNPRO_CC) || defined (__APPLE_CC__) || defined (_LONG_LONG) || defined (_CRAYC) || defined (S_SPLINT_S)
+#  define stdint_int64_defined
+   typedef long long int64_t;
+   typedef unsigned long long uint64_t;
+#  define UINT64_C(v) v ## ULL
+#  define  INT64_C(v) v ## LL
+#  ifndef PRINTF_INT64_MODIFIER
+#   define PRINTF_INT64_MODIFIER "ll"
+#  endif
+# elif (defined(__WATCOMC__) && defined(__WATCOM_INT64__)) || (defined(_MSC_VER) && _INTEGRAL_MAX_BITS >= 64) || (defined (__BORLANDC__) && __BORLANDC__ > 0x460) || defined (__alpha) || defined (__DECC)
+#  define stdint_int64_defined
+   typedef __int64 int64_t;
+   typedef unsigned __int64 uint64_t;
+#  define UINT64_C(v) v ## UI64
+#  define  INT64_C(v) v ## I64
+#  ifndef PRINTF_INT64_MODIFIER
+#   define PRINTF_INT64_MODIFIER "I64"
+#  endif
+# endif
+#endif
+
+#if !defined (LONG_LONG_MAX) && defined (INT64_C)
+# define LONG_LONG_MAX INT64_C (9223372036854775807)
+#endif
+#ifndef ULONG_LONG_MAX
+# define ULONG_LONG_MAX UINT64_C (18446744073709551615)
+#endif
+
+#if !defined (INT64_MAX) && defined (INT64_C)
+# define INT64_MAX INT64_C (9223372036854775807)
+#endif
+#if !defined (INT64_MIN) && defined (INT64_C)
+# define INT64_MIN INT64_C (-9223372036854775808)
+#endif
+#if !defined (UINT64_MAX) && defined (INT64_C)
+# define UINT64_MAX UINT64_C (18446744073709551615)
+#endif
+
+/*
+ *  Width of hexadecimal for number field.
+ */
+
+#ifndef PRINTF_INT64_HEX_WIDTH
+# define PRINTF_INT64_HEX_WIDTH "16"
+#endif
+#ifndef PRINTF_INT32_HEX_WIDTH
+# define PRINTF_INT32_HEX_WIDTH "8"
+#endif
+#ifndef PRINTF_INT16_HEX_WIDTH
+# define PRINTF_INT16_HEX_WIDTH "4"
+#endif
+#ifndef PRINTF_INT8_HEX_WIDTH
+# define PRINTF_INT8_HEX_WIDTH "2"
+#endif
+
+#ifndef PRINTF_INT64_DEC_WIDTH
+# define PRINTF_INT64_DEC_WIDTH "20"
+#endif
+#ifndef PRINTF_INT32_DEC_WIDTH
+# define PRINTF_INT32_DEC_WIDTH "10"
+#endif
+#ifndef PRINTF_INT16_DEC_WIDTH
+# define PRINTF_INT16_DEC_WIDTH "5"
+#endif
+#ifndef PRINTF_INT8_DEC_WIDTH
+# define PRINTF_INT8_DEC_WIDTH "3"
+#endif
+
+/*
+ *  Ok, lets not worry about 128 bit integers for now.  Moore's law says
+ *  we don't need to worry about that until about 2040 at which point
+ *  we'll have bigger things to worry about.
+ */
+
+#ifdef stdint_int64_defined
+  typedef int64_t intmax_t;
+  typedef uint64_t uintmax_t;
+# define  INTMAX_MAX   INT64_MAX
+# define  INTMAX_MIN   INT64_MIN
+# define UINTMAX_MAX  UINT64_MAX
+# define UINTMAX_C(v) UINT64_C(v)
+# define  INTMAX_C(v)  INT64_C(v)
+# ifndef PRINTF_INTMAX_MODIFIER
+#   define PRINTF_INTMAX_MODIFIER PRINTF_INT64_MODIFIER
+# endif
+# ifndef PRINTF_INTMAX_HEX_WIDTH
+#  define PRINTF_INTMAX_HEX_WIDTH PRINTF_INT64_HEX_WIDTH
+# endif
+# ifndef PRINTF_INTMAX_DEC_WIDTH
+#  define PRINTF_INTMAX_DEC_WIDTH PRINTF_INT64_DEC_WIDTH
+# endif
+#else
+  typedef int32_t intmax_t;
+  typedef uint32_t uintmax_t;
+# define  INTMAX_MAX   INT32_MAX
+# define UINTMAX_MAX  UINT32_MAX
+# define UINTMAX_C(v) UINT32_C(v)
+# define  INTMAX_C(v)  INT32_C(v)
+# ifndef PRINTF_INTMAX_MODIFIER
+#   define PRINTF_INTMAX_MODIFIER PRINTF_INT32_MODIFIER
+# endif
+# ifndef PRINTF_INTMAX_HEX_WIDTH
+#  define PRINTF_INTMAX_HEX_WIDTH PRINTF_INT32_HEX_WIDTH
+# endif
+# ifndef PRINTF_INTMAX_DEC_WIDTH
+#  define PRINTF_INTMAX_DEC_WIDTH PRINTF_INT32_DEC_WIDTH
+# endif
+#endif
+
+/*
+ *  Because this file currently only supports platforms which have
+ *  precise powers of 2 as bit sizes for the default integers, the
+ *  least definitions are all trivial.  Its possible that a future
+ *  version of this file could have different definitions.
+ */
+
+#ifndef stdint_least_defined
+  typedef   int8_t   int_least8_t;
+  typedef  uint8_t  uint_least8_t;
+  typedef  int16_t  int_least16_t;
+  typedef uint16_t uint_least16_t;
+  typedef  int32_t  int_least32_t;
+  typedef uint32_t uint_least32_t;
+# define PRINTF_LEAST32_MODIFIER PRINTF_INT32_MODIFIER
+# define PRINTF_LEAST16_MODIFIER PRINTF_INT16_MODIFIER
+# define  UINT_LEAST8_MAX  UINT8_MAX
+# define   INT_LEAST8_MAX   INT8_MAX
+# define UINT_LEAST16_MAX UINT16_MAX
+# define  INT_LEAST16_MAX  INT16_MAX
+# define UINT_LEAST32_MAX UINT32_MAX
+# define  INT_LEAST32_MAX  INT32_MAX
+# define   INT_LEAST8_MIN   INT8_MIN
+# define  INT_LEAST16_MIN  INT16_MIN
+# define  INT_LEAST32_MIN  INT32_MIN
+# ifdef stdint_int64_defined
+    typedef  int64_t  int_least64_t;
+    typedef uint64_t uint_least64_t;
+#   define PRINTF_LEAST64_MODIFIER PRINTF_INT64_MODIFIER
+#   define UINT_LEAST64_MAX UINT64_MAX
+#   define  INT_LEAST64_MAX  INT64_MAX
+#   define  INT_LEAST64_MIN  INT64_MIN
+# endif
+#endif
+#undef stdint_least_defined
+
+/*
+ *  The ANSI C committee pretending to know or specify anything about
+ *  performance is the epitome of misguided arrogance.  The mandate of
+ *  this file is to *ONLY* ever support that absolute minimum
+ *  definition of the fast integer types, for compatibility purposes.
+ *  No extensions, and no attempt to suggest what may or may not be a
+ *  faster integer type will ever be made in this file.  Developers are
+ *  warned to stay away from these types when using this or any other
+ *  stdint.h.
+ */
+
+typedef   int_least8_t   int_fast8_t;
+typedef  uint_least8_t  uint_fast8_t;
+typedef  int_least16_t  int_fast16_t;
+typedef uint_least16_t uint_fast16_t;
+typedef  int_least32_t  int_fast32_t;
+typedef uint_least32_t uint_fast32_t;
+#define  UINT_FAST8_MAX  UINT_LEAST8_MAX
+#define   INT_FAST8_MAX   INT_LEAST8_MAX
+#define UINT_FAST16_MAX UINT_LEAST16_MAX
+#define  INT_FAST16_MAX  INT_LEAST16_MAX
+#define UINT_FAST32_MAX UINT_LEAST32_MAX
+#define  INT_FAST32_MAX  INT_LEAST32_MAX
+#define   INT_FAST8_MIN   INT_LEAST8_MIN
+#define  INT_FAST16_MIN  INT_LEAST16_MIN
+#define  INT_FAST32_MIN  INT_LEAST32_MIN
+#ifdef stdint_int64_defined
+  typedef  int_least64_t  int_fast64_t;
+  typedef uint_least64_t uint_fast64_t;
+# define UINT_FAST64_MAX UINT_LEAST64_MAX
+# define  INT_FAST64_MAX  INT_LEAST64_MAX
+# define  INT_FAST64_MIN  INT_LEAST64_MIN
+#endif
+
+#undef stdint_int64_defined
+
+/*
+ *  Whatever piecemeal, per compiler thing we can do about the wchar_t
+ *  type limits.
+ */
+
+#if defined(__WATCOMC__) || defined(_MSC_VER) || defined (__GNUC__)
+# include <wchar.h>
+# ifndef WCHAR_MIN
+#  define WCHAR_MIN 0
+# endif
+# ifndef WCHAR_MAX
+#  define WCHAR_MAX ((wchar_t)-1)
+# endif
+#endif
+
+/*
+ *  Whatever piecemeal, per compiler/platform thing we can do about the
+ *  (u)intptr_t types and limits.
+ */
+
+#if defined (_MSC_VER) && defined (_UINTPTR_T_DEFINED)
+# define STDINT_H_UINTPTR_T_DEFINED
+#endif
+
+#ifndef STDINT_H_UINTPTR_T_DEFINED
+# if defined (__alpha__) || defined (__ia64__) || defined (__x86_64__) || defined (_WIN64)
+#  define stdint_intptr_bits 64
+# elif defined (__WATCOMC__) || defined (__TURBOC__)
+#  if defined(__TINY__) || defined(__SMALL__) || defined(__MEDIUM__)
+#    define stdint_intptr_bits 16
+#  else
+#    define stdint_intptr_bits 32
+#  endif
+# elif defined (__i386__) || defined (_WIN32) || defined (WIN32)
+#  define stdint_intptr_bits 32
+# elif defined (__INTEL_COMPILER)
+/* TODO -- what will Intel do about x86-64? */
+# endif
+
+# ifdef stdint_intptr_bits
+#  define stdint_intptr_glue3_i(a,b,c)  a##b##c
+#  define stdint_intptr_glue3(a,b,c)    stdint_intptr_glue3_i(a,b,c)
+#  ifndef PRINTF_INTPTR_MODIFIER
+#    define PRINTF_INTPTR_MODIFIER      stdint_intptr_glue3(PRINTF_INT,stdint_intptr_bits,_MODIFIER)
+#  endif
+#  ifndef PTRDIFF_MAX
+#    define PTRDIFF_MAX                 stdint_intptr_glue3(INT,stdint_intptr_bits,_MAX)
+#  endif
+#  ifndef PTRDIFF_MIN
+#    define PTRDIFF_MIN                 stdint_intptr_glue3(INT,stdint_intptr_bits,_MIN)
+#  endif
+#  ifndef UINTPTR_MAX
+#    define UINTPTR_MAX                 stdint_intptr_glue3(UINT,stdint_intptr_bits,_MAX)
+#  endif
+#  ifndef INTPTR_MAX
+#    define INTPTR_MAX                  stdint_intptr_glue3(INT,stdint_intptr_bits,_MAX)
+#  endif
+#  ifndef INTPTR_MIN
+#    define INTPTR_MIN                  stdint_intptr_glue3(INT,stdint_intptr_bits,_MIN)
+#  endif
+#  ifndef INTPTR_C
+#    define INTPTR_C(x)                 stdint_intptr_glue3(INT,stdint_intptr_bits,_C)(x)
+#  endif
+#  ifndef UINTPTR_C
+#    define UINTPTR_C(x)                stdint_intptr_glue3(UINT,stdint_intptr_bits,_C)(x)
+#  endif
+  typedef stdint_intptr_glue3(uint,stdint_intptr_bits,_t) uintptr_t;
+  typedef stdint_intptr_glue3( int,stdint_intptr_bits,_t)  intptr_t;
+# else
+/* TODO -- This following is likely wrong for some platforms, and does
+   nothing for the definition of uintptr_t. */
+  typedef ptrdiff_t intptr_t;
+# endif
+# define STDINT_H_UINTPTR_T_DEFINED
+#endif
+
+/*
+ *  Assumes sig_atomic_t is signed and we have a 2s complement machine.
+ */
+
+#ifndef SIG_ATOMIC_MAX
+# define SIG_ATOMIC_MAX ((((sig_atomic_t) 1) << (sizeof (sig_atomic_t)*CHAR_BIT-1)) - 1)
+#endif
+
+#endif
+
+#if defined (__TEST_PSTDINT_FOR_CORRECTNESS)
+
+/* 
+ *  Please compile with the maximum warning settings to make sure macros are not
+ *  defined more than once.
+ */
+ 
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+ 
+#define glue3_aux(x,y,z) x ## y ## z
+#define glue3(x,y,z) glue3_aux(x,y,z)
+
+#define DECLU(bits) glue3(uint,bits,_t) glue3(u,bits,=) glue3(UINT,bits,_C) (0);
+#define DECLI(bits) glue3(int,bits,_t) glue3(i,bits,=) glue3(INT,bits,_C) (0);
+
+#define DECL(us,bits) glue3(DECL,us,) (bits)
+
+#define TESTUMAX(bits) glue3(u,bits,=) glue3(~,u,bits); if (glue3(UINT,bits,_MAX) glue3(!=,u,bits)) printf ("Something wrong with UINT%d_MAX\n", bits)
+ 
+int main () {
+	DECL(I,8)
+	DECL(U,8)
+	DECL(I,16)
+	DECL(U,16)
+	DECL(I,32)
+	DECL(U,32)
+#ifdef INT64_MAX
+	DECL(I,64)
+	DECL(U,64)
+#endif
+	intmax_t imax = INTMAX_C(0);
+	uintmax_t umax = UINTMAX_C(0);
+	char str0[256], str1[256];
+
+	sprintf (str0, "%d %x\n", 0, ~0);
+	
+	sprintf (str1, "%d %x\n",  i8, ~0);
+	if (0 != strcmp (str0, str1)) printf ("Something wrong with i8 : %s\n", str1);
+	sprintf (str1, "%u %x\n",  u8, ~0);
+	if (0 != strcmp (str0, str1)) printf ("Something wrong with u8 : %s\n", str1);
+	sprintf (str1, "%d %x\n",  i16, ~0);
+	if (0 != strcmp (str0, str1)) printf ("Something wrong with i16 : %s\n", str1);
+	sprintf (str1, "%u %x\n",  u16, ~0);
+	if (0 != strcmp (str0, str1)) printf ("Something wrong with u16 : %s\n", str1);	
+	sprintf (str1, "%" PRINTF_INT32_MODIFIER "d %x\n",  i32, ~0);
+	if (0 != strcmp (str0, str1)) printf ("Something wrong with i32 : %s\n", str1);
+	sprintf (str1, "%" PRINTF_INT32_MODIFIER "u %x\n",  u32, ~0);
+	if (0 != strcmp (str0, str1)) printf ("Something wrong with u32 : %s\n", str1);
+#ifdef INT64_MAX	
+	sprintf (str1, "%" PRINTF_INT64_MODIFIER "d %x\n",  i64, ~0);
+	if (0 != strcmp (str0, str1)) printf ("Something wrong with i64 : %s\n", str1);
+#endif
+	sprintf (str1, "%" PRINTF_INTMAX_MODIFIER "d %x\n",  imax, ~0);
+	if (0 != strcmp (str0, str1)) printf ("Something wrong with imax : %s\n", str1);
+	sprintf (str1, "%" PRINTF_INTMAX_MODIFIER "u %x\n",  umax, ~0);
+	if (0 != strcmp (str0, str1)) printf ("Something wrong with umax : %s\n", str1);	
+	
+	TESTUMAX(8);
+	TESTUMAX(16);
+	TESTUMAX(32);
+#ifdef INT64_MAX
+	TESTUMAX(64);
+#endif
+
+	return EXIT_SUCCESS;
+}
+
+#endif
+
+#endif /* WIN32 */
Index: trunk/CanGateway/driver/kvaser/windows/kvmlib.h
===================================================================
--- trunk/CanGateway/driver/kvaser/windows/kvmlib.h	(revision 93)
+++ trunk/CanGateway/driver/kvaser/windows/kvmlib.h	(revision 93)
@@ -0,0 +1,786 @@
+/**
+ **                   Copyright 2015 by KVASER AB, SWEDEN
+ **                        WWW: http://www.kvaser.com
+ **
+ ** This software is furnished under a license and may be used and copied
+ ** only in accordance with the terms of such license.
+ **
+ ** \file kvmlib.h
+ ** \brief   Library for accessing Kvaser Memorator (2nd generation)
+ **
+ ** Description:
+ **         Library for accessing Kvaser Memorator (2nd generation). This
+ **         library is used to extract log data, initialize disk, read and
+ **         write configuration to a device, handle on device databases and
+ **         more.
+ **
+ ** ---------------------------------------------------------------------------
+ */
+
+
+#ifndef KVMLIB_H
+#define KVMLIB_H
+
+
+#include <windows.h>
+#include <stdio.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * \name kvmDEVICE_xxx
+ * \anchor kvmDEVICE_xxx
+ *
+ * Device type, used to connect to a Memorator device.
+ *
+ * @{
+ */
+#define kvmDEVICE_MHYDRA    0      ///< Kvaser Memorator (2nd generation)
+/** @} */
+
+/**
+ * \brief A handle to a KME file
+ */
+typedef HANDLE kmeFileHandle;
+
+/**
+ * \name kvmFS_xxx
+ * \anchor kvmFS_xxx
+ *
+ * File system used when formatting disk.
+ *
+ * @{
+ */
+#define kvmFS_FAT16   0      ///< fat16
+#define kvmFS_FAT32   1      ///< fat32
+/** @} */
+
+/**
+ * \name kvmFILE_xxx
+ * \anchor kvmFILE_xxx
+ *
+ * KME file type, a binary file format representing log data.
+ *
+ * @{
+ */
+#define kvmFILE_KME24   0      ///< Deprecated
+#define kvmFILE_KME25   1      ///< Deprecated
+#define kvmFILE_KME40   2      ///< Kvaser binary format (KME 4.0)
+/** @} */
+
+/**
+ * \brief A handle to a Memorator or equivalent KMF file
+ */
+typedef HANDLE kvmHandle;
+
+typedef signed char                     int8;
+typedef unsigned char                   uint8;
+typedef short                           int16;
+typedef unsigned short                  uint16;
+typedef long int                        int32;
+typedef unsigned long int               uint32;
+typedef __int64                         int64;
+
+
+/**
+ * \name kvmStatus
+ * \anchor kvmERR_xxx
+ *
+ * Generally, a return code greater than or equal to zero means success. A
+ * value less than zero means failure.
+ *
+ * @{
+ */
+
+  // If you change here, remember to also change kvmlib.cpp and kvmlibtest...
+typedef enum {
+  kvmOK                      =  0,  ///< OK!
+  kvmFail                    = -1,  ///< Generic error.
+  kvmERR_PARAM               = -3,  ///< Error in supplied parameters.
+  kvmERR_LOGFILEOPEN         = -8,  ///< Can't find/open log file.
+  kvmERR_NOSTARTTIME         = -9,  ///< Start time not found.
+  kvmERR_NOLOGMSG            = -10,  ///< No log message found.
+  kvmERR_LOGFILEWRITE        = -11,  ///< Error writing log file.
+  kvmEOF                     = -12,  ///< End of file found.
+  kvmERR_NO_DISK             = -13,  ///< No disk found.
+  kvmERR_LOGFILEREAD         = -14,  ///< Error while reading log file.
+  kvmERR_QUEUE_FULL          = -20,  ///< Queue is full.
+  kvmERR_CRC_ERROR           = -21,  ///< CRC check failed.
+  kvmERR_SECTOR_ERASED       = -22,  ///< Sector unexpectadly erased.
+  kvmERR_FILE_ERROR          = -23,  ///< File I/O error.
+  kvmERR_DISK_ERROR          = -24,  ///< General disk error.
+  kvmERR_DISKFULL_DIR        = -25,  ///< Disk full (directory).
+  kvmERR_DISKFULL_DATA       = -26,  ///< Disk full (data).
+  kvmERR_SEQ_ERROR           = -27,  ///< Unexpected sequence.
+  kvmERR_FILE_SYSTEM_CORRUPT = -28,  ///< File system corrupt.
+  kvmERR_UNSUPPORTED_VERSION = -29,  ///< Unsupported version.
+  kvmERR_NOT_IMPLEMENTED     = -30,  ///< Not implemented.
+  kvmERR_FATAL_ERROR         = -31,  ///< Fatal error.
+  kvmERR_ILLEGAL_REQUEST     = -32,  ///< Illegal request.
+  kvmERR_FILE_NOT_FOUND      = -33,  ///< File not found.
+  kvmERR_NOT_FORMATTED       = -34,  ///< Disk not formatted.
+  kvmERR_WRONG_DISK_TYPE     = -35,  ///< Wrong disk type.
+  kvmERR_TIMEOUT             = -36,  ///< Timeout.
+  kvmERR_DEVICE_COMM_ERROR   = -37,  ///< Device communication error.
+  kvmERR_OCCUPIED            = -38,  ///< Device occupied.
+  kvmERR_USER_CANCEL         = -39,  ///< User abort.
+  kvmERR_FIRMWARE            = -40,  ///< Firmware error.
+  kvmERR_CONFIG_ERROR        = -41,  ///< Configuration error.
+  kvmERR_WRITE_PROT          = -42,  ///< Disk is write protected.
+
+} kvmStatus;
+/** @} */
+
+
+/**
+ * \name kvm_SWINFO_xxx
+ * \anchor kvm_SWINFO_xxx
+ *
+ * Different types of version information that can be extracted using
+ * kvmDeviceGetSoftwareInfo()
+ *
+ * @{
+ */
+#define kvm_SWINFO_DRIVER                   2  ///< Returns the used driver version information.
+#define kvm_SWINFO_FIRMWARE                 3  ///< Returns the device firmware version information.
+#define kvm_SWINFO_DRIVER_PRODUCT           4  ///< Obsolete. Returns the product version information.
+#define kvm_SWINFO_CONFIG_VERSION_NEEDED    5  ///< Returns the version of the binary format (param.lif).
+#define kvm_SWINFO_CPLD_VERSION             6  ///< Obsolete.
+/** @} */
+
+#include <pshpack1.h>
+
+#ifndef canMSG_RTR
+/**
+ * \name canMSG_xxx
+ *
+ * The following flags can be found in a kvmLogMsgEx message flags field
+ * returned from kvmKmeReadEvent(). All flags and/or combinations of them are
+ * meaningful for logged message.
+ * \anchor canMSG_xxx
+ * @{
+ */
+#  define canMSG_RTR            0x0001      ///< Message is a remote request
+#  define canMSG_STD            0x0002      ///< Message has a standard ID
+#  define canMSG_EXT            0x0004      ///< Message has an extended ID
+#  define canMSG_ERROR_FRAME    0x0020      ///< Message is an error frame
+#  define canMSG_TXACK          0x0040      ///< Message is a TX ACK (msg is really sent)
+#  define canMSG_TXRQ           0x0080      ///< Message is a TX REQUEST (msg is transfered to the CAN controller chip)
+#  define canMSGERR_OVERRUN     0x0600      ///< Message overrun condition occurred.
+/** @} */
+#endif
+
+/**
+ * \name TRIGVAR_TYPE_xxx
+ *
+ * The following trigger types can be found in a kvmLogTriggerEx message type
+ * field.
+ * \anchor TRIGVAR_TYPE_xxx
+ * @{
+ */
+#define TRIGVAR_TYPE_MSG_ID         0       ///< Message ID trigger
+#define TRIGVAR_TYPE_MSG_DLC        1       ///< Message DLC trigger
+#define TRIGVAR_TYPE_MSG_FLAG       2       ///< Message flag trigger
+#define TRIGVAR_TYPE_SIGVAL         3       ///< Signal value trigger
+#define TRIGVAR_TYPE_EXTERNAL       4       ///< External trigger
+#define TRIGVAR_TYPE_TIMER          5       ///< Timer trigger
+#define TRIGVAR_TYPE_DISK_FULL      6       ///< Disk is full trigger
+#define TRIGVAR_TYPE_STARTUP        9       ///< Startup trigger
+/** @} */
+
+/**
+ * \brief A CAN message
+ */
+typedef struct {
+  uint32 id;            ///< The message identifier
+  int64  timeStamp;     ///< The timestamp in units of 1 nanosecond
+  uint32 channel;       ///< The device channel on which the message arrived, 0,1,...
+  uint32 dlc;           ///< The length of the message
+  uint32 flags;         ///< Message flags \ref canMSG_xxx
+  uint8  data[64];      ///< Message data (64 bytes)
+} kvmLogMsgEx;
+
+/**
+ * \brief A RTC clock message
+ */
+typedef struct {
+  uint32 calendarTime;   ///< RTC date, seconds since 1970-01-01T00:00:00+00:00 (UTC)
+  int64  timeStamp;      ///< The timestamp in units of 1 nanosecond
+} kvmLogRtcClockEx;
+
+
+/**
+ * \brief A trigger message
+ */
+typedef struct {
+  int32   type;           ///< The type of trigger \ref TRIGVAR_TYPE_xxx
+  int32   preTrigger;     ///< Pretrigger time in milliseconds
+  int32   postTrigger;    ///< Posttrigger time in milliseconds
+  uint32  trigMask;       ///< Bitmask with all active triggers
+  int64   timeStamp;      ///< The timestamp in units of 1 nanosecond
+} kvmLogTriggerEx;
+
+/**
+ * \name kvmLOG_TYPE_xxx
+ * \anchor kvmLOG_TYPE_xxx
+ *
+ * Event types in log
+ * @{
+ */
+#define kvmLOG_TYPE_INVALID    0 ///< Invalid MEMOLOG type
+#define kvmLOG_TYPE_CLOCK      1 ///< The type used in kvmLogRtcClockEx
+#define kvmLOG_TYPE_MSG        2 ///< The type used in kvmLogMsgEx
+#define kvmLOG_TYPE_TRIGGER    3 ///< The type used in kvmLogTriggerEx
+/** @} */
+
+/**
+ * \brief The union of events used by kvmKmeReadEvent().
+ */
+typedef struct {
+  uint32               type;    ///< \ref MEMOLOG_TYPE_xxx, Event types in log
+  union {
+    kvmLogMsgEx        msg;     ///< A CAN message
+    kvmLogRtcClockEx   rtc;     ///< An RTC message
+    kvmLogTriggerEx    trig;    ///< A trigger message
+    uint8              raw[128]; ///< Raw data in a array
+  } eventUnion;
+} kvmLogEventEx;
+
+#include <poppack.h>
+
+/**
+ * \ingroup Initialization
+ *
+ * This function must be called before any other functions are used.  It will
+ * initialize the memolib library.
+ */
+void WINAPI kvmInitialize(void);
+
+/**
+ * \ingroup Initialization
+ *
+ * Convert a \ref kvmStatus errorcode to a text.
+ *
+ * \param[in]  error         The error code to convert.
+ * \param[out] buf           Buffer to receive error text.
+ * \param[in]  len           Buffer size in bytes.
+ */
+kvmStatus WINAPI kvmGetErrorText(kvmStatus error, char *buf, size_t len);
+
+/**
+ * \ingroup Connection
+ *
+ * Close the connection to the Memorator (device or file) opened with
+ * kvmOpenDevice() or kvmDeviceMountKmf(). The handle becomes invalid.
+ *
+ * \param[in]  h         An open kvmHandle.
+ *
+ * \return \ref kvmOK (zero) if success
+ * \return \ref kvmERR_xxx (negative) if failure
+ *
+ * \sa kvmDeviceMountKmf(), kvmDeviceOpen()
+ */
+kvmStatus WINAPI kvmClose(kvmHandle h);
+
+/**
+ *\ingroup Connection
+ *
+ * Connect to a Memorator device and obtain a handle for subsequent device operations.
+ * The argument \a cardNr is the Card Number property (decreased by one) displayed in
+ * Kvaser Hardware.
+ *
+ * \param[in]  cardNr      Card number
+ * \param[out] status      \ref kvmOK if completely successful,
+ *                         \ref kvmERR_xxx (negative) if failure
+ * \param[in]  deviceType  \ref kvmDEVICE_xxx
+ *
+ * \return Returns an open handle to a Memorator on success.
+ *
+ * \sa kvmClose(), kvmLogFileMount()
+ */
+kvmHandle    WINAPI kvmDeviceOpen(int32 cardNr,
+                                     kvmStatus *status,
+                                     int32 deviceType);
+
+/**
+ *\ingroup Connection
+ *
+ * Mount the log area on the SD card on a connected Kvaser Memorator.
+ *
+ * \note Must be called after \ref kvmDeviceOpen before any subsequent
+ * log operations are called.
+ *
+ * param[in]  h         An open kvmHandle.
+ *
+ * \return \ref kvmOK (zero) if success
+ * \return \ref kvmERR_xxx (negative) if failure
+ *
+ * kvmClose(), kvmDeviceOpen()
+ */
+kvmStatus WINAPI kvmDeviceMountKmf(kvmHandle h);
+
+/**
+ * \ingroup Connection
+ *
+ * Open a KMF file on a hard disk or SD card reader and obtain a handle for
+ * subsequent operations. \a deviceType is the device type that generated the
+ * file.
+ *
+ * \param[in]  filename    KMF filename
+ * \param[out] status      \ref kvmOK if successful, otherwise
+ *                         \ref kvmERR_xxx
+ * \param[in]  deviceType  \ref kvmDEVICE_xxx
+ *
+ * \return Returns an open handle to a Memorator on success.
+ *
+ * \sa kvmClose(), kvmDeviceOpen()
+ *
+ * \todo What is returned upon failure?
+ */
+kvmHandle    WINAPI kvmKmfOpen(const char *filename,
+                                 kvmStatus *status,
+                                 int32 deviceType);
+
+/**
+ * \ingroup DiskOperations
+ *
+ * Check for errors
+ *
+ * \param[in]  h         An open kvmHandle.
+ *
+ * \return \ref kvmOK (zero) if success
+ * \return \ref kvmERR_xxx (negative) if failure
+ */
+kvmStatus WINAPI kvmKmfValidate(kvmHandle h);
+
+/**
+ * \ingroup DiskOperations
+ *
+ * Format the SD memory card in a connected Memorator.
+ *
+ *
+ * \param[in]  h             An open kvmHandle.
+ * \param[in]  fileSystem    Creates FAT32 if set to non-zero, else creates FAT16. \ref kvmFS_xxx
+ * \param[in]  reserveSpace  Space to reserve for user files, in MB.
+ * \param[in]  dbaseSpace    Space to reserve for database files, in MB.
+ *
+ * \return \ref kvmOK (zero) if success
+ * \return \ref kvmERR_xxx (negative) if failure
+ *
+ * \sa kvmDeviceDiskSize
+ */
+kvmStatus WINAPI kvmDeviceFormatDisk(kvmHandle h,
+                                   int fileSystem,
+                                   uint32 reserveSpace,
+                                   uint32 dbaseSpace);
+
+/**
+ * \ingroup DataExtraction
+ *
+ * Count the number of log files
+ *
+ * \param[in]  h             An open kvmHandle.
+ * \param[out] fileCount     The number of log files on disk.
+ *
+ * \return \ref kvmOK (zero) if success
+ * \return \ref kvmERR_xxx (negative) if failure
+ */
+kvmStatus WINAPI kvmLogFileGetCount(kvmHandle h, uint32* fileCount);
+
+/**
+ * \ingroup DataExtraction
+ *
+ * Mount the log file with the specified index. The index starts at 0. The
+ * approximate number of events in the log file is returned.
+ *
+ * \param[in]  h             An open kvmHandle.
+ * \param[in]  fileIndx      Index of the log file to open.
+ * \param[out] eventCount    The approximate number of events in the log file
+ *
+ * \return \ref kvmOK (zero) if success
+ * \return \ref kvmERR_xxx (negative) if failure
+ *
+ * \sa kvmLogFileDismount()
+ */
+kvmStatus WINAPI kvmLogFileMount(kvmHandle h, uint32 fileIndx,
+                                    uint32 *eventCount);
+
+/**
+ * \ingroup DataExtraction
+ *
+ * Dismount the log file opened with kvmLogFileMount(). The handle will stay valid.
+ *
+ * \param[in]  h             An open kvmHandle.
+ */
+kvmStatus WINAPI kvmLogFileDismount(kvmHandle h);
+
+/**
+ * \ingroup DataExtraction
+ *
+ * Get the time of the first event in the log file. The time is returned in
+ * standard unix time format (number of seconds since 1970-01-01T00:00:00+00:00).
+ *
+ * \param[in]   h            An open kvmHandle.
+ * \param[out]  startTime    The time of the first event in the log file (UTC)
+ *
+ * \return \ref kvmOK (zero) if success
+ * \return \ref kvmERR_xxx (negative) if failure
+ */
+kvmStatus WINAPI kvmLogFileGetStartTime (kvmHandle h,
+                                         uint32 *startTime);
+
+/**
+ * \ingroup DataExtraction
+ *
+ * Get the serialnumber of the interface that created the log file.
+ *
+ * \param[in]   h              An open kvmHandle.
+ * \param[out]  serialNumber   The serialnumber of the interface that created the
+ *                             log file.
+ *
+ * \return \ref kvmOK (zero) if success
+ * \return \ref kvmERR_xxx (negative) if failure
+ */
+kvmStatus WINAPI kvmLogFileGetCreatorSerial(kvmHandle h,
+                                         uint32 *serialNumber);
+
+/**
+ * \ingroup DataExtraction
+ *
+ * Read an event from a log file opened with kvmLogFileMount().
+ *
+ * \param[in]   h              An open kvmHandle.
+ * \param[out]  e              Event from log file.
+ *
+ * \return \ref kvmOK (zero) if success
+ * \return \ref kvmERR_xxx (negative) if failure
+ *
+ * \todo Will a call to this function increment to next event?
+ */
+kvmStatus WINAPI kvmLogFileReadEvent(kvmHandle h, kvmLogEventEx *e);
+
+
+/**
+ * \ingroup DataExtraction
+ *
+ * Delete all log files from a Memorator.
+ *
+ * \param[in]  h         An open kvmHandle.
+ *
+ * \return \ref kvmOK (zero) if success
+ * \return \ref kvmERR_xxx (negative) if failure
+ */
+kvmStatus WINAPI kvmLogFileDeleteAll(kvmHandle h);
+
+/**
+ * \ingroup SystemInformation
+ *
+ * Check if the SD memory card is present.
+ *
+ * \note This function is not supported by all devices.
+ *
+ * \param[in]   h              An open kvmHandle.
+ * \param[out]  present        Non-zero means that SD memory card is present.
+ *
+ * \return \ref kvmOK (zero) if success
+ * \return \ref kvmERR_xxx (negative) if failure
+ */
+kvmStatus WINAPI kvmDeviceDiskStatus(kvmHandle h, int *present);
+
+/**
+ * \ingroup SystemInformation
+ *
+ * Get disk usage statistics, reported in number of (512 byte) sectors.
+ *
+ *
+ * \param[in]   h                 An open kvmHandle.
+ * \param[out]  totalSectorCount  Total number of sectors devoted for logging
+ * \param[out]  usedSectorCount   Number of logging sectors used
+ *
+ * \return \ref kvmOK (zero) if success
+ * \return \ref kvmERR_xxx (negative) if failure
+ */
+kvmStatus WINAPI kvmKmfGetUsage(kvmHandle h,
+                                           uint32 *totalSectorCount,
+                                           uint32 *usedSectorCount);
+
+/**
+ * \ingroup SystemInformation
+ *
+ * Get disk size, reported in number of (512 byte) sectors.
+ *
+ *
+ * \param[in]   h              An open kvmHandle.
+ * \param[out]  diskSize       Disk size in number of (512 byte) sectors.
+ *
+ * \return \ref kvmOK (zero) if success
+ * \return \ref kvmERR_xxx (negative) if failure
+ */
+kvmStatus WINAPI kvmDeviceDiskSize(kvmHandle h, uint32 *diskSize);
+
+/**
+ * \ingroup SystemInformation
+ *
+ * Get serial number related to the Memorator handle.
+ *
+ * \param[in]   h            An open kvmHandle.
+ * \param[out]  serial       Serial number of connected device.
+ *
+ * \return \ref kvmOK (zero) if success
+ * \return \ref kvmERR_xxx (negative) if failure
+ */
+kvmStatus WINAPI kvmDeviceGetSerialNumber(kvmHandle h, unsigned int *serial);
+
+/**
+ * \ingroup SystemInformation
+ *
+ * Get software version information.
+ *
+ * \param[in]   h            An open kvmHandle.
+ * \param[in]   itemCode     An item code specifying the type of version to get. \ref kvm_SWINFO_xxx
+ * \param[out]  major        Major version number
+ * \param[out]  minor        Minor version number
+ * \param[out]  build        Build number
+ * \param[out]  flags        For internal use only
+ *
+ * \return \ref kvmOK (zero) if success
+ * \return \ref kvmERR_xxx (negative) if failure
+ */
+kvmStatus WINAPI kvmDeviceGetSoftwareInfo(kvmHandle h,
+                                               int32 itemCode,
+                                               unsigned int *major,
+                                               unsigned int *minor,
+                                               unsigned int *build,
+                                               unsigned int *flags);
+/**
+ * \ingroup SystemInformation
+ *
+ * Flash all LEDs on the opened Memorator device
+ *
+ * \param[in]   h            An open kvmHandle.
+ *
+ * \return \ref kvmOK (zero) if success
+ * \return \ref kvmERR_xxx (negative) if failure
+ */
+kvmStatus WINAPI kvmDeviceFlashLeds(kvmHandle h);
+
+
+/**
+ * \ingroup RealTimeClock
+ *
+ * Get date and time from the RTC chip.  The time is returned in standard
+ * unix time format (number of seconds since 1970-01-01T00:00:00+00:00).
+ * Only for device handles
+ *
+ * \param[in]   h            An open kvmHandle.
+ * \param[out]  t            Time in Unix time format
+ *
+ * \return \ref kvmOK (zero) if success
+ * \return \ref kvmERR_xxx (negative) if failure
+ */
+kvmStatus WINAPI kvmDeviceGetRTC(kvmHandle h, unsigned long *t);
+
+/**
+ * \ingroup RealTimeClock
+ *
+ * Set date and time in the RTC. The time is returned in standard unix
+ * time format (number of seconds since 1970-01-01T00:00:00+00:00).
+ * Only for device handles.
+ *
+ * \param[in]   h            An open kvmHandle.
+ * \param[in]   t            Time in Unix time format
+ *
+ * \return \ref kvmOK (zero) if success
+ * \return \ref kvmERR_xxx (negative) if failure
+ */
+kvmStatus WINAPI kvmDeviceSetRTC(kvmHandle h, unsigned long t);
+
+/**
+ * \ingroup Configurations
+ *
+ * Read binary configuration data (param.lif) from a KMF file.
+ *
+ * \param[in]   h            An open kvmHandle.
+ * \param[out]  buf          A pointer to buffer where the configuration (param.lif) will be written.
+ * \param[in]   buflen       The length of the buffer buf.
+ * \param[out]  actual_len   The actual length of the configuration written to buf.
+ *
+ * \return \ref kvmOK (zero) if success
+ * \return \ref kvmERR_xxx (negative) if failure
+ */
+kvmStatus WINAPI kvmKmfReadConfig(kvmHandle h, void *buf,
+                                    size_t buflen, size_t *actual_len);
+
+/**
+ * \ingroup Configurations
+ *
+ * Write binary configuration data (param.lif) to a KMF file.
+ *
+ * \param[in]   h            An open kvmHandle.
+ * \param[in]   buf          A pointer to buffer containing the configuration (param.lif) to be written.
+ * \param[in]   buflen       The length of the buffer buf.
+ *
+ * \return \ref kvmOK (zero) if success
+ * \return \ref kvmERR_xxx (negative) if failure
+ */
+kvmStatus WINAPI kvmKmfWriteConfig(kvmHandle h, void *buf, size_t buflen);
+
+
+/**
+ * \ingroup Database
+ *
+ * Read the database file. The database will be extracted to path and the
+ * name of the created file copied to filenamebuf.
+ *
+ * \param[in]   h            An open kvmHandle.
+ * \param[in]   path         The path where the database file will be stored.
+ * \param[out]  filenamebuf  The filename of the database. (should be greater then 12 bytes)
+ * \param[in]   buflen       The lenght of filenamebuf
+ *
+ * \return \ref kvmOK (zero) if success
+ * \return \ref kvmERR_xxx (negative) if failure
+ *
+ * \sa kvmKmfPutDbaseFile()
+ */
+kvmStatus WINAPI kvmKmfGetDbaseFile(kvmHandle h, char *path, char *filenamebuf, size_t buflen);
+
+/**
+ * \ingroup Database
+ *
+ * Write the database file
+ *
+ * \param[in]   h            An open kvmHandle.
+ * \param[in]   filename     The full path and name of the file, e.g. C:\\temp\\myfile.data
+ *                           Note that the filename will be trucated to an 8.3 filename.
+ *
+ * \return \ref kvmOK (zero) if success
+ * \return \ref kvmERR_xxx (negative) if failure
+ *
+ * \sa kvmKmfGetDbaseFile()
+ */
+kvmStatus WINAPI kvmKmfPutDbaseFile(kvmHandle h, char *filename);
+
+/**
+ * \ingroup Database
+ *
+ * Erase the database file
+ *
+ * \param[in]   h            An open kvmHandle.
+ *
+ * \return \ref kvmOK (zero) if success
+ * \return \ref kvmERR_xxx (negative) if failure
+ */
+kvmStatus WINAPI kvmKmfEraseDbaseFile(kvmHandle h);
+
+/**
+ * \ingroup Files
+ *
+ * Open a KME file for reading and obtain a handle for subsequent operations.
+ *
+ * \param[in]   filename     The full path and name of the KME file, e.g. C:\\temp\\myfile.kme
+ * \param[in]   fileType     \ref kvmFILE_xxx
+ * \param[out]  status       \ref kvmOK (zero) if success
+ *                           \ref kvmERR_xxx (negative) if failure
+ *
+ * \return Returns an open handle to a KME file on success.
+ *
+ * \sa kvmKmeReadEvent(), kvmKmeCountEvents(), kvmKmeCloseFile()
+ *
+ */
+kmeFileHandle    WINAPI kvmKmeOpenFile (const char *filename,
+                                    kvmStatus *status,
+                                    int32 fileType);
+/**
+ * \ingroup Files
+ *
+ * Open a KME file for writing and obtain a handle for subsequent operations.
+ * Note that kvmKmeCreateFile() will overwrite any existing file and that
+ * \ref kvmFILE_KME24 and \ref kvmFILE_KME25 are deprecated formats. Please
+ * use \ref kvmFILE_KME40.
+ *
+ * \param[in]   filename     The full path and name of the KME file, e.g. C:\\temp\\myfile.kme
+ * \param[in]   fileType     \ref kvmFILE_xxx
+ * \param[out]  status       \ref kvmOK (zero) if success
+ *                           \ref kvmERR_xxx (negative) if failure
+ *
+ * \return Returns an open handle to a KME file on success.
+ *
+ * \sa kvmKmeWriteEvent(), kvmKmeCountEvents(), kvmKmeCloseFile()
+ *
+ */
+kmeFileHandle    WINAPI kvmKmeCreateFile (const char *filename,
+                                      kvmStatus *status,
+                                      int32 fileType);
+
+/**
+ * \ingroup Files
+ *
+ * Read an event from a KME file opened with kvmKmeOpenFile().
+ *
+ * \param[in]   h              An open handle to a KME file.
+ * \param[out]  e              Event from a KME file.
+ *
+ * \return \ref kvmOK (zero) if success
+ * \return \ref kvmERR_NOLOGMSG on EOF
+ * \return \ref kvmERR_xxx (negative) if failure
+*
+ * \sa kvmKmeOpenFile(), kvmKmeCountEvents(), kvmKmeCloseFile()
+ *
+ */
+kvmStatus    WINAPI kvmKmeReadEvent (kmeFileHandle h, kvmLogEventEx *e);
+
+/**
+ * \ingroup Files
+ *
+ * Write an event to a KME file created with kvmKmeCreateFile().
+ *
+ * \param[in]  h               An open handle to a KME file.
+ * \param[in]  e               Event to write.
+ *
+ * \return \ref kvmOK (zero) if success
+ * \return \ref kvmERR_xxx (negative) if failure
+*
+ * \sa kvmKmeCreateFile(), kvmKmeCountEvents(), kvmKmeCloseFile()
+ *
+ */
+kvmStatus    WINAPI kvmKmeWriteEvent (kmeFileHandle h, kvmLogEventEx *e);
+
+/**
+ * \ingroup Files
+ *
+ * Count the number of events in a KME file.
+ *
+ * \param[in]  h               An open handle to a KME file.
+ * \param[out] eventCount      Approximate number of events in a KME file.
+ *
+ * \return \ref kvmOK (zero) if success
+ * \return \ref kvmERR_xxx (negative) if failure
+ *
+ * \sa kvmKmeOpenFile(), kvmKmeCreateFile()
+ *
+ */
+kvmStatus    WINAPI kvmKmeCountEvents(kmeFileHandle h, uint32 *eventCount);
+
+/**
+ * \ingroup Files
+ *
+ * Close an open KME file opened with kvmKmeOpenFile() or created
+ * with kvmKmeCreateFile(). The handle becomes invalid.
+ *
+ * \param[in]  h               An open handle to a KME file.
+ *
+ * \return \ref kvmOK (zero) if success
+ * \return \ref kvmERR_xxx (negative) if failure
+ *
+ * \sa kvmKmeOpenFile(), kvmKmeCreateFile()
+ *
+ */
+kvmStatus    WINAPI kvmKmeCloseFile (kmeFileHandle h);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif //KVMLIB_H
Index: trunk/CanGateway/driver/kvaser/windows/kvrlib.h
===================================================================
--- trunk/CanGateway/driver/kvaser/windows/kvrlib.h	(revision 93)
+++ trunk/CanGateway/driver/kvaser/windows/kvrlib.h	(revision 93)
@@ -0,0 +1,1216 @@
+/**
+ * \section LICENSE
+ *                   Copyright 2011 by KVASER AB, SWEDEN
+ *
+ *                        WWW: http://www.kvaser.com
+ *
+ * This software is furnished under a license and may be used and copied
+ * only in accordance with the terms of such license.
+ *
+ * \section DESCRIPTION
+ *
+ * THIS IS A PRELIMINARY VERSION AND SUBJECT TO CHANGE.
+ *
+ * Proposed new remote device API.
+ *
+ * \file kvrlib.h
+ * \version PRELIMINARY
+ * \author Kvaser AB
+ */
+ 
+#ifndef KVRLIB_H_
+#define KVRLIB_H_
+
+#include <windows.h>
+#include <kvaser_stdint.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * Return type of kvrlib functions.
+ */
+typedef enum {
+  kvrOK                    =  0,  /**< OK! */ 
+  kvrERR_NOT_INITIALIZED   = -1,  /**< kvrlib has not been initialized. */
+  kvrERR_GENERIC           = -2,  /**< Generic error. */
+  kvrERR_CHECKSUM          = -3,  /**< Checksum problem. */
+  kvrERR_PARAMETER         = -4,  /**< Error in supplied in parameters. */
+  kvrERR_PASSWORD          = -5,  /**< Supplied password was wrong. */
+  kvrERR_BLANK             = -6,  /**< List was not set or no more results. */
+  kvrERR_NO_DEVICE         = -7,  /**< Remote device is unreachable. */
+  kvrERR_NO_ANSWER         = -8,  /**< No answer arrived within given timeout. */
+  kvrERR_NOT_IMPLEMENTED   = -9,  /**< Function is not yet implemented. */
+  kvrERR_PERMISSION_DENIED = -10, /**< Permission denied. */
+  kvrERR_OUT_OF_SPACE      = -11, /**< Out of space, eg. to many open handles, to small buffer. */
+  kvrERR_NO_SERVICE        = -12, /**< The helper service is not running. */
+  kvrERR_DUPLICATED_DEVICE = -13, /**< There are duplicates in the device list. */
+  /* Remember to update the list of errorstrings (error_text_array) in the library as well. */  
+} kvrStatus;
+
+/**
+ * \defgroup Configuration  Local configuration
+ */
+/**@{*/
+
+/** 
+ * A configuration handle. Created by calling \ref kvrConfigOpen() or \ref kvrConfigOpenEx().
+ */
+typedef int32_t kvrConfigHandle;
+
+/**
+ * \name kvrConfigMode_xxx
+ * Configuration mode.
+ * \anchor kvrConfigMode_xxx
+ * @{
+ */
+#define kvrConfigMode_R         0  /**< Read only. */
+#define kvrConfigMode_RW        1  /**< Read/write. */
+#define kvrConfigMode_ERASE     2  /**< Erase and write. */
+/** @} */
+
+/**
+ * Open a configuration handle to the device.
+ * It should later be closed with \ref kvrConfigClose().
+ *
+ * This configuration handle is used both for changing the device configuration,
+ * reading status information, e.g. \ref kvrNetworkGetConnectionStatus(), and
+ * issuing some other commands such as e.g. \ref kvrNetworkConnectionTest() and
+ * \ref kvrWlanStartScan().
+ *
+ * To change the configuration, you need to open the configuration with
+ * \ref kvrConfigMode_RW before calling \ref kvrConfigSet(). 
+ *
+ * To read the configuration, you can open the configuration with either
+ * \ref kvrConfigMode_RW or \ref kvrConfigMode_R before calling \ref kvrConfigGet().
+ *
+ * Setting a password is done through the configuration (with \ref kvrConfigSet()).
+ * Resetting a password can be done by erasing the whole configuration with
+ * \ref kvrConfigClear(), while first opening the configuration with
+ * \ref kvrConfigMode_ERASE and supplying an empty password.
+ *
+ * Before calling any other function, you must open the configuration with
+ * \ref kvrConfigMode_R.
+ *
+ * \param[in]  can_channel_no  CAN channel number.
+ * \param[in]  mode            Can be set to one of \ref kvrConfigMode_xxx
+ * \param[in]  password        The password as a C string.
+ *                             Use an empty string, i.e. "", if no password 
+ *                             is required.
+ * \param[out] handle          A configuration handle
+ *
+ * \return \ref kvrOK on success or any other \ref kvrStatus on failure.
+ *
+ * \note \ref kvrConfigOpen() will operate on the active profile.
+ * See \ref page_configuration.
+ * \note When using \ref kvrConfigMode_RW or \ref kvrConfigMode_ERASE, a pause of
+ *       ~2 seconds is needed after \ref kvrConfigClose(), to allow CANlib time to
+ *       discard the device.
+ * \sa \ref kvrConfigOpenEx()
+ */
+kvrStatus WINAPI kvrConfigOpen(int32_t can_channel_no, 
+                               int32_t mode, 
+                               const char *password, 
+                               kvrConfigHandle *handle);
+
+
+/**
+ * Set active profile. See \ref page_configuration. 
+ * 
+ *
+ * \param[in] can_channel_no  CAN channel number
+ * \param[in] profile_number  
+ * \return \ref kvrOK on success or any other \ref kvrStatus on failure.
+ *
+ * \note A pause of ~2 seconds is needed after \ref kvrConfigActiveProfileSet(),
+ *       to allow CANlib time to discard the device.
+ */                               
+kvrStatus WINAPI kvrConfigActiveProfileSet (int32_t can_channel_no, int32_t profile_number);
+
+/**
+ * Get active profile. See \ref page_configuration. 
+ * 
+ *
+ * \param[in] can_channel_no  CAN channel number
+ * \param[out] profile_number  
+ * \return \ref kvrOK on success or any other \ref kvrStatus on failure.
+ */                               
+kvrStatus WINAPI kvrConfigActiveProfileGet (int32_t can_channel_no, int32_t *profile_number);
+
+/**
+ * Get the maximum number of profile(s) the device can store. 
+ * See \ref page_configuration. 
+ * 
+ *
+ * \param[in] can_channel_no  CAN channel number
+ * \param[out] no_profiles  
+ * \return \ref kvrOK on success or any other \ref kvrStatus on failure.
+ */                               
+kvrStatus WINAPI kvrConfigNoProfilesGet(int32_t can_channel_no, int32_t *no_profiles);
+
+
+/**
+ * Open a configuration handle to the device.
+ * It should later be closed with \ref kvrConfigClose().
+ *
+ * This configuration handle is used both for changing the device configuration,
+ * reading status information, e.g. \ref kvrNetworkGetConnectionStatus(), and
+ * issuing some other commands such as e.g. \ref kvrNetworkConnectionTest() and
+ * \ref kvrWlanStartScan().
+ *
+ * To change the configuration, you need to open the configuration with
+ * \ref kvrConfigMode_RW before calling \ref kvrConfigSet(). 
+ *
+ * To read the configuration, you can open the configuration with either
+ * \ref kvrConfigMode_RW or \ref kvrConfigMode_R before calling \ref kvrConfigGet().
+ *
+ * Setting a password is done through the configuration (with \ref kvrConfigSet()).
+ * Resetting a password can be done by erasing the whole configuration with
+ * \ref kvrConfigClear(), while first opening the configuration with
+ * \ref kvrConfigMode_ERASE and supplying an empty password.
+ *
+ * Before calling any other function, you must open the configuration with
+ * \ref kvrConfigMode_R.
+ * 
+ * The profile number is used to open a specific profile. 
+ * See \ref page_configuration. 
+ *
+ * \param[in]  can_channel_no  CAN channel number
+ * \param[in]  mode            Can be set to one of \ref kvrConfigMode_xxx
+ * \param[in]  password        The password as a C string.
+ *                             Use an empty string, i.e. "", if no password 
+ *                             is required.
+ * \param[out] handle          A configuration handle
+ * \param[in]  profile_no      Profile number
+ *
+ * \return \ref kvrOK on success or any other \ref kvrStatus on failure.
+ *
+ * \note When using \ref kvrConfigMode_RW or \ref kvrConfigMode_ERASE, a pause of
+ *       ~2 seconds is needed after \ref kvrConfigClose(), to allow CANlib time to
+ *       discard the device.
+ * \sa \ref kvrConfigOpen()
+ */
+kvrStatus WINAPI kvrConfigOpenEx(int32_t can_channel_no, 
+                               int32_t mode, 
+                               const char *password, 
+                               kvrConfigHandle *handle,
+                               uint32_t profile_no);
+
+/**
+ * Closes the device's configuration area without programming it.
+ * Programming is done with \ref kvrConfigSet().
+ *
+ * \param[in] handle  A configuration handle
+ *
+ * \note When using \ref kvrConfigMode_RW or \ref kvrConfigMode_ERASE, a pause of
+ *       ~2 seconds is needed after \ref kvrConfigClose(), to allow CANlib time to
+ *       discard the device.
+ */
+void WINAPI kvrConfigClose(kvrConfigHandle handle);
+
+/**
+ * Verify that the xml buffer complies with both the DTD and internal restrictions. If
+ * the XML input creates any errors and err_buffer is to small to hold the resulting
+ * error message, \ref kvrERR_PARAMETER will be returned.
+ *
+ * \param[in]  xml_buffer       A pointer to a C string containing an XML configuration.
+ * \param[out] err_buffer       A pointer to a buffer that will hold any error messages.
+ * \param[in]  err_buffer_size  The buffer size. Maximum size needed is 2048 bytes.
+ *
+ * \return \ref kvrOK on success or any other \ref kvrStatus on failure.
+ *
+ */
+kvrStatus WINAPI kvrConfigVerifyXml(const char *xml_buffer,
+                                    char *err_buffer,
+                                    uint32_t err_buffer_size);
+
+/**
+ * Set the device configuration. The area is erased before it is
+ * programmed. The handle must be opened \ref kvrConfigMode_RW and closed with
+ * \ref kvrConfigClose() afterward. If the XML input creates any errors,
+ * \ref kvrERR_PARAMETER will be returned.
+ *
+ * \param[in] handle      A configuration handle.
+ * \param[in] xml_buffer  A pointer to a C string containing a valid XML config.
+ *
+ * \return \ref kvrOK on success or any other \ref kvrStatus on failure.
+ *
+ */
+kvrStatus WINAPI kvrConfigSet(kvrConfigHandle handle, const char *xml_buffer);
+
+/**
+ * Reads the device configuration. On successful return, the buffer
+ * will contain a valid C string with the configuration in XML format.
+ * The handle must be opened \ref kvrConfigMode_R or \ref kvrConfigMode_RW and closed
+ * with \ref kvrConfigClose().
+ *
+ * \param[in]  handle           A configuration handle.
+ * \param[out] xml_buffer       A pointer to the data buffer.
+ * \param[in]  xml_buffer_size  The buffer size.
+ *
+ * \return \ref kvrOK on success or any other \ref kvrStatus on failure.
+ *
+ */
+kvrStatus WINAPI kvrConfigGet(kvrConfigHandle handle, 
+                              char *xml_buffer, 
+                              uint32_t xml_buffer_size);
+
+/**
+ * Reads a simplified version of A device configuration PROFILE.
+ * On successful return, the buffer will contain a valid C string of this
+ * in XML format.
+ * Since the function takes a CAN channel rather than a \ref kvrConfigHandle, it is
+ * not necessary to know the configuration password.
+ * Note that the partial XML data returned is not enough to reconfigure a device.
+ *
+ * \param[in]  can_channel_no   CAN channel number.
+ * \param[in]  profile_no       Profile number
+ * \param[out] xml_buffer       A pointer to the data buffer.
+ * \param[in]  xml_buffer_size  The buffer size.
+ *
+ * \return \ref kvrOK on success,
+ *         \ref kvrERR_BLANK when the profile is empty,
+ *         or any other \ref kvrStatus on failure.
+ *
+ */
+kvrStatus WINAPI kvrConfigInfoGet(int32_t can_channel_no,
+                                  int32_t profile_no,
+                                  char *xml_buffer,   
+                                  uint32_t xml_buffer_size);
+
+/**
+ * Clear the device configuration area. This will also clear any
+ * previously set device password. The handle must be opened \ref kvrConfigMode_ERASE
+ * and closed with \ref kvrConfigClose().
+ *
+ * \param[in] handle  A configuration handle.
+ *
+ * \return \ref kvrOK on success or any other \ref kvrStatus on failure.
+ */
+kvrStatus WINAPI kvrConfigClear(kvrConfigHandle handle);
+
+/**@}*/
+
+/**
+ * \defgroup Network Network information
+ */
+/**@{*/
+
+/**
+ * Device address.
+ */
+typedef struct {
+  uint32_t type;        /**< \ref kvrAddressType_xxx. */
+  uint8_t address[20];  /**< IP or MAC address. */
+} kvrAddress;
+
+
+/**
+ * Capability of a WLAN AP. These are values from the standard 802.11 beacon.
+ *
+ * To convert the security information into a more human readable form,
+ * use \ref kvrWlanGetSecurityText().
+ */
+typedef struct {
+  uint32_t version;
+  uint32_t capability;        /**< Advertised capabilities. 
+                               capability[5] Privacy flag 1: WEP
+                                                          0: Open */
+  uint32_t group_cipher;      /**< 0xff: No WPA/RSN.
+                                   0x02: TKIP
+                                   0x04: CCMP */
+  uint32_t list_cipher_auth;  /**< 8 nybbles (In each nybble: 
+                                   pos 0: cipher where;
+                                      0x2: TKIP
+                                      0x4: CCMP
+                                   pos 1: authentication where;
+                                      0xa: PSK
+                                      0x9: RADIUS                                      
+                                   Unused nybbles are set to 0xf. */
+} kvrCipherInfoElement;
+
+/**
+ * Type of device address. 
+ * \note Ports are currently not used.
+ * \anchor kvrAddressType_xxx
+ * \name kvrAddressType_xxx
+ * @{
+ */
+#define kvrAddressType_UNKNOWN     0  /**< Unknown (e.g., no reply from device). */
+#define kvrAddressType_IPV4        1  /**< IP v.4 address. */
+#define kvrAddressType_IPV6        2  /**< IP v.6 address. */
+#define kvrAddressType_IPV4_PORT   3  /**< IP v.4 address with tcp-port. */
+#define kvrAddressType_MAC         4  /**< Ethernet MAC address. */  
+/** @} */
+
+/**
+ * Receive Signal Strength Indicator (RSSI).
+ */
+typedef int32_t kvrRssiHistory;
+
+/**
+ * Round-trip delay time (RTT).
+ */
+typedef uint32_t kvrRttHistory;
+
+ /**
+ * States for network connection.
+ * \anchor kvrNetworkState_xxx
+ * \name kvrNetworkState_xxx
+ * @{
+ */
+#define kvrNetworkState_UNKNOWN                0  /**< Bad state, should never be reported. */
+#define kvrNetworkState_INVALID                1  /**< Network hardware has been disabled. */
+#define kvrNetworkState_STARTUP                2  /**< Configuring network hardware. */
+#define kvrNetworkState_INITIALIZING           3  /**< Started, waiting for initialization. */
+#define kvrNetworkState_NOT_CONNECTED          4  /**< No connection (may auto-connect). */
+#define kvrNetworkState_CONNECTION_DELAY       5  /**< Delay during connection (ad-hoc). */
+#define kvrNetworkState_CONNECTING             6  /**< Waiting for connections (ad-hoc).  */
+#define kvrNetworkState_CONNECTED              7  /**< Network is reached. */
+#define kvrNetworkState_AUTHENTICATING         8  /**< EAPOL handshake ongoing. */
+#define kvrNetworkState_AUTHENTICATION_FAILED  9  /**< Authentication have failed. */
+#define kvrNetworkState_ONLINE                 10 /**< Authentication completed. */
+#define kvrNetworkState_FAILED_MIC             11 /**< MIC verification (EAPOL-key) failed. */
+/** @} */
+
+/**
+ * Basic Service Set.
+ * \anchor kvrBss_xxx
+ * \name kvrBss_xxx
+ * @{
+ */
+#define kvrBss_INFRASTRUCTURE     0 /**< Network with AP. */
+#define kvrBss_INDEPENDENT        1 /**< Ad-hoc network. */
+#define kvrBss_ANY                2 /**< Any. */
+/** @} */
+
+/**
+ * Regulatory domain.
+ * \anchor kvrRegulatoryDomain_xxx
+ * \name kvrRegulatoryDomain_xxx
+ * @{
+ */
+
+#define kvrRegulatoryDomain_JAPAN_TELEC         0  /**< TELEC */
+#define kvrRegulatoryDomain_EUROPE_ETSI         1  /**< ETSI */
+#define kvrRegulatoryDomain_NORTH_AMERICA_FCC   2  /**< FCC */
+#define kvrRegulatoryDomain_WORLD               3  /**< WORLD */
+#define kvrRegulatoryDomain_CHINA_MII           4  /**< MII */
+/** @} */
+
+/**
+ * Activate or deactivate connection test. When actived, the device will
+ * connect and start pinging itself to measure RTT. Use \ref kvrNetworkGetRssiRtt()
+ * (after a while) to get the latest values.
+ *
+ * \param[in] handle  A configuration handle.
+ * \param[in] active  Activate or deactivate connection test.
+ *
+ * \return \ref kvrOK on success or any other \ref kvrStatus on failure.
+ * \sa \ref kvrNetworkGetRssiRtt()
+ */
+ kvrStatus WINAPI kvrNetworkConnectionTest(kvrConfigHandle handle, 
+                                           int32_t active);
+
+/**
+ * Get a history of Receive Signal Strength Indicator (RSSI) and
+ * round-trip delay time (RTT) from the connection test.
+ *
+ * \param[in]  handle       A configuration handle.
+ * \param[out] rssi         Receive Signal Strength Indicator.
+ * \param[in]  rssi_size    Number of entries in \a rssi.
+ * \param[out] rssi_count   Number of RSSI elements returned.
+ * \param[out] rtt          Round-trip delay time.
+ * \param[in]  rtt_size     Number of entries in \a rtt.
+ * \param[out] rtt_count    Number of RTT elements returned.
+ *
+ * \return \ref kvrOK on success or any other \ref kvrStatus on failure.
+ * \sa \ref kvrNetworkConnectionTest()
+ */
+kvrStatus WINAPI kvrNetworkGetRssiRtt(kvrConfigHandle handle,
+                                      kvrRssiHistory *rssi,
+                                      uint32_t rssi_size,
+                                      uint32_t *rssi_count,
+                                      kvrRttHistory *rtt,
+                                      uint32_t rtt_size,
+                                      uint32_t *rtt_count);
+
+/**
+ * Initiate a scan for existing WLAN networks. The result is acquired
+ * with consecutive calls to \ref kvrWlanGetScanResults(). A new scan can not
+ * be initiated until all data has been retrieved from the previous one.
+ *
+ * \note The device should not be connected to a network when scanning. This
+ *       includes the implicit connection done by \ref kvrNetworkConnectionTest().
+ * 
+ * \param[in] handle    A configuration handle.
+ * \param[in] active    If set, performs an active scan.
+ * \param[in] bss_type  Basic service set (BSS) selection. \ref kvrBss_xxx.
+ * \param[in] domain    Regulatory domain. See \ref kvrRegulatoryDomain_xxx.
+ *
+ * \return \ref kvrOK on success,
+ *         \ref kvrERR_NO_ANSWER when previous scan is ongoing
+ *         or any other \ref kvrStatus on failure.
+ */
+
+kvrStatus WINAPI kvrWlanStartScan(kvrConfigHandle handle,
+                                  int32_t active,
+                                  int32_t bss_type,
+                                  int32_t domain);
+
+
+/**
+ * Get results from WLAN scan. Call \ref kvrWlanGetScanResults() until it returns
+ * \ref kvrERR_BLANK to mark that no more information is available from this scan.
+ *
+ * To convert the security information into a more human readable form,
+ * use \ref kvrWlanGetSecurityText().
+ *
+ * \param[in]  handle       A configuration handle.
+ * \param[out] rssi         Receive Signal Strength Indicator (RSSI).
+ * \param[out] channel      WLAN Channel.
+ * \param[out] mac          Media Access Control address. 
+ * \param[out] bss_type     Basic Service Set (BSS) (see \ref kvrBss_xxx).
+ * \param[out] ssid         Service Set Identifier(SSID) as a C string.
+ *                          Maximum length is 32 bytes.
+ * \param[out] capability   The advertised capabilities of the BSS.
+ * \param[out] type_wpa     Only type 1 (802.1X) is supported for connection.
+ * \param[out] wpa_info     Advertised information for WPA 
+ *                          (see \ref kvrCipherInfoElement).
+ * \param[out] rsn_info     Advertised information for RSN 
+ *                          (see \ref kvrCipherInfoElement).
+ *
+ * \return \ref kvrOK on success,
+ *         \ref kvrERR_NO_ANSWER when waiting for further scan results
+ *         \ref kvrERR_BLANK when no further scan results are available
+ *         or any other \ref kvrStatus on failure.
+ *
+ */
+kvrStatus WINAPI kvrWlanGetScanResults(kvrConfigHandle handle,
+                                       int32_t *rssi,
+                                       int32_t *channel,
+                                       kvrAddress *mac,
+                                       int32_t *bss_type,
+                                       char *ssid,
+                                       uint32_t *capability,
+                                       uint32_t *type_wpa,
+                                       kvrCipherInfoElement *wpa_info,
+                                       kvrCipherInfoElement *rsn_info);
+
+/**
+ * Read the device Hostname.
+ *
+ * \param[in] handle               A configuration handle
+ * \param[out] buffer              The device Hostname as a C string.
+ * \param[in]  buffer_size         The device Hostname buffer size.
+ *
+ * \return \ref kvrOK on success or any other \ref kvrStatus on failure.
+ */                                                                        
+kvrStatus WINAPI kvrNetworkGetHostName(kvrConfigHandle handle, 
+                                       char* buffer, uint32_t buffer_size);
+                                              
+/**
+ * Read the generated Hostname.
+ *
+ * \param[in] ean_hi               The device EAN_high number.
+ * \param[in] ean_lo               The device EAN_low number.
+ * \param[in] ser_no               The device serial number.
+ * \param[out] buffer              The device Hostname as a C string.
+ * \param[in]  buffer_size         The device Hostname buffer size.
+ *
+ * \return \ref kvrOK on success or any other \ref kvrStatus on failure.
+ */                                                                        
+kvrStatus WINAPI kvrHostName(uint32_t ean_hi, uint32_t ean_lo, uint32_t ser_no, 
+                             char* buffer, uint32_t buffer_size);
+                                       
+                                       
+/**
+ * Get connection status information. 
+ *
+ * \param[in]  handle      A configuration handle.
+ * \param[out] state       Network connection state, see \ref kvrNetworkState_xxx.
+ * \param[out] tx_rate     Transmit rate in kbit/s.
+ * \param[out] rx_rate     Receive rate in kbit/s.
+ * \param[out] channel     Channel.
+ * \param[out] rssi        Receive Signal Strength Indicator (RSSI).
+ * \param[out] tx_power    Transmit power level in dB.
+ *
+ * \return \ref kvrOK on success or any other \ref kvrStatus on failure.
+ */
+kvrStatus WINAPI kvrNetworkGetConnectionStatus(kvrConfigHandle handle,
+                                               int32_t *state,
+                                               int32_t *tx_rate,
+                                               int32_t *rx_rate,
+                                               int32_t *channel,
+                                               int32_t *rssi,
+                                               int32_t *tx_power);
+
+/**
+ * Get information about the network address settings.
+ * For a WLAN connected device, address1, netmask and gateway are IP addresses
+ * and address2 is the MAC address.
+ *
+ * \param[in]  handle    A configuration handle.
+ * \param[out] address1  The first address associated with the device.
+ * \param[out] address2  The second address associated with the device.
+ * \param[out] netmask   The netmask for the device.
+ * \param[out] gateway   The gateway for the device.
+ * \param[out] dhcp      The device ueses Dynamic Host Configuration 
+ *                       Protocol (DHCP).
+ *
+ * \return \ref kvrOK on success or any other \ref kvrStatus on failure.
+ */
+kvrStatus WINAPI kvrNetworkGetAddressInfo(kvrConfigHandle handle,
+                                          kvrAddress *address1,
+                                          kvrAddress *address2,  
+                                          kvrAddress *netmask,
+                                          kvrAddress *gateway,
+                                          int32_t *dhcp);
+
+/**@}*/
+
+/**
+ * \defgroup Discovery Device discovery
+ */
+/**@{*/
+
+/**
+ * Remote device usage status.
+ * \anchor kvrDeviceUsage_xxx
+ * \name kvrDeviceUsage_xxx
+ * @{
+ */
+
+#define kvrDeviceUsage_UNKNOWN   0 /**< Unknown (e.g., no reply from device). */
+#define kvrDeviceUsage_FREE      1 /**< Not in use. */
+#define kvrDeviceUsage_REMOTE    2 /**< Connected to a PC (as a remote device). */
+#define kvrDeviceUsage_USB       3 /**< Connected via USB cable. */
+#define kvrDeviceUsage_CONFIG    4 /**< Device is being configured via USB. */
+/** @} */
+
+
+/**
+ * Remote device accessability status.
+ * \anchor kvrAccessibility_xxx
+ * \name kvrAccessibility_xxx
+ */
+#define kvrAccessibility_UNKNOWN      0 /**< Unknown (e.g., no reply from device). */
+#define kvrAccessibility_PUBLIC       1 /**< Public (visible for all, no password required to connect). */
+#define kvrAccessibility_PROTECTED    2 /**< Protected (visible for all, password needed to connect). */
+#define kvrAccessibility_PRIVATE      3 /**< Private (invisible, password needed to connect). */
+/** @} */
+
+/**
+ * State of connection to device.
+ * \anchor kvrRemoteState_xxx
+ * \name kvrRemoteState_xxx
+ * @{
+ */
+
+#define kvrRemoteState_VOID                  0  /**< Marked as not in list. */
+#define kvrRemoteState_AVAILABLE             1  /**< Tries to ping known device. */
+#define kvrRemoteState_DISCOVERED            2  /**< Currently not used. */
+#define kvrRemoteState_STARTING              3  /**< Initializes for new device. */
+#define kvrRemoteState_STARTED               4  /**< Currently not used. */
+#define kvrRemoteState_CONNECTION_DOWN       5  /**< Will try and restore connection. */
+#define kvrRemoteState_CONNECTION_UP         6  /**< Device connected, heartbeat up. */
+#define kvrRemoteState_REDISCOVER            7  /**< Trying to talk to device. */
+#define kvrRemoteState_UNWILLING             8  /**< Device turned down connection req. */
+#define kvrRemoteState_REDISCOVER_PENDING    9  /**< Will do rediscover in a moment. */
+#define kvrRemoteState_CLOSING               10 /**< Will stop communication. */
+#define kvrRemoteState_REMOVE_ME             11 /**< Device removed, it will be stopped. */
+#define kvrRemoteState_STANDBY               12 /**< Known device, but unused. */
+#define kvrRemoteState_CONFIG_CHANGED        13 /**< Same as UNWILLING. */
+#define kvrRemoteState_STOPPING              14 /**< Tries to stop device. */
+#define kvrRemoteState_INSTALLING            15 /**< Driver installation is in progress. */
+/** @} */
+
+/**
+ * Device avalability flags.
+ * \anchor kvrAvailability_xxx
+ * \name kvrAvailability_xxx
+ * @{
+ */
+#define kvrAvailability_NONE             0 /**< Manually added. */
+#define kvrAvailability_FOUND_BY_SCAN    1 /**< Device was found by scan. */
+#define kvrAvailability_STORED           2 /**< Device was stored. */
+/** @} */
+
+
+/**
+ * \brief Holds information about a discovered device.
+ *
+ * The information in here is returned when a device is discovered.
+ * For a WLAN connected device, device_address and client_address are IP
+ * addresses, and base_station_id is the ethernet MAC address of the AP.
+ *
+ * Depending on the "availability" flag, not all fields may be used. If
+ * "availability" includes the flag \ref kvrAvailability_STORED the following
+ * fields are set: ean_hi, ean_lo, ser_no, device_address, request_connection,
+ * name and accessibility_pwd.
+ * 
+ * If the field "availability" includes the flag
+ * \ref kvrAvailability_FOUND_BY_SCAN, the following fields are set: fw_major_ver,
+ * fw_minor_ver, fw_build_ver, usage, accessibility, host_name and
+ * client_address.
+ */
+typedef struct {
+  uint32_t      struct_size;     /**< Size of struct, used for compatibility. */
+  uint32_t      ean_hi;          /**< High part of EAN. */
+  uint32_t      ean_lo;          /**< Low part of EAN. */
+  uint32_t      ser_no;          /**< Serial number. */
+  int32_t       fw_major_ver;    /**< Major firmware version. */
+  int32_t       fw_minor_ver;    /**< Minor firmware version. */
+  int32_t       fw_build_ver;    /**< Firmware build version. */
+  char          name[256];       /**< User-defined name. */
+  char          host_name[256];  /**< DNS hostname or empty. */
+  int32_t       usage;           /**< \ref kvrDeviceUsage_xxx. */
+  int32_t       accessibility;   /**< \ref kvrAccessibility_xxx. */
+  char          accessibility_pwd[256];  /**< Accessibility password or empty. */  
+  kvrAddress    device_address;  /**< Address of remote device. */
+  kvrAddress    client_address;  /**< Address of connected client, if any. */
+  kvrAddress    base_station_id; /**< Unique ID of base station, if any. */
+  int32_t       request_connection; /**< Activate or deactivate a request for connection to a specified device. 
+                                      * Activation means that the device will be connected to when it appears in the 
+                                      * future. */
+  int32_t       availability;    /**< The device availability. One or more \ref kvrAvailability_xxx flags.*/
+  char          encryption_key[32];  /**< Encryption key. */  
+  char          reserved1[256];
+  char          reserved2[256];
+} kvrDeviceInfo;
+
+/** 
+ * Handle used for discovery.
+ */
+typedef int32_t kvrDiscoveryHandle;
+
+ 
+/**
+ * Flags for setting what addresses that should be returned by
+ * \ref kvrDiscoveryGetDefaultAddresses().
+ * \anchor kvrAddressTypeFlag_xxx
+ * \name kvrAddressTypeFlag_xxx
+ * @{
+ */
+#define kvrAddressTypeFlag_ALL         0xff /**< All defined below */
+#define kvrAddressTypeFlag_BROADCAST   0x01 /**< Broadcast addresses */
+#define kvrAddressTypeFlag_STORED      0x02 /**< Previously stored addresses */
+/** @} */
+
+/**
+ * Read out the list of default broadcast addresses. If \a address_type_flags
+ * is set to \ref kvrAddressTypeFlag_ALL the returned list will contain all found
+ * addresses (both broadcast addresses and earlier stored addresses).
+ *
+ * \param[out]    address_list        An array of addresses.
+ * \param[in]     address_list_size   Number of entries in \a address_list.
+ * \param[out]    address_list_count  Number of addresses returned.
+ * \param[in]     address_type_flags  Which \ref kvrAddressTypeFlag_xxx types of addresses to return
+ *
+ * \return \ref kvrOK on success or any other \ref kvrStatus on failure.
+ */
+kvrStatus WINAPI kvrDiscoveryGetDefaultAddresses(kvrAddress address_list[],
+                                                 uint32_t address_list_size,
+                                                 uint32_t *address_list_count,
+                                                 uint32_t address_type_flags);
+
+/**
+ * Create a handle for device discovery. Used by for instance \ref kvrDiscoveryStart(). 
+ * Close with \ref kvrDiscoveryClose(). 
+ *
+ * \param[out]     handle             Discovery handle.
+ *
+ * \return \ref kvrOK on success or any other \ref kvrStatus on failure.
+ */                                              
+kvrStatus WINAPI kvrDiscoveryOpen(kvrDiscoveryHandle *handle);
+
+/**
+ * Closes the discovery handle opened with \ref kvrDiscoveryOpen().
+ *
+ * \param[in]     handle             Discovery handle.
+ *
+ * \return \ref kvrOK on success or any other \ref kvrStatus on failure.
+ */                                              
+kvrStatus WINAPI kvrDiscoveryClose(kvrDiscoveryHandle handle);
+                                     
+/**
+ * Set a list of addresses to use for discovery (overwrites any 
+ * existing addresses).
+ * Setting \a address_list_size with size = 0 will cause \ref kvrDiscoveryStart() 
+ * to only return stored devices (no network traffic). 
+ *
+ * \param[in]     handle             Discovery handle.
+ * \param[in]     address_list       An array of addresses.
+ * \param[in]     address_list_size  Number of entries in \a address_list.
+ * \return \ref kvrOK on success or any other \ref kvrStatus on failure.
+ */
+kvrStatus WINAPI kvrDiscoverySetAddresses(kvrDiscoveryHandle handle, 
+                                          const kvrAddress address_list[], 
+                                          uint32_t address_list_size);
+                        
+                        
+/**
+ * Start discovering devices on the addresses previously specified with
+ * \ref kvrDiscoverySetAddresses().  A delay of \a delay_ms ms is inferred between
+ * each device address request. After the last device address is probed, one
+ * more delay of \a timeout_ms is added before returning.
+ *
+ * This means that the function will return in (about)
+ * &lt;address_list_size&gt; * \a delay_ms + \a timeout_ms ms
+ *
+ * The results can be retrieved using \ref kvrDiscoveryGetResults(). A new call to 
+ * \ref kvrDiscoveryStart() will discard any results not yet retrieved by 
+ * \ref kvrDiscoveryGetResults().
+ *
+ * To decide if an address is a broadcast address, the ip address and subnet
+ * mask for all availible network cards are considered.
+ *
+ * Beside returning the devices discovered by scan, it will also return any
+ * devices previously stored with \ref kvrDiscoveryStoreDevices().
+ *
+ * \note A remote device with accessibility set to "private" will not reply to
+ * a broadcast scan.
+ *
+ * \param[in]  handle      Discovery handle. 
+ * \param[in]  delay_ms    Delay (in ms) in between sending discovery 
+ *                         messages to addresses in the address list.
+ * \param[in]  timeout_ms  Stop waiting for device discovery after timeout_ms milliseconds.
+ *
+ * \return \ref kvrOK on success or any other \ref kvrStatus on failure.
+ */
+kvrStatus WINAPI kvrDiscoveryStart(kvrDiscoveryHandle handle, uint32_t delay_ms,
+                                   uint32_t timeout_ms);
+ 
+/**
+ * Call this after calling \ref kvrDiscoveryStart(). The first call will return the first result, 
+ * second call will return the second etc. 
+ * Will return found devices until \ref kvrERR_BLANK is returned. 
+ *
+ * \param[in]   handle       Discovery handle. 
+ * \param[out]  device_info  Device info.
+ *
+ * \return \ref kvrOK on success or any other \ref kvrStatus on failure.
+ */ 
+kvrStatus WINAPI kvrDiscoveryGetResults(kvrDiscoveryHandle handle,
+                                        kvrDeviceInfo *device_info);
+
+/**
+ * Store a list of devices that can be discovered later. 
+ *
+ * \param[in] device_info_list        A list of devices to remember. 
+ * \param[in] device_info_list_size   The number of elements in \a device_info_list.
+ *
+ * \return \ref kvrOK on success or any other \ref kvrStatus on failure.
+ */                                 
+kvrStatus WINAPI kvrDiscoveryStoreDevices(const kvrDeviceInfo device_info_list[],
+                                          uint32_t device_info_list_size);
+                                      
+                                      
+/**
+ * Turn automatic clearing of the stored devices on/off. 
+ *
+ * \param[in] onoff        Turn auto-clear on/off. TRUE: Stored devices will 
+ * be cleared automatically when the application exits, even if the application 
+ * terminates abnormally. FALSE: Stored devices will be stored until removed. 
+ *
+ * \return \ref kvrOK on success or any other \ref kvrStatus on failure.
+ */                                 
+kvrStatus WINAPI kvrDiscoveryClearDevicesAtExit(BOOL onoff);
+
+/**
+ * Sets the accessibility password to use when connecting to a device.
+ *
+ * \param[in] device_info             The device to set the password for.
+ * \param[in] password                The password as a C string.
+ *
+ * \return \ref kvrOK on success or any other \ref kvrStatus on failure.
+ */                                 
+kvrStatus WINAPI kvrDiscoverySetPassword(kvrDeviceInfo *device_info,
+                                         const char *password);
+                                       
+/**
+ * Sets the encryption key to use when encrypting communication.
+ *
+ * \param[in] device_info             The device to set the password for.
+ * \param[in] key                     The key as a C string.
+ *
+ * \return \ref kvrOK on success or any other \ref kvrStatus on failure.
+ */                                                                        
+kvrStatus WINAPI kvrDiscoverySetEncryptionKey(kvrDeviceInfo *device_info,
+                                              const char *key);
+                                             
+                             
+/**
+ * Returns local connection status of the selected device as ASCII text.
+ *
+ * \param[in]  device_info      The device to request the status information from.
+ * \param[out] buffer           The service status as a C string.
+ * \param[in]  buffer_size      The service status buffer size.
+ *
+ * \return \ref kvrOK on success or any other \ref kvrStatus on failure.
+ */
+kvrStatus WINAPI kvrDeviceGetServiceStatusText(const kvrDeviceInfo *device_info,
+                                               char *buffer,
+                                               uint32_t buffer_size);
+
+
+/**
+ * Current service state
+ * \anchor kvrServiceState_xxx
+ * \name kvrServiceState_xxx
+ * @{
+ */
+#define kvrServiceState_VOID               0  /**< Void */
+#define kvrServiceState_AVAILABLE          1  /**< Device available */
+#define kvrServiceState_DISCOVERED         2  /**< Device discovered */
+  /**
+   * Device is starting, other devices may inhibit this device from being started 
+   * at the moment (e.g. by installing).
+   */
+#define kvrServiceState_STARTING           3  
+#define kvrServiceState_STARTED            4  /**< Device is started */
+#define kvrServiceState_CONNECTION_DOWN    5  /**< Connection is currently down */
+#define kvrServiceState_CONNECTION_UP      6  /**< Connection is corrently up */
+#define kvrServiceState_REDISCOVER         7  /**< We've lost the device - rediscover it */
+#define kvrServiceState_UNWILLING          8  /**< Unwilling, see sub state for reason */
+#define kvrServiceState_REDISCOVER_PENDING 9  /**< Rediscover is pending */
+#define kvrServiceState_CLOSING            10 /**< Closing */
+#define kvrServiceState_REMOVE_ME          11 /**< Remove me */
+#define kvrServiceState_STANDBY            12 /**< Standbe */
+#define kvrServiceState_CONFIG_CHANGED     13 /**< Configuration has changed */
+#define kvrServiceState_STOPPING           14 /**< Stopping */
+#define kvrServiceState_INSTALLING         15 /**< Device is currently being installed */
+/** @} */
+
+/**
+ * Current start information
+ * \anchor kvrStartInfo_xxx
+ * \name kvrStartInfo_xxx
+ * @{
+ */
+#define kvrStartInfo_NONE               0 /**< No information available */
+#define kvrStartInfo_START_OK           1 /**< Started OK */
+#define kvrStartInfo_ERR_IN_USE         2 /**< Already connected to someone else */
+#define kvrStartInfo_ERR_PWD            3 /**< Wrong connection pwd */
+#define kvrStartInfo_ERR_NOTME          4 /**< This start is not for me */
+#define kvrStartInfo_ERR_CONFIGURING    5 /**< I'm being configured so won't start */
+#define kvrStartInfo_ERR_PARAM          6 /**< Invalid parameters in QRV (non matching versions) */
+#define kvrStartInfo_ERR_ENCRYPTION_PWD 7 /**< Wrong encryption password.  */   
+/** @} */
+
+
+/**
+ * Returns local connection status of the selected device.
+ *
+ * \param[in]  device_info      The device to request the status information from.
+ * \param[out] state            The service state as a \ref kvrServiceState_xxx
+ * \param[out] start_info       The start information as a \ref kvrStartInfo_xxx
+ *
+ * \return \ref kvrOK on success or any other \ref kvrStatus on failure.
+ */
+kvrStatus WINAPI kvrDeviceGetServiceStatus(const kvrDeviceInfo *device_info,
+                                           int32_t *state, int32_t *start_info);
+
+/**@}*/
+
+
+
+
+/**
+ * \defgroup Helper Helper functions
+ */
+/**@{*/
+
+/**
+ * Convert a \ref kvrStatus errorcode to a text.
+ *
+ * \param[in]  error         The error code to convert.
+ * \param[out]  buffer       Buffer to receive error text.
+ * \param[in]  buffer_size   Buffer size in bytes.
+ */
+kvrStatus WINAPI kvrGetErrorText(kvrStatus error, char *buffer,
+                                 uint32_t buffer_size);
+
+/**
+ * Return the version of the kvrlib DLL.  The most significant byte is
+ * the major version number and the least significant byte is the
+ * minor version number.
+ * 
+ * \source_cs       <b>static short kvrGetVersion();</b>
+ *
+ * \source_delphi   <b>function kvrGetVersion: Word;</b> 
+ * \source_end
+ *
+ * \return version number of kvrlib32.dll
+ */
+uint16_t WINAPI kvrGetVersion(void);
+
+/**
+ * Convert a \ref kvrAddress to a text string. 
+ * The output format depends on the \ref kvrAddressType_xxx. 
+ * \a buffer_size must be the maximum lenth for each type. 
+ * i.e. \ref kvrAddressType_IPV4 must have lenght at least 16. 
+ *
+ * \param[out] buffer         The converted string as a C string.
+ * \param[in]  buffer_size    Size of buffer.
+ * \param[in]  address        The address to convert.
+ */
+kvrStatus WINAPI kvrStringFromAddress(char *buffer, uint32_t buffer_size,
+                                      const kvrAddress *address);
+
+/**
+ * Convert a C string into a \ref kvrAddress.
+  *
+ * Examples: 
+ * - <b>MAC address</b><br>
+ * address_string: "90:E6:BA:3C:32:12"<br>
+ * type: \ref kvrAddressType_MAC
+ *
+ * - <b>IP v.4</b><br>
+ * address_string: "192.168.1.142"<br>
+ * type: \ref kvrAddressType_IPV4
+ *
+ * - <b>IP v.4 with port</b><br>
+ * address_string: "192.168.1.142:8080"<br>
+ * type: \ref kvrAddressType_IPV4_PORT
+ * 
+ *
+ * \param[in]  address_type    \ref kvrAddressType_xxx to convert into.
+ * \param[out] address         Returned address.
+ * \param[in]  address_string  C string to convert into a kvrAddress.
+ */
+kvrStatus WINAPI kvrAddressFromString(int32_t address_type, kvrAddress *address,
+                                      const char *address_string);
+ 
+/**
+ * Returns a C string in human readable format from the security
+ * information gathered with \ref kvrWlanGetScanResults()
+ *
+ * Example output: 
+ * "WPA2: G-TKIP (PSK) P1-AES P2-TKIP WPA: G-TKIP (PSK) P1-AES P2-TKIP"
+ *
+ * The above example shows a network using Pre-Shared Key with both
+ * WPA2 and WPA enabled, for both modes, a group key using TKIP is
+ * needed, and in both modes you can choose between AES (CCMP) and
+ * TKIP as the cipher for the pairwise key.
+ *
+ * The length of the generated string could theoretically be up to
+ * about 180 characters. If the length of the supplied security_string
+ * is too short, the result will be truncated and the function will
+ * return \ref kvrERR_PARAMETER.
+ *
+ * \param[out] security_string       A C string.
+ * \param[in]  security_string_size  Max size of security_string.
+ * \param[in]  capability            The advertised capabilities of the BSS.
+ * \param[in]  type_wpa              Authentication suite type.
+ * \param[in]  wpa_info              Advertised information for WPA.
+ * \param[in]  rsn_info              Advertised information for RSN.
+ *
+ * \return \ref kvrOK on success or any other \ref kvrStatus on failure.
+ */
+kvrStatus WINAPI kvrWlanGetSecurityText(char *security_string,
+                                        uint32_t security_string_size,
+                                        uint32_t capability,
+                                        uint32_t type_wpa,
+                                        const kvrCipherInfoElement *wpa_info,
+                                        const kvrCipherInfoElement *rsn_info);
+
+/**
+ * Generates four 64-bit and one 128-bit WEP keys.
+ *
+ * All generated keys are returned as ASCII hexadecimal C strings.
+ *
+ * \param[in]  pass_phrase  The pass phrase as a C string.
+ * \param[out] key64_1      Generated 64-bit WEP key 1 (10 + 1 bytes).
+ * \param[out] key64_2      Generated 64-bit WEP key 2 (10 + 1 bytes).
+ * \param[out] key64_3      Generated 64-bit WEP key 3 (10 + 1 bytes).
+ * \param[out] key64_4      Generated 64-bit WEP key 4 (10 + 1 bytes).
+ * \param[out] key128       Generated 128-bit WEP key  (26 + 1 bytes).
+ *
+ * \return \ref kvrOK on success or any other \ref kvrStatus on failure.
+ */
+kvrStatus WINAPI kvrNetworkGenerateWepKeys(const char *pass_phrase,
+                                           char *key64_1, 
+                                           char *key64_2,
+                                           char *key64_3,
+                                           char *key64_4,
+                                           char *key128);
+
+/**
+ * Generates a WPA key.
+ *
+ * \param[in]  pass_phrase  The pass phrase as a C string.
+ * \param[in]  ssid         SSID as a C string. Maximum length is 32 bytes.
+ * \param[out] key          The WPA key, 256 bits as a an ASCII hexadecimal 
+ *                          C string (64 + 1 bytes).
+ *
+ * \return \ref kvrOK on success or any other \ref kvrStatus on failure.
+ */
+kvrStatus WINAPI kvrNetworkGenerateWpaKeys(const char *pass_phrase,
+                                           const char *ssid,
+                                           char *key);
+
+/**@}*/
+
+/**
+ * Initializes library stuff.
+ * Call this function before calling any other kvr function.
+ */
+void WINAPI kvrInitializeLibrary(void);
+
+
+/**
+ * Unloads library stuff.
+ * Call this function after calling all other kvr functions.
+ */
+void WINAPI kvrUnloadLibrary(void);
+
+
+/**
+ * Queries the status of the helper service. The helper service is installed as a part
+ * of the driver package and is normally set to automatic start.
+ *
+ * \note This API call requires read access to the service.
+ *
+ * \param[out]     status             Win32 status code on failure.
+ *
+ * \return \ref kvrOK on success (meaning that the service is running) or any other \ref kvrStatus on failure.
+ */                                              
+kvrStatus WINAPI kvrServiceQuery(int *status);
+
+/**
+ * Starts the helper service. The helper service is installed as a part
+ * of the driver package and is normally set to automatic start.
+ *
+ * \note This API call requires control access to the service.
+ *
+ * \param[out]     status             Win32 status code on failure.
+ *
+ * \return \ref kvrOK on success (meaning that the service is started or
+ * already is running) or any other \ref kvrStatus on failure.
+ */                                              
+kvrStatus WINAPI kvrServiceStart(int *status);
+
+/**
+ * Stops the helper service. The helper service is installed as a part
+ * of the driver package and is normally set to automatic start.
+ *
+ * \note This API call requires control access to the service.
+ *
+ * \param[out]     status             Win32 status code on failure.
+ *
+ * \return \ref kvrOK on success (meaning that the service is stopped or
+ * already is stopped) or any other \ref kvrStatus on failure.
+ */                                              
+kvrStatus WINAPI kvrServiceStop(int *status);
+
+
+/**
+ * \mainpage Remote Device API
+ *
+ * <h1>THIS IS A PRELIMINARY VERSION AND SUBJECT TO CHANGE</h1>
+ *
+ * This is an API for remote devices.
+ *
+ * - \subpage page_configuration
+ * - \subpage page_discovery
+ * - \subpage page_network
+ * - \subpage page_support
+ *
+ * \page page_support Support
+ * For support, contact support@kvaser.com
+ *
+ * \page page_discovery Device discovery
+ * The following is an example of calls that can be used for device discovery. 
+ *
+ * Initialize/Unload library
+ * - \ref kvrInitializeLibrary()  
+ * - \ref kvrUnloadLibrary()
+ *
+ * Get the default addresses used for discovering devices
+ * - \ref kvrDiscoveryGetDefaultAddresses()
+ *
+ * Discover all devices 
+ * to the device list
+ * - \ref kvrDiscoveryStart()
+ * - \ref kvrDiscoveryGetResults()
+ *
+ * Save devices you want to remember or use. 
+ * - \ref kvrDiscoveryStoreDevices()
+ *
+ * Get device status
+ * - \ref kvrDeviceGetServiceStatusText()
+ * 
+ * \page page_configuration Local Configuration
+ * When the remote device is connected to the host it can be configured. 
+ * A device can hold a number of different profiles. The number of profiles 
+ * that the device supports can be found by using \ref kvrConfigNoProfilesGet(). 
+ * Each profile contains a complete configuration. To configure a specific 
+ * profile open it with \ref kvrConfigOpenEx(). To activate a specific profile 
+ * use \ref kvrConfigActiveProfileSet(). The active profile is the one the 
+ * device will use. 
+ * 
+ * 
+ * The following is an example of calls that are used to configure a device. 
+ *
+ * Initialize/Unload library
+ * - \ref kvrInitializeLibrary() 
+ * - \ref kvrUnloadLibrary() 
+ *
+ * Get the number of supported profiles. 
+ * - \ref kvrConfigNoProfilesGet()
+ *
+ * Get and set the active profile. 
+ * - \ref kvrConfigActiveProfileGet()
+ * - \ref kvrConfigActiveProfileSet()
+ *
+ * Open the device's configuration area. If protected, you need to enter a
+ * password as well.
+ * - \ref kvrConfigOpen()
+ * - \ref kvrConfigOpenEx()
+ *
+ * If password is unknown, it is possible to first clear entire area including 
+ * password
+ * - \ref kvrConfigClear()
+ *
+ * Write new configuration and read the configuration from the device
+ * - \ref kvrConfigSet()
+ * - \ref kvrConfigGet()
+ *
+ * Close the device's configuration area for writing
+ * - \ref kvrConfigClose() 
+ *
+ * \page page_network Network information
+ * The following is an example of calls that are used for network maintenance. 
+ *
+ * Initialize library
+ * - \ref kvrInitializeLibrary()  
+ *
+ * Start scan for existing WLAN networks and get the result
+ * - \ref kvrWlanStartScan()
+ * - \ref kvrWlanGetScanResults()
+ *
+ * Get device's IP settings
+ * - \ref kvrNetworkGetAddressInfo()
+ *
+ * Get status information; WLAN connection state, RSSI, RTT, TX power etc.
+ * - \ref kvrNetworkGetConnectionStatus()
+ *
+ * Start sending 'ping' and get latest RTT (and RSSI) values.
+ * - \ref kvrNetworkConnectionTest()
+ * - \ref kvrNetworkGetRssiRtt() 
+ */
+
+ 
+/**
+ * \example kvrConnect.c
+ * \example kvrConfig.c
+ * \example kvrNetworkConnectionTest.c
+ */
+
+#ifdef __cplusplus
+}
+#endif
+ 
+#endif
Index: trunk/CanGateway/driver/kvaser/windows/linlib.h
===================================================================
--- trunk/CanGateway/driver/kvaser/windows/linlib.h	(revision 93)
+++ trunk/CanGateway/driver/kvaser/windows/linlib.h	(revision 93)
@@ -0,0 +1,711 @@
+/**
+ * \section LICENSE
+ *                   Copyright 2003-2013 by KVASER AB, SWEDEN
+ *                        WWW: http://www.kvaser.com
+ *
+ * This software is furnished under a license and may be used and copied
+ * only in accordance with the terms of such license.
+ *
+ * \section DESCRIPTION
+ *
+ *   Definitions for the LINlib API.
+ *
+ * \file linlib.h
+ * \author Kvaser AB
+ */
+
+#ifndef __LINLIB_H
+#define __LINLIB_H
+
+/**
+ * \defgroup LIN LIN
+ * @{
+ */
+
+ /**
+  * LIN handle
+  */
+typedef int LinHandle;
+
+/**
+ * Invalid LIN handle
+ */
+#define linINVALID_HANDLE      ((LinHandle)(-1))
+
+#if !WIN32
+#  define CompilerAssert(exp) extern char _CompilerAssert[(exp) ? 1 : -1]
+#endif
+
+
+/**
+ * \name Return codes from the LINlib functions
+ * \anchor linERR_xxx
+ * @{
+ */
+typedef enum {
+  linOK                  = 0,      ///< OK - no error
+  linERR_NOMSG           = -1,     ///< No messages available
+  linERR_NOTRUNNING      = -3,
+  linERR_RUNNING         = -4,
+  linERR_MASTERONLY      = -5,
+  linERR_SLAVEONLY       = -6,
+  linERR_PARAM           = -7,     ///< Error in parameter 
+  linERR_NOTFOUND        = -8,     ///< Specified hardware not found. This error is reported when the LIN transceiver isn't powered up
+  linERR_NOMEM           = -9,     ///< Out of memory
+  linERR_NOCHANNELS      = -10,    ///< No channels avaliable
+  linERR_TIMEOUT         = -11,    ///< Timeout occurred
+  linERR_NOTINITIALIZED  = -12,    ///< Library not initialized
+  linERR_NOHANDLES       = -13,    ///< Can't get handle
+  linERR_INVHANDLE       = -14,    ///< Handle is invalid
+  linERR_CANERROR        = -15,
+  linERR_ERRRESP         = -16,    ///< There was an error response from the LIN interface
+  linERR_WRONGRESP       = -17,    ///< The LIN interface response wasn't the expected one
+  linERR_DRIVER          = -18,    ///< CAN driver type not supported
+  linERR_DRIVERFAILED    = -19,    ///< DeviceIOControl failed; use the Win32 GetLastError API to get the real (WIn32) error code.
+  linERR_NOCARD          = -20,    ///< The card was removed or not inserted
+  linERR_LICENSE         = -21,    ///< The license is not valid
+  linERR_INTERNAL        = -22,    ///< Internal error in the driver
+  linERR_NO_ACCESS       = -23,    ///< Access denied
+  linERR_VERSION         = -24     ///< Function not supported in this version
+} LinStatus;
+/** @} */
+
+
+// sizeof(LinMessageInfo) should be 68 for correct alignment
+#if WIN32
+#include <pshpack1.h>
+#endif
+
+/**
+ * In certain LIN bus API calls, the following structure is used to provide more 
+ * information about the LIN messages.
+ *
+ * \note The precision of the timing data given in us (microseconds) can be less 
+ * than one microsecond; for low bitrates the lowest bits might always be zero.
+ * 
+ * \note The min and max values listed inside [] of the message timing values 
+ * can be calculated from the LIN specification by using the shortest (0 bytes) 
+ * or longest (8 bytes) messages at the lowest or highest allowed bitrate.
+ *
+ * \note The LIN interface will accept messages that are a bit out-of-bounds as 
+ * well.
+ */
+typedef struct {
+  /**
+   * Kvaser DRV Lin timestamp - Timestamp in milliseconds of the falling edge of
+   * the synch break of the message. Uses the canlib CAN timer.
+   *
+   * Kvaser LIN Leaf timestamp - Timestamp in milliseconds of the falling edge 
+   * of the synch break of the message. Uses the canlib CAN timer. 
+   *
+   * \note All Kvaser Leaf with Kvaser MagiSync&tm; are synchronized 
+   * (also with CAN channels).
+   */
+  unsigned long timestamp;
+
+  /** 
+   * Length of the synch break in microseconds.
+   * [650 .. 13000],  [400 .. 8000] for a wakeup signal.
+   */
+  unsigned long synchBreakLength;
+
+  /**
+   * The total frame length in microseconds; from the synch break to the
+   * end of the crc. [2200 .. 173600]
+   */
+  unsigned long frameLength;
+
+  /**
+   * The bitrate of the message in bits per seconds.
+   * Range [1000 .. 20000] (plus some margin)
+   */
+  unsigned long bitrate;
+
+  /**
+   * The checksum as read from the LIN bus. Might not
+   * match the data in case of \ref LIN_CSUM_ERROR.
+   */
+  unsigned char checkSum;
+
+  /**
+   * The id with parity of the message as read from the
+   * LIN bus. Might be invalid in case of \ref LIN_PARITY_ERROR.
+   */
+  unsigned char idPar;
+
+  unsigned short z; ///< Dummy for alignment
+
+  /**
+   * Time in microseconds of the falling edges in the
+   * synch byte relative the falling edge of the start bit.
+   */
+  unsigned long synchEdgeTime[4];
+
+  /**
+   * Start time in microseconds of each data byte. In case of 8-byte messages, 
+   * the crc time isn't included (but can be deduced from frameLength).
+   */
+   unsigned long byteTime[8];
+} LinMessageInfo;
+
+#if WIN32
+#include <poppack.h>
+#endif
+
+
+/**
+ * \name LIN message flags
+ * \anchor LIN_xxx
+ * The following flags can be returned from \ref linReadMessage() and 
+ * \ref linReadMessageWait().
+ *
+ * @{
+ */
+#define LIN_TX              1   ///< The message was something we transmitted on the bus
+#define LIN_RX              2   ///< The message was something we received from the bus
+#define LIN_WAKEUP_FRAME    4   ///< A wake up frame was received. Id/msg/dlc are undefined
+#define LIN_NODATA          8   ///< No data, only a header
+#define LIN_CSUM_ERROR      16  ///< Checksum error
+#define LIN_PARITY_ERROR    32  ///< ID parity error
+#define LIN_SYNCH_ERROR     64  ///< A synch error
+#define LIN_BIT_ERROR       128 ///< Bit error when transmitting
+/** @} */
+
+/**
+ * Macro for determining if a flag field contains a LIN error flag bit.
+ */
+#define LINERROR(f) ((f) & (LIN_NODATA | LIN_CSUM_ERROR | LIN_SYNCH_ERROR | LIN_BIT_ERROR))
+
+
+// Define LINLIBAPI unless it's done already.
+// (linlib.c provides its own definition of LINLIBAPI before including this file.)
+//
+#if WIN32
+#ifndef LINLIBAPI
+#   if defined(__BORLANDC__)
+#      define LINLIBAPI __stdcall
+#   elif defined(_MSC_VER) || defined(__MWERKS__) || defined(__GNUC__)
+#      define LINLIBAPI __stdcall
+#   endif
+#endif
+#else
+#define LINLIBAPI
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/** 
+ * This function initializes the LIN library and must be called before any other 
+ * LIN function is called. If this function isn't called, subsequent calls to 
+ * the other LIN functions will return \ref linERR_NOTINITIALIZED.
+ *
+ * \sa \ref linOpenChannel()
+ */
+void LINLIBAPI linInitializeLibrary(void);
+
+
+/** 
+ * Retrieves the transceiver information for a CAN channel. The application 
+ * typically uses this call to find out whether a particular CAN channel has a 
+ * LIN interface connected to it.
+ * For a Kvaser LIN Leaf it retrieves the transceiver type and device information.
+ *
+ * This function call will open the CAN channel, but no CAN messages are 
+ * transmitted on it. In other words, it's risk-free to use even if no LIN 
+ * interface is connected, or if the channel is connected to a CAN system. 
+ *
+ * \note Attempts to use the channel for LIN communication will be meaningful 
+ * only if \ref linGetTransceiverData() stores \ref canTRANSCEIVER_TYPE_LIN in \a ttype. 
+ *
+ * \note A LIN interface need not be powered for this call to succeed. 
+ *
+ * \note The information may not always be accurate. Especially after changing 
+ * transceiver on a running LAPcan card, you should go on bus and off bus again 
+ * to be sure the transceiver information is updated. 
+ *
+ * \param[in]  channel The number of a CAN channel for which the transceiver 
+ *                     data will be retrieved. 
+ * \param[out] eanNo   A pointer to an array of 8 bytes where the EAN number of 
+ *                     the LIN interface will be stored. 
+ * \param[out] serNo   A pointer to an array of 8 bytes where the serial number 
+ *                     of the LIN interface will be stored. 
+ * \param[out] ttype   A pointer to an integer where the transceiver type will 
+ *                     be stored.
+ *
+ * \return \ref linOK (zero) if success
+ * \return \ref linERR_xxx (negative) if failure
+ *
+ * \sa \ref linGetFirmwareVersion()
+ */ 
+LinStatus LINLIBAPI linGetTransceiverData(int channel, unsigned char eanNo[8],
+                                          unsigned char serNo[8], int *ttype);
+
+/** 
+ * Open a channel to a LIN interface.
+ *
+ * \note For DRV Lin: The cable must be powered and connected to a LAPcan channel.
+ *
+ * \note For Kvaser LIN Leaf: The Leaf must be powered from the LIN side.
+ *
+ * \param[in] channel  The number of the channel. Channel numbering is hardware
+ *                     dependent. 
+ *                     This is the same channel number as used by \ref canOpenChannel().
+ * \param[in] flags    Either one of the following values: \ref LIN_MASTER or 
+ *                     \ref LIN_SLAVE. 
+ *
+ * \return If the call succeeds, a handle to the opened channel is returned. 
+ * The handle is an integer greater than or equal to zero.
+ *
+ * \return If the call fails, the return value is a negative integer indicating 
+ * an error code. See \ref linERR_xxx for a list of possible error codes.
+ *
+ * \sa \ref linClose()
+ */
+LinHandle LINLIBAPI linOpenChannel(int channel, int flags);
+
+
+/**
+ * \name Flags for linOpenChannel()
+ * @{
+ */
+#define LIN_MASTER 1 ///< The LIN interface will be a LIN master
+#define LIN_SLAVE 2  ///< The LIN interface will be a LIN slave
+/** @} */
+
+
+/** 
+ * Closes an open handle to a LIN channel. The handle becomes invalid and can 
+ * not be used in subsequent calls to the LIN functions.
+ *
+ * \param[in] h        A handle to an open LIN channel.
+ *
+ * \return \ref linOK (zero) if success
+ * \return \ref linERR_xxx (negative) if failure
+ *
+ * \sa \ref linOpenChannel()
+ */
+LinStatus LINLIBAPI linClose(LinHandle h);
+
+/**
+ * This function retrieves the firmware version from the LIN interface.
+ *
+ * 
+ * \note The version numbers aren't valid until \ref linBusOn() has been called.
+ *
+ * \note The firmware in the LIN interface is divided into two parts, the boot 
+ * code and the application. The boot code is used only when reprogramming 
+ * (reflashing) the LIN interface. The application handles all LIN communication.
+ *
+ * \note Version numbers are, since the precambric era, divided into a major 
+ * version number, a minor version number and a build number. These are usually 
+ * written like, for example, 3.2.12. Here the major number is 3, the minor 
+ * number 2 and the build number 12.
+ *
+ * \param[in]  h             A handle to an open LIN channel.
+ * \param[out] bootVerMajor  A pointer to a byte where the major version number 
+ *                           of the boot code is stored. 
+ * \param[out] bootVerMinor  A pointer to a byte where the minor version number 
+ *                           of the boot code is stored. 
+ * \param[out] bootVerBuild  A pointer to a byte where the build number of the 
+ *                           boot code is stored. 
+ * \param[out] appVerMajor   A pointer to a byte where the major version number 
+ *                           of the application code is stored.
+ * \param[out] appVerMinor   A pointer to a byte where the minor version number 
+ *                           of the application code is stored. 
+ * \param[out] appVerBuild   A pointer to a byte where the build number of the application is stored. 
+ *
+ * \return \ref linOK (zero) if success
+ * \return \ref linERR_xxx (negative) if failure
+ */
+LinStatus LINLIBAPI linGetFirmwareVersion(LinHandle h,
+                                          unsigned char *bootVerMajor,
+                                          unsigned char *bootVerMinor,
+                                          unsigned char *bootVerBuild,
+                                          unsigned char *appVerMajor,
+                                          unsigned char *appVerMinor,
+                                          unsigned char *appVerBuild);
+
+/** 
+ * This function sets the bit rate for a master, or the initial bit rate for a 
+ * slave. The LIN interface should not be on-bus when this function is called.
+ *
+ * \note The LIN Interface should not be on bus.
+ *
+ * \note Supported bit rates are 1000 - 20000 bits per second.
+ *
+ * \param[in] h   A handle to an open LIN channel.
+ * \param[in] bps Bit rate in bits per second.
+ *
+ * \return \ref linOK (zero) if success
+ * \return \ref linERR_xxx (negative) if failure
+ */
+LinStatus LINLIBAPI linSetBitrate(LinHandle h, unsigned int bps);
+
+/** 
+ * This function activates the LIN interface.
+ *
+ * \note It will be reset, so any setups done earlier will be lost.
+ *
+ * \param[in] h A handle to an open LIN channel.
+ *
+ * \return \ref linOK (zero) if success
+ * \return \ref linERR_xxx (negative) if failure
+ *
+ * \sa \ref linBusOff()
+ */
+LinStatus LINLIBAPI linBusOn(LinHandle h);
+
+/** 
+ * This function deactivates the LIN interface. It will not participate further 
+ * in the LIN bus traffic.
+ *
+ * \param[in] h A handle to an open LIN channel.
+ *
+ * \return \ref linOK (zero) if success
+ * \return \ref linERR_xxx (negative) if failure
+ *
+ * \sa \ref linBusOn()
+ */
+LinStatus LINLIBAPI linBusOff(LinHandle h);
+
+/** 
+ * Return the current timer value (used for timestamps)
+ *
+ * \note For convenience, this call returns the timer value instead of passing 
+ * it in a parameter. This means that if the call fails, it will still return 
+ * a value (which then is the error code, type casted to a long unsigned 
+ * integer - e.g. 0xFFFFFFF2 for \ref linERR_INVHANDLE. Watch out. 
+ *
+ * \param[in] h        A handle to an open LIN channel.
+ * \return If the call succeeds, the present timer value is returned.
+ */
+unsigned long LINLIBAPI linReadTimer(LinHandle h);
+
+/** 
+ * Write a LIN message.
+ * It is advisable to wait until the message is echoed by \ref linReadMessage() 
+ * before transmitting a new message, or in case of a schedule table being used, 
+ * transmit the next message when the previous one is known to be complete.
+ * 
+ * \note Only available in master mode.
+ *
+ * \param[in] h        A handle to an open LIN channel.
+ * \param[in] id       The identifier of the LIN message.
+ * \param[in] msg      A pointer to a buffer containing the data of the LIN 
+ *                     message.
+ * \param[in] dlc      The length of the LIN message. 
+ *
+ * \return \ref linOK (zero) if success
+ * \return \ref linERR_xxx (negative) if failure
+ *
+ * \sa \ref linWriteSync()
+ */
+LinStatus LINLIBAPI linWriteMessage(LinHandle h, unsigned int id, const void *msg,
+                                    unsigned int dlc);
+
+/** 
+ * This function writes a LIN message header to the LIN bus. A slave in the 
+ * system is then expected to fill in the header with data. 
+ *
+ * \note This call is only available in master mode. 
+ *
+ * \param[in] h        A handle to an open LIN channel.
+ * \param[in] id       The identifier of the LIN message. 
+ *
+ * \return \ref linOK (zero) if success
+ * \return \ref linERR_xxx (negative) if failure
+ */
+LinStatus LINLIBAPI linRequestMessage(LinHandle h, unsigned int id);
+
+/** 
+ * Read a message from the LIN interface. If a message is available for 
+ * reception, \ref linOK is returned. This is a non-blocking call. If no message 
+ * is available in the LIN interface, an error code is returned.
+ *
+ * \note This call will also return echoes of what the LIN interface is 
+ * transmitting with \ref linWriteMessage. In other words, the LIN interface can hear 
+ * itself. 
+ *
+ * \param[in] h        A handle to an open LIN channel.
+ * \param[out] id      A pointer to an integer where the identifier of the 
+ *                     received LIN message will be stored. 
+ * \param[out] msg     A pointer to a buffer where the data of the LIN message 
+ *                     will be stored. 
+ * \param[out] dlc     A pointer to an integer where the length of the received 
+ *                     LIN message will be stored. 
+ * \param[out] flags   A combination of zero or more of the \ref LIN_xxx flags. 
+ * \param[out] msgInfo A pointer to a \ref LinMessageInfo struct where data about the 
+ *                     received LIN message will be stored. 
+ *
+ * \return \ref linOK (zero) if success
+ * \return \ref linERR_xxx (negative) if failure
+ *
+ * \sa \ref linReadMessageWait()
+ */
+LinStatus LINLIBAPI linReadMessage(LinHandle h, unsigned int *id, void *msg,
+                                   unsigned int *dlc, unsigned int *flags,
+                                   LinMessageInfo *msgInfo);
+
+/** 
+ * Read a message from the LIN interface. If a message is available for 
+ * reception, \ref linOK is returned. This is a blocking call. It waits until a 
+ * message is received in the LIN interface, or the specified timeout period 
+ * elapses.
+ *
+ * \note This call will also return echoes of what the LIN interface is 
+ * transmitting with \ref linWriteMessage(). In other words, the LIN interface can
+ * hear itself. 
+ *
+ * \param[in] h        A handle to an open LIN channel.
+ * \param[in] timeout  The maximum number of milliseconds to wait for a message 
+ *                     to be received by the LIN interface. 
+ * \param[out] id      A pointer to an integer where the identifier of the 
+ *                     received LIN message will be stored. 
+ * \param[out] msg     A pointer to a buffer where the data of the LIN message 
+ *                     will be stored. 
+ * \param[out] dlc     A pointer to an integer where the length of the received 
+ *                     LIN message will be stored. 
+ * \param[out] flags   A combination of zero or more of the \ref LIN_xxx flags. 
+ * \param[out] msgInfo A pointer to a \ref LinMessageInfo struct where data about the 
+ *                     received LIN message will be stored. 
+ *
+ * \return \ref linOK (zero) if success
+ * \return \ref linERR_xxx (negative) if failure
+ *
+ * \sa \ref linReadMessage()
+ */
+LinStatus LINLIBAPI linReadMessageWait(LinHandle h, unsigned int *id, void *msg,
+                                       unsigned int *dlc, unsigned int *flags,
+                                       LinMessageInfo *msgInfo, unsigned long timeout);
+
+/**
+ * This function updates a message buffer in a slave. The contents of the 
+ * message buffer will be used the next time the slave is polled for the 
+ * specified LIN message id.
+ *
+ * \note The LIN Interface must be on bus.
+ *
+ * \param[in] h        A handle to an open LIN channel.
+ * \param[in] id       The identifier of the LIN message. 
+ * \param[in] msg      A pointer to a buffer containing the data of the LIN message.
+ * \param[in] dlc      The length of the LIN message. 
+ *
+ * \return \ref linOK (zero) if success
+ * \return \ref linERR_xxx (negative) if failure
+ *
+ * \sa \ref linClearMessage()
+ */
+LinStatus LINLIBAPI linUpdateMessage(LinHandle h, unsigned int id, const void *msg,
+                                     unsigned int dlc);
+
+
+/**
+ * Using this function, it is possible to use the LIN interface to create 
+ * corrupted LIN messages. You call the function once for each LIN identifier 
+ * that should be affected. 
+ *
+ * To return to normal mode, either restart the LIN interface (by going off bus 
+ * and on the bus again) or call the function with delay and \a cFlags set to zero.
+ *
+ * \note  The LIN Interface must be on bus for this command to work.
+ * \note It is supported in firmware version 2.4.1 and later.
+ *
+ * \param[in] h        A handle to an open LIN channel.
+ * \param[in] id       The identifier of the LIN message. 
+ * \param[in] cFlags   One or more of the \ref LIN_MSG_DISTURB_xxx flags.
+ * \param[in] delay    The delay parameter will result in a delay of this many 
+ *                     bittimes after the header and before the first data byte. 
+ *
+ * \return \ref linOK (zero) if success
+ * \return \ref linERR_xxx (negative) if failure
+ *
+ * \sa \ref linSetupLIN()
+ */
+LinStatus LINLIBAPI linSetupIllegalMessage(LinHandle h, unsigned int id,
+                                           unsigned int cFlags, unsigned int delay);
+                                           
+/**
+ * \name LIN illegal message flags
+ * \anchor LIN_MSG_DISTURB_xxx
+ * @{
+ */
+/**
+ * The checksum of transmitted messages will be inverted (and consequently illegal.)
+ */
+#define LIN_MSG_DISTURB_CSUM   1
+/**
+ * The two parity bits will be inverted (and consequently illegal.)
+ * Used only in master mode.
+ */
+#define LIN_MSG_DISTURB_PARITY 2
+/** @} */
+
+
+/**
+ * \name LIN message parity
+ * \anchor LIN_MSG_USE_xxx
+ * @{
+ */
+/**
+ * Use enhanced (2.x) parity for the specified msg
+ */
+#define LIN_MSG_USE_STANDARD_PARITY 0x04
+/**
+ * Use standard (1.x) parity for the specified msg
+ */ 
+#define LIN_MSG_USE_ENHANCED_PARITY 0x08 
+/** @} */
+
+/** 
+ * This function changes various settings on a LIN Interface that is on bus.
+ * When going on bus, the bit rate and the flag values listed below are set to 
+ * the default value (either as hard-coded in the firmware, or as stored in the 
+ * non-volatile memory of the LIN Interface). 
+ *
+ * With this function, you can do one or more of the following things:
+ * - Select checksum according to LIN 2.0 
+ * - Turn variable message length off. The message length then will depend on 
+ *   the message ID. 
+ *
+ * In master mode it is also possible to change the bit rate without going off 
+ * bus first.
+ *
+ * \note The LIN Interface must be on bus for this command to work.
+ * \note It is supported in firmware version 2.5.1 and later.
+ * \note For LIN 2.0 compliance, you must specify both \ref LIN_ENHANCED_CHECKSUM 
+ * and \ref LIN_VARIABLE_DLC. 
+ *
+ * \param[in] h        A handle to an open LIN channel.
+ * \param[in] lFlags   One or more of the following flags: 
+ *                     \ref LIN_ENHANCED_CHECKSUM, \ref LIN_VARIABLE_DLC 
+ * \param bps          Specifies the bit rate in bits per second. This parameter 
+ *                     can be used only in master mode. The bit rate is set 
+ *                     without going off bus. 
+ *
+ * \return \ref linOK (zero) if success
+ * \return \ref linERR_xxx (negative) if failure
+ *
+ * \sa \ref linSetupIllegalMessage()
+ */
+LinStatus LINLIBAPI linSetupLIN(LinHandle h, unsigned int lFlags, unsigned int bps);
+
+
+/**
+ * \name LIN setup
+ * @{
+ */
+/**
+ * When specified, the LIN interface will use the "enhanced" checksum according 
+ * to LIN 2.0. Note that (as per the LIN 2.0 spec) the enhanced checksum is not 
+ * used on the diagnostic frames even if the \ref LIN_ENHANCED_CHECKSUM setting 
+ * is in effect. 
+ *
+ * The default value is OFF.
+ */
+#define LIN_ENHANCED_CHECKSUM  1
+/**
+ * When specified, turns variable message length on, so the the message length 
+ * will depend on the message ID. 
+ *
+ * The default value is ON.
+ */
+#define LIN_VARIABLE_DLC       2
+/** @} */
+
+/** 
+ * Write a wakeup frame.
+ *
+ * If count is zero, one single wakeup frame is transmitted. If count > 1, 
+ * several wakeup frames are transmitted spaced with 'interval' bittimes. 
+ * The LIN interface will interrupt the sequence when a LIN message or another 
+ * command is received. The stream of wakeups will be recived as incoming 
+ * messages with the LIN_RX flag bit set.
+ *
+ * \param[in] h        A handle to an open LIN channel.
+ * \param[in] count    The number of wakeup frames to send. 
+ * \param[in] interval The time, in bit times, between the wakeup frames.
+ *
+ * \return \ref linOK (zero) if success
+ * \return \ref linERR_xxx (negative) if failure
+ */
+LinStatus LINLIBAPI linWriteWakeup(LinHandle h, unsigned int count,
+                                   unsigned int interval);
+
+
+/**
+ * Clear a message buffer for a LIN slave. The message buffer will not answer 
+ * next time it is polled.
+ *
+ * \param[in] h        A handle to an open LIN channel.
+ * \param[in] id       The LIN message id for which the corresponding buffer 
+ *                     will be cleared. 
+ *
+ * \return \ref linOK (zero) if success
+ * \return \ref linERR_xxx (negative) if failure
+ */
+LinStatus LINLIBAPI linClearMessage(LinHandle h, unsigned int id);
+
+/** 
+ * Call this function to make sure all messages transmitted to the
+ * LIN Interface has been received by it.
+ *
+ * When messages are transmitted to the LIN Interface, they are queued by
+ * Windows before appearing on the CAN bus.
+ *
+ * The function returns \ref linOK if all writes are done, \ref linERR_TIMEOUT in
+ * case of timeout or possibly some other error code.
+ *
+ * If the LIN Interface is in master mode and a LIN message has been 
+ * transmitted with \ref linWriteMessage(), this function will return when
+ * the LIN Interface has received the message. If another LIN messa ge is being
+ * received or transmitted, the message will not be transmitted on the
+ * LIN bus at once. And even if the LIN Interface is idle, the header of the new
+ * message will just have been started when \ref linWriteSync() retur ns.
+ * 
+ * After calling \ref linUpdateMessage() and \ref linClearMessage() for a slave,
+ * this function is enough to know that the LIN Interface is updated. 
+ * 
+ * After \ref linWriteMessage(), it is advisable to wait until the message is
+ * echoed by \ref linReadMessage() before transmitting a new message, or in
+ * case of a schedule table being used, transmit the next message when
+ * the previous one is known to be complete.
+ *
+ * When, in master mode, a message should be transmitted after a poll
+ * (reception) is done, it might be necessary to call \ref linWriteMessage()
+ * before the result is received via \ref linReadMessage() as the LIN Interface waits
+ * up to the maximum frame length before knowing a received message is
+ * complete. A new message to transmit will force completion if the
+ * currently received one.
+ *
+ * \param[in]  h       A handle to an open LIN channel.
+ * \param[in] timeout  The maximum number of milliseconds to wait for the queued 
+ *                     messages to be transmitted by the LIN interface. 
+ *
+ * \return \ref linOK (zero) if success
+ * \return \ref linERR_xxx (negative) if failure
+ *
+ * \sa \ref linWriteMessage()
+ */
+LinStatus LINLIBAPI linWriteSync(LinHandle h, unsigned long timeout);
+
+/**
+ * Return the CAN handle given an open LIN handle
+ *
+ * \param[in]  h          A handle to an open LIN channel.
+ * \param[out] canHandle  A pointer to an integer where the CAN handle will be 
+ *                        stored. 
+ *
+ * \return \ref linOK (zero) if success
+ * \return \ref linERR_xxx (negative) if failure
+ */
+LinStatus LINLIBAPI linGetCanHandle(LinHandle h, unsigned int *canHandle);
+
+#ifdef __cplusplus
+}
+#endif
+
+/** @} */
+
+#endif // __LINLIB_H
Index: trunk/CanGateway/driver/kvaser/windows/obsolete.h
===================================================================
--- trunk/CanGateway/driver/kvaser/windows/obsolete.h	(revision 93)
+++ trunk/CanGateway/driver/kvaser/windows/obsolete.h	(revision 93)
@@ -0,0 +1,295 @@
+/**
+ * \section LICENSE
+ *                   Copyright 1998-2011 by KVASER AB, SWEDEN
+ *
+ *                        WWW: http://www.kvaser.com
+ *
+ * This software is furnished under a license and may be used and copied
+ * only in accordance with the terms of such license.
+ *
+ * \section DESCRIPTION
+ *
+ *   This file contains definitions which are retained for compatibility.
+ *
+ * \file obsolete.h
+ * \author Kvaser AB
+ */
+
+#ifndef _OBSOLETE_H_
+#define _OBSOLETE_H_
+
+/**
+ * \defgroup Obsolete Obsolete API Reference
+ * @{
+ */
+
+#define canCIRCUIT_ANY          -1   ///< Any circuit will do \warning Obsolete! 
+#define canCARD_ANY             -1   ///< Any card will do    \warning Obsolete! 
+#define canCHANNEL_ANY          -1   ///< Any channel will do \warning Obsolete! 
+
+#define CANID_METAMSG  (-1L)        ///< Like msgs containing bus status changes. \warning Obsolete! 
+#define CANID_WILDCARD (-2L)        ///< We don't care or don't know. \warning Obsolete! 
+
+/**
+ * Retained for compatibility.
+ */
+ 
+/**
+ * \warning Obsolete!
+ */
+typedef void* (*canMemoryAllocator)  (size_t size);
+
+/**
+ * \warning Obsolete!
+ */
+typedef void  (*canMemoryDeallocator)(void* p);
+
+/**
+ * \warning Obsolete!
+ */
+typedef struct tagCanHWDescr {
+    int                    circuitType;
+    int                    cardType;
+    int                    channel;
+} canHWDescr;
+
+/**
+ * \warning Obsolete!
+ */
+typedef struct tagCanSWDescr {
+    unsigned int           rxBufSize;
+    unsigned int           txBufSize;
+    canMemoryAllocator     alloc;
+    canMemoryDeallocator   deAlloc;
+} canSWDescr;
+
+#ifdef __WIN32__
+/**
+ * \warning Obsolete!
+ */
+typedef struct {
+    unsigned int size;
+    unsigned int rxBufSize;
+    unsigned int txBufSize;
+} canSWDescriptorEx;
+#endif
+
+/**
+ * \warning Obsolete!
+ */
+canStatus CANLIBAPI canLocateHardware(void);
+
+/**
+ * \warning Obsolete!
+ */
+int CANLIBAPI canOpen(const canHWDescr * const hwdescr,
+                      const canSWDescr * const swdescr,
+                      const unsigned int flags);
+
+/**
+ * \warning Obsolete!
+ */
+canStatus CANLIBAPI canGetCircuits(int * context,
+                                   char * name,
+                                   char * vendor,
+                                   char * version,
+                                   unsigned int * cardtype,
+                                   unsigned int * circtype,
+                                   unsigned int * channel);
+
+/**
+ * \name Some obsolete codes; they are not used nowadays.
+ * \warning Obsolete!
+ * @{
+ */
+#define canERR_BUFOFL           canERR_RESERVED_3   ///< "Buffer overflow"                 \warning Obsolete!
+#define canERR_REINIT           canERR_RESERVED_4   ///< "Reinitialization failed"         \warning Obsolete!
+#define canERR_MSGLOST          canERR_RESERVED_5   ///< "Message lost by CAN-chip"        \warning Obsolete!
+#define canERR_OVERRUN          canERR_RESERVED_6   ///< "Receive buffer overrun"          \warning Obsolete!
+#define canERR_CARDCOMMFAILED   canERR_RESERVED_7   ///< "Can't communicate with the card" \warning Obsolete!
+/** @} */
+
+/**
+ * \name Circuit status flags, retained for compatibility
+ * \warning Obsolete!
+ * @{
+ */
+#define canCIRCSTAT_ERROR_PASSIVE 0x0001    ///< Error passive \warning Obsolete!
+#define canCIRCSTAT_BUS_OFF       0x0002    ///< Bus off \warning Obsolete!
+#define canCIRCSTAT_ERROR_WARNING 0x0004    ///< Error counter > 96 \warning Obsolete!
+/** @} */
+
+/**
+ * \name Sticky status flags
+ * \warning Obsolete!
+ * @{
+ */
+#define canSTICKY_ACK_ERROR       0x80000801 ///< \warning Obsolete!
+#define canSTICKY_FORM_ERROR      0x80000002 ///< \warning Obsolete!
+#define canSTICKY_STUFF_ERROR     0x80000004 ///< \warning Obsolete!
+#define canSTICKY_CRC_ERROR       0x80000008 ///< \warning Obsolete!
+#define canSTICKY_BIT0_ERROR      0x80000010 ///< \warning Obsolete!
+#define canSTICKY_BIT1_ERROR      0x80000020 ///< \warning Obsolete!
+#define canSTICKY_HW_OVERRUN      0x80000040 ///< \warning Obsolete!
+#define canSTICKY_SW_OVERRUN      0x80000080 ///< \warning Obsolete!
+/** @} */
+
+#define canSTAT_INACTIVE          canSTAT_RESERVED_1    ///< The circuit is not active (removed from the sw bus) \warning Obsolete!
+
+
+/*
+#define canCIRCSTAT_TXERR       0x0001      // TX error has occurred
+#define canCIRCSTAT_RXERR       0x0002      // Receive error has occurred
+#define canCIRCSTAT_OVERRUN     0x0004      // Receiver overrun
+#define canCIRCSTAT_WAKEUP      0x0008      // Wakeup has occurred
+#define canCIRCSTAT_INT         0x0010      // ??
+#define canCIRCSTAT_ACK         0x0020      // ACK error
+#define canCIRCSTAT_BIT         0x0040      // Bit error
+*/
+/*
+More apocryphs.
+#define canCIRCSTAT_OVERRUN     0x0004      // Receiver overrun
+#define canCIRCSTAT_WAKEUP      0x0008      // Wakeup has occurred
+#define canCIRCSTAT_ACK         0x0010      // ACK error
+#define canCIRCSTAT_BIT0        0x0020      // Bit error
+#define canCIRCSTAT_BIT1        0x0040      // Bit error
+#define canCIRCSTAT_BOFF        0x0080      // Chip went Bus Off
+*/
+/*
+Even more.
+#define canCIRCSTAT_BOFF_HW     0x10000L      // Chip is Bus Off
+#define canCIRCSTAT_BOFF_SW     0x20000L      // We are Bus Off
+*/
+
+
+/**
+ * \name Flags for canOpen
+ * \warning Obsolete! Use \ref canOPEN_xxx instead.
+ * @{
+ */
+#define canWANT_ACTIONS         0x01  ///< \warning Obsolete!
+#define canWANT_OWN_BUFFERS     0x02  ///< \warning Obsolete!
+#define canWANT_ERROR_COUNTERS  0x04  ///< \warning Obsolete!
+#define canWANT_EXCLUSIVE       0x08  ///< \warning Obsolete! Use \ref canOPEN_xxx instead.
+#define canWANT_EXTENDED        0x10  ///< \warning Obsolete! Use \ref canOPEN_xxx instead.
+#if defined(CANLIB_DECLARE_ALL)
+# define canWANT_VIRTUAL        0x20  ///< \warning Obsolete! Use \ref canOPEN_xxx instead.
+#endif
+
+/** @} */
+
+/**
+ * \name Circuit types.
+ * \warning Obsolete!
+ * @{
+ */
+// No circuit                   0
+#define PCCAN_PHILIPS           1     ///< 82C200 on PCCAN 1.0  \warning Obsolete!
+#define PCCAN_INTEL526          2     ///< Not supported.       \warning Obsolete!
+#define PCCAN_INTEL527          3     ///< 82527 on PCCAN 1.0   \warning Obsolete!
+#define CANCARD_NEC72005        4     ///< NEC72005 on CANCard  \warning Obsolete!
+#define CIRC_VIRTUAL            5     ///<                      \warning Obsolete!
+#define CIRC_SJA1000            6     ///<                      \warning Obsolete!
+/** @} */
+
+/**
+ * \name Card types.
+ * \warning Obsolete!
+ * @{
+ */
+#define canCARD_PCCAN           1     ///< PCCAN ver 1.x (KVASER)       \warning Obsolete!
+#define canCARD_CANCARD         2     ///< CANCard (Softing)            \warning Obsolete!
+#define canCARD_AC2             3     ///< CAN-AC2 (Softing)            \warning Obsolete!
+#define canCARD_LAPCAN          4     ///<                              \warning Obsolete!
+#define canCARD_ISACAN          5     ///<                              \warning Obsolete!
+#define canCARD_PCCAN_OEM       6     ///< Special for OEM PCcan cards. \warning Obsolete!
+/** @} */
+
+/**
+ * \name The canFlgXXX are left for compatibility.
+ * \warning Obsolete!
+ * @{
+ */
+#define canFlgACCEPT            1     ///< \warning Obsolete!
+#define canFlgREJECT            2     ///< \warning Obsolete!
+#define canFlgCODE              3     ///< \warning Obsolete!
+#define canFlgMASK              4     ///< \warning Obsolete!
+/** @} */
+
+/**
+ * \name Flags for action routines
+ * \warning Obsolete!
+ * @{
+ */
+#define canDISCARD_MESSAGE      3     ///< \warning Obsolete!
+#define canRETAIN_MESSAGE       4     ///< \warning Obsolete!
+/** @} */
+
+/**
+ * \name For busParams - sync on rising edge only or both rising and falling edge
+ * (Not supported)
+ * \warning Obsolete!
+ * @{
+ */
+#define canSLOW_MODE            0x01  ///< Sync on rising and falling edge \warning Obsolete!
+/** @} */
+
+/**
+ * \name CAN driver types; these constants are retained for compatibility.
+ * (Not supported)
+ * \warning Obsolete!
+ * @{
+ */
+#define canOFF                  0     ///<                            \warning Obsolete!
+#define canTRISTATE             1     ///<                            \warning Obsolete!
+#define canPULLUP               2     ///<                            \warning Obsolete!
+#define canPULLDOWN             3     ///<                            \warning Obsolete!
+#define canPUSHPULL             4     ///< This is the usual setting. \warning Obsolete!
+#define canINVPULLUP            5     ///<                            \warning Obsolete!
+#define canINVPULLDOWN          6     ///<                            \warning Obsolete!
+#define canINVPUSHPULL          7     ///<                            \warning Obsolete!
+/** @} */
+
+/**
+ * \name These were never implemented.
+ * (Not supported)
+ * \warning Obsolete!
+ * @{
+ */
+#define canIOCTL_LOCAL_ECHO_ON  3     ///< \warning Obsolete!
+#define canIOCTL_LOCAL_ECHO_OFF 4     ///< \warning Obsolete!
+
+#define canMSG_STATUS 0x0008
+/** @} */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * \warning Obsolete!
+ */
+canStatus CANLIBAPI canInstallAction(int handle, long id, int (*fn)());
+
+/**
+ * \warning Obsolete!
+ */
+canStatus CANLIBAPI canUninstallAction(int handle, long id);
+
+/**
+ * \warning Obsolete!
+ */
+canStatus CANLIBAPI canInstallOwnBuffer(int handle, long id, unsigned int len,
+                                        void * buf);
+
+/**
+ * \warning Obsolete!
+ */
+canStatus CANLIBAPI canUninstallOwnBuffer(int handle, long id);
+#ifdef __cplusplus
+}
+#endif
+
+/** @} */
+
+#endif
Index: trunk/CanGateway/driver/kvaser/windows/predef.h
===================================================================
--- trunk/CanGateway/driver/kvaser/windows/predef.h	(revision 93)
+++ trunk/CanGateway/driver/kvaser/windows/predef.h	(revision 93)
@@ -0,0 +1,103 @@
+/*
+**                   Copyright 2007 by KVASER AB, SWEDEN      
+**                        WWW: http://www.kvaser.com
+**
+** This software is furnished under a license and may be used and copied
+** only in accordance with the terms of such license.
+**
+** Description:
+** This file removes the differences between BCC and MSC with regards
+** to some predefined macros. The other differences remain. Sigh.
+** ---------------------------------------------------------------------------
+*/
+
+#ifndef _PREDEF_H_
+#define _PREDEF_H_
+
+// 1) Win16: Borland defines _Windows
+//    MSC defines _WINDOWS
+//    We want _WINDOWS (but also _Windows to be sure)
+#if defined(_Windows) && !defined(_WINDOWS)
+#   define _WINDOWS 1
+#endif
+
+#if defined(_WINDOWS) && !defined(_Windows)
+#   define _Windows 1
+#endif
+
+
+// 2) Win32: Borland defines _Windows and __WIN32__ and _WIN32
+//    MSC defines _WIN32
+//    We want __WIN32__ and _WINDOWS and _Windows and _WIN32
+#if defined(_WIN32) || defined(__WIN32__)
+#   if !defined(__WIN32__)
+#       define __WIN32__ 1
+#   endif
+#   if !defined(_WINDOWS)
+#       define _WINDOWS 1
+#   endif
+#   if !defined(_Windows)
+#       define _Windows 1
+#   endif
+#endif
+
+
+// 3) DLL: Borland defines __DLL__
+//    MSC defines _DLL
+//    We want __DLL__
+#if defined (_DLL) && !defined(__DLL__)
+#   define __DLL__ 1
+#endif
+
+
+
+
+//===========================================================================
+#ifndef USE_CANLIB39_TYPES
+  // New typedefs for CANLIB 4.0 and beyond, partly to take care about
+  // the 64 bit ints, partly to alleviate pre3.9 mixing of ints and
+  // longs.
+  #if __STDC_VERSION__ >= 199901L
+    #include <stdint.h>
+    #define KVINT32   int32_t
+    #define KVINT64   int64_t
+    #define KVINT32L  int32_t
+    #define KVUINT32   uint32_t
+    #define KVUINT64   uint64_t
+    #define KVUINT32L  uint32_t
+  #elif defined(__GNUC__)
+    #define KVINT32   int
+    #define KVINT64   long long
+    #define KVINT32L  int
+    #define KVUINT32   unsigned int
+    #define KVUINT64   unsigned long long
+    #define KVUINT32L  unsigned int
+  #else
+    #define KVINT32   int
+    #define KVINT64   __int64
+    #define KVINT32L  int
+    #define KVUINT32   unsigned int
+    #define KVUINT64   unsigned __int64
+    #define KVUINT32L  unsigned int
+  #endif
+#else
+  // Old typedefs for compability with CANLIB 3.9 and older.
+  #ifdef __GNUC__
+    #define KVINT32   int
+    #define KVINT64   long long
+    #define KVINT32L  long
+    #define KVUINT32   unsigned int
+    #define KVUINT64   unsigned long long
+    #define KVUINT32L  unsigned long
+  #else
+    #define KVINT32   int
+    #define KVINT64   __int64
+    #define KVINT32L  long
+    #define KVUINT32   unsigned int
+    #define KVUINT64   unsigned __int64
+    #define KVUINT32L  unsigned long
+  #endif
+#endif
+
+#endif
+
Index: trunk/CanGateway/driver/kvaser/windows/sing.h
===================================================================
--- trunk/CanGateway/driver/kvaser/windows/sing.h	(revision 93)
+++ trunk/CanGateway/driver/kvaser/windows/sing.h	(revision 93)
@@ -0,0 +1,240 @@
+/*
+**                        Copyright 1997 by KVASER AB
+**            P.O Box 4076 S-51104 KINNAHULT, SWEDEN Tel. +46 320 15287
+**
+** This software is furnished under a license and may be used and copied
+** only in accordance with the terms of such license.
+**
+*/
+/*
+** This file replaces cancard.h from Softing GmbH.
+*/
+
+#ifndef _SING_H_
+#define _SING_H_
+
+#if defined(__WIN32__) || defined(_WIN32)
+
+#  if !defined(FAR)
+#     define FAR
+#  endif
+#  if !defined(SINGAPI)
+#     define SINGAPI extern int __declspec(dllimport) __stdcall
+#  endif
+
+#else
+
+#  if !defined(FAR)
+#     define FAR far
+#  endif
+#  if !defined(SINGAPI)
+#     define SINGAPI extern int __export FAR PASCAL
+#  endif
+
+#endif
+
+typedef struct  {
+    unsigned long   Ident;
+    int             DataLength;
+    int             RecOverrun_flag;
+    int             RCV_fifo_lost_msg;
+    unsigned char   RCV_data[8];
+    int             AckOverrun_flag;
+    int             XMT_ack_fifo_lost_acks;
+    int             XMT_rmt_fifo_lost_remotes;
+    int             Bus_state;
+    int             Error_state;
+    int             Can;
+    unsigned long   Time;
+} param_struct;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+SINGAPI INIPC_initialize_board(int address);
+
+SINGAPI CANPC_reset_board(void);
+
+SINGAPI CANPC_reset_chip(void);
+
+SINGAPI CANPC_initialize_chip (int presc, int sjw, int tseg1,
+                               int tseg2, int sam);
+
+SINGAPI CANPC_initialize_chip2(int presc, int sjw, int tseg1,
+                               int tseg2, int sam);
+
+SINGAPI CANPC_set_mode (int SleepMode, int SpeedMode);
+
+SINGAPI CANPC_set_mode2(int SleepMode, int SpeedMode);
+
+SINGAPI CANPC_set_acceptance (unsigned int AccCodeStd,
+                              unsigned int AccMaskStd,
+                              unsigned long AccCodeXtd,
+                              unsigned long AccMaskXtd);
+
+SINGAPI CANPC_set_acceptance2(unsigned int AccCodeStd,
+                              unsigned int AccMaskStd,
+                              unsigned long AccCodeXtd,
+                              unsigned long AccMaskXtd);
+
+SINGAPI CANPC_set_output_control (int OutputControl);
+
+SINGAPI CANPC_set_output_control2(int OutputControl);
+
+SINGAPI CANPC_initialize_interface(int ReceiveFifoEnable,
+                                   int ReceivePollAll,
+                                   int ReceiveEnableAll,
+                                   int ReceiveIntEnableAll,
+                                   int AutoRemoteEnableAll,
+                                   int TransmitReqFifoEnable,
+                                   int TransmitPollAll,
+                                   int TransmitAckEnableAll,
+                                   int TransmitAckFifoEnableAll,
+                                   int TransmitRmtFifoEnableAll);
+
+SINGAPI CANPC_enable_fifo(void);
+
+SINGAPI CANPC_optimize_rcv_speed(void);
+
+SINGAPI CANPC_enable_timestamps(void);
+
+SINGAPI CANPC_enable_fifo_transmit_ack (void);
+
+SINGAPI CANPC_enable_fifo_transmit_ack2(void);
+
+SINGAPI CANPC_get_version(int * sw_version,
+                          int *  fw_version,
+                          int * hw_version,
+                          int * license,
+                          int * can_chip_type);
+
+SINGAPI CANPC_start_chip(void);
+
+SINGAPI CANPC_read_ac(param_struct * param);
+
+SINGAPI CANPC_send_data (unsigned long Ident, int Xtd,
+                         int DataLength, unsigned char * pData);
+
+SINGAPI CANPC_send_data2(unsigned long Ident, int Xtd,
+                         int DataLength, unsigned char * pData);
+
+SINGAPI CANPC_send_remote (unsigned long Ident, int Xtd, int DataLength);
+
+SINGAPI CANPC_send_remote2(unsigned long Ident, int Xtd, int DataLength);
+
+SINGAPI CANPC_reinitialize(void);
+
+SINGAPI CANPC_reset_rcv_fifo(void);
+
+SINGAPI CANPC_get_time(unsigned long * time);
+
+SINGAPI INIPC_close_board(void);
+
+SINGAPI CANPC_set_interrupt_event(HANDLE hEvent);
+
+SINGAPI CANPC_get_serial_number(unsigned long * ser_number);
+
+SINGAPI CANPC_get_trigger (int * level);
+
+SINGAPI CANPC_get_trigger2(int * level);
+
+SINGAPI CANPC_set_trigger (int level);
+
+SINGAPI CANPC_set_trigger2(int level);
+
+SINGAPI CANPC_get_bus_state(int Can);
+
+SINGAPI CANPC_reset_xmt_fifo(void);
+
+SINGAPI CANPC_reset_lost_msg_counter(void);
+
+SINGAPI CANPC_read_rcv_fifo_level(void);
+
+SINGAPI CANPC_read_xmt_fifo_level(void);
+
+SINGAPI CANPC_set_path(char * path);
+
+SINGAPI CANPC_enable_error_frame_detection(void);
+
+// Dummy functions.
+SINGAPI CANPC_define_cyclic (int ObjectNumber,
+                             unsigned int Rate,
+                             unsigned int Cycles);
+SINGAPI CANPC_define_cyclic2(int ObjectNumber,
+                             unsigned int Rate,
+                             unsigned int Cycles);
+SINGAPI CANPC_define_object (unsigned long Handle,
+                             int FAR * ObjectNumber,
+                             int Type,
+                             int ReceiveIntEnable,
+                             int AutoRemoteEnable,
+                             int TransmitAckEnable);
+SINGAPI CANPC_define_object2(unsigned long Handle,
+                             int FAR * ObjectNumber,
+                             int Type,
+                             int ReceiveIntEnable,
+                             int AutoRemoteEnable,
+                             int TransmitAckEnable);
+SINGAPI CANPC_enable_dyn_obj_buf(void);
+SINGAPI CANPC_initialize_interface(int ReceiveFifoEnable,
+                                   int ReceivePollAll,
+                                   int ReceiveEnableAll,
+                                   int ReceiveIntEnableAll,
+                                   int AutoRemoteEnable,
+                                   int TransmitReqFifoEnable,
+                                   int TransmitPollAll,
+                                   int TransmitAckEnableAll,
+                                   int TransmitAckFifoEnable,
+                                   int TransmitRmtFifoEnable);
+SINGAPI CANPC_read_rcv_data (int  ObjectNumber,
+                             unsigned char FAR * pRCV_Data,
+                             unsigned long FAR * Time);
+SINGAPI CANPC_read_rcv_data2(int  ObjectNumber,
+                             unsigned char FAR * pRCV_Data,
+                             unsigned long FAR * Time);
+SINGAPI CANPC_read_xmt_data (int  ObjectNumber,
+                             int FAR * pDataLength,
+                             unsigned char FAR * pXMT_Data);
+SINGAPI CANPC_read_xmt_data2(int  ObjectNumber,
+                             int FAR * pDataLength,
+                             unsigned char FAR * pXMT_Data);
+SINGAPI CANPC_send_object (int  ObjectNumber,
+                           int  DataLength);
+SINGAPI CANPC_send_object2(int  ObjectNumber,
+                           int  DataLength);
+SINGAPI CANPC_send_remote_object (int ObjectNumber,
+                                  int DataLength);
+SINGAPI CANPC_send_remote_object2(int ObjectNumber,
+                                  int DataLength);
+SINGAPI CANPC_supply_object_data (int  ObjectNumber,
+                                  int  DataLength,
+                                  unsigned char FAR * pData);
+SINGAPI CANPC_supply_object_data2(int  ObjectNumber,
+                                  int  DataLength,
+                                  unsigned char FAR * pData);
+SINGAPI CANPC_supply_rcv_object_data (int  ObjectNumber,
+                                      int  DataLength,
+                                      unsigned char FAR * pData);
+SINGAPI CANPC_supply_rcv_object_data2(int  ObjectNumber,
+                                      int  DataLength,
+                                      unsigned char FAR * pData);
+SINGAPI CANPC_write_object (int  ObjectNumber,
+                            int  DataLength,
+                            unsigned char FAR * pData);
+SINGAPI CANPC_write_object2(int  ObjectNumber,
+                            int  DataLength,
+                            unsigned char FAR * pData);
+
+
+
+
+// Additions.
+SINGAPI CANPC_GetEventHandle(HANDLE *h);
+SINGAPI CANPC_SetTimerRate(unsigned int rate);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
Index: trunk/CanGateway/driver/kvaser/windows/std.h
===================================================================
--- trunk/CanGateway/driver/kvaser/windows/std.h	(revision 93)
+++ trunk/CanGateway/driver/kvaser/windows/std.h	(revision 93)
@@ -0,0 +1,143 @@
+/*
+**                     Copyright 1995,1996 by KVASER AB
+**         P.O Box 4076 S-51104 KINNAHULT, SWEDEN. Tel. +46 320 15287
+**
+** This software is furnished under a license and may be used and copied
+** only in accordance with the terms of such license.
+**
+*/
+
+#pragma message("This file is obsolete")
+
+
+
+#ifndef _STD_H_
+#define _STD_H_
+
+#define ARGUSED(x)  (void)(x)
+#define PRIVATE static
+#define PUBLIC
+
+#define COUNTOF(x) ((signed int)(sizeof(x)/sizeof(x[0])))
+
+#include "predef.h"
+
+
+#ifdef _WINDOWS
+   //
+   // Building Windows (16/32) version
+   //
+#  include <windows.h>
+#else
+   //
+   // Building DOS version
+   // 
+#  define TRUE             1
+#  define FALSE            0
+#  define BOOL             int
+
+#  define WM_USER          0x0400
+
+typedef unsigned char      BYTE;
+typedef unsigned short     WORD;
+typedef unsigned long      DWORD;
+
+typedef WORD               WPARAM;
+typedef DWORD              LPARAM;
+
+typedef void (*HWND)(WPARAM aMsg, WPARAM aHandle, LPARAM aLparam);
+
+#endif
+
+
+
+typedef unsigned long ulong;
+typedef unsigned short ushort;
+typedef unsigned char uchar;
+typedef unsigned int uint;
+
+
+/*
+** Define macros for direct port I/O. (not for Win32)
+*/
+#if !defined(__WIN32__)
+#   if defined(__BORLANDC__)
+#      define WRITE_PORT_UCHAR(PORT, VALUE) outportb((unsigned int)(PORT), (VALUE))
+#      define READ_PORT_UCHAR(PORT) inportb((unsigned int)(PORT))
+#      define DISABLE_INTERRUPTS _disable()
+#      define ENABLE_INTERRUPTS  _enable()
+#   endif /* __BORLANDC__ */
+
+#   if defined(_MSC_VER)
+       /*Prototypes from conio.h, MSVC1.52*/
+       int __cdecl _inp(unsigned);
+       int __cdecl _outp(unsigned, int);
+#      define WRITE_PORT_UCHAR(PORT, VALUE) _outp((unsigned int)(PORT), (int)(VALUE))
+#      define READ_PORT_UCHAR(PORT) (unsigned char)_inp((unsigned int)(PORT))
+#      define DISABLE_INTERRUPTS _disable()
+#      define ENABLE_INTERRUPTS  _enable()
+#   endif /* __MSC */
+#endif /*!defined(__WIN32__)*/
+
+/*
+** Used to convert a major.minor type version number to a 16-bit word.
+*/
+#define VERSION_NUMBER(x,y) (((x)<<8) + (y))
+
+/*
+** A macro for notifying the caller when messages arrives (or something
+** else happens.)  If we are running under Windows, we use the standard
+** message passing routine PostMessage.  In DOS, we fake messaging by
+** calling a user-supplied routine instead - note that it will be called at
+** interrupt level.
+*/
+#if defined(_Windows) || defined(__WIN32__)
+/* Win16/32 version */
+#     define NOTIFY(hWnd, msg, handle, status) \
+                    (void)PostMessage((hWnd), WM__CANLIB, \
+                    ((WPARAM)(handle)), \
+                    ((LPARAM)(((long)(status))<<16) + (msg)))
+
+#else
+/* DOS version */
+#  define NOTIFY(hWnd, msg, handle, status) \
+                if (hWnd)   \
+                (*(hWnd))(WM__CANLIB, \
+                ((WPARAM)(handle)), \
+                ((LPARAM)(((long)(status))<<16) + (msg)))
+#endif
+
+
+#if defined(__cplusplus) && defined(__BORLANDC__) && (__BORLANDC__ < 0x460)
+// These templates are defined in Borland C++ 4.52
+       template <class T> inline const T min(const T& a, const T& b) {
+           if (a < b)
+               return a;
+           else
+               return b;
+       }
+       template <class T> inline const T max(const T& a, const T& b) {
+           if (a > b)
+               return a;
+           else
+               return b;
+       }
+#endif
+
+#define minmax(n, a, b) max(a, min(b, n))
+
+#ifndef CompilerAssert
+// An assert that is evaluated during compilation.
+// If the expression is zero, the compiler will warn that the vector
+// _Dummy[] has zero elements, otherwise it is silent.
+//
+// Lint warning 506 is "Constant value Boolean",
+// 762 is "Redundantly declared ... previously declared at line ..."
+#define CompilerAssert(e)     \
+  /*lint -save -e506 -e762 */ \
+  extern char _Dummy[(e)?1:0] \
+  /*lint -restore */
+#endif
+
+       
+#endif
