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 
138 #ifndef _CANLIB_H_
139 #define _CANLIB_H_
140 
141 #include <stdlib.h>
142 
143 #include <stdint.h>
144 
145 #include "canstat.h"
146 
148 typedef int canHandle;
149 
150 # define canINVALID_HANDLE (-1)
151 
154 
155 typedef struct canNotifyData {
156  void *tag;
158  union {
159  struct {
160  unsigned long time;
161  } busErr;
162  struct {
163  long id;
164  unsigned long time;
165  } rx;
166  struct {
167  long id;
168  unsigned long time;
169  } tx;
170  struct {
171  unsigned char busStatus;
172  unsigned char txErrorCounter;
173  unsigned char rxErrorCounter;
174  unsigned long time;
175  } status;
176  } info;
177 } canNotifyData;
178 
179 
189 // The canWANT_xxx names are also obsolete, use canOPEN_xxx instead for new developments.
190 #define canWANT_EXCLUSIVE 0x0008
191 #define canWANT_EXTENDED 0x0010
192 #define canWANT_VIRTUAL 0x0020
193 
199 #define canOPEN_EXCLUSIVE 0x0008
200 
212 #define canOPEN_REQUIRE_EXTENDED 0x0010
213 
221 # define canOPEN_ACCEPT_VIRTUAL 0x0020
222 
231 # define canOPEN_OVERRIDE_EXCLUSIVE 0x0040
232 
249 # define canOPEN_REQUIRE_INIT_ACCESS 0x0080
250 
262 # define canOPEN_NO_INIT_ACCESS 0x0100
263 
275 # define canOPEN_ACCEPT_LARGE_DLC 0x0200 // DLC can be greater than 8
276 
283 # define canOPEN_CAN_FD 0x0400
284 
298 # define canOPEN_CAN_FD_NONISO 0x0800
299 
300 
304 # define canOPEN_INTERNAL_L 0x1000
305 
317 #define canFILTER_ACCEPT 1
318 #define canFILTER_REJECT 2
319 
320 #define canFILTER_SET_CODE_STD 3
321 
322 #define canFILTER_SET_MASK_STD 4
323 
324 #define canFILTER_SET_CODE_EXT 5
325 
326 #define canFILTER_SET_MASK_EXT 6
327 
328 #define canFILTER_NULL_MASK 0L
329 
345 #define canDRIVER_NORMAL 4
346 
353 #define canDRIVER_SILENT 1
354 
358 #define canDRIVER_SELFRECEPTION 8
359 
363 #define canDRIVER_OFF 0
364 
387 #define canBITRATE_1M (-1)
388 
389 #define canBITRATE_500K (-2)
390 
391 #define canBITRATE_250K (-3)
392 
393 #define canBITRATE_125K (-4)
394 
395 #define canBITRATE_100K (-5)
396 
397 #define canBITRATE_62K (-6)
398 
399 #define canBITRATE_50K (-7)
400 
401 #define canBITRATE_83K (-8)
402 
403 #define canBITRATE_10K (-9)
404 
405 // CAN FD Bit Rates
409 #define canFD_BITRATE_500K_80P (-1000)
410 
413 #define canFD_BITRATE_1M_80P (-1001)
414 
417 #define canFD_BITRATE_2M_80P (-1002)
418 
421 #define canFD_BITRATE_4M_80P (-1003)
422 
425 #define canFD_BITRATE_8M_60P (-1004)
426 
428 #define BAUD_1M (-1)
429 
430 #define BAUD_500K (-2)
431 
432 #define BAUD_250K (-3)
433 
434 #define BAUD_125K (-4)
435 
436 #define BAUD_100K (-5)
437 
438 #define BAUD_62K (-6)
439 
440 #define BAUD_50K (-7)
441 
442 #define BAUD_83K (-8)
443 
446 //
447 // Define CANLIBAPI unless it's done already.
448 // (canlib.c provides its own definitions of CANLIBAPI, DLLIMPORT
449 // and DLLEXPORT before including this file.)
450 //
451 #ifndef CANLIBAPI
452 # define CANLIBAPI
453 #endif /* CANLIBAPI */
454 
455 
456 #ifdef __cplusplus
457 extern "C" {
458 #endif /* __cplusplus */
459 
481 void CANLIBAPI canInitializeLibrary (void);
482 
507 canStatus CANLIBAPI canClose (const CanHandle hnd);
508 
533 canStatus CANLIBAPI canBusOn (const CanHandle hnd);
534 
554 canStatus CANLIBAPI canBusOff (const CanHandle hnd);
555 
602 canStatus CANLIBAPI canSetBusParams (const CanHandle hnd,
603  long freq,
604  unsigned int tseg1,
605  unsigned int tseg2,
606  unsigned int sjw,
607  unsigned int noSamp,
608  unsigned int syncmode);
609 
641 canStatus CANLIBAPI canSetBusParamsFd(const CanHandle hnd,
642  long freq_brs,
643  unsigned int tseg1_brs,
644  unsigned int tseg2_brs,
645  unsigned int sjw_brs);
646 
647 
679 canStatus CANLIBAPI canGetBusParams (const CanHandle hnd,
680  long *freq,
681  unsigned int *tseg1,
682  unsigned int *tseg2,
683  unsigned int *sjw,
684  unsigned int *noSamp,
685  unsigned int *syncmode);
686 
687 
710 canStatus CANLIBAPI canGetBusParamsFd(const CanHandle hnd,
711  long *freq_brs,
712  unsigned int *tseg1_brs,
713  unsigned int *tseg2_brs,
714  unsigned int *sjw_brs);
739 canStatus CANLIBAPI canSetBusOutputControl (const CanHandle hnd,
740  const unsigned int drivertype);
741 
776 canStatus CANLIBAPI canGetBusOutputControl (const CanHandle hnd,
777  unsigned int *drivertype);
778 
819 canStatus CANLIBAPI canAccept (const CanHandle hnd,
820  const long envelope,
821  const unsigned int flag);
822 
846 canStatus CANLIBAPI canReadStatus (const CanHandle hnd,
847  unsigned long *const flags);
848 
885 canStatus CANLIBAPI canReadErrorCounters (const CanHandle hnd,
886  unsigned int *txErr,
887  unsigned int *rxErr,
888  unsigned int *ovErr);
889 
931 canStatus CANLIBAPI canWrite (const CanHandle hnd,
932  long id,
933  void *msg,
934  unsigned int dlc,
935  unsigned int flag);
936 
964 canStatus CANLIBAPI canWriteSync (const CanHandle hnd, unsigned long timeout);
965 
1017 canStatus CANLIBAPI canRead (const CanHandle hnd,
1018  long *id,
1019  void *msg,
1020  unsigned int *dlc,
1021  unsigned int *flag,
1022  unsigned long *time);
1073 canStatus CANLIBAPI canReadWait (const CanHandle hnd,
1074  long *id,
1075  void *msg,
1076  unsigned int *dlc,
1077  unsigned int *flag,
1078  unsigned long *time,
1079  unsigned long timeout);
1080 
1132 canStatus CANLIBAPI canReadSpecific (const CanHandle hnd, long id, void * msg,
1133  unsigned int * dlc, unsigned int * flag,
1134  unsigned long * time);
1135 
1166 canStatus CANLIBAPI canReadSync (const CanHandle hnd, unsigned long timeout);
1167 
1199 canStatus CANLIBAPI canReadSyncSpecific (const CanHandle hnd,
1200  long id,
1201  unsigned long timeout);
1202 
1248 canStatus CANLIBAPI canReadSpecificSkip (const CanHandle hnd,
1249  long id,
1250  void * msg,
1251  unsigned int * dlc,
1252  unsigned int * flag,
1253  unsigned long * time);
1254 
1275 canStatus CANLIBAPI canSetNotify (const CanHandle hnd,
1276  void (*callback)(canNotifyData *),
1277  unsigned int notifyFlags,
1278  void *tag);
1279 
1293 canStatus CANLIBAPI canGetRawHandle (const CanHandle hnd, void *pvFd);
1294 
1329 canStatus CANLIBAPI canTranslateBaud (long *const freq,
1330  unsigned int *const tseg1,
1331  unsigned int *const tseg2,
1332  unsigned int *const sjw,
1333  unsigned int *const nosamp,
1334  unsigned int *const syncMode);
1335 
1358 canStatus CANLIBAPI canGetErrorText (canStatus err, char *buf, unsigned int bufsiz);
1359 
1389 unsigned short CANLIBAPI canGetVersion (void);
1390 
1420 canStatus CANLIBAPI canIoCtl (const CanHandle hnd,
1421  unsigned int func,
1422  void *buf,
1423  unsigned int buflen);
1424 
1425 
1436 canStatus CANLIBAPI canReadTimer (const CanHandle hnd, unsigned long *time);
1437 
1488 CanHandle CANLIBAPI canOpenChannel (int channel, int flags);
1489 
1510 canStatus CANLIBAPI canGetNumberOfChannels (int *channelCount);
1511 
1512 
1520 #define kvREMOTE_TYPE_NOT_REMOTE 0
1521 #define kvREMOTE_TYPE_WLAN 1
1522 #define kvREMOTE_TYPE_LAN 2
1523 
1532 #define kvLOGGER_TYPE_NOT_A_LOGGER 0
1533 #define kvLOGGER_TYPE_V1 1
1534 #define kvLOGGER_TYPE_V2 2
1535 
1567 canStatus CANLIBAPI canGetChannelData (int channel,
1568  int item,
1569  void *buffer,
1570  size_t bufsize);
1571 
1590 #define canCHANNELDATA_CHANNEL_CAP 1
1591 
1601 #define canCHANNELDATA_TRANS_CAP 2
1602 
1609 #define canCHANNELDATA_CHANNEL_FLAGS 3 // available, etc
1610 
1619 #define canCHANNELDATA_CARD_TYPE 4
1620 
1630 #define canCHANNELDATA_CARD_NUMBER 5
1631 
1639 #define canCHANNELDATA_CHAN_NO_ON_CARD 6
1640 
1650 #define canCHANNELDATA_CARD_SERIAL_NO 7
1651 
1661 #define canCHANNELDATA_TRANS_SERIAL_NO 8
1662 
1673 #define canCHANNELDATA_CARD_FIRMWARE_REV 9
1674 
1685 #define canCHANNELDATA_CARD_HARDWARE_REV 10
1686 
1696 #define canCHANNELDATA_CARD_UPC_NO 11
1697 
1708 #define canCHANNELDATA_TRANS_UPC_NO 12
1709 
1725 #define canCHANNELDATA_CHANNEL_NAME 13
1726 
1742 # define canCHANNELDATA_DLL_FILE_VERSION 14
1743 
1759 # define canCHANNELDATA_DLL_PRODUCT_VERSION 15
1760 
1776 # define canCHANNELDATA_DLL_FILETYPE 16
1777 
1786 # define canCHANNELDATA_TRANS_TYPE 17
1787 
1811 # define canCHANNELDATA_DEVICE_PHYSICAL_POSITION 18
1812 
1825 # define canCHANNELDATA_UI_NUMBER 19
1826 
1850 # define canCHANNELDATA_TIMESYNC_ENABLED 20
1851 
1866 # define canCHANNELDATA_DRIVER_FILE_VERSION 21
1867 
1882 # define canCHANNELDATA_DRIVER_PRODUCT_VERSION 22
1883 
1892 # define canCHANNELDATA_MFGNAME_UNICODE 23
1893 
1901 # define canCHANNELDATA_MFGNAME_ASCII 24
1902 
1911 # define canCHANNELDATA_DEVDESCR_UNICODE 25
1912 
1920 # define canCHANNELDATA_DEVDESCR_ASCII 26
1921 
1932 # define canCHANNELDATA_DRIVER_NAME 27
1933 
1946 # define canCHANNELDATA_CHANNEL_QUALITY 28
1947 
1956 # define canCHANNELDATA_ROUNDTRIP_TIME 29
1957 
1966 # define canCHANNELDATA_BUS_TYPE 30
1967 
1979 # define canCHANNELDATA_DEVNAME_ASCII 31
1980 
1991 # define canCHANNELDATA_TIME_SINCE_LAST_SEEN 32
1992 
2002 # define canCHANNELDATA_REMOTE_OPERATIONAL_MODE 33
2003 
2012 # define canCHANNELDATA_REMOTE_PROFILE_NAME 34
2013 
2022 # define canCHANNELDATA_REMOTE_HOST_NAME 35
2023 
2032 # define canCHANNELDATA_REMOTE_MAC 36
2033 
2042 # define canCHANNELDATA_MAX_BITRATE 37
2043 
2054 # define canCHANNELDATA_CHANNEL_CAP_MASK 38
2055 
2065 # define canCHANNELDATA_IS_REMOTE 40
2066 
2075 # define canCHANNELDATA_REMOTE_TYPE 41
2076 
2085 # define canCHANNELDATA_LOGGER_TYPE 42
2086 
2096 # define canCHANNELDATA_HW_STATUS 43
2097 
2107 # define canCHANNELDATA_FEATURE_EAN 44
2108 
2117 #define canCHANNELDATA_CUST_CHANNEL_NAME 39
2118 
2132 #define canCHANNEL_IS_EXCLUSIVE 0x0001
2133 
2135 #define canCHANNEL_IS_OPEN 0x0002
2136 
2139 #define canCHANNEL_IS_CANFD 0x0004
2140 
2141 //#define canCHANNEL_IS_CANFD_NON_ISO 0x0008 Reserved for when needed
2142 
2145 #define canCHANNEL_IS_LIN 0x0010
2146 
2149 #define canCHANNEL_IS_LIN_MASTER 0x0020
2150 
2153 #define canCHANNEL_IS_LIN_SLAVE 0x0040
2154 
2155 
2174 #define canHWTYPE_NONE 0
2175 #define canHWTYPE_VIRTUAL 1
2176 #define canHWTYPE_LAPCAN 2
2177 #define canHWTYPE_CANPARI 3
2178 #define canHWTYPE_PCCAN 8
2179 #define canHWTYPE_PCICAN 9
2180 #define canHWTYPE_USBCAN 11
2181 #define canHWTYPE_PCICAN_II 40
2182 #define canHWTYPE_USBCAN_II 42
2183 #define canHWTYPE_SIMULATED 44
2184 #define canHWTYPE_ACQUISITOR 46
2185 #define canHWTYPE_LEAF 48
2186 #define canHWTYPE_PC104_PLUS 50
2187 #define canHWTYPE_PCICANX_II 52
2188 #define canHWTYPE_MEMORATOR_II 54
2189 #define canHWTYPE_MEMORATOR_PRO 54
2190 #define canHWTYPE_USBCAN_PRO 56
2191 #define canHWTYPE_IRIS 58
2192 #define canHWTYPE_BLACKBIRD 58
2193 #define canHWTYPE_MEMORATOR_LIGHT 60
2194 #define canHWTYPE_MINIHYDRA 62
2195 #define canHWTYPE_EAGLE 62
2196 #define canHWTYPE_BAGEL 64
2197 #define canHWTYPE_BLACKBIRD_V2 64
2198 #define canHWTYPE_MINIPCIE 66
2199 #define canHWTYPE_USBCAN_KLINE 68
2200 #define canHWTYPE_ETHERCAN 70
2201 #define canHWTYPE_USBCAN_LIGHT 72
2202 #define canHWTYPE_USBCAN_PRO2 74
2203 #define canHWTYPE_PCIE_V2 76
2204 #define canHWTYPE_MEMORATOR_PRO2 78
2205 #define canHWTYPE_LEAF2 80
2206 #define canHWTYPE_MEMORATOR_V2 82
2207 #define canHWTYPE_CANLINHYBRID 84
2208 
2209 
2218 #define canCHANNEL_CAP_EXTENDED_CAN 0x00000001L
2219 #define canCHANNEL_CAP_BUS_STATISTICS 0x00000002L
2220 #define canCHANNEL_CAP_ERROR_COUNTERS 0x00000004L
2221 #define canCHANNEL_CAP_RESERVED_2 0x00000008L
2222 #define canCHANNEL_CAP_GENERATE_ERROR 0x00000010L
2223 #define canCHANNEL_CAP_GENERATE_OVERLOAD 0x00000020L
2224 #define canCHANNEL_CAP_TXREQUEST 0x00000040L
2225 #define canCHANNEL_CAP_TXACKNOWLEDGE 0x00000080L
2226 #define canCHANNEL_CAP_VIRTUAL 0x00010000L
2227 #define canCHANNEL_CAP_SIMULATED 0x00020000L
2228 #define canCHANNEL_CAP_RESERVED_1 0x00040000L
2229 #define canCHANNEL_CAP_CAN_FD 0x00080000L
2230 #define canCHANNEL_CAP_CAN_FD_NONISO 0x00100000L
2231 #define canCHANNEL_CAP_SILENT_MODE 0x00200000L
2232 #define canCHANNEL_CAP_SINGLE_SHOT 0x00400000L
2233 #define canCHANNEL_CAP_LOGGER 0x00800000L
2234 #define canCHANNEL_CAP_REMOTE_ACCESS 0x01000000L
2235 #define canCHANNEL_CAP_SCRIPT 0x02000000L
2236 #define canCHANNEL_CAP_DIAGNOSTICS 0x10000000L
2237 
2238 
2250 #define canCHANNEL_OPMODE_NONE 1
2251 
2255 #define canCHANNEL_OPMODE_INFRASTRUCTURE 2
2256 
2260 #define canCHANNEL_OPMODE_RESERVED 3
2261 
2265 #define canCHANNEL_OPMODE_ADHOC 4
2266 
2276 #define canDRIVER_CAP_HIGHSPEED 0x00000001L
2277 
2302 #define canIOCTL_PREFER_EXT 1
2303 
2316 #define canIOCTL_PREFER_STD 2
2317 
2333 #define canIOCTL_CLEAR_ERROR_COUNTERS 5
2334 
2345 #define canIOCTL_SET_TIMER_SCALE 6
2346 
2362 #define canIOCTL_SET_TXACK 7
2363 
2376 #define canIOCTL_GET_RX_BUFFER_LEVEL 8
2377 
2390 #define canIOCTL_GET_TX_BUFFER_LEVEL 9
2391 
2401 #define canIOCTL_FLUSH_RX_BUFFER 10
2402 
2412 #define canIOCTL_FLUSH_TX_BUFFER 11
2413 
2422 #define canIOCTL_GET_TIMER_SCALE 12
2423 
2435 #define canIOCTL_SET_TXRQ 13
2436 
2437 
2444 #define canIOCTL_SET_BYPASS_MODE 15
2445 
2451 #define canIOCTL_SET_WAKEUP 16
2452 
2462 # define canIOCTL_GET_DRIVERHANDLE 17
2463 
2469 # define canIOCTL_MAP_RXQUEUE 18
2470 
2476 # define canIOCTL_GET_WAKEUP 19
2477 
2489 # define canIOCTL_SET_REPORT_ACCESS_ERRORS 20
2490 
2498 # define canIOCTL_GET_REPORT_ACCESS_ERRORS 21
2499 
2509 # define canIOCTL_CONNECT_TO_VIRTUAL_BUS 22
2510 
2520 # define canIOCTL_DISCONNECT_FROM_VIRTUAL_BUS 23
2521 
2531 # define canIOCTL_SET_USER_IOPORT 24
2532 
2543 # define canIOCTL_GET_USER_IOPORT 25
2544 
2550 # define canIOCTL_SET_BUFFER_WRAPAROUND_MODE 26
2551 
2568 # define canIOCTL_SET_RX_QUEUE_SIZE 27
2569 
2575 # define canIOCTL_SET_USB_THROTTLE 28
2576 
2582 # define canIOCTL_GET_USB_THROTTLE 29
2583 
2594 # define canIOCTL_SET_BUSON_TIME_AUTO_RESET 30
2595 
2607 # define canIOCTL_GET_TXACK 31
2608 
2623 # define canIOCTL_SET_LOCAL_TXECHO 32
2624 
2637 # define canIOCTL_SET_ERROR_FRAMES_REPORTING 33
2638 
2652 # define canIOCTL_GET_CHANNEL_QUALITY 34
2653 
2663 # define canIOCTL_GET_ROUNDTRIP_TIME 35
2664 
2673 # define canIOCTL_GET_BUS_TYPE 36
2674 
2687 # define canIOCTL_GET_DEVNAME_ASCII 37
2688 
2700 # define canIOCTL_GET_TIME_SINCE_LAST_SEEN 38
2701 
2715 # define canIOCTL_GET_TREF_LIST 39
2716 
2738 # define canIOCTL_TX_INTERVAL 40
2739 
2751 # define canIOCTL_SET_BRLIMIT 43
2752 
2753 
2768 # define canIOCTL_SET_THROTTLE_SCALED 41
2769 
2770 
2785 # define canIOCTL_GET_THROTTLE_SCALED 42
2786 
2793 # define canIOCTL_RESET_OVERRUN_COUNT 44
2794 
2803 # define canIOCTL_LIN_MODE 45
2804 
2807 typedef struct {
2808  unsigned int portNo;
2809  unsigned int portValue;
2811 
2812 
2853 canStatus CANLIBAPI canSetBusParamsC200 (const CanHandle hnd, unsigned char btr0, unsigned char btr1);
2854 
2855 
2856 
2892 canStatus CANLIBAPI canSetDriverMode (const CanHandle hnd, int lineMode, int resNet);
2893 
2930 canStatus CANLIBAPI canGetDriverMode (const CanHandle hnd, int *lineMode, int *resNet);
2931 
2951 #define canVERSION_CANLIB32_VERSION 0
2952 
2963 #define canVERSION_CANLIB32_PRODVER 1
2964 
2976 #define canVERSION_CANLIB32_PRODVER32 2
2977 
2988 #define canVERSION_CANLIB32_BETA 3
2989 
3009 unsigned int CANLIBAPI canGetVersionEx (unsigned int itemCode);
3010 
3011 
3031 canStatus CANLIBAPI canObjBufFreeAll (const CanHandle hnd);
3032 
3053 canStatus CANLIBAPI canObjBufAllocate (const CanHandle hnd, int type);
3054 
3063 #define canOBJBUF_TYPE_AUTO_RESPONSE 0x01
3064 #define canOBJBUF_TYPE_PERIODIC_TX 0x02
3065 
3087 canStatus CANLIBAPI canObjBufFree (const CanHandle hnd, int idx);
3088 
3089 // Writes CAN data to the object buffer with the specified index.
3090 
3116 canStatus CANLIBAPI canObjBufWrite (const CanHandle hnd,
3117  int idx,
3118  int id,
3119  void* msg,
3120  unsigned int dlc,
3121  unsigned int flags);
3122 
3149 canStatus CANLIBAPI canObjBufSetFilter (const CanHandle hnd,
3150  int idx,
3151  unsigned int code,
3152  unsigned int mask);
3153 
3174 canStatus CANLIBAPI canObjBufSetFlags (const CanHandle hnd,
3175  int idx,
3176  unsigned int flags);
3177 
3195 # define canOBJBUF_AUTO_RESPONSE_RTR_ONLY 0x01
3196 
3218 canStatus CANLIBAPI canObjBufSetPeriod (const CanHandle hnd,
3219  int idx,
3220  unsigned int period);
3221 
3242 canStatus CANLIBAPI canObjBufSetMsgCount (const CanHandle hnd,
3243  int idx,
3244  unsigned int count);
3245 
3265 canStatus CANLIBAPI canObjBufEnable (const CanHandle hnd, int idx);
3266 
3286 canStatus CANLIBAPI canObjBufDisable (const CanHandle hnd, int idx);
3287 
3311 canStatus CANLIBAPI canObjBufSendBurst (const CanHandle hnd,
3312  int idx,
3313  unsigned int burstlen);
3314 
3315 
3338 canStatus CANLIBAPI canResetBus (const CanHandle hnd);
3339 
3378 canStatus CANLIBAPI canWriteWait (const CanHandle hnd,
3379  long id,
3380  void *msg,
3381  unsigned int dlc,
3382  unsigned int flag,
3383  unsigned long timeout);
3384 
3385 
3411 canStatus CANLIBAPI canUnloadLibrary (void);
3412 
3472 canStatus CANLIBAPI canSetAcceptanceFilter (const CanHandle hnd,
3473  unsigned int code,
3474  unsigned int mask,
3475  int is_extended);
3499 canStatus CANLIBAPI canFlushReceiveQueue (const CanHandle hnd);
3500 
3525 canStatus CANLIBAPI canFlushTransmitQueue (const CanHandle hnd);
3526 
3527 
3536 #define kvLED_ACTION_ALL_LEDS_ON 0
3537 #define kvLED_ACTION_ALL_LEDS_OFF 1
3538 #define kvLED_ACTION_LED_0_ON 2
3539 #define kvLED_ACTION_LED_0_OFF 3
3540 #define kvLED_ACTION_LED_1_ON 4
3541 #define kvLED_ACTION_LED_1_OFF 5
3542 #define kvLED_ACTION_LED_2_ON 6
3543 #define kvLED_ACTION_LED_2_OFF 7
3544 #define kvLED_ACTION_LED_3_ON 8
3545 #define kvLED_ACTION_LED_3_OFF 9
3546 #define kvLED_ACTION_LED_4_ON 10
3547 #define kvLED_ACTION_LED_4_OFF 11
3548 #define kvLED_ACTION_LED_5_ON 12
3549 #define kvLED_ACTION_LED_5_OFF 13
3550 #define kvLED_ACTION_LED_6_ON 14
3551 #define kvLED_ACTION_LED_6_OFF 15
3552 #define kvLED_ACTION_LED_7_ON 16
3553 #define kvLED_ACTION_LED_7_OFF 17
3554 #define kvLED_ACTION_LED_8_ON 18
3555 #define kvLED_ACTION_LED_8_OFF 19
3556 #define kvLED_ACTION_LED_9_ON 20
3557 #define kvLED_ACTION_LED_9_OFF 21
3558 #define kvLED_ACTION_LED_10_ON 22
3559 #define kvLED_ACTION_LED_10_OFF 23
3560 #define kvLED_ACTION_LED_11_ON 24
3561 #define kvLED_ACTION_LED_11_OFF 25
3562 
3563 
3586 canStatus CANLIBAPI kvFlashLeds (const CanHandle hnd, int action, int timeout);
3587 
3607 canStatus CANLIBAPI canRequestChipStatus (const CanHandle hnd);
3608 
3635 canStatus CANLIBAPI canRequestBusStatistics (const CanHandle hnd);
3636 
3642 typedef struct canBusStatistics_s {
3643  unsigned long stdData;
3644  unsigned long stdRemote;
3645  unsigned long extData;
3646  unsigned long extRemote;
3647  unsigned long errFrame;
3648 
3653  unsigned long busLoad;
3654  unsigned long overruns;
3656 
3679 canStatus CANLIBAPI canGetBusStatistics (const CanHandle hnd,
3680  canBusStatistics *stat,
3681  size_t bufsiz);
3682 
3683 
3704 canStatus CANLIBAPI canGetHandleData (const CanHandle hnd,
3705  int item,
3706  void *buffer,
3707  size_t bufsize);
3708 
3710 typedef void *kvTimeDomain;
3711 
3714 
3719 typedef struct kvTimeDomainData_s {
3725 
3754 kvStatus CANLIBAPI kvTimeDomainCreate (kvTimeDomain *domain);
3755 
3778 kvStatus CANLIBAPI kvTimeDomainDelete (kvTimeDomain domain);
3779 
3805 kvStatus CANLIBAPI kvTimeDomainResetTime (kvTimeDomain domain);
3806 
3831 kvStatus CANLIBAPI kvTimeDomainGetData (kvTimeDomain domain,
3832  kvTimeDomainData *data,
3833  size_t bufsiz);
3834 
3857 kvStatus CANLIBAPI kvTimeDomainAddHandle(kvTimeDomain domain,
3858  const CanHandle hnd);
3859 
3881 kvStatus CANLIBAPI kvTimeDomainRemoveHandle (kvTimeDomain domain,
3882  const CanHandle hnd);
3883 
3896 typedef void (CANLIBAPI *kvCallback_t) (CanHandle hnd, void* context, unsigned int notifyEvent);
3897 
3931 kvStatus CANLIBAPI kvSetNotifyCallback (const CanHandle hnd,
3932  kvCallback_t callback,
3933  void* context,
3934  unsigned int notifyFlags);
3935 
3949 #define kvBUSTYPE_NONE 0
3950 
3955 #define kvBUSTYPE_PCI 1
3956 
3961 #define kvBUSTYPE_PCMCIA 2
3962 
3967 #define kvBUSTYPE_USB 3
3968 
3973 #define kvBUSTYPE_WLAN 4
3974 
3979 #define kvBUSTYPE_PCI_EXPRESS 5
3980 
3985 #define kvBUSTYPE_ISA 6
3986 
3991 #define kvBUSTYPE_VIRTUAL 7
3992 
3997 #define kvBUSTYPE_PC104_PLUS 8
3998 
4003 #define kvBUSTYPE_LAN 9
4004 
4020 #define kvBUSTYPE_GROUP_VIRTUAL 1
4021 
4026 #define kvBUSTYPE_GROUP_LOCAL 2
4027 
4032 #define kvBUSTYPE_GROUP_REMOTE 3
4033 
4037 #define kvBUSTYPE_GROUP_INTERNAL 4
4038 
4092 kvStatus CANLIBAPI kvGetSupportedInterfaceInfo (int index,
4093  char *hwName,
4094  size_t nameLen,
4095  int *hwType,
4096  int *hwBusType);
4097 
4122 kvStatus CANLIBAPI kvReadDeviceCustomerData (const CanHandle hnd,
4123  int userNumber,
4124  int itemNumber,
4125  void *data,
4126  size_t bufsiz);
4127 
4141 #define kvENVVAR_TYPE_INT 1
4142 
4148 #define kvENVVAR_TYPE_FLOAT 2
4149 
4155 #define kvENVVAR_TYPE_STRING 3
4156 
4172 #define kvEVENT_TYPE_KEY 1
4173 
4181  typedef int64_t kvEnvHandle;
4182 
4202 kvStatus CANLIBAPI kvScriptStart (const CanHandle hnd, int slotNo);
4203 
4210 #define kvSCRIPT_STOP_NORMAL 0
4211 #define kvSCRIPT_STOP_FORCED -9
4235 kvStatus CANLIBAPI kvScriptStop (const CanHandle hnd, int slotNo, int mode);
4236 
4255 kvStatus CANLIBAPI kvScriptUnload (const CanHandle hnd, int slotNo);
4256 
4281 kvStatus CANLIBAPI kvScriptSendEvent (const CanHandle hnd,
4282  int slotNo,
4283  int eventType,
4284  int eventNo,
4285  unsigned int data);
4286 
4313 kvEnvHandle CANLIBAPI kvScriptEnvvarOpen (const CanHandle hnd,
4314  char* envvarName,
4315  int *envvarType,
4316  int *envvarSize); // returns scriptHandle
4317 
4337 kvStatus CANLIBAPI kvScriptEnvvarClose (kvEnvHandle eHnd);
4338 
4361 kvStatus CANLIBAPI kvScriptEnvvarSetInt (kvEnvHandle eHnd, int val);
4362 
4386 kvStatus CANLIBAPI kvScriptEnvvarGetInt (kvEnvHandle eHnd, int *val);
4387 
4410 kvStatus CANLIBAPI kvScriptEnvvarSetFloat (kvEnvHandle eHnd, float val);
4411 
4435 kvStatus CANLIBAPI kvScriptEnvvarGetFloat (kvEnvHandle eHnd, float *val);
4436 
4463 kvStatus CANLIBAPI kvScriptEnvvarSetData (kvEnvHandle eHnd,
4464  void *buf,
4465  int start_index,
4466  int data_len);
4467 
4493 kvStatus CANLIBAPI kvScriptEnvvarGetData (kvEnvHandle eHnd,
4494  void *buf,
4495  int start_index,
4496  int data_len);
4497 
4523 kvStatus CANLIBAPI kvScriptLoadFileOnDevice (const CanHandle hnd,
4524  int slotNo,
4525  char *localFile);
4526 
4550 kvStatus CANLIBAPI kvScriptLoadFile (const CanHandle hnd,
4551  int slotNo,
4552  char *filePathOnPC);
4553 
4554 
4555 
4562 #define kvSCRIPT_STATUS_LOADED 1
4563 #define kvSCRIPT_STATUS_RUNNING 2
4586 kvStatus CANLIBAPI kvScriptStatus(const CanHandle hnd,
4587  int slot,
4588  unsigned int *status);
4589 
4590 
4609 kvStatus CANLIBAPI kvScriptGetMaxEnvvarSize(int hnd, int *envvarSize);
4610 
4641 kvStatus CANLIBAPI kvScriptTxeGetData(const char *filePathOnPC,
4642  int item,
4643  void *buffer,
4644  unsigned int *bufsize);
4645 
4671 #define canTXEDATA_FILE_VERSION 1
4672 
4688 #define canTXEDATA_COMPILER_VERSION 2
4689 
4708 #define canTXEDATA_DATE 3
4709 
4720 #define canTXEDATA_DESCRIPTION 4
4721 
4735 #define canTXEDATA_SOURCE 5
4736 
4746 #define canTXEDATA_SIZE_OF_CODE 6
4747 
4757 #define canTXEDATA_IS_ENCRYPTED 7
4758 
4759 
4785 kvStatus CANLIBAPI kvFileCopyToDevice (const CanHandle hnd,
4786  char *hostFileName,
4787  char *deviceFileName);
4788 
4811 kvStatus CANLIBAPI kvFileCopyFromDevice (const CanHandle hnd,
4812  char *deviceFileName,
4813  char *hostFileName);
4814 
4836 kvStatus CANLIBAPI kvFileDelete (const CanHandle hnd, char *deviceFileName);
4837 
4860 kvStatus CANLIBAPI kvFileGetName (const CanHandle hnd,
4861  int fileNo,
4862  char *name,
4863  int namelen);
4864 
4884 kvStatus CANLIBAPI kvFileGetCount (const CanHandle hnd, int *count);
4885 
4908 kvStatus CANLIBAPI kvFileGetSystemData (const CanHandle hnd,
4909  int itemCode,
4910  int *result);
4911 
4929 #define kvDEVICE_MODE_INTERFACE 0x00
4930 
4935 #define kvDEVICE_MODE_LOGGER 0x01
4936 
4961 kvStatus CANLIBAPI kvDeviceSetMode (const CanHandle hnd, int mode);
4962 
4985 kvStatus CANLIBAPI kvDeviceGetMode (const CanHandle hnd, int *result);
4986 
4987 
5012 kvStatus CANLIBAPI kvReadTimer (const CanHandle hnd, unsigned int *time);
5036 kvStatus CANLIBAPI kvReadTimer64 (const CanHandle hnd, uint64_t *time);
5037 
5038 
5039 #ifdef __cplusplus
5040 }
5041 #endif /* __cplusplus */
5042 
5043 #include "obsolete.h"
5044 
5045 
5046 
5047 
5048 #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:3644
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:171
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:2808
int64_t kvEnvHandle
Definition: canlib.h:4181
int nNonMagiSyncCards
number of non MagiSync™ interfaces
Definition: canlib.h:3722
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:3710
unsigned char rxErrorCounter
Definition: canlib.h:173
unsigned long extRemote
Number of received extended (29-bit identifiers) remote frames.
Definition: canlib.h:3646
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:148
canStatus canObjBufDisable(const CanHandle hnd, int idx)
void * tag
Definition: canlib.h:156
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:157
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:163
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:155
struct kvTimeDomainData_s kvTimeDomainData
kvStatus kvScriptTxeGetData(const char *filePathOnPC, int item, void *buffer, unsigned int *bufsize)
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:2809
unsigned short canGetVersion(void)
unsigned long errFrame
Number of error frames.
Definition: canlib.h:3647
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:3645
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:172
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:3896
canStatus canSetBusParamsC200(const CanHandle hnd, unsigned char btr0, unsigned char btr1)
int nMagiSyncGroups
number of MagiSync™ groups
Definition: canlib.h:3720
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:3643
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:3654
kvStatus kvTimeDomainAddHandle(kvTimeDomain domain, const CanHandle hnd)
Definition: canlib.h:3719
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:3653
canStatus canRequestChipStatus(const CanHandle hnd)
Definition: canlib.h:3642
kvStatus kvScriptLoadFileOnDevice(const CanHandle hnd, int slotNo, char *localFile)
canStatus canUnloadLibrary(void)
struct canNotifyData::@0::@1 busErr
canHandle CanHandle
Definition: canlib.h:153
canStatus kvStatus
Definition: canlib.h:3713
Definition: canlib.h:2807
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:3723
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:160
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:3721