canlib.h
Go to the documentation of this file.
1 /*
2  * Copyright 2017 by Kvaser AB, Molndal, Sweden
3  * http://www.kvaser.com
4  *
5  * This software is dual licensed under the following two licenses:
6  * BSD-new and GPLv2. You may use either one. See the included
7  * COPYING file for details.
8  *
9  * License: BSD-new
10  * ==============================================================================
11  * Redistribution and use in source and binary forms, with or without
12  * modification, are permitted provided that the following conditions are met:
13  * * Redistributions of source code must retain the above copyright
14  * notice, this list of conditions and the following disclaimer.
15  * * Redistributions in binary form must reproduce the above copyright
16  * notice, this list of conditions and the following disclaimer in the
17  * documentation and/or other materials provided with the distribution.
18  * * Neither the name of the <organization> nor the
19  * names of its contributors may be used to endorse or promote products
20  * derived from this software without specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
29  * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
30  * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32  * POSSIBILITY OF SUCH DAMAGE.
33  *
34  *
35  * License: GPLv2
36  * ==============================================================================
37  * This program is free software; you can redistribute it and/or modify
38  * it under the terms of the GNU General Public License as published by
39  * the Free Software Foundation; either version 2 of the License, or
40  * (at your option) any later version.
41  *
42  * This program is distributed in the hope that it will be useful,
43  * but WITHOUT ANY WARRANTY; without even the implied warranty of
44  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
45  * GNU General Public License for more details.
46  *
47  * You should have received a copy of the GNU General Public License
48  * along with this program; if not, write to the Free Software
49  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
50  *
51  *
52  * IMPORTANT NOTICE:
53  * ==============================================================================
54  * This source code is made available for free, as an open license, by Kvaser AB,
55  * for use with its applications. Kvaser AB does not accept any liability
56  * whatsoever for any third party patent or other immaterial property rights
57  * violations that may result from any usage of this source code, regardless of
58  * the combination of source code and various applications that it can be used
59  * in, or with.
60  *
61  * -----------------------------------------------------------------------------
62  */
63 
128 #ifndef _CANLIB_H_
129 #define _CANLIB_H_
130 
131 #include <stdlib.h>
132 
133 #include <stdint.h>
134 
135 #include "canstat.h"
136 
138 typedef int canHandle;
139 
140 # define canINVALID_HANDLE (-1)
141 
144 
145 typedef struct canNotifyData {
146  void *tag;
148  union {
149  struct {
150  unsigned long time;
151  } busErr;
152  struct {
153  long id;
154  unsigned long time;
155  } rx;
156  struct {
157  long id;
158  unsigned long time;
159  } tx;
160  struct {
161  unsigned char busStatus;
162  unsigned char txErrorCounter;
163  unsigned char rxErrorCounter;
164  unsigned long time;
165  } status;
166  } info;
167 } canNotifyData;
168 
169 
179 // The canWANT_xxx names are also obsolete, use canOPEN_xxx instead for new developments.
180 #define canWANT_EXCLUSIVE 0x0008
181 #define canWANT_EXTENDED 0x0010
182 #define canWANT_VIRTUAL 0x0020
183 
189 #define canOPEN_EXCLUSIVE 0x0008
190 
202 #define canOPEN_REQUIRE_EXTENDED 0x0010
203 
211 # define canOPEN_ACCEPT_VIRTUAL 0x0020
212 
221 # define canOPEN_OVERRIDE_EXCLUSIVE 0x0040
222 
239 # define canOPEN_REQUIRE_INIT_ACCESS 0x0080
240 
252 # define canOPEN_NO_INIT_ACCESS 0x0100
253 
265 # define canOPEN_ACCEPT_LARGE_DLC 0x0200 // DLC can be greater than 8
266 
273 # define canOPEN_CAN_FD 0x0400
274 
288 # define canOPEN_CAN_FD_NONISO 0x0800
289 
290 
294 # define canOPEN_INTERNAL_L 0x1000
295 
307 #define canFILTER_ACCEPT 1
308 #define canFILTER_REJECT 2
309 
310 #define canFILTER_SET_CODE_STD 3
311 
312 #define canFILTER_SET_MASK_STD 4
313 
314 #define canFILTER_SET_CODE_EXT 5
315 
316 #define canFILTER_SET_MASK_EXT 6
317 
318 #define canFILTER_NULL_MASK 0L
319 
335 #define canDRIVER_NORMAL 4
336 
343 #define canDRIVER_SILENT 1
344 
348 #define canDRIVER_SELFRECEPTION 8
349 
353 #define canDRIVER_OFF 0
354 
377 #define canBITRATE_1M (-1)
378 
379 #define canBITRATE_500K (-2)
380 
381 #define canBITRATE_250K (-3)
382 
383 #define canBITRATE_125K (-4)
384 
385 #define canBITRATE_100K (-5)
386 
387 #define canBITRATE_62K (-6)
388 
389 #define canBITRATE_50K (-7)
390 
391 #define canBITRATE_83K (-8)
392 
393 #define canBITRATE_10K (-9)
394 
395 // CAN FD Bit Rates
399 #define canFD_BITRATE_500K_80P (-1000)
400 
403 #define canFD_BITRATE_1M_80P (-1001)
404 
407 #define canFD_BITRATE_2M_80P (-1002)
408 
411 #define canFD_BITRATE_4M_80P (-1003)
412 
415 #define canFD_BITRATE_8M_60P (-1004)
416 
418 #define BAUD_1M (-1)
419 
420 #define BAUD_500K (-2)
421 
422 #define BAUD_250K (-3)
423 
424 #define BAUD_125K (-4)
425 
426 #define BAUD_100K (-5)
427 
428 #define BAUD_62K (-6)
429 
430 #define BAUD_50K (-7)
431 
432 #define BAUD_83K (-8)
433 
436 //
437 // Define CANLIBAPI unless it's done already.
438 // (canlib.c provides its own definitions of CANLIBAPI, DLLIMPORT
439 // and DLLEXPORT before including this file.)
440 //
441 #ifndef CANLIBAPI
442 # define CANLIBAPI
443 #endif /* CANLIBAPI */
444 
445 
446 #ifdef __cplusplus
447 extern "C" {
448 #endif /* __cplusplus */
449 
471 void CANLIBAPI canInitializeLibrary (void);
472 
497 canStatus CANLIBAPI canClose (const CanHandle hnd);
498 
523 canStatus CANLIBAPI canBusOn (const CanHandle hnd);
524 
544 canStatus CANLIBAPI canBusOff (const CanHandle hnd);
545 
592 canStatus CANLIBAPI canSetBusParams (const CanHandle hnd,
593  long freq,
594  unsigned int tseg1,
595  unsigned int tseg2,
596  unsigned int sjw,
597  unsigned int noSamp,
598  unsigned int syncmode);
599 
631 canStatus CANLIBAPI canSetBusParamsFd(const CanHandle hnd,
632  long freq_brs,
633  unsigned int tseg1_brs,
634  unsigned int tseg2_brs,
635  unsigned int sjw_brs);
636 
637 
669 canStatus CANLIBAPI canGetBusParams (const CanHandle hnd,
670  long *freq,
671  unsigned int *tseg1,
672  unsigned int *tseg2,
673  unsigned int *sjw,
674  unsigned int *noSamp,
675  unsigned int *syncmode);
676 
677 
700 canStatus CANLIBAPI canGetBusParamsFd(const CanHandle hnd,
701  long *freq_brs,
702  unsigned int *tseg1_brs,
703  unsigned int *tseg2_brs,
704  unsigned int *sjw_brs);
729 canStatus CANLIBAPI canSetBusOutputControl (const CanHandle hnd,
730  const unsigned int drivertype);
731 
766 canStatus CANLIBAPI canGetBusOutputControl (const CanHandle hnd,
767  unsigned int *drivertype);
768 
809 canStatus CANLIBAPI canAccept (const CanHandle hnd,
810  const long envelope,
811  const unsigned int flag);
812 
836 canStatus CANLIBAPI canReadStatus (const CanHandle hnd,
837  unsigned long *const flags);
838 
875 canStatus CANLIBAPI canReadErrorCounters (const CanHandle hnd,
876  unsigned int *txErr,
877  unsigned int *rxErr,
878  unsigned int *ovErr);
879 
921 canStatus CANLIBAPI canWrite (const CanHandle hnd,
922  long id,
923  void *msg,
924  unsigned int dlc,
925  unsigned int flag);
926 
954 canStatus CANLIBAPI canWriteSync (const CanHandle hnd, unsigned long timeout);
955 
1007 canStatus CANLIBAPI canRead (const CanHandle hnd,
1008  long *id,
1009  void *msg,
1010  unsigned int *dlc,
1011  unsigned int *flag,
1012  unsigned long *time);
1063 canStatus CANLIBAPI canReadWait (const CanHandle hnd,
1064  long *id,
1065  void *msg,
1066  unsigned int *dlc,
1067  unsigned int *flag,
1068  unsigned long *time,
1069  unsigned long timeout);
1070 
1122 canStatus CANLIBAPI canReadSpecific (const CanHandle hnd, long id, void * msg,
1123  unsigned int * dlc, unsigned int * flag,
1124  unsigned long * time);
1125 
1156 canStatus CANLIBAPI canReadSync (const CanHandle hnd, unsigned long timeout);
1157 
1189 canStatus CANLIBAPI canReadSyncSpecific (const CanHandle hnd,
1190  long id,
1191  unsigned long timeout);
1192 
1238 canStatus CANLIBAPI canReadSpecificSkip (const CanHandle hnd,
1239  long id,
1240  void * msg,
1241  unsigned int * dlc,
1242  unsigned int * flag,
1243  unsigned long * time);
1244 
1265 canStatus CANLIBAPI canSetNotify (const CanHandle hnd,
1266  void (*callback)(canNotifyData *),
1267  unsigned int notifyFlags,
1268  void *tag);
1269 
1283 canStatus CANLIBAPI canGetRawHandle (const CanHandle hnd, void *pvFd);
1284 
1319 canStatus CANLIBAPI canTranslateBaud (long *const freq,
1320  unsigned int *const tseg1,
1321  unsigned int *const tseg2,
1322  unsigned int *const sjw,
1323  unsigned int *const nosamp,
1324  unsigned int *const syncMode);
1325 
1348 canStatus CANLIBAPI canGetErrorText (canStatus err, char *buf, unsigned int bufsiz);
1349 
1379 unsigned short CANLIBAPI canGetVersion (void);
1380 
1410 canStatus CANLIBAPI canIoCtl (const CanHandle hnd,
1411  unsigned int func,
1412  void *buf,
1413  unsigned int buflen);
1414 
1415 
1426 canStatus CANLIBAPI canReadTimer (const CanHandle hnd, unsigned long *time);
1427 
1478 CanHandle CANLIBAPI canOpenChannel (int channel, int flags);
1479 
1500 canStatus CANLIBAPI canGetNumberOfChannels (int *channelCount);
1501 
1502 
1510 #define kvREMOTE_TYPE_NOT_REMOTE 0
1511 #define kvREMOTE_TYPE_WLAN 1
1512 #define kvREMOTE_TYPE_LAN 2
1513 
1522 #define kvLOGGER_TYPE_NOT_A_LOGGER 0
1523 #define kvLOGGER_TYPE_V1 1
1524 #define kvLOGGER_TYPE_V2 2
1525 
1557 canStatus CANLIBAPI canGetChannelData (int channel,
1558  int item,
1559  void *buffer,
1560  size_t bufsize);
1561 
1580 #define canCHANNELDATA_CHANNEL_CAP 1
1581 
1591 #define canCHANNELDATA_TRANS_CAP 2
1592 
1599 #define canCHANNELDATA_CHANNEL_FLAGS 3 // available, etc
1600 
1609 #define canCHANNELDATA_CARD_TYPE 4
1610 
1620 #define canCHANNELDATA_CARD_NUMBER 5
1621 
1629 #define canCHANNELDATA_CHAN_NO_ON_CARD 6
1630 
1640 #define canCHANNELDATA_CARD_SERIAL_NO 7
1641 
1651 #define canCHANNELDATA_TRANS_SERIAL_NO 8
1652 
1663 #define canCHANNELDATA_CARD_FIRMWARE_REV 9
1664 
1675 #define canCHANNELDATA_CARD_HARDWARE_REV 10
1676 
1686 #define canCHANNELDATA_CARD_UPC_NO 11
1687 
1698 #define canCHANNELDATA_TRANS_UPC_NO 12
1699 
1715 #define canCHANNELDATA_CHANNEL_NAME 13
1716 
1733 # define canCHANNELDATA_DLL_FILE_VERSION 14
1734 
1751 # define canCHANNELDATA_DLL_PRODUCT_VERSION 15
1752 
1768 # define canCHANNELDATA_DLL_FILETYPE 16
1769 
1778 # define canCHANNELDATA_TRANS_TYPE 17
1779 
1803 # define canCHANNELDATA_DEVICE_PHYSICAL_POSITION 18
1804 
1817 # define canCHANNELDATA_UI_NUMBER 19
1818 
1842 # define canCHANNELDATA_TIMESYNC_ENABLED 20
1843 
1859 # define canCHANNELDATA_DRIVER_FILE_VERSION 21
1860 
1876 # define canCHANNELDATA_DRIVER_PRODUCT_VERSION 22
1877 
1886 # define canCHANNELDATA_MFGNAME_UNICODE 23
1887 
1895 # define canCHANNELDATA_MFGNAME_ASCII 24
1896 
1905 # define canCHANNELDATA_DEVDESCR_UNICODE 25
1906 
1914 # define canCHANNELDATA_DEVDESCR_ASCII 26
1915 
1926 # define canCHANNELDATA_DRIVER_NAME 27
1927 
1940 # define canCHANNELDATA_CHANNEL_QUALITY 28
1941 
1950 # define canCHANNELDATA_ROUNDTRIP_TIME 29
1951 
1960 # define canCHANNELDATA_BUS_TYPE 30
1961 
1973 # define canCHANNELDATA_DEVNAME_ASCII 31
1974 
1985 # define canCHANNELDATA_TIME_SINCE_LAST_SEEN 32
1986 
1996 # define canCHANNELDATA_REMOTE_OPERATIONAL_MODE 33
1997 
2006 # define canCHANNELDATA_REMOTE_PROFILE_NAME 34
2007 
2016 # define canCHANNELDATA_REMOTE_HOST_NAME 35
2017 
2026 # define canCHANNELDATA_REMOTE_MAC 36
2027 
2036 # define canCHANNELDATA_MAX_BITRATE 37
2037 
2048 # define canCHANNELDATA_CHANNEL_CAP_MASK 38
2049 
2059 # define canCHANNELDATA_IS_REMOTE 40
2060 
2069 # define canCHANNELDATA_REMOTE_TYPE 41
2070 
2079 # define canCHANNELDATA_LOGGER_TYPE 42
2080 
2090 # define canCHANNELDATA_HW_STATUS 43
2091 
2101 # define canCHANNELDATA_FEATURE_EAN 44
2102 
2111 #define canCHANNELDATA_CUST_CHANNEL_NAME 39
2112 
2126 #define canCHANNEL_IS_EXCLUSIVE 0x0001
2127 
2129 #define canCHANNEL_IS_OPEN 0x0002
2130 
2133 #define canCHANNEL_IS_CANFD 0x0004
2134 
2135 //#define canCHANNEL_IS_CANFD_NON_ISO 0x0008 Reserved for when needed
2136 
2139 #define canCHANNEL_IS_LIN 0x0010
2140 
2143 #define canCHANNEL_IS_LIN_MASTER 0x0020
2144 
2147 #define canCHANNEL_IS_LIN_SLAVE 0x0040
2148 
2149 
2168 #define canHWTYPE_NONE 0
2169 #define canHWTYPE_VIRTUAL 1
2170 #define canHWTYPE_LAPCAN 2
2171 #define canHWTYPE_CANPARI 3
2172 #define canHWTYPE_PCCAN 8
2173 #define canHWTYPE_PCICAN 9
2174 #define canHWTYPE_USBCAN 11
2175 #define canHWTYPE_PCICAN_II 40
2176 #define canHWTYPE_USBCAN_II 42
2177 #define canHWTYPE_SIMULATED 44
2178 #define canHWTYPE_ACQUISITOR 46
2179 #define canHWTYPE_LEAF 48
2180 #define canHWTYPE_PC104_PLUS 50
2181 #define canHWTYPE_PCICANX_II 52
2182 #define canHWTYPE_MEMORATOR_II 54
2183 #define canHWTYPE_MEMORATOR_PRO 54
2184 #define canHWTYPE_USBCAN_PRO 56
2185 #define canHWTYPE_IRIS 58
2186 #define canHWTYPE_BLACKBIRD 58
2187 #define canHWTYPE_MEMORATOR_LIGHT 60
2188 #define canHWTYPE_MINIHYDRA 62
2189 #define canHWTYPE_EAGLE 62
2190 #define canHWTYPE_BAGEL 64
2191 #define canHWTYPE_BLACKBIRD_V2 64
2192 #define canHWTYPE_MINIPCIE 66
2193 #define canHWTYPE_USBCAN_KLINE 68
2194 #define canHWTYPE_ETHERCAN 70
2195 #define canHWTYPE_USBCAN_LIGHT 72
2196 #define canHWTYPE_USBCAN_PRO2 74
2197 #define canHWTYPE_PCIE_V2 76
2198 #define canHWTYPE_MEMORATOR_PRO2 78
2199 #define canHWTYPE_LEAF2 80
2200 #define canHWTYPE_MEMORATOR_V2 82
2201 #define canHWTYPE_CANLINHYBRID 84
2202 
2203 
2212 #define canCHANNEL_CAP_EXTENDED_CAN 0x00000001L
2213 #define canCHANNEL_CAP_BUS_STATISTICS 0x00000002L
2214 #define canCHANNEL_CAP_ERROR_COUNTERS 0x00000004L
2215 #define canCHANNEL_CAP_RESERVED_2 0x00000008L
2216 #define canCHANNEL_CAP_GENERATE_ERROR 0x00000010L
2217 #define canCHANNEL_CAP_GENERATE_OVERLOAD 0x00000020L
2218 #define canCHANNEL_CAP_TXREQUEST 0x00000040L
2219 #define canCHANNEL_CAP_TXACKNOWLEDGE 0x00000080L
2220 #define canCHANNEL_CAP_VIRTUAL 0x00010000L
2221 #define canCHANNEL_CAP_SIMULATED 0x00020000L
2222 #define canCHANNEL_CAP_RESERVED_1 0x00040000L
2223 #define canCHANNEL_CAP_CAN_FD 0x00080000L
2224 #define canCHANNEL_CAP_CAN_FD_NONISO 0x00100000L
2225 #define canCHANNEL_CAP_SILENT_MODE 0x00200000L
2226 #define canCHANNEL_CAP_SINGLE_SHOT 0x00400000L
2227 #define canCHANNEL_CAP_LOGGER 0x00800000L
2228 #define canCHANNEL_CAP_REMOTE_ACCESS 0x01000000L
2229 #define canCHANNEL_CAP_SCRIPT 0x02000000L
2230 #define canCHANNEL_CAP_LIN_HYBRID 0x04000000L
2231 #define canCHANNEL_CAP_DIAGNOSTICS 0x08000000L
2232 
2233 
2246 #define canCHANNEL_OPMODE_NONE 1
2247 
2251 #define canCHANNEL_OPMODE_INFRASTRUCTURE 2
2252 
2256 #define canCHANNEL_OPMODE_RESERVED 3
2257 
2261 #define canCHANNEL_OPMODE_ADHOC 4
2262 
2272 #define canDRIVER_CAP_HIGHSPEED 0x00000001L
2273 
2298 #define canIOCTL_PREFER_EXT 1
2299 
2312 #define canIOCTL_PREFER_STD 2
2313 
2329 #define canIOCTL_CLEAR_ERROR_COUNTERS 5
2330 
2341 #define canIOCTL_SET_TIMER_SCALE 6
2342 
2358 #define canIOCTL_SET_TXACK 7
2359 
2372 #define canIOCTL_GET_RX_BUFFER_LEVEL 8
2373 
2386 #define canIOCTL_GET_TX_BUFFER_LEVEL 9
2387 
2397 #define canIOCTL_FLUSH_RX_BUFFER 10
2398 
2408 #define canIOCTL_FLUSH_TX_BUFFER 11
2409 
2418 #define canIOCTL_GET_TIMER_SCALE 12
2419 
2431 #define canIOCTL_SET_TXRQ 13
2432 
2433 
2440 #define canIOCTL_SET_BYPASS_MODE 15
2441 
2447 #define canIOCTL_SET_WAKEUP 16
2448 
2458 # define canIOCTL_GET_DRIVERHANDLE 17
2459 
2465 # define canIOCTL_MAP_RXQUEUE 18
2466 
2472 # define canIOCTL_GET_WAKEUP 19
2473 
2485 # define canIOCTL_SET_REPORT_ACCESS_ERRORS 20
2486 
2494 # define canIOCTL_GET_REPORT_ACCESS_ERRORS 21
2495 
2505 # define canIOCTL_CONNECT_TO_VIRTUAL_BUS 22
2506 
2516 # define canIOCTL_DISCONNECT_FROM_VIRTUAL_BUS 23
2517 
2527 # define canIOCTL_SET_USER_IOPORT 24
2528 
2539 # define canIOCTL_GET_USER_IOPORT 25
2540 
2546 # define canIOCTL_SET_BUFFER_WRAPAROUND_MODE 26
2547 
2564 # define canIOCTL_SET_RX_QUEUE_SIZE 27
2565 
2571 # define canIOCTL_SET_USB_THROTTLE 28
2572 
2578 # define canIOCTL_GET_USB_THROTTLE 29
2579 
2592 # define canIOCTL_SET_BUSON_TIME_AUTO_RESET 30
2593 
2605 # define canIOCTL_GET_TXACK 31
2606 
2621 # define canIOCTL_SET_LOCAL_TXECHO 32
2622 
2635 # define canIOCTL_SET_ERROR_FRAMES_REPORTING 33
2636 
2650 # define canIOCTL_GET_CHANNEL_QUALITY 34
2651 
2661 # define canIOCTL_GET_ROUNDTRIP_TIME 35
2662 
2671 # define canIOCTL_GET_BUS_TYPE 36
2672 
2685 # define canIOCTL_GET_DEVNAME_ASCII 37
2686 
2698 # define canIOCTL_GET_TIME_SINCE_LAST_SEEN 38
2699 
2713 # define canIOCTL_GET_TREF_LIST 39
2714 
2736 # define canIOCTL_TX_INTERVAL 40
2737 
2749 # define canIOCTL_SET_BRLIMIT 43
2750 
2751 
2766 # define canIOCTL_SET_THROTTLE_SCALED 41
2767 
2768 
2783 # define canIOCTL_GET_THROTTLE_SCALED 42
2784 
2791 # define canIOCTL_RESET_OVERRUN_COUNT 44
2792 
2801 # define canIOCTL_LIN_MODE 45
2802 
2805 typedef struct {
2806  unsigned int portNo;
2807  unsigned int portValue;
2809 
2810 
2851 canStatus CANLIBAPI canSetBusParamsC200 (const CanHandle hnd, unsigned char btr0, unsigned char btr1);
2852 
2853 
2854 
2890 canStatus CANLIBAPI canSetDriverMode (const CanHandle hnd, int lineMode, int resNet);
2891 
2928 canStatus CANLIBAPI canGetDriverMode (const CanHandle hnd, int *lineMode, int *resNet);
2929 
2949 #define canVERSION_CANLIB32_VERSION 0
2950 
2961 #define canVERSION_CANLIB32_PRODVER 1
2962 
2974 #define canVERSION_CANLIB32_PRODVER32 2
2975 
2986 #define canVERSION_CANLIB32_BETA 3
2987 
3007 unsigned int CANLIBAPI canGetVersionEx (unsigned int itemCode);
3008 
3009 
3029 canStatus CANLIBAPI canObjBufFreeAll (const CanHandle hnd);
3030 
3051 canStatus CANLIBAPI canObjBufAllocate (const CanHandle hnd, int type);
3052 
3061 #define canOBJBUF_TYPE_AUTO_RESPONSE 0x01
3062 #define canOBJBUF_TYPE_PERIODIC_TX 0x02
3063 
3085 canStatus CANLIBAPI canObjBufFree (const CanHandle hnd, int idx);
3086 
3087 // Writes CAN data to the object buffer with the specified index.
3088 
3114 canStatus CANLIBAPI canObjBufWrite (const CanHandle hnd,
3115  int idx,
3116  int id,
3117  void* msg,
3118  unsigned int dlc,
3119  unsigned int flags);
3120 
3147 canStatus CANLIBAPI canObjBufSetFilter (const CanHandle hnd,
3148  int idx,
3149  unsigned int code,
3150  unsigned int mask);
3151 
3172 canStatus CANLIBAPI canObjBufSetFlags (const CanHandle hnd,
3173  int idx,
3174  unsigned int flags);
3175 
3193 # define canOBJBUF_AUTO_RESPONSE_RTR_ONLY 0x01
3194 
3216 canStatus CANLIBAPI canObjBufSetPeriod (const CanHandle hnd,
3217  int idx,
3218  unsigned int period);
3219 
3240 canStatus CANLIBAPI canObjBufSetMsgCount (const CanHandle hnd,
3241  int idx,
3242  unsigned int count);
3243 
3263 canStatus CANLIBAPI canObjBufEnable (const CanHandle hnd, int idx);
3264 
3284 canStatus CANLIBAPI canObjBufDisable (const CanHandle hnd, int idx);
3285 
3309 canStatus CANLIBAPI canObjBufSendBurst (const CanHandle hnd,
3310  int idx,
3311  unsigned int burstlen);
3312 
3313 
3336 canStatus CANLIBAPI canResetBus (const CanHandle hnd);
3337 
3376 canStatus CANLIBAPI canWriteWait (const CanHandle hnd,
3377  long id,
3378  void *msg,
3379  unsigned int dlc,
3380  unsigned int flag,
3381  unsigned long timeout);
3382 
3383 
3409 canStatus CANLIBAPI canUnloadLibrary (void);
3410 
3470 canStatus CANLIBAPI canSetAcceptanceFilter (const CanHandle hnd,
3471  unsigned int code,
3472  unsigned int mask,
3473  int is_extended);
3497 canStatus CANLIBAPI canFlushReceiveQueue (const CanHandle hnd);
3498 
3523 canStatus CANLIBAPI canFlushTransmitQueue (const CanHandle hnd);
3524 
3525 
3534 #define kvLED_ACTION_ALL_LEDS_ON 0
3535 #define kvLED_ACTION_ALL_LEDS_OFF 1
3536 #define kvLED_ACTION_LED_0_ON 2
3537 #define kvLED_ACTION_LED_0_OFF 3
3538 #define kvLED_ACTION_LED_1_ON 4
3539 #define kvLED_ACTION_LED_1_OFF 5
3540 #define kvLED_ACTION_LED_2_ON 6
3541 #define kvLED_ACTION_LED_2_OFF 7
3542 #define kvLED_ACTION_LED_3_ON 8
3543 #define kvLED_ACTION_LED_3_OFF 9
3544 #define kvLED_ACTION_LED_4_ON 10
3545 #define kvLED_ACTION_LED_4_OFF 11
3546 #define kvLED_ACTION_LED_5_ON 12
3547 #define kvLED_ACTION_LED_5_OFF 13
3548 #define kvLED_ACTION_LED_6_ON 14
3549 #define kvLED_ACTION_LED_6_OFF 15
3550 #define kvLED_ACTION_LED_7_ON 16
3551 #define kvLED_ACTION_LED_7_OFF 17
3552 #define kvLED_ACTION_LED_8_ON 18
3553 #define kvLED_ACTION_LED_8_OFF 19
3554 #define kvLED_ACTION_LED_9_ON 20
3555 #define kvLED_ACTION_LED_9_OFF 21
3556 #define kvLED_ACTION_LED_10_ON 22
3557 #define kvLED_ACTION_LED_10_OFF 23
3558 #define kvLED_ACTION_LED_11_ON 24
3559 #define kvLED_ACTION_LED_11_OFF 25
3560 
3561 
3584 canStatus CANLIBAPI kvFlashLeds (const CanHandle hnd, int action, int timeout);
3585 
3605 canStatus CANLIBAPI canRequestChipStatus (const CanHandle hnd);
3606 
3633 canStatus CANLIBAPI canRequestBusStatistics (const CanHandle hnd);
3634 
3640 typedef struct canBusStatistics_s {
3641  unsigned long stdData;
3642  unsigned long stdRemote;
3643  unsigned long extData;
3644  unsigned long extRemote;
3645  unsigned long errFrame;
3646 
3651  unsigned long busLoad;
3652  unsigned long overruns;
3654 
3677 canStatus CANLIBAPI canGetBusStatistics (const CanHandle hnd,
3678  canBusStatistics *stat,
3679  size_t bufsiz);
3680 
3681 
3702 canStatus CANLIBAPI canGetHandleData (const CanHandle hnd,
3703  int item,
3704  void *buffer,
3705  size_t bufsize);
3706 
3708 typedef void *kvTimeDomain;
3709 
3712 
3717 typedef struct kvTimeDomainData_s {
3723 
3752 kvStatus CANLIBAPI kvTimeDomainCreate (kvTimeDomain *domain);
3753 
3776 kvStatus CANLIBAPI kvTimeDomainDelete (kvTimeDomain domain);
3777 
3803 kvStatus CANLIBAPI kvTimeDomainResetTime (kvTimeDomain domain);
3804 
3829 kvStatus CANLIBAPI kvTimeDomainGetData (kvTimeDomain domain,
3830  kvTimeDomainData *data,
3831  size_t bufsiz);
3832 
3855 kvStatus CANLIBAPI kvTimeDomainAddHandle(kvTimeDomain domain,
3856  const CanHandle hnd);
3857 
3879 kvStatus CANLIBAPI kvTimeDomainRemoveHandle (kvTimeDomain domain,
3880  const CanHandle hnd);
3881 
3894 typedef void (CANLIBAPI *kvCallback_t) (CanHandle hnd, void* context, unsigned int notifyEvent);
3895 
3929 kvStatus CANLIBAPI kvSetNotifyCallback (const CanHandle hnd,
3930  kvCallback_t callback,
3931  void* context,
3932  unsigned int notifyFlags);
3933 
3947 #define kvBUSTYPE_NONE 0
3948 
3953 #define kvBUSTYPE_PCI 1
3954 
3959 #define kvBUSTYPE_PCMCIA 2
3960 
3965 #define kvBUSTYPE_USB 3
3966 
3971 #define kvBUSTYPE_WLAN 4
3972 
3977 #define kvBUSTYPE_PCI_EXPRESS 5
3978 
3983 #define kvBUSTYPE_ISA 6
3984 
3989 #define kvBUSTYPE_VIRTUAL 7
3990 
3995 #define kvBUSTYPE_PC104_PLUS 8
3996 
4001 #define kvBUSTYPE_LAN 9
4002 
4018 #define kvBUSTYPE_GROUP_VIRTUAL 1
4019 
4024 #define kvBUSTYPE_GROUP_LOCAL 2
4025 
4030 #define kvBUSTYPE_GROUP_REMOTE 3
4031 
4035 #define kvBUSTYPE_GROUP_INTERNAL 4
4036 
4090 kvStatus CANLIBAPI kvGetSupportedInterfaceInfo (int index,
4091  char *hwName,
4092  size_t nameLen,
4093  int *hwType,
4094  int *hwBusType);
4095 
4120 kvStatus CANLIBAPI kvReadDeviceCustomerData (const CanHandle hnd,
4121  int userNumber,
4122  int itemNumber,
4123  void *data,
4124  size_t bufsiz);
4125 
4139 #define kvENVVAR_TYPE_INT 1
4140 
4146 #define kvENVVAR_TYPE_FLOAT 2
4147 
4153 #define kvENVVAR_TYPE_STRING 3
4154 
4170 #define kvEVENT_TYPE_KEY 1
4171 
4179  typedef int64_t kvEnvHandle;
4180 
4200 kvStatus CANLIBAPI kvScriptStart (const CanHandle hnd, int slotNo);
4201 
4208 #define kvSCRIPT_STOP_NORMAL 0
4209 #define kvSCRIPT_STOP_FORCED -9
4233 kvStatus CANLIBAPI kvScriptStop (const CanHandle hnd, int slotNo, int mode);
4234 
4253 kvStatus CANLIBAPI kvScriptUnload (const CanHandle hnd, int slotNo);
4254 
4279 kvStatus CANLIBAPI kvScriptSendEvent (const CanHandle hnd,
4280  int slotNo,
4281  int eventType,
4282  int eventNo,
4283  unsigned int data);
4284 
4311 kvEnvHandle CANLIBAPI kvScriptEnvvarOpen (const CanHandle hnd,
4312  char* envvarName,
4313  int *envvarType,
4314  int *envvarSize); // returns scriptHandle
4315 
4335 kvStatus CANLIBAPI kvScriptEnvvarClose (kvEnvHandle eHnd);
4336 
4359 kvStatus CANLIBAPI kvScriptEnvvarSetInt (kvEnvHandle eHnd, int val);
4360 
4384 kvStatus CANLIBAPI kvScriptEnvvarGetInt (kvEnvHandle eHnd, int *val);
4385 
4408 kvStatus CANLIBAPI kvScriptEnvvarSetFloat (kvEnvHandle eHnd, float val);
4409 
4433 kvStatus CANLIBAPI kvScriptEnvvarGetFloat (kvEnvHandle eHnd, float *val);
4434 
4461 kvStatus CANLIBAPI kvScriptEnvvarSetData (kvEnvHandle eHnd,
4462  void *buf,
4463  int start_index,
4464  int data_len);
4465 
4491 kvStatus CANLIBAPI kvScriptEnvvarGetData (kvEnvHandle eHnd,
4492  void *buf,
4493  int start_index,
4494  int data_len);
4495 
4521 kvStatus CANLIBAPI kvScriptLoadFileOnDevice (const CanHandle hnd,
4522  int slotNo,
4523  char *localFile);
4524 
4548 kvStatus CANLIBAPI kvScriptLoadFile (const CanHandle hnd,
4549  int slotNo,
4550  char *filePathOnPC);
4551 
4552 
4553 
4560 #define kvSCRIPT_STATUS_LOADED 1
4561 #define kvSCRIPT_STATUS_RUNNING 2
4584 kvStatus CANLIBAPI kvScriptStatus(const CanHandle hnd,
4585  int slot,
4586  unsigned int *status);
4587 
4588 
4607 kvStatus CANLIBAPI kvScriptGetMaxEnvvarSize(int hnd, int *envvarSize);
4608 
4609 
4632 kvStatus CANLIBAPI kvFileCopyToDevice (const CanHandle hnd,
4633  char *hostFileName,
4634  char *deviceFileName);
4635 
4658 kvStatus CANLIBAPI kvFileCopyFromDevice (const CanHandle hnd,
4659  char *deviceFileName,
4660  char *hostFileName);
4661 
4683 kvStatus CANLIBAPI kvFileDelete (const CanHandle hnd, char *deviceFileName);
4684 
4707 kvStatus CANLIBAPI kvFileGetName (const CanHandle hnd,
4708  int fileNo,
4709  char *name,
4710  int namelen);
4711 
4731 kvStatus CANLIBAPI kvFileGetCount (const CanHandle hnd, int *count);
4732 
4755 kvStatus CANLIBAPI kvFileGetSystemData (const CanHandle hnd,
4756  int itemCode,
4757  int *result);
4758 
4776 #define kvDEVICE_MODE_INTERFACE 0x00
4777 
4782 #define kvDEVICE_MODE_LOGGER 0x01
4783 
4808 kvStatus CANLIBAPI kvDeviceSetMode (const CanHandle hnd, int mode);
4809 
4832 kvStatus CANLIBAPI kvDeviceGetMode (const CanHandle hnd, int *result);
4833 
4834 
4859 kvStatus CANLIBAPI kvReadTimer (const CanHandle hnd, unsigned int *time);
4883 kvStatus CANLIBAPI kvReadTimer64 (const CanHandle hnd, uint64_t *time);
4884 
4885 #ifdef __cplusplus
4886 }
4887 #endif /* __cplusplus */
4888 
4889 #include "obsolete.h"
4890 
4891 
4892 
4893 
4894 #endif /* _CANLIB_H_ */
Definitions which are retained for compatibility.
kvStatus kvScriptEnvvarGetFloat(kvEnvHandle eHnd, float *val)
unsigned long stdRemote
Number of received standard (11-bit identifiers) remote frames.
Definition: canlib.h:3642
canStatus canGetBusParamsFd(const CanHandle hnd, long *freq_brs, unsigned int *tseg1_brs, unsigned int *tseg2_brs, unsigned int *sjw_brs)
canStatus canWriteSync(const CanHandle hnd, unsigned long timeout)
unsigned char busStatus
Definition: canlib.h:161
canStatus canGetBusOutputControl(const CanHandle hnd, unsigned int *drivertype)
kvStatus kvTimeDomainDelete(kvTimeDomain domain)
canStatus canGetDriverMode(const CanHandle hnd, int *lineMode, int *resNet)
struct canNotifyData::@0::@2 rx
void canInitializeLibrary(void)
canStatus canReadStatus(const CanHandle hnd, unsigned long *const flags)
kvStatus kvTimeDomainCreate(kvTimeDomain *domain)
unsigned int portNo
Port number used in e.g. canIOCTL_SET_USER_IOPORT.
Definition: canlib.h:2806
int64_t kvEnvHandle
Definition: canlib.h:4179
int nNonMagiSyncCards
number of non MagiSync™ interfaces
Definition: canlib.h:3720
kvStatus kvScriptEnvvarSetData(kvEnvHandle eHnd, void *buf, int start_index, int data_len)
canStatus canRequestBusStatistics(const CanHandle hnd)
kvStatus kvDeviceSetMode(const CanHandle hnd, int mode)
void * kvTimeDomain
Definition: canlib.h:3708
unsigned char rxErrorCounter
Definition: canlib.h:163
unsigned long extRemote
Number of received extended (29-bit identifiers) remote frames.
Definition: canlib.h:3644
canStatus canClose(const CanHandle hnd)
struct canNotifyData canNotifyData
kvStatus kvFileGetCount(const CanHandle hnd, int *count)
canStatus canTranslateBaud(long *const freq, unsigned int *const tseg1, unsigned int *const tseg2, unsigned int *const sjw, unsigned int *const nosamp, unsigned int *const syncMode)
canStatus canObjBufSetMsgCount(const CanHandle hnd, int idx, unsigned int count)
canStatus kvFlashLeds(const CanHandle hnd, int action, int timeout)
canStatus canSetAcceptanceFilter(const CanHandle hnd, unsigned int code, unsigned int mask, int is_extended)
int canHandle
Definition: canlib.h:138
canStatus canObjBufDisable(const CanHandle hnd, int idx)
void * tag
Definition: canlib.h:146
canStatus canGetBusParams(const CanHandle hnd, long *freq, unsigned int *tseg1, unsigned int *tseg2, unsigned int *sjw, unsigned int *noSamp, unsigned int *syncmode)
kvStatus kvScriptEnvvarGetInt(kvEnvHandle eHnd, int *val)
Definitions for the CANLIB API.
kvStatus kvScriptGetMaxEnvvarSize(int hnd, int *envvarSize)
canStatus canSetBusOutputControl(const CanHandle hnd, const unsigned int drivertype)
int eventType
Definition: canlib.h:147
kvStatus kvFileGetSystemData(const CanHandle hnd, int itemCode, int *result)
kvStatus kvScriptEnvvarSetInt(kvEnvHandle eHnd, int val)
canStatus canObjBufSendBurst(const CanHandle hnd, int idx, unsigned int burstlen)
canStatus canGetRawHandle(const CanHandle hnd, void *pvFd)
unsigned int canGetVersionEx(unsigned int itemCode)
canStatus canBusOn(const CanHandle hnd)
long id
Definition: canlib.h:153
canStatus canWriteWait(const CanHandle hnd, long id, void *msg, unsigned int dlc, unsigned int flag, unsigned long timeout)
kvStatus kvReadDeviceCustomerData(const CanHandle hnd, int userNumber, int itemNumber, void *data, size_t bufsiz)
canStatus canWrite(const CanHandle hnd, long id, void *msg, unsigned int dlc, unsigned int flag)
canStatus canObjBufWrite(const CanHandle hnd, int idx, int id, void *msg, unsigned int dlc, unsigned int flags)
Definition: canlib.h:145
struct kvTimeDomainData_s kvTimeDomainData
kvStatus kvScriptEnvvarClose(kvEnvHandle eHnd)
canStatus canFlushReceiveQueue(const CanHandle hnd)
kvStatus kvScriptLoadFile(const CanHandle hnd, int slotNo, char *filePathOnPC)
unsigned int portValue
Port value used in e.g. canIOCTL_SET_USER_IOPORT.
Definition: canlib.h:2807
unsigned short canGetVersion(void)
unsigned long errFrame
Number of error frames.
Definition: canlib.h:3645
canStatus canReadWait(const CanHandle hnd, long *id, void *msg, unsigned int *dlc, unsigned int *flag, unsigned long *time, unsigned long timeout)
canStatus canReadSyncSpecific(const CanHandle hnd, long id, unsigned long timeout)
canStatus canFlushTransmitQueue(const CanHandle hnd)
kvStatus kvReadTimer64(const CanHandle hnd, uint64_t *time)
kvStatus kvFileGetName(const CanHandle hnd, int fileNo, char *name, int namelen)
kvStatus kvTimeDomainResetTime(kvTimeDomain domain)
kvStatus kvFileDelete(const CanHandle hnd, char *deviceFileName)
canStatus canAccept(const CanHandle hnd, const long envelope, const unsigned int flag)
CanHandle canOpenChannel(int channel, int flags)
kvStatus kvScriptEnvvarSetFloat(kvEnvHandle eHnd, float val)
unsigned long extData
Number of received extended (29-bit identifiers) data frames.
Definition: canlib.h:3643
kvStatus kvReadTimer(const CanHandle hnd, unsigned int *time)
canStatus canObjBufEnable(const CanHandle hnd, int idx)
kvStatus kvSetNotifyCallback(const CanHandle hnd, kvCallback_t callback, void *context, unsigned int notifyFlags)
kvStatus kvScriptSendEvent(const CanHandle hnd, int slotNo, int eventType, int eventNo, unsigned int data)
kvStatus kvTimeDomainGetData(kvTimeDomain domain, kvTimeDomainData *data, size_t bufsiz)
kvStatus kvScriptStart(const CanHandle hnd, int slotNo)
kvStatus kvTimeDomainRemoveHandle(kvTimeDomain domain, const CanHandle hnd)
canStatus canSetNotify(const CanHandle hnd, void(*callback)(canNotifyData *), unsigned int notifyFlags, void *tag)
unsigned char txErrorCounter
Definition: canlib.h:162
canStatus canObjBufSetFlags(const CanHandle hnd, int idx, unsigned int flags)
kvEnvHandle kvScriptEnvvarOpen(const CanHandle hnd, char *envvarName, int *envvarType, int *envvarSize)
void(* kvCallback_t)(CanHandle hnd, void *context, unsigned int notifyEvent)
Definition: canlib.h:3894
canStatus canSetBusParamsC200(const CanHandle hnd, unsigned char btr0, unsigned char btr1)
int nMagiSyncGroups
number of MagiSync™ groups
Definition: canlib.h:3718
canStatus canReadSpecificSkip(const CanHandle hnd, long id, void *msg, unsigned int *dlc, unsigned int *flag, unsigned long *time)
struct canBusStatistics_s canBusStatistics
canStatus canSetBusParamsFd(const CanHandle hnd, long freq_brs, unsigned int tseg1_brs, unsigned int tseg2_brs, unsigned int sjw_brs)
canStatus
Definition: canstat.h:84
kvStatus kvFileCopyFromDevice(const CanHandle hnd, char *deviceFileName, char *hostFileName)
kvStatus kvDeviceGetMode(const CanHandle hnd, int *result)
canStatus canReadErrorCounters(const CanHandle hnd, unsigned int *txErr, unsigned int *rxErr, unsigned int *ovErr)
unsigned long stdData
Number of received standard (11-bit identifiers) data frames.
Definition: canlib.h:3641
canStatus canSetDriverMode(const CanHandle hnd, int lineMode, int resNet)
unsigned long overruns
The number of overruns detected by the hardware, firmware or driver.
Definition: canlib.h:3652
kvStatus kvTimeDomainAddHandle(kvTimeDomain domain, const CanHandle hnd)
Definition: canlib.h:3717
canStatus canReadTimer(const CanHandle hnd, unsigned long *time)
canStatus canGetBusStatistics(const CanHandle hnd, canBusStatistics *stat, size_t bufsiz)
canStatus canBusOff(const CanHandle hnd)
canStatus canReadSpecific(const CanHandle hnd, long id, void *msg, unsigned int *dlc, unsigned int *flag, unsigned long *time)
canStatus canGetErrorText(canStatus err, char *buf, unsigned int bufsiz)
unsigned long busLoad
Definition: canlib.h:3651
canStatus canRequestChipStatus(const CanHandle hnd)
Definition: canlib.h:3640
kvStatus kvScriptLoadFileOnDevice(const CanHandle hnd, int slotNo, char *localFile)
canStatus canUnloadLibrary(void)
struct canNotifyData::@0::@1 busErr
canHandle CanHandle
Definition: canlib.h:143
canStatus kvStatus
Definition: canlib.h:3711
Definition: canlib.h:2805
union canNotifyData::@0 info
canStatus canResetBus(const CanHandle hnd)
canStatus canObjBufAllocate(const CanHandle hnd, int type)
int nNonMagiSyncedMembers
number of non MagiSync™ members
Definition: canlib.h:3721
canStatus canGetNumberOfChannels(int *channelCount)
canStatus canGetHandleData(const CanHandle hnd, int item, void *buffer, size_t bufsize)
kvStatus kvScriptEnvvarGetData(kvEnvHandle eHnd, void *buf, int start_index, int data_len)
unsigned long time
Definition: canlib.h:150
kvStatus kvFileCopyToDevice(const CanHandle hnd, char *hostFileName, char *deviceFileName)
canStatus canReadSync(const CanHandle hnd, unsigned long timeout)
kvStatus kvScriptUnload(const CanHandle hnd, int slotNo)
canStatus canObjBufSetPeriod(const CanHandle hnd, int idx, unsigned int period)
canStatus canObjBufFreeAll(const CanHandle hnd)
canStatus canIoCtl(const CanHandle hnd, unsigned int func, void *buf, unsigned int buflen)
struct canNotifyData::@0::@4 status
canStatus canSetBusParams(const CanHandle hnd, long freq, unsigned int tseg1, unsigned int tseg2, unsigned int sjw, unsigned int noSamp, unsigned int syncmode)
canStatus canObjBufSetFilter(const CanHandle hnd, int idx, unsigned int code, unsigned int mask)
struct canNotifyData::@0::@3 tx
kvStatus kvGetSupportedInterfaceInfo(int index, char *hwName, size_t nameLen, int *hwType, int *hwBusType)
canStatus canRead(const CanHandle hnd, long *id, void *msg, unsigned int *dlc, unsigned int *flag, unsigned long *time)
int nMagiSyncedMembers
number of MagiSync™ members
Definition: canlib.h:3719