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 
1368 unsigned short CANLIBAPI canGetVersion (void);
1369 
1399 canStatus CANLIBAPI canIoCtl (const CanHandle hnd,
1400  unsigned int func,
1401  void *buf,
1402  unsigned int buflen);
1403 
1404 
1433 canStatus CANLIBAPI canReadTimer (const CanHandle hnd, unsigned long *time);
1434 
1485 CanHandle CANLIBAPI canOpenChannel (int channel, int flags);
1486 
1507 canStatus CANLIBAPI canGetNumberOfChannels (int *channelCount);
1508 
1509 
1517 #define kvREMOTE_TYPE_NOT_REMOTE 0
1518 #define kvREMOTE_TYPE_WLAN 1
1519 #define kvREMOTE_TYPE_LAN 2
1520 
1529 #define kvLOGGER_TYPE_NOT_A_LOGGER 0
1530 #define kvLOGGER_TYPE_V1 1
1531 #define kvLOGGER_TYPE_V2 2
1532 
1564 canStatus CANLIBAPI canGetChannelData (int channel,
1565  int item,
1566  void *buffer,
1567  size_t bufsize);
1568 
1587 #define canCHANNELDATA_CHANNEL_CAP 1
1588 
1598 #define canCHANNELDATA_TRANS_CAP 2
1599 
1608 #define canCHANNELDATA_CHANNEL_FLAGS 3 // available, etc
1609 
1618 #define canCHANNELDATA_CARD_TYPE 4
1619 
1629 #define canCHANNELDATA_CARD_NUMBER 5
1630 
1638 #define canCHANNELDATA_CHAN_NO_ON_CARD 6
1639 
1649 #define canCHANNELDATA_CARD_SERIAL_NO 7
1650 
1660 #define canCHANNELDATA_TRANS_SERIAL_NO 8
1661 
1672 #define canCHANNELDATA_CARD_FIRMWARE_REV 9
1673 
1684 #define canCHANNELDATA_CARD_HARDWARE_REV 10
1685 
1695 #define canCHANNELDATA_CARD_UPC_NO 11
1696 
1707 #define canCHANNELDATA_TRANS_UPC_NO 12
1708 
1724 #define canCHANNELDATA_CHANNEL_NAME 13
1725 
1742 # define canCHANNELDATA_DLL_FILE_VERSION 14
1743 
1760 # define canCHANNELDATA_DLL_PRODUCT_VERSION 15
1761 
1777 # define canCHANNELDATA_DLL_FILETYPE 16
1778 
1787 # define canCHANNELDATA_TRANS_TYPE 17
1788 
1812 # define canCHANNELDATA_DEVICE_PHYSICAL_POSITION 18
1813 
1826 # define canCHANNELDATA_UI_NUMBER 19
1827 
1851 # define canCHANNELDATA_TIMESYNC_ENABLED 20
1852 
1868 # define canCHANNELDATA_DRIVER_FILE_VERSION 21
1869 
1885 # define canCHANNELDATA_DRIVER_PRODUCT_VERSION 22
1886 
1895 # define canCHANNELDATA_MFGNAME_UNICODE 23
1896 
1904 # define canCHANNELDATA_MFGNAME_ASCII 24
1905 
1914 # define canCHANNELDATA_DEVDESCR_UNICODE 25
1915 
1923 # define canCHANNELDATA_DEVDESCR_ASCII 26
1924 
1935 # define canCHANNELDATA_DRIVER_NAME 27
1936 
1949 # define canCHANNELDATA_CHANNEL_QUALITY 28
1950 
1959 # define canCHANNELDATA_ROUNDTRIP_TIME 29
1960 
1969 # define canCHANNELDATA_BUS_TYPE 30
1970 
1982 # define canCHANNELDATA_DEVNAME_ASCII 31
1983 
1994 # define canCHANNELDATA_TIME_SINCE_LAST_SEEN 32
1995 
2005 # define canCHANNELDATA_REMOTE_OPERATIONAL_MODE 33
2006 
2015 # define canCHANNELDATA_REMOTE_PROFILE_NAME 34
2016 
2025 # define canCHANNELDATA_REMOTE_HOST_NAME 35
2026 
2035 # define canCHANNELDATA_REMOTE_MAC 36
2036 
2045 # define canCHANNELDATA_MAX_BITRATE 37
2046 
2057 # define canCHANNELDATA_CHANNEL_CAP_MASK 38
2058 
2068 # define canCHANNELDATA_IS_REMOTE 40
2069 
2078 # define canCHANNELDATA_REMOTE_TYPE 41
2079 
2088 # define canCHANNELDATA_LOGGER_TYPE 42
2089 
2099 # define canCHANNELDATA_HW_STATUS 43
2100 
2110 # define canCHANNELDATA_FEATURE_EAN 44
2111 
2120 #define canCHANNELDATA_CUST_CHANNEL_NAME 39
2121 
2135 #define canCHANNEL_IS_EXCLUSIVE 0x0001
2136 
2138 #define canCHANNEL_IS_OPEN 0x0002
2139 
2143 #define canCHANNEL_IS_CANFD 0x0004
2144 
2145 //#define canCHANNEL_IS_CANFD_NON_ISO 0x0008 Reserved for when needed
2146 
2149 #define canCHANNEL_IS_LIN 0x0010
2150 
2152 #define canCHANNEL_IS_LIN_MASTER 0x0020
2153 
2155 #define canCHANNEL_IS_LIN_SLAVE 0x0040
2156 
2157 
2176 #define canHWTYPE_NONE 0
2177 #define canHWTYPE_VIRTUAL 1
2178 #define canHWTYPE_LAPCAN 2
2179 #define canHWTYPE_CANPARI 3
2180 #define canHWTYPE_PCCAN 8
2181 #define canHWTYPE_PCICAN 9
2182 #define canHWTYPE_USBCAN 11
2183 #define canHWTYPE_PCICAN_II 40
2184 #define canHWTYPE_USBCAN_II 42
2185 #define canHWTYPE_SIMULATED 44
2186 #define canHWTYPE_ACQUISITOR 46
2187 #define canHWTYPE_LEAF 48
2188 #define canHWTYPE_PC104_PLUS 50
2189 #define canHWTYPE_PCICANX_II 52
2190 #define canHWTYPE_MEMORATOR_II 54
2191 #define canHWTYPE_MEMORATOR_PRO 54
2192 #define canHWTYPE_USBCAN_PRO 56
2193 #define canHWTYPE_IRIS 58
2194 #define canHWTYPE_BLACKBIRD 58
2195 #define canHWTYPE_MEMORATOR_LIGHT 60
2196 #define canHWTYPE_MINIHYDRA 62
2197 #define canHWTYPE_EAGLE 62
2198 #define canHWTYPE_BAGEL 64
2199 #define canHWTYPE_BLACKBIRD_V2 64
2200 #define canHWTYPE_MINIPCIE 66
2201 #define canHWTYPE_USBCAN_KLINE 68
2202 #define canHWTYPE_ETHERCAN 70
2203 #define canHWTYPE_USBCAN_LIGHT 72
2204 #define canHWTYPE_USBCAN_PRO2 74
2205 #define canHWTYPE_PCIE_V2 76
2206 #define canHWTYPE_MEMORATOR_PRO2 78
2207 #define canHWTYPE_LEAF2 80
2208 #define canHWTYPE_MEMORATOR_V2 82
2209 #define canHWTYPE_CANLINHYBRID 84
2210 
2211 
2220 #define canCHANNEL_CAP_EXTENDED_CAN 0x00000001L
2221 #define canCHANNEL_CAP_BUS_STATISTICS 0x00000002L
2222 #define canCHANNEL_CAP_ERROR_COUNTERS 0x00000004L
2223 #define canCHANNEL_CAP_CAN_DIAGNOSTICS 0x00000008L
2224 #define canCHANNEL_CAP_GENERATE_ERROR 0x00000010L
2225 #define canCHANNEL_CAP_GENERATE_OVERLOAD 0x00000020L
2226 #define canCHANNEL_CAP_TXREQUEST 0x00000040L
2227 #define canCHANNEL_CAP_TXACKNOWLEDGE 0x00000080L
2228 #define canCHANNEL_CAP_VIRTUAL 0x00010000L
2229 #define canCHANNEL_CAP_SIMULATED 0x00020000L
2230 #define canCHANNEL_CAP_RESERVED_1 0x00040000L
2231 #define canCHANNEL_CAP_CAN_FD 0x00080000L
2232 #define canCHANNEL_CAP_CAN_FD_NONISO 0x00100000L
2233 #define canCHANNEL_CAP_SILENT_MODE 0x00200000L
2234 #define canCHANNEL_CAP_SINGLE_SHOT 0x00400000L
2235 #define canCHANNEL_CAP_LOGGER 0x00800000L
2236 #define canCHANNEL_CAP_REMOTE_ACCESS 0x01000000L
2237 #define canCHANNEL_CAP_SCRIPT 0x02000000L
2238 
2239 
2252 #define canCHANNEL_OPMODE_NONE 1
2253 
2257 #define canCHANNEL_OPMODE_INFRASTRUCTURE 2
2258 
2262 #define canCHANNEL_OPMODE_RESERVED 3
2263 
2267 #define canCHANNEL_OPMODE_ADHOC 4
2268 
2278 #define canDRIVER_CAP_HIGHSPEED 0x00000001L
2279 
2304 #define canIOCTL_PREFER_EXT 1
2305 
2318 #define canIOCTL_PREFER_STD 2
2319 
2335 #define canIOCTL_CLEAR_ERROR_COUNTERS 5
2336 
2347 #define canIOCTL_SET_TIMER_SCALE 6
2348 
2364 #define canIOCTL_SET_TXACK 7
2365 
2378 #define canIOCTL_GET_RX_BUFFER_LEVEL 8
2379 
2392 #define canIOCTL_GET_TX_BUFFER_LEVEL 9
2393 
2403 #define canIOCTL_FLUSH_RX_BUFFER 10
2404 
2414 #define canIOCTL_FLUSH_TX_BUFFER 11
2415 
2424 #define canIOCTL_GET_TIMER_SCALE 12
2425 
2437 #define canIOCTL_SET_TXRQ 13
2438 
2439 
2446 #define canIOCTL_SET_BYPASS_MODE 15
2447 
2453 #define canIOCTL_SET_WAKEUP 16
2454 
2464 # define canIOCTL_GET_DRIVERHANDLE 17
2465 
2471 # define canIOCTL_MAP_RXQUEUE 18
2472 
2478 # define canIOCTL_GET_WAKEUP 19
2479 
2491 # define canIOCTL_SET_REPORT_ACCESS_ERRORS 20
2492 
2500 # define canIOCTL_GET_REPORT_ACCESS_ERRORS 21
2501 
2511 # define canIOCTL_CONNECT_TO_VIRTUAL_BUS 22
2512 
2522 # define canIOCTL_DISCONNECT_FROM_VIRTUAL_BUS 23
2523 
2533 # define canIOCTL_SET_USER_IOPORT 24
2534 
2545 # define canIOCTL_GET_USER_IOPORT 25
2546 
2552 # define canIOCTL_SET_BUFFER_WRAPAROUND_MODE 26
2553 
2570 # define canIOCTL_SET_RX_QUEUE_SIZE 27
2571 
2577 # define canIOCTL_SET_USB_THROTTLE 28
2578 
2584 # define canIOCTL_GET_USB_THROTTLE 29
2585 
2598 # define canIOCTL_SET_BUSON_TIME_AUTO_RESET 30
2599 
2611 # define canIOCTL_GET_TXACK 31
2612 
2627 # define canIOCTL_SET_LOCAL_TXECHO 32
2628 
2629 
2630 
2644 # define canIOCTL_GET_TREF_LIST 39
2645 
2667 # define canIOCTL_TX_INTERVAL 40
2668 
2680 # define canIOCTL_SET_BRLIMIT 43
2681 
2688 # define canIOCTL_RESET_OVERRUN_COUNT 44
2689 
2696 # define canIOCTL_LIN_MODE 45
2697 
2700 typedef struct {
2701  unsigned int portNo;
2702  unsigned int portValue;
2704 
2705 
2746 canStatus CANLIBAPI canSetBusParamsC200 (const CanHandle hnd, unsigned char btr0, unsigned char btr1);
2747 
2748 
2749 
2785 canStatus CANLIBAPI canSetDriverMode (const CanHandle hnd, int lineMode, int resNet);
2786 
2823 canStatus CANLIBAPI canGetDriverMode (const CanHandle hnd, int *lineMode, int *resNet);
2824 
2825 
2845 canStatus CANLIBAPI canObjBufFreeAll (const CanHandle hnd);
2846 
2867 canStatus CANLIBAPI canObjBufAllocate (const CanHandle hnd, int type);
2868 
2877 #define canOBJBUF_TYPE_AUTO_RESPONSE 0x01
2878 #define canOBJBUF_TYPE_PERIODIC_TX 0x02
2879 
2901 canStatus CANLIBAPI canObjBufFree (const CanHandle hnd, int idx);
2902 
2903 // Writes CAN data to the object buffer with the specified index.
2904 
2930 canStatus CANLIBAPI canObjBufWrite (const CanHandle hnd,
2931  int idx,
2932  int id,
2933  void* msg,
2934  unsigned int dlc,
2935  unsigned int flags);
2936 
2963 canStatus CANLIBAPI canObjBufSetFilter (const CanHandle hnd,
2964  int idx,
2965  unsigned int code,
2966  unsigned int mask);
2967 
2988 canStatus CANLIBAPI canObjBufSetFlags (const CanHandle hnd,
2989  int idx,
2990  unsigned int flags);
2991 
3009 # define canOBJBUF_AUTO_RESPONSE_RTR_ONLY 0x01
3010 
3032 canStatus CANLIBAPI canObjBufSetPeriod (const CanHandle hnd,
3033  int idx,
3034  unsigned int period);
3035 
3056 canStatus CANLIBAPI canObjBufSetMsgCount (const CanHandle hnd,
3057  int idx,
3058  unsigned int count);
3059 
3079 canStatus CANLIBAPI canObjBufEnable (const CanHandle hnd, int idx);
3080 
3100 canStatus CANLIBAPI canObjBufDisable (const CanHandle hnd, int idx);
3101 
3125 canStatus CANLIBAPI canObjBufSendBurst (const CanHandle hnd,
3126  int idx,
3127  unsigned int burstlen);
3128 
3129 
3152 canStatus CANLIBAPI canResetBus (const CanHandle hnd);
3153 
3192 canStatus CANLIBAPI canWriteWait (const CanHandle hnd,
3193  long id,
3194  void *msg,
3195  unsigned int dlc,
3196  unsigned int flag,
3197  unsigned long timeout);
3198 
3199 
3225 canStatus CANLIBAPI canUnloadLibrary (void);
3226 
3286 canStatus CANLIBAPI canSetAcceptanceFilter (const CanHandle hnd,
3287  unsigned int code,
3288  unsigned int mask,
3289  int is_extended);
3313 canStatus CANLIBAPI canFlushReceiveQueue (const CanHandle hnd);
3314 
3339 canStatus CANLIBAPI canFlushTransmitQueue (const CanHandle hnd);
3340 
3341 
3350 #define kvLED_ACTION_ALL_LEDS_ON 0
3351 #define kvLED_ACTION_ALL_LEDS_OFF 1
3352 #define kvLED_ACTION_LED_0_ON 2
3353 #define kvLED_ACTION_LED_0_OFF 3
3354 #define kvLED_ACTION_LED_1_ON 4
3355 #define kvLED_ACTION_LED_1_OFF 5
3356 #define kvLED_ACTION_LED_2_ON 6
3357 #define kvLED_ACTION_LED_2_OFF 7
3358 #define kvLED_ACTION_LED_3_ON 8
3359 #define kvLED_ACTION_LED_3_OFF 9
3360 #define kvLED_ACTION_LED_4_ON 10
3361 #define kvLED_ACTION_LED_4_OFF 11
3362 #define kvLED_ACTION_LED_5_ON 12
3363 #define kvLED_ACTION_LED_5_OFF 13
3364 #define kvLED_ACTION_LED_6_ON 14
3365 #define kvLED_ACTION_LED_6_OFF 15
3366 #define kvLED_ACTION_LED_7_ON 16
3367 #define kvLED_ACTION_LED_7_OFF 17
3368 #define kvLED_ACTION_LED_8_ON 18
3369 #define kvLED_ACTION_LED_8_OFF 19
3370 #define kvLED_ACTION_LED_9_ON 20
3371 #define kvLED_ACTION_LED_9_OFF 21
3372 #define kvLED_ACTION_LED_10_ON 22
3373 #define kvLED_ACTION_LED_10_OFF 23
3374 #define kvLED_ACTION_LED_11_ON 24
3375 #define kvLED_ACTION_LED_11_OFF 25
3376 
3377 
3400 canStatus CANLIBAPI kvFlashLeds (const CanHandle hnd, int action, int timeout);
3401 
3421 canStatus CANLIBAPI canRequestChipStatus (const CanHandle hnd);
3422 
3449 canStatus CANLIBAPI canRequestBusStatistics (const CanHandle hnd);
3450 
3456 typedef struct canBusStatistics_s {
3457  unsigned long stdData;
3458  unsigned long stdRemote;
3459  unsigned long extData;
3460  unsigned long extRemote;
3461  unsigned long errFrame;
3462 
3467  unsigned long busLoad;
3468  unsigned long overruns;
3470 
3493 canStatus CANLIBAPI canGetBusStatistics (const CanHandle hnd,
3494  canBusStatistics *stat,
3495  size_t bufsiz);
3496 
3497 
3518 canStatus CANLIBAPI canGetHandleData (const CanHandle hnd,
3519  int item,
3520  void *buffer,
3521  size_t bufsize);
3522 
3524 typedef void *kvTimeDomain;
3525 
3528 
3533 typedef struct kvTimeDomainData_s {
3539 
3568 kvStatus CANLIBAPI kvTimeDomainCreate (kvTimeDomain *domain);
3569 
3592 kvStatus CANLIBAPI kvTimeDomainDelete (kvTimeDomain domain);
3593 
3619 kvStatus CANLIBAPI kvTimeDomainResetTime (kvTimeDomain domain);
3620 
3645 kvStatus CANLIBAPI kvTimeDomainGetData (kvTimeDomain domain,
3646  kvTimeDomainData *data,
3647  size_t bufsiz);
3648 
3671 kvStatus CANLIBAPI kvTimeDomainAddHandle(kvTimeDomain domain,
3672  const CanHandle hnd);
3673 
3695 kvStatus CANLIBAPI kvTimeDomainRemoveHandle (kvTimeDomain domain,
3696  const CanHandle hnd);
3697 
3710 typedef void (CANLIBAPI *kvCallback_t) (CanHandle hnd, void* context, unsigned int notifyEvent);
3711 
3745 kvStatus CANLIBAPI kvSetNotifyCallback (const CanHandle hnd,
3746  kvCallback_t callback,
3747  void* context,
3748  unsigned int notifyFlags);
3749 
3763 #define kvBUSTYPE_NONE 0
3764 
3769 #define kvBUSTYPE_PCI 1
3770 
3775 #define kvBUSTYPE_PCMCIA 2
3776 
3781 #define kvBUSTYPE_USB 3
3782 
3787 #define kvBUSTYPE_WLAN 4
3788 
3793 #define kvBUSTYPE_PCI_EXPRESS 5
3794 
3799 #define kvBUSTYPE_ISA 6
3800 
3805 #define kvBUSTYPE_VIRTUAL 7
3806 
3811 #define kvBUSTYPE_PC104_PLUS 8
3812 
3817 #define kvBUSTYPE_LAN 9
3818 
3834 #define kvBUSTYPE_GROUP_VIRTUAL 1
3835 
3840 #define kvBUSTYPE_GROUP_LOCAL 2
3841 
3846 #define kvBUSTYPE_GROUP_REMOTE 3
3847 
3851 #define kvBUSTYPE_GROUP_INTERNAL 4
3852 
3906 kvStatus CANLIBAPI kvGetSupportedInterfaceInfo (int index,
3907  char *hwName,
3908  size_t nameLen,
3909  int *hwType,
3910  int *hwBusType);
3911 
3936 kvStatus CANLIBAPI kvReadDeviceCustomerData (const CanHandle hnd,
3937  int userNumber,
3938  int itemNumber,
3939  void *data,
3940  size_t bufsiz);
3941 
3955 #define kvENVVAR_TYPE_INT 1
3956 
3962 #define kvENVVAR_TYPE_FLOAT 2
3963 
3969 #define kvENVVAR_TYPE_STRING 3
3970 
3986 #define kvEVENT_TYPE_KEY 1
3987 
3995  typedef int64_t kvEnvHandle;
3996 
4016 kvStatus CANLIBAPI kvScriptStart (const CanHandle hnd, int slotNo);
4017 
4024 #define kvSCRIPT_STOP_NORMAL 0
4025 #define kvSCRIPT_STOP_FORCED -9
4049 kvStatus CANLIBAPI kvScriptStop (const CanHandle hnd, int slotNo, int mode);
4050 
4069 kvStatus CANLIBAPI kvScriptUnload (const CanHandle hnd, int slotNo);
4070 
4095 kvStatus CANLIBAPI kvScriptSendEvent (const CanHandle hnd,
4096  int slotNo,
4097  int eventType,
4098  int eventNo,
4099  unsigned int data);
4100 
4127 kvEnvHandle CANLIBAPI kvScriptEnvvarOpen (const CanHandle hnd,
4128  char* envvarName,
4129  int *envvarType,
4130  int *envvarSize); // returns scriptHandle
4131 
4151 kvStatus CANLIBAPI kvScriptEnvvarClose (kvEnvHandle eHnd);
4152 
4175 kvStatus CANLIBAPI kvScriptEnvvarSetInt (kvEnvHandle eHnd, int val);
4176 
4200 kvStatus CANLIBAPI kvScriptEnvvarGetInt (kvEnvHandle eHnd, int *val);
4201 
4224 kvStatus CANLIBAPI kvScriptEnvvarSetFloat (kvEnvHandle eHnd, float val);
4225 
4249 kvStatus CANLIBAPI kvScriptEnvvarGetFloat (kvEnvHandle eHnd, float *val);
4250 
4277 kvStatus CANLIBAPI kvScriptEnvvarSetData (kvEnvHandle eHnd,
4278  void *buf,
4279  int start_index,
4280  int data_len);
4281 
4307 kvStatus CANLIBAPI kvScriptEnvvarGetData (kvEnvHandle eHnd,
4308  void *buf,
4309  int start_index,
4310  int data_len);
4311 
4337 kvStatus CANLIBAPI kvScriptLoadFileOnDevice (const CanHandle hnd,
4338  int slotNo,
4339  char *localFile);
4340 
4364 kvStatus CANLIBAPI kvScriptLoadFile (const CanHandle hnd,
4365  int slotNo,
4366  char *filePathOnPC);
4367 
4368 
4369 
4376 #define kvSCRIPT_STATUS_LOADED 1
4377 #define kvSCRIPT_STATUS_RUNNING 2
4399 kvStatus CANLIBAPI kvScriptStatus(const CanHandle hnd,
4400  int slot,
4401  unsigned int *status);
4402 
4403 
4420 kvStatus CANLIBAPI kvScriptGetMaxEnvvarSize(int hnd, int *envvarSize);
4421 
4422 
4445 kvStatus CANLIBAPI kvFileCopyToDevice (const CanHandle hnd,
4446  char *hostFileName,
4447  char *deviceFileName);
4448 
4471 kvStatus CANLIBAPI kvFileCopyFromDevice (const CanHandle hnd,
4472  char *deviceFileName,
4473  char *hostFileName);
4474 
4496 kvStatus CANLIBAPI kvFileDelete (const CanHandle hnd, char *deviceFileName);
4497 
4520 kvStatus CANLIBAPI kvFileGetName (const CanHandle hnd,
4521  int fileNo,
4522  char *name,
4523  int namelen);
4524 
4544 kvStatus CANLIBAPI kvFileGetCount (const CanHandle hnd, int *count);
4545 
4568 kvStatus CANLIBAPI kvFileGetSystemData (const CanHandle hnd,
4569  int itemCode,
4570  int *result);
4571 
4589 #define kvDEVICE_MODE_INTERFACE 0x00
4590 
4595 #define kvDEVICE_MODE_LOGGER 0x01
4596 
4621 kvStatus CANLIBAPI kvDeviceSetMode (const CanHandle hnd, int mode);
4622 
4645 kvStatus CANLIBAPI kvDeviceGetMode (const CanHandle hnd, int *result);
4646 
4647 
4672 kvStatus CANLIBAPI kvReadTimer (const CanHandle hnd, unsigned int *time);
4696 kvStatus CANLIBAPI kvReadTimer64 (const CanHandle hnd, uint64_t *time);
4697 
4698 #ifdef __cplusplus
4699 }
4700 #endif /* __cplusplus */
4701 
4702 #include "obsolete.h"
4703 
4704 
4705 
4706 #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:3458
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:2701
int64_t kvEnvHandle
Definition: canlib.h:3995
int nNonMagiSyncCards
number of non MagiSync™ interfaces
Definition: canlib.h:3536
kvStatus kvScriptEnvvarSetData(kvEnvHandle eHnd, void *buf, int start_index, int data_len)
canStatus canRequestBusStatistics(const CanHandle hnd)
kvStatus kvDeviceSetMode(const CanHandle hnd, int mode)
canStatus canReadTimer(const CanHandle hnd, unsigned long *time)
void * kvTimeDomain
Definition: canlib.h:3524
unsigned char rxErrorCounter
Definition: canlib.h:163
unsigned long extRemote
Number of received extended (29-bit identifiers) remote frames.
Definition: canlib.h:3460
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)
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:2702
unsigned short canGetVersion(void)
unsigned long errFrame
Number of error frames.
Definition: canlib.h:3461
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:3459
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:3710
canStatus canSetBusParamsC200(const CanHandle hnd, unsigned char btr0, unsigned char btr1)
int nMagiSyncGroups
number of MagiSync™ groups
Definition: canlib.h:3534
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:3457
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:3468
kvStatus kvTimeDomainAddHandle(kvTimeDomain domain, const CanHandle hnd)
Definition: canlib.h:3533
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:3467
canStatus canRequestChipStatus(const CanHandle hnd)
Definition: canlib.h:3456
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:3527
Definition: canlib.h:2700
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:3537
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:3535