source: pacpussensors/trunk/CanGateway/driver/kvaser/windows/canlib.h@ 107

Last change on this file since 107 was 93, checked in by DHERBOMEZ Gérald, 9 years ago

move files in windows folder

File size: 200.8 KB
Line 
1/**
2 * \section LICENSE
3 * Copyright 1994-2015 by KVASER AB, SWEDEN
4 *
5 * WWW: http://www.kvaser.com
6 *
7 * This software is furnished under a license and may be used and copied
8 * only in accordance with the terms of such license.
9 *
10 * \section DESCRIPTION
11 *
12 * Definitions for the CANLIB API.
13 *
14 * \file canlib.h
15 * \author Kvaser AB
16 *
17 * \note MATLAB users on Windows: if you define WIN32_LEAN_AND_MEAN before
18 * including this file, you will see a lot less warnings.
19 *
20 * \defgroup General General
21 * \defgroup CAN CAN
22 * \defgroup ObjectBuffers Object buffers
23 * \win_start
24 * \defgroup TimeDomainHandling Time Domain Handling
25 * \defgroup NamedParameterSettings Named Parameter Settings
26 * \defgroup tScript t-script
27 * \win_end
28 */
29
30#ifndef _CANLIB_H_
31#define _CANLIB_H_
32
33#include <stdlib.h>
34
35# include <windows.h>
36# include "predef.h"
37# include "canevt.h"
38# define CANLIB_DECLARE_ALL
39#include "canstat.h"
40
41/** Handle to an opened circuit. */
42typedef int canHandle;
43/** Handle to an opened circuit, created with \ref canOpenChannel(). */
44# define CanHandle int
45/** Denotes an invalid circuit handle. */
46# define canINVALID_HANDLE (-1)
47
48/** Notify message sent to the application window */
49# define WM__CANLIB (WM_USER+16354)
50
51/**
52 * \name canOPEN_xxx
53 * \anchor canOPEN_xxx
54 *
55 * These defines are used in \ref canOpenChannel().
56 *
57 * @{
58 */
59
60
61/**
62 * Don't allow sharing of this circuit between applications.
63 *
64 * This define is used in \ref canOpenChannel()
65 */
66#define canOPEN_EXCLUSIVE 0x0008
67
68/**
69 * This flag causes two things to happen:
70 *
71 * \li The call will fail if the specified circuit doesn't allow extended CAN
72 * (CAN 2.0B).
73 *
74 * \li If no frame-type flag is specified in a call to \ref canWrite, it is assumed
75 * that extended CAN should be used.
76 *
77 * This define is used in \ref canOpenChannel().
78 */
79#define canOPEN_REQUIRE_EXTENDED 0x0010
80
81/**
82 * Allow opening of virtual channels as well as physical channels.
83 *
84 * This define is used in \ref canOpenChannel().
85 *
86 * \sa \ref page_user_guide_virtual_info
87 */
88# define canOPEN_ACCEPT_VIRTUAL 0x0020
89
90/**
91 * Open the channel even if it is opened for exclusive
92 * access already.
93 *
94 * \warning Use this flag with caution.
95 *
96 * This define is used in \ref canOpenChannel().
97 */
98# define canOPEN_OVERRIDE_EXCLUSIVE 0x0040
99
100/**
101 * Fail the call if the channel cannot be opened with init access.
102 *
103 * Init access means that the thread that owns the handle can set bit rate and
104 * CAN driver mode. Init access is the default. At most one thread can have
105 * init access to any given channel. If you try to set the bit rate or CAN
106 * driver mode for a handle to which you don't have init access, the call will
107 * silently fail (i.e. \ref canOK is returned although the call had no effect),
108 * unless you enable "access error reporting" by calling \ref canIoCtl(). Access
109 * error reporting is by default off.
110 *
111 * This define is used in \ref canOpenChannel().
112 *
113 * \sa \ref canOPEN_NO_INIT_ACCESS
114 */
115# define canOPEN_REQUIRE_INIT_ACCESS 0x0080
116
117/**
118 * Don't open the handle with init access.
119 *
120 * This define is used in \ref canOpenChannel().
121 *
122 * \sa \ref canOPEN_REQUIRE_INIT_ACCESS
123 */
124# define canOPEN_NO_INIT_ACCESS 0x0100
125
126/**
127 * The channel will accept messages with DLC (Data Length Code) greater than
128 * 8. If this flag is not used, a message with DLC > 8 will always be
129 * reported or transmitted as a message with DLC = 8. If the
130 * \ref canOPEN_ACCEPT_LARGE_DLC flag is used, the message will be sent and/or
131 * received with the true DLC, which can be at most 15.
132 *
133 * \note The length of the message is always at most 8.
134 *
135 * This define is used in \ref canOpenChannel().
136 */
137# define canOPEN_ACCEPT_LARGE_DLC 0x0200 // DLC can be greater than 8
138
139/**
140 * The channel will use the CAN FD protocol.
141 *
142 * This define is used in \ref canOpenChannel().
143 */
144# define canOPEN_CAN_FD 0x0400
145
146/**
147 * The channel will use the CAN FD NON-ISO protocol.
148 *
149 * This define is used in \ref canOpenChannel().
150 */
151# define canOPEN_CAN_FD_NONISO 0x0800
152/** @} */
153
154/**
155 * \ingroup CAN
156 * \name canFILTER_xxx
157 * \anchor canFILTER_xxx
158 *
159 * Flags for \ref canAccept().
160 *
161 * @{
162 */
163#define canFILTER_ACCEPT 1
164#define canFILTER_REJECT 2
165/** Sets the code for standard (11-bit) identifiers. */
166#define canFILTER_SET_CODE_STD 3
167/** Sets the mask for standard (11-bit) identifiers. */
168#define canFILTER_SET_MASK_STD 4
169/** Sets the code for extended (29-bit) identifiers. */
170#define canFILTER_SET_CODE_EXT 5
171/** Sets the mask for extended (29-bit) identifiers. */
172#define canFILTER_SET_MASK_EXT 6
173
174#define canFILTER_NULL_MASK 0L
175/** @} */
176
177
178/**
179 * \ingroup CAN
180 * \name canDRIVER_xxx
181 * \anchor canDRIVER_xxx
182 *
183 * CAN driver types - not all are supported on all cards.
184 *
185 * @{
186 */
187
188/**
189 * The "normal" driver type (push-pull). This is the default.
190 */
191#define canDRIVER_NORMAL 4
192
193/**
194 * Sets the CAN controller in Silent Mode; that is, it doesn't send anything,
195 * not even ACK bits, on the bus. Reception works as usual.
196 *
197 * \note The values 2,3,5,6,7 are reserved values for compatibility reasons.
198 */
199#define canDRIVER_SILENT 1
200
201/**
202 * Self-reception. Not implemented.
203 */
204#define canDRIVER_SELFRECEPTION 8
205
206/**
207 * The driver is turned off. Not implemented in all types of hardware.
208 */
209#define canDRIVER_OFF 0
210
211/** @} */
212
213
214/**
215 * \ingroup CAN
216 * \anchor BAUD_xxx
217 * \anchor canBITRATE_xxx
218 * \name canBITRATE_xxx
219 *
220 * Common bus speeds. Used in \ref canSetBusParams() and \ref canSetBusParamsC200().
221 * The values are translated in canlib, \ref canTranslateBaud().
222 *
223 * \note The \ref BAUD_xxx names are only retained for compability.
224 *
225 * \sa \ref page_user_guide_misc_bitrate
226 *
227 * @{
228 */
229
230
231/** Used in \ref canSetBusParams() and \ref canSetBusParamsC200(). Indicate a bitrate of 1 Mbit/s. */
232#define canBITRATE_1M (-1)
233/** Used in \ref canSetBusParams() and \ref canSetBusParamsC200(). Indicate a bitrate of 500 kbit/s. */
234#define canBITRATE_500K (-2)
235/** Used in \ref canSetBusParams() and \ref canSetBusParamsC200(). Indicate a bitrate of 250 kbit/s. */
236#define canBITRATE_250K (-3)
237/** Used in \ref canSetBusParams() and \ref canSetBusParamsC200(). Indicate a bitrate of 125 kbit/s. */
238#define canBITRATE_125K (-4)
239/** Used in \ref canSetBusParams() and \ref canSetBusParamsC200(). Indicate a bitrate of 100 kbit/s. */
240#define canBITRATE_100K (-5)
241/** Used in \ref canSetBusParams() and \ref canSetBusParamsC200(). Indicate a bitrate of 62 kbit/s. */
242#define canBITRATE_62K (-6)
243/** Used in \ref canSetBusParams() and \ref canSetBusParamsC200(). Indicate a bitrate of 50 kbit/s. */
244#define canBITRATE_50K (-7)
245/** Used in \ref canSetBusParams() and \ref canSetBusParamsC200(). Indicate a bitrate of 83 kbit/s. */
246#define canBITRATE_83K (-8)
247/** Used in \ref canSetBusParams() and \ref canSetBusParamsC200(). Indicate a bitrate of 10 kbit/s. */
248#define canBITRATE_10K (-9)
249
250// CAN FD Bit Rates
251/** Used in \ref canSetBusParamsFd(). Indicates a bitrate of 0.5 Mbit/s and sampling point at 80%. */
252#define canFD_BITRATE_500K_80P (-1001)
253/** Used in \ref canSetBusParamsFd(). Indicates a bitrate of 1.0 Mbit/s and sampling point at 80%. */
254#define canFD_BITRATE_1M_80P (-1002)
255/** Used in \ref canSetBusParamsFd(). Indicates a bitrate of 2.0 Mbit/s and sampling point at 80%. */
256#define canFD_BITRATE_2M_80P (-1003)
257
258/** The \ref BAUD_xxx names are deprecated, use \ref canBITRATE_1M instead. */
259#define BAUD_1M (-1)
260/** The \ref BAUD_xxx names are deprecated, use \ref canBITRATE_500K instead. */
261#define BAUD_500K (-2)
262/** The \ref BAUD_xxx names are deprecated, use \ref canBITRATE_250K instead. */
263#define BAUD_250K (-3)
264/** The \ref BAUD_xxx names are deprecated, use \ref canBITRATE_125K instead. */
265#define BAUD_125K (-4)
266/** The \ref BAUD_xxx names are deprecated, use \ref canBITRATE_100K instead. */
267#define BAUD_100K (-5)
268/** The \ref BAUD_xxx names are deprecated, use \ref canBITRATE_62K instead. */
269#define BAUD_62K (-6)
270/** The \ref BAUD_xxx names are deprecated, use \ref canBITRATE_50K instead. */
271#define BAUD_50K (-7)
272/** The \ref BAUD_xxx names are deprecated, use \ref canBITRATE_83K instead. */
273#define BAUD_83K (-8)
274/** @} */
275
276
277//
278// Define CANLIBAPI unless it's done already.
279// (canlib.c provides its own definitions of CANLIBAPI, DLLIMPORT
280// and DLLEXPORT before including this file.)
281//
282#ifndef CANLIBAPI
283# define CANLIBAPI __stdcall
284# define DLLIMPORT __declspec(dllimport)
285# define DLLEXPORT __declspec(dllexport)
286#endif
287
288
289#ifdef __cplusplus
290extern "C" {
291#endif
292
293/**
294 * \ingroup General
295 *
296 * \source_cs <b>static void canInitializeLibrary(void);</b>
297 *
298 * \source_delphi <b>procedure canInitializeLibrary; </b>
299 * \source_end
300 * This function must be called before any other functions is used. It will
301 * initialize the driver.
302 *
303 * You may call \ref canInitializeLibrary() more than once. The actual
304 * initialization will take place only once.
305 *
306 * Any errors encountered during library initialization will be "silent" and an
307 * appropriate \ref canERR_xxx error code will be returned later on when
308 * \ref canOpenChannel() (or any other API call that requires initialization) is
309 * called.
310 *
311 * \note This call replaces the \ref canLocateHardware() API call and serves the
312 * same purpose.
313 *
314 * \sa \ref page_code_snippets_examples
315 *
316 */
317void CANLIBAPI canInitializeLibrary (void);
318
319/**
320 * \ingroup CAN
321 *
322 * \source_cs <b>static Canlib.canStatus canClose(int handle);</b>
323 *
324 * \source_delphi <b>function canClose(handle: canHandle): canStatus;</b>
325 * \source_end
326 *
327 * Closes the channel associated with the handle. If no other threads
328 * are using the CAN circuit, it is taken off bus. The handle can not be
329 * used for further references to the channel, so any variable containing
330 * it should be zeroed.
331 *
332 * \ref canClose() will almost always return \ref canOK; the specified handle is closed
333 * on an best-effort basis.
334 *
335 * \param[in] hnd An open handle to a CAN channel.
336 *
337 * \return \ref canOK (zero) if success
338 * \return \ref canERR_xxx (negative) if failure
339 *
340 * \sa \ref page_code_snippets_examples
341 * \sa \ref canOpenChannel(), \ref canBusOn(), \ref canBusOff()
342 */
343canStatus CANLIBAPI canClose (const CanHandle hnd);
344
345/**
346 * \ingroup CAN
347 *
348 * \source_cs <b>static Canlib.canStatus canBusOn(int handle);</b>
349 *
350 * \source_delphi <b>function canBusOn(handle: canHandle): canStatus; </b>
351 * \source_end
352 *
353 * Takes the specified channel on-bus.
354 *
355 * If you are using multiple handles to the same physical channel, for example
356 * if you are writing a threaded application, you must call \ref canBusOn() once for
357 * each handle. The same applies to \ref canBusOff() - the physical channel will not
358 * go off bus until the last handle to the channel goes off bus.
359 *
360 * \param[in] hnd An open handle to a CAN channel.
361 *
362 * \return \ref canOK (zero) if success
363 * \return \ref canERR_xxx (negative) if failure
364 *
365 * \sa \ref page_code_snippets_examples
366 * \sa \ref canBusOff(), \ref canResetBus()
367 *
368 */
369canStatus CANLIBAPI canBusOn (const CanHandle hnd);
370
371/**
372 * \ingroup CAN
373 *
374 * \source_cs <b>static Canlib.canStatus canBusOff(int handle);</b>
375 *
376 * \source_delphi <b>function canBusOff(handle: canHandle): canStatus; </b>
377 * \source_end
378 *
379 * Takes the specified channel off-bus.
380 *
381 * \param[in] hnd An open handle to a CAN channel.
382 *
383 * \return \ref canOK (zero) if success
384 * \return \ref canERR_xxx (negative) if failure
385 *
386 * \sa \ref page_code_snippets_examples
387 * \sa \ref canBusOn(), \ref canResetBus()
388 *
389 */
390canStatus CANLIBAPI canBusOff (const CanHandle hnd);
391
392/**
393 * \ingroup CAN
394 *
395 * \source_cs <b>static Canlib.canStatus canSetBusParams(int handle, int freq, int tseg1, int tseg2, int sjw, int noSamp, int syncmode); </b>
396 *
397 * \source_delphi <b>function canSetBusParams(handle: canHandle; freq: Longint; tseg1, tseg2, sjw, noSamp, syncmode: Cardinal): canStatus; </b>
398 * \source_end
399 *
400 * This function sets the bus timing parameters for the specified CAN controller.
401 *
402 * The library provides default values for \a tseg1, \a tseg2, \a sjw and \a
403 * noSamp when \a freq is specified to one of the
404 * pre-defined constants, \ref canBITRATE_xxx.
405 *
406 * If \a freq is any other value, no default values are supplied by the
407 * library.
408 *
409 * If you are using multiple handles to the same physical channel, for example
410 * if you are writing a threaded application, you must call \ref canBusOff() once
411 * for each handle. The same applies to \ref canBusOn() - the physical channel will
412 * not go off bus until the last handle to the channel goes off bus.
413 *
414 * \note Use \ref canSetBusParamsC200() to set the bus timing parameters in the
415 * ubiquitous 82c200 bit-timing register format.
416 *
417 * \param[in] hnd An open handle to a CAN controller.
418 * \param[in] freq Bit rate (measured in bits per second); or one of the
419 * predefined constants \ref canBITRATE_xxx, which are described below.
420 * \param[in] tseg1 Time segment 1, that is, the number of quanta from (but not
421 * including) the Sync Segment to the sampling point.
422 * \param[in] tseg2 Time segment 2, that is, the number of quanta from the sampling
423 * point to the end of the bit.
424 * \param[in] sjw The Synchronization Jump Width; can be 1,2,3, or 4.
425 * \param[in] noSamp The number of sampling points; can be 1 or 3.
426 * \param[in] syncmode Unsupported and ignored.
427 *
428 * \return \ref canOK (zero) if success
429 * \return \ref canERR_xxx (negative) if failure
430 *
431 * \sa \ref page_code_snippets_bit_rate, \ref page_user_guide_misc_bitrate,
432 * \ref page_user_guide_init_bit_rate, \ref page_code_snippets_examples
433 * \sa \ref canSetBusParamsC200(), \ref canGetBusParams()
434 *
435 */
436canStatus CANLIBAPI canSetBusParams (const CanHandle hnd,
437 long freq,
438 unsigned int tseg1,
439 unsigned int tseg2,
440 unsigned int sjw,
441 unsigned int noSamp,
442 unsigned int syncmode);
443
444/**
445 * \ingroup CAN
446 *
447 * \source_cs <b>static Canlib.canStatus canSetBusParamsFd(int hnd, int freq_brs, int tseg1_brs, int tseg2_brs, int sjw_brs);</b>
448 *
449 * \source_delphi <b>function canSetBusParamsFd(hnd: canHandle; freq_brs: Longint; tseg1_brs, tseg2_brs, sjw_brs): canStatus;</b>
450 * \source_end
451 *
452 * This function sets the bus timing parameters for the specified
453 * CAN FD controller.
454 *
455 * The library provides default values for \a tseg1_brs, \a tseg2_brs,
456 * \a sjw_brs and \a freq_brs is specified to one of the pre-defined
457 * constants, \ref canBITRATE_xxx.
458 *
459 * If \a freq_brs is any other value, no default values are supplied
460 * by the library.
461 *
462 * \param[in] hnd An open handle to a CAN controller.
463 * \param[in] freq_brs Bit rate (measured in bits per second); or one of the
464 * predefined constants \ref canBITRATE_xxx, which are described below.
465 * \param[in] tseg1_brs Time segment 1, that is, the number of quanta from (but not
466 * including) the Sync Segment to the sampling point.
467 * \param[in] tseg2_brs Time segment 2, that is, the number of quanta from the sampling
468 * point to the end of the bit.
469 * \param[in] sjw_brs The Synchronization Jump Width; can be 1,2,3, or 4.
470 *
471 * \return \ref canOK (zero) if success
472 * \return \ref canERR_xxx (negative) if failure
473 */
474canStatus CANLIBAPI canSetBusParamsFd(const CanHandle hnd,
475 long freq_brs,
476 unsigned int tseg1_brs,
477 unsigned int tseg2_brs,
478 unsigned int sjw_brs);
479
480/**
481 * \ingroup CAN
482 * \name canFD_SSP_xxx
483 * \anchor canFD_SSP_xxx
484 *
485 * Flags for \ref canFdSecondarySamplePoint().
486 *
487 * @{
488 */
489/** Secondary sample point is automatically adjusted dynamically. */
490#define canFD_SSP_AUTO 0
491/** Set secondary sample point. */
492#define canFD_SSP_SET 1
493/** Get secondary sample point. */
494#define canFD_SSP_GET 2
495/** @} */
496
497/**
498 * \ingroup CAN
499 *
500 * \source_cs <b>static Canlib.canStatus canFdSecondarySamplePoint(int hnd, ref int ns, int mode);</b>
501 *
502 * \source_delphi <b>function canFdSecondarySamplePoint(hnd: canHandle; var ns: Cardinal; mode: Cardinal): canStatus;</b>
503 * \source_end
504 *
505 * This function sets or retrieves the secondary sampling point for
506 * the specified CAN FD controller.
507 *
508 * If \a mode is canFD_SSP_AUTO, the \a ns argument is ignored, and
509 * the secondary sampling point is automatically adjusted dynamically.
510 * If \a mode is canFD_SSP_SET, the secondary sampling point is set to
511 * \a ns, and if \a mode is canFD_SSP_GET, it is retrived and stored
512 * in \a ns.
513 *
514 * \param[in] hnd An open handle to a CAN controller.
515 * \param[in,out] ns Secondary sampling point delay, in nanoseconds.
516 * \param[in] mode One of canFD_SSP_AUTO, canFD_SSP_GET, or
517 * canFD_SSP_SET.
518 *
519 * \return \ref canOK (zero) if success
520 * \return \ref canERR_xxx (negative) if failure
521 */
522canStatus CANLIBAPI canFdSecondarySamplePoint(const CanHandle hnd,
523 unsigned int *ns,
524 int mode);
525
526/**
527 * \ingroup CAN
528 *
529 * \source_cs <b>static Canlib.canStatus canGetBusParams(int handle, out long freq, out int tseg1, out int tseg2, out int sjw, out int noSamp, out int syncmode);</b>
530 *
531 * \source_delphi <b>function canGetBusParams(handle: canHandle; var freq: Longint; var tseg1, tseg2, sjw, noSamp, syncmode: Cardinal): canStatus; </b>
532 * \source_end
533 *
534 * This function retrieves the current bus parameters for the specified
535 * channel.
536 *
537 * The anatomy of a CAN bit is discussed in detail at Kvaser's
538 * web site at <a href="http://www.kvaser.com">www.kvaser.com</a>.
539 *
540 * \param[in] hnd An open handle to a CAN controller.
541 * \param[out] freq Bit rate (bits per second).
542 * \param[out] tseg1 Time segment 1, that is, the number of quanta from (but not
543 * including) the Sync Segment to the sampling point.
544 * \param[out] tseg2 Time segment 2, that is, the number of quanta from the sampling
545 * point to the end of the bit.
546 * \param[out] sjw The Synchronization Jump Width; can be 1,2,3, or 4.
547 * \param[out] noSamp The number of sampling points; can be 1 or 3.
548 * \param[out] syncmode Unsupported, always read as zero.
549 *
550 * \return \ref canOK (zero) if success
551 * \return \ref canERR_xxx (negative) if failure
552 *
553 * \sa \ref page_code_snippets_bit_rate, \ref page_user_guide_init_bit_rate
554 * \sa \ref canSetBusParams(), \ref canSetBusParamsC200()
555 *
556 */
557canStatus CANLIBAPI canGetBusParams (const CanHandle hnd,
558 long *freq,
559 unsigned int *tseg1,
560 unsigned int *tseg2,
561 unsigned int *sjw,
562 unsigned int *noSamp,
563 unsigned int *syncmode);
564
565
566/**
567 * \ingroup CAN
568 *
569 * \source_cs <b>static Canlib.canStatus canGetBusParamsFd(int hnd, out long freq_brs, out int tseg1_brs, out int tseg2_brs, out int sjw_brs);</b>
570 *
571 * \source_delphi <b>function canGetBusParamsFd(hnd: canHandle; var freq_brs: Longint; var tseg1_brs, tseg2_brs, sjw_brs): canStatus;</b>
572 * \source_end
573 *
574 * This function retrieves the current bus parameters for the specified
575 * CAN FD channel.
576 *
577 * \param[in] hnd An open handle to a CAN FD controller.
578 * \param[out] freq_brs Bit rate (bits per second).
579 * \param[out] tseg1_brs Time segment 1, that is, the number of quanta from (but not
580 * including) the Sync Segment to the sampling point.
581 * \param[out] tseg2_brs Time segment 2, that is, the number of quanta from the sampling
582 * point to the end of the bit.
583 * \param[out] sjw_brs The Synchronization Jump Width; can be 1,2,3, or 4.
584 *
585 * \return \ref canOK (zero) if success
586 * \return \ref canERR_xxx (negative) if failure
587 */
588canStatus CANLIBAPI canGetBusParamsFd(const CanHandle hnd,
589 long *freq_brs,
590 unsigned int *tseg1_brs,
591 unsigned int *tseg2_brs,
592 unsigned int *sjw_brs);
593/**
594 * \ingroup CAN
595 *
596 * \source_cs <b>static Canlib.canStatus canSetBusOutputControl(int handle, int drivertype);</b>
597 *
598 * \source_delphi <b>function canSetBusOutputControl(handle: canHandle; drivertype: Cardinal): canStatus; </b>
599 * \source_end
600 *
601 * This function sets the driver type for a CAN controller. This corresponds
602 * loosely to the bus output control register in the CAN controller, hence the
603 * name of this function. CANLIB does not allow for direct manipulation of the
604 * bus output control register; instead, symbolic constants are used to select
605 * the desired driver type.
606 *
607 * \note Not all CAN driver types are supported on all cards.
608 *
609 * \param[in] hnd A handle to an open circuit.
610 * \param[out] drivertype Can driver type, \ref canDRIVER_xxx)
611 *
612 * \return \ref canOK (zero) if success
613 * \return \ref canERR_xxx (negative) if failure
614 *
615 * \sa \ref canGetBusOutputControl()
616 */
617canStatus CANLIBAPI canSetBusOutputControl (const CanHandle hnd,
618 const unsigned int drivertype);
619
620/**
621 * \ingroup CAN
622 *
623 * \source_cs <b>static Canlib.canStatus canGetBusOutputControl(int handle, out int drivertype);</b>
624 *
625 * \source_delphi <b>function canGetBusOutputControl(handle: canHandle; var drivertype: Cardinal): canStatus; </b>
626 * \source_end
627 *
628 * This function retrieves the current CAN controller driver type.
629 * This corresponds loosely to the bus output control register in the
630 * CAN controller, hence the name of this function. CANLIB does not
631 * allow for direct manipulation of the bus output control register;
632 * instead, symbolic constants are used to select the desired driver
633 * type.
634 *
635 * \note Don't confuse the CAN controller driver type with the bus driver
636 * type. The CAN controller is not connected directly to the CAN bus;
637 * instead, it is connected to a bus transceiver circuit which interfaces
638 * directly to the bus. The "CAN controller driver type" we are talking
639 * about here refers to the mode which the CAN controller uses to drive
640 * the bus transceiver circuit.
641 *
642 * \note Silent Mode is not supported by all CAN controllers.
643 *
644 * \param[in] hnd An open handle to a CAN circuit.
645 * \param[in] drivertype A pointer to an unsigned int which receives the
646 * current driver type. The driver type can be either
647 * \ref canDRIVER_NORMAL or \ref canDRIVER_SILENT.
648 *
649 * \return \ref canOK (zero) if success
650 * \return \ref canERR_xxx (negative) if failure
651 *
652 * \sa \ref canSetBusOutputControl()
653 */
654canStatus CANLIBAPI canGetBusOutputControl (const CanHandle hnd,
655 unsigned int *drivertype);
656
657/**
658 * \ingroup CAN
659 *
660 * \source_cs <b>static Canlib.canStatus canAccept(int handle, int envelope, int flag);</b>
661 *
662 * \source_delphi <b>function canAccept(handle: canHandle; envelope: Longint; flag: Cardinal): canStatus; </b>
663 * \source_end
664 *
665 * This routine sets the message acceptance filters on a CAN channel.
666 *
667 * On some boards the acceptance filtering is done by the CAN hardware; on
668 * other boards (typically those with an embedded CPU,) the acceptance
669 * filtering is done by software. \ref canAccept() behaves in the same way for all
670 * boards, however.
671 *
672 * \ref canSetAcceptanceFilter() and \ref canAccept() both serve the same purpose but the
673 * former can set the code and mask in just one call.
674 *
675 * If you want to remove a filter, call \ref canAccept() with the mask set to 0.
676 *
677 * \note You can set the extended code and mask only on CAN boards that support
678 * extended identifiers.
679 *
680 * \note Not all CAN boards support different masks for standard and extended
681 * CAN identifiers.
682 *
683 * \param[in] hnd An open handle to a CAN circuit.
684 * \param[in] envelope The mask or code to set.
685 * \param[in] flag Any of \ref canFILTER_SET_CODE_STD,
686 * \ref canFILTER_SET_MASK_STD,
687 * \ref canFILTER_SET_CODE_EXT or
688 * \ref canFILTER_SET_MASK_EXT
689 *
690 * \return \ref canOK (zero) if success
691 * \return \ref canERR_xxx (negative) if failure
692 *
693 * \sa \ref page_user_guide_misc_code_and_mask,
694 * \ref page_user_guide_send_recv_filters,
695 * \ref page_code_snippets_examples
696 */
697canStatus CANLIBAPI canAccept (const CanHandle hnd,
698 const long envelope,
699 const unsigned int flag);
700
701/**
702 * \ingroup CAN
703 *
704 * \source_cs <b>static Canlib.canStatus canReadStatus(int handle, out long flags);</b>
705 *
706 * \source_delphi <b>function canReadStatus(handle: canHandle; var flags: Longint): canStatus; </b>
707 * \source_end
708 *
709 * Returns the status for the specified circuit. flags points to a longword
710 * which receives a combination of the \ref canSTAT_xxx flags.
711 *
712 * \note \ref canReadStatus() returns the latest known status of the specified
713 * circuit. If a status change happens precisely when \ref canReadStatus() is
714 * called, it may not be reflected in the returned result.
715 *
716 * \param[in] hnd A handle to an open circuit.
717 * \param[out] flags Pointer to a \c DWORD which receives the status flags;
718 * this is a combination of any of the \ref canSTAT_xxx.
719 *
720 * \return \ref canOK (zero) if success
721 * \return \ref canERR_xxx (negative) if failure
722 *
723 */
724canStatus CANLIBAPI canReadStatus (const CanHandle hnd,
725 unsigned long *const flags);
726
727/**
728 * \ingroup CAN
729 *
730 * \source_cs <b>static Canlib.canStatus canReadErrorCounters(int handle, out int txErr, out int rxErr, out int ovErr);</b>
731 *
732 * \source_delphi <b>function canReadErrorCounters(handle: canHandle; var txErr, rxErr, ovErr: Cardinal): canStatus; </b>
733 * \source_end
734 *
735 * Reads the error counters of the CAN controller.
736 *
737 * \ref canReadErrorCounters() returns the latest known values of the error counters
738 * in the specified circuit. If the error counters change values precisely when
739 * \ref canReadErrorCounters() is called, it may not be reflected in the returned
740 * result.
741 *
742 * It is allowed to pass \c NULL as the value of the \a txErr, \a rxErr, and \a
743 * ovErr parameters.
744 *
745 * Use \ref canIoCtl() to clear the counters.
746 *
747 * \note Not all CAN controllers provide access to the error counters;
748 * in this case, an educated guess is returned.
749 *
750 * \param[in] hnd A handle to an open circuit.
751 * \param[out] txErr A pointer to a \c DWORD which receives the transmit error
752 * counter.
753 * \param[out] rxErr A pointer to a \c DWORD which receives the receive error
754 * counter.
755 * \param[out] ovErr A pointer to a \c DWORD which receives the number of
756 * overrun errors.
757 *
758 * \return \ref canOK (zero) if success
759 * \return \ref canERR_xxx (negative) if failure
760 *
761 * \sa \ref canIoCtl()
762 */
763canStatus CANLIBAPI canReadErrorCounters (const CanHandle hnd,
764 unsigned int *txErr,
765 unsigned int *rxErr,
766 unsigned int *ovErr);
767
768/**
769 * \ingroup CAN
770 *
771 * \source_cs <b>static Canlib.canStatus canWrite(int handle, int id, byte[] msg, int dlc, int flag);</b>
772 *
773 * \source_delphi <b>function canWrite(handle: canHandle; id: Longint; msg: Pointer; dlc: Cardinal; flag: Cardinal): canStatus; </b>
774 * \source_end
775 *
776 * This function sends a CAN message. The call returns immediately after queuing
777 * the message to the driver.
778 *
779 * If you are using the same channel via multiple handles, note that the
780 * default behaviour is that the different handles will "hear" each other just as
781 * if each handle referred to a channel of its own. If you open, say, channel 0
782 * from thread A and thread B and then send a message from thread A, it will be
783 * "received" by thread B.
784 * This behaviour can be changed using \ref canIOCTL_SET_LOCAL_TXECHO.
785 *
786 * \note The message has been queued for transmission when this calls return.
787 * It has not necessarily been sent.
788 *
789 * \param[in] hnd A handle to an open CAN circuit.
790 * \param[in] id The identifier of the CAN message to send.
791 * \param[in] msg A pointer to the message data, or \c NULL.
792 * \param[in] dlc The length of the message. Can be at most 8.
793 * \param[in] flag A combination of message flags, \ref canMSG_xxx.
794 * Use this parameter to send extended (29-bit) frames
795 * and/or remote frames. Use \ref canMSG_EXT and/or
796 * \ref canMSG_RTR for this purpose.
797 *
798 * \return \ref canOK (zero) if success
799 * \return \ref canERR_xxx (negative) if failure
800 *
801 * \sa \ref page_user_guide_send_recv_sending, \ref page_code_snippets_examples
802 * \sa \ref canWriteSync(), \ref canWriteWait()
803 *
804 */
805canStatus CANLIBAPI canWrite (const CanHandle hnd,
806 long id,
807 void *msg,
808 unsigned int dlc,
809 unsigned int flag);
810
811/**
812 * \ingroup CAN
813 *
814 * \source_cs <b>static Canlib.canStatus canWriteSync(int handle, long timeout);</b>
815 *
816 * \source_delphi <b>function canWriteSync(handle: canHandle; timeout: Longint): canStatus; </b>
817 * \source_end
818 *
819 * Waits until all CAN messages for the specified handle are sent, or the
820 * timeout period expires.
821 *
822 * \param[in] hnd A handle to an open CAN circuit.
823 * \param[in] timeout The timeout in milliseconds. 0xFFFFFFFF gives an
824 * infinite timeout.
825 *
826 * \return \ref canOK (zero) if the queue emptied before the timeout period came to
827 * its end.
828 * \return \ref canERR_TIMEOUT (negative) not all messages were transmitted when
829 * the timeout occurred.
830 * \return \ref canERR_PARAM (negative) This could be caused by an erroneous
831 * parameter, or if you have turned TXACKs off (by using \ref canIoCtl())
832 * because if you do you can't use this call. The driver simply doesn't
833 * know when all the messages are sent!
834 * \return \ref canERR_xxx (negative) if failure
835 *
836 * \sa \ref canWrite(), \ref canWriteWait()
837 */
838canStatus CANLIBAPI canWriteSync (const CanHandle hnd, unsigned long timeout);
839
840/**
841 * \ingroup CAN
842 *
843 * \source_cs <b>static Canlib.canStatus canRead(int handle, out int id, byte[] msg, out int dlc, out int flag, out long time);</b>
844 *
845 * \source_delphi <b>function canRead(handle: canHandle; var id: Longint; msg: Pointer; var dlc: Cardinal; var flag: Cardinal; var time: Longint): canStatus; </b>
846 * \source_end
847 *
848 * Reads a message from the receive buffer. If no message is available, the
849 * function returns immediately with return code \ref canERR_NOMSG.
850 *
851 * If you are using the same channel via multiple handles, note that the
852 * default behaviour is that the different handles will "hear" each other just as
853 * if each handle referred to a channel of its own. If you open, say, channel 0
854 * from thread A and thread B and then send a message from thread A, it will be
855 * "received" by thread B.
856 * This behaviour can be changed using \ref canIOCTL_SET_LOCAL_TXECHO.
857 *
858 * It is allowed to pass \c NULL as the value of \a id, \a msg, \a dlc, \a
859 * flag, and \a time.
860 *
861 * \param[in] hnd A handle to an open circuit.
862 * \param[out] id Pointer to a buffer which receives the CAN identifier.
863 * This buffer will only get the identifier. To determine
864 * whether this identifier was standard (11-bit) or extended
865 * (29-bit), and/or whether it was remote or not, or if it
866 * was an error frame, examine the contents of the flag
867 * argument.
868 * \param[out] msg Pointer to the buffer which receives the message data.
869 * This buffer must be large enough (i.e. 8 bytes.) Only the
870 * message data is copied; the rest of the buffer is left
871 * as-is.
872 * \param[out] dlc Pointer to a buffer which receives the message length.
873 * \param[out] flag Pointer to a buffer which receives the message flags,
874 * which is a combination of the \ref canMSG_xxx and
875 * \ref canMSGERR_xxx values.
876 * \param[out] time Pointer to a buffer which receives the message time stamp.
877 *
878 * \return \ref canOK (zero) if a message was read.
879 * \return \ref canERR_NOMSG (negative) if there was no message available.
880 * \return \ref canERR_xxx (negative) if failure
881 *
882 * \sa \ref page_user_guide_send_recv_reading, \ref
883 * page_user_guide_send_recv_mailboxes, \ref page_code_snippets_examples,
884 * \ref page_user_guide_time_accuracy_and_resolution
885 * \sa \ref canReadSpecific(), \ref canReadSpecificSkip(), \ref canReadSync(),
886 * \ref canReadSyncSpecific(), \ref canReadWait()
887 *
888 */
889canStatus CANLIBAPI canRead (const CanHandle hnd,
890 long *id,
891 void *msg,
892 unsigned int *dlc,
893 unsigned int *flag,
894 unsigned long *time);
895
896/**
897 * \ingroup CAN
898 *
899 * \source_cs <b>static Canlib.canStatus canReadWait(int handle, out int id, byte[] msg, out int dlc, out int flag, out long time, long timeout);</b>
900 *
901 * \source_delphi <b>function canReadWait(handle: canHandle; var id: Longint; msg: Pointer; var dlc: Cardinal; var flag: Cardinal; var time: Longint; timeout: Longint): canStatus; </b>
902 * \source_end
903 *
904 * Reads a message from the receive buffer. If no message is available, the
905 * function waits until a message arrives or a timeout occurs.
906 *
907 * If you are using the same channel via multiple handles, note that the
908 * default behaviour is that the different handles will "hear" each other just as
909 * if each handle referred to a channel of its own. If you open, say, channel 0
910 * from thread A and thread B and then send a message from thread A, it will be
911 * "received" by thread B.
912 * This behaviour can be changed using \ref canIOCTL_SET_LOCAL_TXECHO.
913 *
914 * It is allowed to pass \c NULL as the value of \a id, \a msg, \a dlc, \a
915 * flag, and \a time.
916 *
917 * \param[in] hnd A handle to an open circuit.
918 * \param[out] id Pointer to a buffer which receives the CAN identifier.
919 * This buffer will only get the identifier. To determine
920 * whether this identifier was standard (11-bit) or extended
921 * (29-bit), and/or whether it was remote or not, or if it
922 * was an error frame, examine the contents of the flag
923 * argument.
924 * \param[out] msg Pointer to the buffer which receives the message data.
925 * This buffer must be large enough (i.e. 8 bytes.).
926 * \param[out] dlc Pointer to a buffer which receives the message length.
927 * \param[out] flag Pointer to a buffer which receives the message flags,
928 * which is a combination of the \ref canMSG_xxx and
929 * \ref canMSGERR_xxx values.
930 * \param[out] time Pointer to a buffer which receives the message time stamp.
931 * \param[in] timeout If no message is immediately available, this parameter
932 * gives the number of milliseconds to wait for a message
933 * before returning. 0xFFFFFFFF gives an infinite timeout.
934 *
935 * \return \ref canOK (zero) if a message was read.
936 * \return \ref canERR_NOMSG (negative) if there was no message available.
937 * \return \ref canERR_xxx (negative) if failure
938 *
939 * \sa \ref canRead(),\win_start \ref canReadSpecific(), \ref canReadSpecificSkip(),
940 * \ref canReadSyncSpecific(),\win_end \ref canReadSync()
941 *
942 * \sa \ref page_user_guide_time_accuracy_and_resolution
943 */
944canStatus CANLIBAPI canReadWait (const CanHandle hnd,
945 long *id,
946 void *msg,
947 unsigned int *dlc,
948 unsigned int *flag,
949 unsigned long *time,
950 unsigned long timeout);
951
952#if defined(CANLIB_DECLARE_ALL)
953/**
954 * \ingroup CAN
955 *
956 * \source_cs <b>static Canlib.canStatus canReadSpecific(int handle, int id, byte[] msg, out int dlc, out int flag, out long time);</b>
957 *
958 * \source_delphi <b>function canReadSpecific(handle: canHandle; id: Longint; msg: Pointer; var dlc: Cardinal; var flag: Cardinal; var time: Longint): canStatus; </b>
959 * \source_end
960 *
961 * Reads a message with a specified identifier from the receive buffer. Any
962 * preceding message not matching the specified identifier will be kept
963 * in the receive buffer. If no message with the specified identifier is
964 * available, the function returns immediately with an error code.
965 *
966 * If you are using the same channel via multiple handles, note that the
967 * default behaviour is that the different handles will "hear" each other just as
968 * if each handle referred to a channel of its own. If you open, say, channel 0
969 * from thread A and thread B and then send a message from thread A, it will be
970 * "received" by thread B.
971 * This behaviour can be changed using \ref canIOCTL_SET_LOCAL_TXECHO.
972 *
973 * It is allowed to pass \c NULL as the value of \a id, \a msg, \a dlc, \a
974 * flag, and \a time.
975 *
976 * \note Use \ref canReadSpecific only if you for some reason must keep the unread
977 * messages in the queue. If this is not the case, consider using
978 * \ref canReadSpecificSkip() or \ref canRead() for better performance.
979 *
980 * \param[in] hnd A handle to an open circuit.
981 * \param[out] id The desired CAN identifier.
982 * \param[out] msg Pointer to the buffer which receives the message data.
983 * This buffer must be large enough (i.e. 8 bytes.).
984 * \param[out] dlc Pointer to a buffer which receives the message length.
985 * \param[out] flag Pointer to a buffer which receives the message flags,
986 * which is a combination of the \ref canMSG_xxx and
987 * \ref canMSGERR_xxx values.
988 * \param[out] time Pointer to a buffer which receives the message time stamp.
989 *
990 * \return \ref canOK (zero) if a message was read.
991 * \return \ref canERR_NOMSG (negative) if a matching message was not found.
992 * There might be other messages in the queue, though.
993 * \return \ref canERR_xxx (negative) if failure
994 *
995 * \sa \ref page_user_guide_send_recv_mailboxes \ref
996 * page_user_guide_send_recv_reading \ref
997 * page_user_guide_time_accuracy_and_resolution
998 * \sa \ref canRead(), \ref canReadSpecificSkip(), \ref canReadSync(), \ref canReadSyncSpecific(),
999 * \ref canReadWait()
1000 *
1001 */
1002canStatus CANLIBAPI canReadSpecific (const CanHandle hnd, long id, void * msg,
1003 unsigned int * dlc, unsigned int * flag,
1004 unsigned long * time);
1005
1006/**
1007 * \ingroup CAN
1008 *
1009 * \source_cs <b>static Canlib.canStatus canReadSync(int handle, long timeout);</b>
1010 *
1011 * \source_delphi <b>function canReadSync(handle: canHandle; timeout: Longint): canStatus; </b>
1012 * \source_end
1013 *
1014 * Waits until the receive buffer contains at least one message or a timeout
1015 * occurs.
1016 *
1017 * If you are using the same channel via multiple handles, note that the
1018 * default behaviour is that the different handles will "hear" each other just as
1019 * if each handle referred to a channel of its own. If you open, say, channel 0
1020 * from thread A and thread B and then send a message from thread A, it will be
1021 * "received" by thread B.
1022 * This behaviour can be changed using \ref canIOCTL_SET_LOCAL_TXECHO.
1023 *
1024 * \param[in] hnd A handle to an open circuit.
1025 * \param[in] timeout The timeout in milliseconds. 0xFFFFFFFF gives an
1026 * infinite timeout.
1027 *
1028 * \return \ref canOK (zero) if the queue contains the desired message.
1029 * \return \ref canERR_TIMEOUT (negative) if a timeout occurs before a message
1030 * arrived.
1031 * \return \ref canERR_xxx (negative) if the call fails.
1032 *
1033 * \sa \ref canRead(), \win_start \ref canReadSpecific(), \ref canReadSpecificSkip(),
1034 * \ref canReadSyncSpecific(),\win_end \ref canReadWait()
1035 */
1036canStatus CANLIBAPI canReadSync (const CanHandle hnd, unsigned long timeout);
1037
1038/**
1039 * \ingroup CAN
1040 *
1041 * \source_cs <b>static Canlib.canStatus canReadSyncSpecific(int handle, int id, long timeout);</b>
1042 *
1043 * \source_delphi <b>function canReadSyncSpecific(handle: canHandle; id, timeout: Longint): canStatus; </b>
1044 * \source_end
1045 *
1046 * Waits until the receive queue contains a message with the specified id, or a
1047 * timeout occurs..
1048 *
1049 * If you are using the same channel via multiple handles, note that the
1050 * default behaviour is that the different handles will "hear" each other just as
1051 * if each handle referred to a channel of its own. If you open, say, channel 0
1052 * from thread A and thread B and then send a message from thread A, it will be
1053 * "received" by thread B.
1054 * This behaviour can be changed using \ref canIOCTL_SET_LOCAL_TXECHO.
1055 *
1056 * \param[in] hnd A handle to an open circuit.
1057 * \param[in] id The desired message identifier.
1058 * \param[in] timeout The timeout in milliseconds. 0xFFFFFFFF gives an
1059 * infinite timeout.
1060 *
1061 * \return \ref canOK (zero) if the queue contains the desired message.
1062 * \return \ref canERR_TIMEOUT (negative) if a timeout occurs before the specified
1063 * message arrived.
1064 * \return \ref canERR_xxx (negative) if the call fails.
1065 *
1066 * \sa \ref canRead(), \ref canReadSpecific(), \ref canReadSpecificSkip(),
1067 * \ref canReadSync(), \ref canReadWait()
1068 */
1069canStatus CANLIBAPI canReadSyncSpecific (const CanHandle hnd,
1070 long id,
1071 unsigned long timeout);
1072
1073/**
1074 * \ingroup CAN
1075 *
1076 * \source_cs <b>static Canlib.canStatus canReadSpecificSkip(int hnd, int id, byte[] msg, out int dlc, out int flag, out long time);</b>
1077 *
1078 * \source_delphi <b>function canReadSpecificSkip(handle: canHandle; id: Longint; msg: Pointer; var dlc: Cardinal; var flag: Cardinal; var time: Longint): canStatus; </b>
1079 * \source_end
1080 *
1081 * Reads a message with a specified identifier from the receive buffer. Any
1082 * preceding message not matching the specified identifier will be removed
1083 * in the receive buffer. If no message with the specified identifier is
1084 * available, the function returns immediately with an error code.
1085 *
1086 * If you are using the same channel via multiple handles, note that the
1087 * default behaviour is that the different handles will "hear" each other just as
1088 * if each handle referred to a channel of its own. If you open, say, channel 0
1089 * from thread A and thread B and then send a message from thread A, it will be
1090 * "received" by thread B.
1091 * This behaviour can be changed using \ref canIOCTL_SET_LOCAL_TXECHO.
1092 *
1093 * It is allowed to pass \c NULL as the value of \a id, \a msg, \a dlc, \a
1094 * flag, and \a time.
1095 *
1096 * \param[in] hnd A handle to an open circuit.
1097 * \param[out] id The desired CAN identifier.
1098 * \param[out] msg Pointer to the buffer which receives the message data.
1099 * This buffer must be large enough (i.e. 8 bytes.).
1100 * \param[out] dlc Pointer to a buffer which receives the message length.
1101 * \param[out] flag Pointer to a buffer which receives the message flags,
1102 * which is a combination of the \ref canMSG_xxx and
1103 * \ref canMSGERR_xxx values.
1104 * \param[out] time Pointer to a buffer which receives the message time stamp.
1105 *
1106 * \return \ref canOK (zero) if a matching message was found.
1107 * \return \ref canERR_NOMSG if there was no matching message available. All other
1108 messages (if any!) were discarded.
1109 * \return \ref canERR_xxx (negative) if failure
1110 *
1111 * \sa \ref page_user_guide_send_recv_reading, \ref
1112 * page_user_guide_time_accuracy_and_resolution
1113 * \sa \ref canRead(), \ref canReadSpecific(), \ref canReadSync(),
1114 * \ref canReadSyncSpecific(), \ref canReadWait()
1115 */
1116canStatus CANLIBAPI canReadSpecificSkip (const CanHandle hnd,
1117 long id,
1118 void * msg,
1119 unsigned int * dlc,
1120 unsigned int * flag,
1121 unsigned long * time);
1122#endif
1123
1124
1125/**
1126 * \ingroup CAN
1127 *
1128 * \source_cs <b>static Canlib.canStatus canSetNotify(int handle, IntPtr win_handle, int aNotifyFlags);</b>
1129 *
1130 * \source_delphi <b>function canSetNotify(handle: canHandle; aHWnd: HWND; aNotifyFlags: Cardinal): canStatus; </b>
1131 * \source_end
1132 *
1133 * This function associates a window handle with the CAN circuit. A
1134 * \c WM__CANLIB message is sent to that window when certain events
1135 * (specified by the \ref canNOTIFY_xxx flags) occur.
1136 *
1137 * When an event take place, a \c WM__CANLIB message will be sent to the window
1138 * whose handle is aHWnd. This \c WM__CANLIB message will have:
1139 *
1140 * \li \c WPARAM handle to the circuit where the event occurred
1141 * \li \c HIWORD(LPARAM) 0
1142 * \li \c LOWORD(LPARAM) \ref canEVENT_xxx
1143 *
1144 * In the routine that handles \c WM__CANLIB, you can call the CANLIB API
1145 * functions (for example, \ref canRead()) using the handle found in \c wParam.
1146 *
1147 * \param[in] hnd A handle to an open CAN circuit.
1148 * \param[in] aHWnd Handle of the window which will receive the
1149 * notification messages.
1150 * \param[in] aNotifyFlags The events specified with \ref canNOTIFY_xxx, for
1151 * which callback should be called.
1152 *
1153 * \return \ref canOK (zero) if success
1154 * \return \ref canERR_xxx (negative) if failure
1155 *
1156 * \n In the routine that handles \c WM__CANLIB, you must call \ref canRead() repeatedly
1157 * until it returns \ref canERR_NOMSG, regardless of the \c LPARAM value. This will
1158 * flush the driver's internal event queues. If you fail to do this, no more
1159 * events will be reported.
1160 *
1161 * \sa \ref page_code_snippets_examples
1162 */
1163canStatus CANLIBAPI canSetNotify (const CanHandle hnd,
1164 HWND aHWnd,
1165 unsigned int aNotifyFlags);
1166
1167
1168/**
1169 * \ingroup CAN
1170 *
1171 * \source_cs <b>static Canlib.canStatus canTranslateBaud(ref int freq, out int tseg1, out int tseg2, out int sjw, out int nosamp, out int syncMode);</b>
1172 *
1173 * \source_delphi <b>function canTranslateBaud(var freq: longint; var tseg1, tseg2, sjw, noSamp, syncMode: Cardinal): canStatus; </b>
1174 * \source_end
1175 *
1176 * This function translates the \ref canBITRATE_xxx constants to their corresponding
1177 * bus parameter values. At return, this \a freq contains the actual bit rate
1178 * (in bits per second). \a TSeg1 is the number of quanta (less one) in a bit
1179 * before the sampling point. \a TSeg2 is the number of quanta after the
1180 * sampling point.
1181 *
1182 * \param[in] freq A pointer to a \c DWORD which contains the \ref canBITRATE_xxx
1183 * constant to translate
1184 * \param[in] tseg1 A pointer to a buffer which receives the Time segment 1,
1185 * that is, the number of quanta from (but not including)
1186 * the Sync Segment to the sampling point.
1187 * \param[in] tseg2 A pointer to a buffer which receives the Time segment 2,
1188 * that is, the number of quanta from the sampling point to
1189 * the end of the bit.
1190 * \param[in] sjw A pointer to a buffer which receives the Synchronization
1191 * Jump Width; can be 1,2,3, or 4.
1192 * \param[in] nosamp A pointer to a buffer which receives the number of
1193 * sampling points; can be 1 or 3.
1194 * \param[in] syncMode Unsupported, always read as zero.
1195 *
1196 * \return \ref canOK (zero) if success
1197 * \return \ref canERR_xxx (negative) if failure
1198 *
1199 * \sa \ref canSetBusParams()
1200 */
1201canStatus CANLIBAPI canTranslateBaud (long *const freq,
1202 unsigned int *const tseg1,
1203 unsigned int *const tseg2,
1204 unsigned int *const sjw,
1205 unsigned int *const nosamp,
1206 unsigned int *const syncMode);
1207
1208/**
1209 * \ingroup General
1210 *
1211 * \source_cs <b>static Canlib.canStatus canGetErrorText(Canlib.canStatus err, out string buf_str);</b>
1212 *
1213 * \source_delphi <b>function canGetErrorText(err: canStatus; buf: PChar; bufsiz: Cardinal): canStatus; </b>
1214 * \source_end
1215 *
1216 * This function translates an error code (\ref canERR_xxx)
1217 * to a human-readable, English text.
1218 *
1219 * \param[in] err The error code.
1220 * \param[in,out] buf The buffer which is to receive the text, which is a
1221 * zero-terminated string (provided the buffer is large enough.)
1222 * \param[in] bufsiz The length of the input buffer.
1223 *
1224 * \return \ref canOK (zero) if success
1225 * \return \ref canERR_xxx (negative) if failure
1226 *
1227 * \sa \ref page_code_snippets_examples
1228 *
1229 */
1230canStatus CANLIBAPI canGetErrorText (canStatus err, char *buf, unsigned int bufsiz);
1231
1232/**
1233 * \ingroup General
1234 *
1235 * \source_cs <b>static short canGetVersion();</b>
1236 *
1237 * \source_delphi <b>function canGetVersion: Word; </b>
1238 * \source_end
1239 *
1240 * \win_start
1241 * This API call returns the version of the CANLIB API DLL (canlib32.dll). The
1242 * most significant byte is the major version number and the least significant
1243 * byte is the minor version number.
1244 *
1245 * The actual version of the different driver files can be obtained by studying
1246 * the version resources in each of the files.
1247 *
1248 * \note The version number of the canlib32.dll file is not related to the
1249 * product version of CANLIB you are using. CANLIB consists of several
1250 * driver and DLL files. To obtain the product version, use
1251 * \ref canGetVersionEx().
1252 *
1253 * \return version number of canlib32.dll
1254 *
1255 * \sa \ref page_user_guide_build_driver_version
1256 * \sa \ref canGetVersionEx(), \ref canProbeVersion()
1257 *
1258 * \win_end
1259 *
1260 * \linux_start
1261 * This API call returns the version of the CANLIB API library (libcanlib.so.x.y). The
1262 * most significant byte is the major version number and the least significant
1263 * byte is the minor version number.
1264 *
1265 * \return version number of libcanlib.so.x.y
1266 *
1267 * \linux_end
1268 *
1269 *
1270 */
1271unsigned short CANLIBAPI canGetVersion (void);
1272
1273/**
1274 * \ingroup General
1275 *
1276 * \source_cs <b>static Canlib.canStatus canIoCtl(int handle, int func, int val);<br>
1277 static Canlib.canStatus canIoCtl(int handle, int func, out int val);<br>
1278 static Canlib.canStatus canIoCtl(int handle, int func, out string str_buf);<br>
1279 static Canlib.canStatus canIoCtl(int handle, int func, ref object obj_buf);</b>
1280 *
1281 * \source_delphi <b>function canIoCtl(handle: canHandle; func: Cardinal; buf: Pointer; buflen: Cardinal): canStatus; </b>
1282 * \source_end
1283 *
1284 * This API call performs several different functions; these are described
1285 * below. The functions are handle-specific unless otherwise noted; this means
1286 * that they affect only the handle you pass to \ref canIoCtl(), whereas other open
1287 * handles will remain unaffected. The contents of \a buf after the call is
1288 * dependent on the function code you specified.
1289 *
1290 * \param[in] hnd A handle to an open circuit.
1291 * \param[in] func A \ref canIOCTL_xxx function code
1292 * \param[in,out] buf Pointer to a buffer containing function-dependent data;
1293 or a \c NULL pointer for certain function codes. The
1294 buffer can be used for both input and output
1295 depending on the function code. See \ref canIOCTL_xxx.
1296 * \param[in] buflen The length of the buffer.
1297 *
1298 * \return \ref canOK (zero) if success
1299 * \return \ref canERR_xxx (negative) if failure
1300 *
1301 */
1302canStatus CANLIBAPI canIoCtl (const CanHandle hnd,
1303 unsigned int func,
1304 void *buf,
1305 unsigned int buflen);
1306
1307/* Note the difference from the windows version */
1308
1309/**
1310 * \ingroup CAN
1311 *
1312 * \source_cs <b>static long canReadTimer(int hnd);</b>
1313 *
1314 * \source_delphi <b>function canReadTimer(handle: canHandle): longint; </b>
1315 * \source_end
1316 *
1317 * Reads the current time from the clock used to timestamp the
1318 * messages for the indicated circuit.
1319 *
1320 * This API may return \ref canERR_INVHANDLE and/or \ref canERR_NOTINITIALIZED!
1321 * This happens if \a hnd is invalid, or if the library was not initialized.
1322 *
1323 * \note \ref kvReadTimer() should be used instead since it separates the returned
1324 * time from the error code.
1325 *
1326 * \note The clock used to timestamp the messages may not be available for
1327 * direct reading on all platforms. In such cases, the PC's clock is used
1328 * to return an approximation of the current time. Note that clock drift might
1329 * occur in this case.
1330 *
1331 * \param[in] hnd A handle to an open circuit.
1332 *
1333 * \return The current time, with the prevailing time resolution (milliseconds
1334 * by default).
1335 *
1336 * \sa \ref page_user_guide_time_accuracy_and_resolution
1337 * \sa \ref kvReadTimer()
1338 */
1339unsigned long CANLIBAPI canReadTimer (const CanHandle hnd);
1340
1341/**
1342 * \ingroup CAN
1343 *
1344 * \source_cs <b>static int canOpenChannel(int channel, int flags);</b>
1345 *
1346 * \source_delphi <b>function canOpenChannel(channel: Integer; flags: Integer): canHandle; </b>
1347 * \source_end
1348 *
1349 * Opens a CAN channel (circuit) and returns a handle which is used
1350 * in subsequent calls to CANLIB.
1351 *
1352 *
1353 * Channel numbering is dependent on the installed hardware. The first channel
1354 * always has number 0.
1355 *
1356 * For example,
1357 *
1358 * \li If you have a single LAPcan, the channels are numbered 0 and 1.
1359 *
1360 * \li If you have a USBcan Professional, the channels are numbered 0-1
1361 * according to the labels on the cables.
1362 *
1363 * \li The virtual channels come after all physical channels.
1364 *
1365 * If you are using multiple threads, note that the returned handle is usable
1366 * only in the context of the thread that created it. That is, you must call
1367 * \ref canOpenChannel() in each of the threads in your application that uses the
1368 * CAN bus. You can open the same channel from multiple threads, but you must
1369 * call \ref canOpenChannel() once per thread.
1370 *
1371 * If you are using the same channel via multiple handles, note that the
1372 * default behaviour is that the different handles will "hear" each other just as
1373 * if each handle referred to a channel of its own. If you open, say, channel 0
1374 * from thread A and thread B and then send a message from thread A, it will be
1375 * "received" by thread B.
1376 * This behaviour can be changed using \ref canIOCTL_SET_LOCAL_TXECHO.
1377 *
1378 * \note The handle returned may be zero which is perfectly valid.
1379 *
1380 * \note This call replaces the \ref canOpen() API call and serves the same purpose.
1381 *
1382 * \param[in] channel The number of the channel. Channel numbering is hardware
1383 * dependent.
1384 * \param[in] flags A combination of \ref canOPEN_xxx flags
1385 *
1386 * \return Returns a handle to the opened circuit, or \ref canERR_xxx
1387 * (negative) if the call failed.
1388 *
1389 * \sa \ref page_code_snippets_examples, \ref page_user_guide_virtual_info
1390 * \sa \ref canGetNumberOfChannels(), \ref canGetChannelData(), \ref canIoCtl()
1391 *
1392 */
1393CanHandle CANLIBAPI canOpenChannel (int channel, int flags);
1394
1395/**
1396 * \ingroup General
1397 *
1398 * \source_cs <b>static Canlib.canStatus canGetNumberOfChannels(out int channelCount);</b>
1399 *
1400 * \source_delphi <b>function canGetNumberOfChannels(var channelCount: Integer): canStatus; </b>
1401 * \source_end
1402 *
1403 * This function returns the number of available CAN channels in the
1404 * computer. The virtual channels are included in this number.
1405 *
1406 * \param[out] channelCount A pointer to a \c DWORD which will receive the current
1407 * number of channels.
1408 *
1409 * \return \ref canOK (zero) if success
1410 * \return \ref canERR_xxx (negative) if failure
1411 *
1412 * \sa \ref page_code_snippets_examples, \ref page_user_guide_virtual_info
1413 * \sa \ref canGetChannelData()
1414 */
1415canStatus CANLIBAPI canGetNumberOfChannels (int *channelCount);
1416
1417/**
1418 * \ingroup General
1419 *
1420 * \source_cs <b>static Canlib.canStatus canGetChannelData(int channel, int item, out object buffer);</b>
1421 *
1422 * \source_delphi <b>function canGetChannelData(channel, item: Integer; var buffer; bufsize: Cardinal): canStatus; </b>
1423 * \source_end
1424 *
1425 * This function can be used to retrieve certain pieces of information about a channel.
1426 *
1427 * \note You must pass a channel number and not a channel handle.
1428 *
1429 * \param[in] channel The number of the channel you are interested in. Channel
1430 * numbers are integers in the interval beginning at 0
1431 * (zero) and ending at the value returned by
1432 * \ref canGetNumberOfChannels() minus 1.
1433 * \param[in] item This parameter specifies what data to obtain for the
1434 * specified channel. The value is one of the constants
1435 * \ref canCHANNELDATA_xxx.
1436 * \param[in,out] buffer The address of a buffer which is to receive the data.
1437 * \param[in] bufsize The size of the buffer to which the buffer parameter
1438 * points.
1439 *
1440 * \return \ref canOK (zero) if success
1441 * \return \ref canERR_xxx (negative) if failure
1442 *
1443 * \sa \ref page_code_snippets_examples
1444 * \sa \ref canGetNumberOfChannels()
1445 */
1446canStatus CANLIBAPI canGetChannelData (int channel,
1447 int item,
1448 void *buffer,
1449 size_t bufsize);
1450
1451/**
1452 * \ingroup General
1453 * \anchor canCHANNELDATA_xxx
1454 * \name canCHANNELDATA_xxx
1455 *
1456 * These defines are used in \ref canGetChannelData().
1457 *
1458 * @{
1459 */
1460
1461 /**
1462 * This define is used in \ref canGetChannelData(), \a buffer
1463 * mentioned below refers to this functions argument.
1464 *
1465 * \a buffer points to a 32-bit unsigned integer that receives the
1466 * capabilities of the CAN controller; this is a combination of the \ref
1467 * canCHANNEL_CAP_xxx flags.
1468 */
1469#define canCHANNELDATA_CHANNEL_CAP 1
1470
1471 /**
1472 * This define is used in \ref canGetChannelData(), \a buffer
1473 * mentioned below refers to this functions argument.
1474 *
1475 * \a buffer points to a 32-bit unsigned integer that receives the
1476 * capabilities of the CAN transceiver; this is a combination of the
1477 * \ref canDRIVER_CAP_xxx flags.
1478 */
1479#define canCHANNELDATA_TRANS_CAP 2
1480
1481 /**
1482 * This define is used in \ref canGetChannelData(), \a buffer
1483 * mentioned below refers to this functions argument.
1484 *
1485 * \note Currently not implemented.
1486 */
1487#define canCHANNELDATA_CHANNEL_FLAGS 3 // available, etc
1488
1489 /**
1490 * This define is used in \ref canGetChannelData(), \a buffer
1491 * mentioned below refers to this functions argument.
1492 *
1493 * \a buffer points to a 32-bit unsigned integer that receives the hardware
1494 * type of the card. This value is any one of the \ref canHWTYPE_xxx
1495 * constants.
1496 */
1497#define canCHANNELDATA_CARD_TYPE 4
1498
1499 /**
1500 * This define is used in \ref canGetChannelData(), \a buffer
1501 * mentioned below refers to this functions argument.
1502 *
1503 * \a buffer points to a 32-bit unsigned integer that receives the card's
1504 * number in the computer. Each card type is numbered separately. For
1505 * example, the first LAPcan card in a machine will have number 0, the second
1506 * LAPcan number 1, etc.
1507 */
1508#define canCHANNELDATA_CARD_NUMBER 5
1509
1510 /**
1511 * This define is used in \ref canGetChannelData(), \a buffer
1512 * mentioned below refers to this functions argument.
1513 *
1514 * \a buffer points to a 32-bit unsigned integer which receives the channel
1515 * number on the card.
1516 */
1517#define canCHANNELDATA_CHAN_NO_ON_CARD 6
1518
1519 /**
1520 * This define is used in \ref canGetChannelData(), \a buffer
1521 * mentioned below refers to this functions argument.
1522 *
1523 * \a buffer points to a 64-bit (8 bytes) area which receives the serial
1524 * number of the card. If the card doesn't have a serial number, 0 is
1525 * returned. The serial number is an 8-byte unsigned integer. Currently, no
1526 * products are using all 8 bytes; at most 4 bytes are used.
1527 */
1528#define canCHANNELDATA_CARD_SERIAL_NO 7
1529
1530 /**
1531 * This define is used in \ref canGetChannelData(), \a buffer
1532 * mentioned below refers to this functions argument.
1533 *
1534 * \a buffer points to a 64-bit (8 bytes) area which receives the serial
1535 * number of the transceiver. The serial number is an 8-byte unsigned
1536 * integer. If the transceiver doesn't have a serial number, 0 is returned.
1537 */
1538#define canCHANNELDATA_TRANS_SERIAL_NO 8
1539
1540 /**
1541 * This define is used in \ref canGetChannelData(), \a buffer
1542 * mentioned below refers to this functions argument.
1543 *
1544 * \a buffer points to a 64-bit (8 bytes) area which receives the firmware
1545 * revision number on the card. This number consists of four 16-bit words:
1546 * the major revision, the minor revision, the release number and the build
1547 * number, listed in order from the most significant to the least
1548 * significant.
1549 */
1550#define canCHANNELDATA_CARD_FIRMWARE_REV 9
1551
1552 /**
1553 * This define is used in \ref canGetChannelData(), \a buffer
1554 * mentioned below refers to this functions argument.
1555 *
1556 * \a buffer points to a 64-bit (8 bytes) area which receives the hardware
1557 * revision number on the card. This number consists of four 16-bit words;
1558 * the two most significant are always 0, and the two least significant are
1559 * the major revision and the minor revision, listed in order from the most
1560 * significant to the least significant.
1561 */
1562#define canCHANNELDATA_CARD_HARDWARE_REV 10
1563
1564 /**
1565 * This define is used in \ref canGetChannelData(), \a buffer
1566 * mentioned below refers to this functions argument.
1567 *
1568 * \a buffer points to a 8-byte area which receives the UPC (EAN) number for
1569 * the card. If there is no UPC number, the buffer is filled with zeros. The
1570 * UPC (EAN) number is coded as a BCD string with the LSB first, so
1571 * e.g. 733-0130-00122-0 is coded as 0x30001220 0x00073301.
1572 */
1573#define canCHANNELDATA_CARD_UPC_NO 11
1574
1575 /**
1576 * This define is used in \ref canGetChannelData(), \a buffer
1577 * mentioned below refers to this functions argument.
1578 *
1579 * \a buffer points to a 8-byte area which receives the UPC (EAN) number for
1580 * the transceiver. If there is no UPC number, the buffer is filled with
1581 * zeros. The UPC (EAN) number is coded as a BCD string with the LSB first,
1582 * so e.g. 733-0130-00122-0 is coded as 0x30001220 0x00073301.
1583 */
1584#define canCHANNELDATA_TRANS_UPC_NO 12
1585
1586 /**
1587 * This define is used in \ref canGetChannelData(), \a buffer
1588 * mentioned below refers to this functions argument.
1589 *
1590 * \a buffer points to an area which receives a zero-terminated string with a
1591 * clear-text name of the channel.
1592 *
1593 * \note Use of this item code is no longer recommended. The returned
1594 * channel name doesn't contain the exact hardware type (it just contains
1595 * the device family) and uses zero-based channel numbering, which is not
1596 * user friendly. Instead, use e.g. \ref canCHANNELDATA_DEVDESCR_ASCII and
1597 * \ref canCHANNELDATA_CHAN_NO_ON_CARD to build your own channel name.
1598 *
1599 *\win_start
1600 * \sa \ref canCHANNELDATA_DEVNAME_ASCII
1601 *\win_end
1602 */
1603#define canCHANNELDATA_CHANNEL_NAME 13
1604#if defined(CANLIB_DECLARE_ALL)
1605
1606 /**
1607 * This define is used in \ref canGetChannelData(), \a buffer
1608 * mentioned below refers to this functions argument.
1609 *
1610 * \a buffer points to an array of 4 16-bit unsigned integers which receives
1611 * the file version number of the second-level DLL driver file, i.e. the DLL
1612 * that interfaces between CANLIB32.DLL and the driver proper.
1613 *
1614 * Contents depening on index:
1615 *
1616 * \li 0: 0
1617 * \li 1: The build number
1618 * \li 2: The minor revision number
1619 * \li 3: The major revision number
1620 */
1621# define canCHANNELDATA_DLL_FILE_VERSION 14
1622
1623 /**
1624 * This define is used in \ref canGetChannelData(), \a buffer
1625 * mentioned below refers to this functions argument.
1626 *
1627 * \a buffer points to an array of 4 16-bit unsigned integers which receives
1628 * the product version number of the second-level DLL driver file, i.e. the
1629 * DLL that interfaces between CANLIB32.DLL and the driver proper.
1630 *
1631 * Contents depening on index:
1632 *
1633 * \li 0: 0
1634 * \li 1: 1
1635 * \li 2: The minor revision number
1636 * \li 3: The major revision number
1637 */
1638# define canCHANNELDATA_DLL_PRODUCT_VERSION 15
1639
1640 /**
1641 * This define is used in \ref canGetChannelData(), \a buffer
1642 * mentioned below refers to this functions argument.
1643 *
1644 * \a buffer points to a 32-bit unsigned integer which receives a number that
1645 * identifies the second-level DLL driver file, i.e. the DLL that interfaces
1646 * between CANLIB32.DLL and the driver proper.
1647 *
1648 * Values:
1649 *
1650 * \li 1: kvalapw.dll - used with CANLIB up to 2.29.
1651 *
1652 * \li 2: kvalapw2.dll - used with CANLIB from 3.0 and on.
1653 */
1654# define canCHANNELDATA_DLL_FILETYPE 16
1655
1656 /**
1657 * This define is used in \ref canGetChannelData(), \a buffer
1658 * mentioned below refers to this functions argument.
1659 *
1660 * \a buffer points to a 32-bit unsigned integer which receives the CAN
1661 * transceiver type of the specified channel. This value is one of the
1662 * \ref canTRANSCEIVER_TYPE_xxx
1663 */
1664# define canCHANNELDATA_TRANS_TYPE 17
1665
1666 /**
1667 * This define is used in \ref canGetChannelData(), \a buffer
1668 * mentioned below refers to this functions argument.
1669 *
1670 * \a buffer points to a 32-bit unsigned integer which receives an address
1671 * indicating where the device is located on its underlying bus. The
1672 * interpretation of this number is bus-specific. If the address is unknown
1673 * or the bus driver does not support an address, the bus driver leaves this
1674 * member at its default value of 0xFFFFFFFF.
1675 *
1676 * The following list describes the information certain bus drivers store in
1677 * the Address field for their child devices:
1678 *
1679 * \li ISA: Does not supply an address. Defaults to 0xFFFFFFFF.
1680 *
1681 * \li PC Card (PCMCIA): The socket number (typically 0x00 or 0x40)
1682 *
1683 * \li PCI: The device number in the high word and the function number in the
1684 * low word.
1685 *
1686 * \li USB: The port number.
1687 */
1688# define canCHANNELDATA_DEVICE_PHYSICAL_POSITION 18
1689
1690 /**
1691 * This define is used in \ref canGetChannelData(), \a buffer
1692 * mentioned below refers to this functions argument.
1693 *
1694 * \a buffer points to a 32-bit unsigned integer which receives a number
1695 * associated with the device that can be displayed in the user
1696 * interface. This number is typically a user-perceived slot number, such as
1697 * a number printed next to the slot on the board, or some other number that
1698 * makes locating the physical device easier for the user. For buses with no
1699 * such convention, or when the UI number is unknown, 0xFFFFFFFF is returned.
1700 */
1701# define canCHANNELDATA_UI_NUMBER 19
1702
1703 /**
1704 * This define is used in \ref canGetChannelData(), \a buffer
1705 * mentioned below refers to this functions argument.
1706 *
1707 * \a buffer points to a 32-bit unsigned integer which is set to 0, if the
1708 * legacy time synchronization is not currently enabled for the specified
1709 * channel, and 1, if the legacy time synchronization is currently enabled
1710 * for the specified channel.
1711 *
1712 * Legacy time synchronization is a mechanism that will keep the PC and CAN
1713 * channel clocks in sync. The synchronization is done in the driver, which
1714 * periodically calculates the difference between the PC clock and the CAN
1715 * device clock and compensates for the clock drift by recalculating the CAN
1716 * message time stamps. You need to enable clock synchronization in the
1717 * Control Panel using the Kvaser Hardware applet.
1718 *
1719 * \note Legacy time synchronization is implemented only on LAPcan and LAPcan
1720 * II. It is not related to Kvaser MagiSync&tm; which is implemented in the
1721 * high-end members of the Kvaser Leaf family. Kvaser MagiSync&tm; is always
1722 * enabled and allows for much more accurate time synchronization.
1723 *
1724 */
1725# define canCHANNELDATA_TIMESYNC_ENABLED 20
1726
1727 /**
1728 * This define is used in \ref canGetChannelData(), \a buffer
1729 * mentioned below refers to this functions argument.
1730 *
1731 * \a buffer points to an array of four 16-bit unsigned integers which
1732 * receives the file version number of the kernel-mode driver.
1733 *
1734 * Contents depening on index:
1735 *
1736 * \li 0: The build number
1737 * \li 1: 0
1738 * \li 2: The minor revision number
1739 * \li 3: The major revision number
1740 */
1741# define canCHANNELDATA_DRIVER_FILE_VERSION 21
1742
1743 /**
1744 * This define is used in \ref canGetChannelData(), \a buffer
1745 * mentioned below refers to this functions argument.
1746 *
1747 * \a buffer points to an array of four 16-bit unsigned integers which
1748 * receives the product version number of the kernel-mode driver.
1749 *
1750 * Contents depening on index:
1751 *
1752 * \li 0: 0
1753 * \li 1: 0
1754 * \li 2: The minor revision number
1755 * \li 3: The major revision number
1756 */
1757# define canCHANNELDATA_DRIVER_PRODUCT_VERSION 22
1758
1759 /**
1760 * This define is used in \ref canGetChannelData(), \a buffer
1761 * mentioned below refers to this functions argument.
1762 *
1763 * \a buffer points to a buffer which receives the device manufacturer's name
1764 * as a zero-terminated Unicode string.
1765 */
1766# define canCHANNELDATA_MFGNAME_UNICODE 23
1767
1768 /**
1769 * This define is used in \ref canGetChannelData(), \a buffer
1770 * mentioned below refers to this functions argument.
1771 *
1772 * \a buffer points to a buffer which receives the device manufacturer's name
1773 * as a zero-terminated ASCII string.
1774 */
1775# define canCHANNELDATA_MFGNAME_ASCII 24
1776
1777 /**
1778 * This define is used in \ref canGetChannelData(), \a buffer
1779 * mentioned below refers to this functions argument.
1780 *
1781 * \a buffer points to a buffer which receives the product name of the device
1782 * as a zero-terminated Unicode string.
1783 */
1784# define canCHANNELDATA_DEVDESCR_UNICODE 25
1785
1786 /**
1787 * This define is used in \ref canGetChannelData(), \a buffer
1788 * mentioned below refers to this functions argument.
1789 *
1790 * \a buffer points to a buffer which receives the product name of the device
1791 * as a zero-terminated ASCII string.
1792 */
1793# define canCHANNELDATA_DEVDESCR_ASCII 26
1794
1795 /**
1796 * This define is used in \ref canGetChannelData(), \a buffer
1797 * mentioned below refers to this functions argument.
1798 *
1799 * \a buffer points to a buffer which receives the name of the device
1800 * driver (e.g. "kcans") as a zero-terminated ASCII string.
1801 *
1802 * \note The device driver names have no special meanings and may change
1803 * from a release to another.
1804 */
1805# define canCHANNELDATA_DRIVER_NAME 27
1806
1807 /**
1808 * This define is used in \ref canGetChannelData(), \a buffer
1809 * mentioned below refers to this functions argument.
1810 *
1811 * \a buffer points to a 32-bit unsigned integer that receives the quality of
1812 * the channel, where the quality is measured in percent of optimal quality.
1813 *
1814 * For WLAN, -90 dBm and -35 dBm are considered 0% and 100%, respectively.
1815 *
1816 * The quality is 100% for any directly connected channel (USB, PCI etc.).
1817 */
1818# define canCHANNELDATA_CHANNEL_QUALITY 28
1819
1820 /**
1821 * This define is used in \ref canGetChannelData(), \a buffer
1822 * mentioned below refers to this functions argument.
1823 *
1824 * \a buffer point to a 32-bit unsigned integer that receives the roundtrip
1825 * time which is measured in milliseconds.
1826 */
1827# define canCHANNELDATA_ROUNDTRIP_TIME 29
1828
1829 /**
1830 * This define is used in \ref canGetChannelData(), \a buffer
1831 * mentioned below refers to this functions argument.
1832 *
1833 * \a buffer points to a 32-bit unsigned integer that receives the
1834 * \ref kvBUSTYPE_GROUP_xxx bus type.
1835 */
1836# define canCHANNELDATA_BUS_TYPE 30
1837
1838 /**
1839 * This define is used in \ref canGetChannelData(), \a buffer
1840 * mentioned below refers to this functions argument.
1841 *
1842 * \a buffer points to a CHAR array of at least 32 characters which receives
1843 * the current device name as a \c NULL terminated ASCII string.
1844 *
1845 * If device name is not set or the device does not support this
1846 * functionality, an error will be returned.
1847 */
1848# define canCHANNELDATA_DEVNAME_ASCII 31
1849
1850 /**
1851 * This define is used in \ref canGetChannelData(), \a buffer
1852 * mentioned below refers to this functions argument.
1853 *
1854 * \a buffer points to a 32-bit unsigned integer that contains the time in
1855 * milliseconds since the last communication occured.
1856 *
1857 * For WLAN devices, this is the time since the last keep-alive message.
1858 */
1859# define canCHANNELDATA_TIME_SINCE_LAST_SEEN 32
1860
1861 /**
1862 * This define is used in \ref canGetChannelData(), \a buffer
1863 * mentioned below refers to this functions argument.
1864 *
1865 * \a buffer points to a 32-bit unsigned integer that receives the
1866 * current WLAN operational mode of the remote capable device;
1867 * \ref canCHANNEL_OPMODE_xxx.
1868 */
1869# define canCHANNELDATA_REMOTE_OPERATIONAL_MODE 33
1870
1871 /**
1872 * This define is used in \ref canGetChannelData(), \a buffer
1873 * mentioned below refers to this functions argument.
1874 *
1875 * \a buffer points to a buffer which receives the remote profile name
1876 * of the device as a zero-terminated ASCII string.
1877 */
1878# define canCHANNELDATA_REMOTE_PROFILE_NAME 34
1879
1880 /**
1881 * This define is used in \ref canGetChannelData(), \a buffer
1882 * mentioned below refers to this functions argument.
1883 *
1884 * \a buffer points to a buffer which receives the remote host name
1885 * of the device as a zero-terminated ASCII string.
1886 */
1887# define canCHANNELDATA_REMOTE_HOST_NAME 35
1888
1889 /**
1890 * This define is used in \ref canGetChannelData(), \a buffer
1891 * mentioned below refers to this functions argument.
1892 *
1893 * \a buffer points to a buffer which receives the mac address
1894 * of the device as a zero-terminated ASCII string.
1895 */
1896# define canCHANNELDATA_REMOTE_MAC 36
1897
1898 /**
1899 * This define is used in \ref canGetChannelData(), \a buffer
1900 * mentioned below refers to this functions argument.
1901 *
1902 * \a buffer points to a 32-bit unsigned integer which receives
1903 * maximum bitrate of the device. Zero value means no limit on
1904 * bitrate.
1905 */
1906# define canCHANNELDATA_MAX_BITRATE 37
1907
1908
1909#endif
1910
1911 /** @} */
1912
1913
1914/**
1915 * \name canCHANNEL_IS_xxx
1916 * \anchor canCHANNEL_IS_xxx
1917 *
1918 * These channelFlags are used in \ref canGetChannelData() and in conjunction with \ref
1919 * canCHANNELDATA_CHANNEL_FLAGS.
1920 * @{
1921 */
1922/** Used with \ref canCHANNELDATA_CHANNEL_FLAGS, indicates that the channel is
1923 opened exclusively. */
1924#define canCHANNEL_IS_EXCLUSIVE 0x0001
1925/** Used with \ref canCHANNELDATA_CHANNEL_FLAGS, indicates that the channel is
1926 opened. */
1927#define canCHANNEL_IS_OPEN 0x0002
1928
1929/** Used with \ref canCHANNELDATA_CHANNEL_FLAGS, indicates that the channel is
1930 * opened as CAN FD. */
1931
1932#define canCHANNEL_IS_CANFD 0x0004
1933 /** @} */
1934
1935
1936/**
1937 * \name canHWTYPE_xxx
1938 * \anchor canHWTYPE_xxx
1939 *
1940 * The following constants can be returned from \ref canGetChannelData(), using the
1941 * \ref canCHANNELDATA_CARD_TYPE item code. They identify the hardware type for
1942 * the channel specified in the call to \ref canGetChannelData().
1943 *
1944 * \note They indicate a hardware type, but not necessarily a specific
1945 * product. For example, \ref canHWTYPE_LAPCAN is returned both for LAPcan and
1946 * LAPcan II. (You can use \ref canGetChannelData() to obtain the UPC/EAN code for
1947 * the device. This number uniquely identifies the product.)
1948 *
1949 * @{
1950 */
1951#define canHWTYPE_NONE 0 ///< Unknown or undefined
1952#define canHWTYPE_VIRTUAL 1 ///< The virtual CAN bus
1953#define canHWTYPE_LAPCAN 2 ///< LAPcan Family
1954#define canHWTYPE_CANPARI 3 ///< CANpari (obsolete).
1955#define canHWTYPE_PCCAN 8 ///< PCcan Family
1956#define canHWTYPE_PCICAN 9 ///< PCIcan Family
1957#define canHWTYPE_USBCAN 11 ///< USBcan (obsolete).
1958#define canHWTYPE_PCICAN_II 40 ///< PCIcan II family
1959#define canHWTYPE_USBCAN_II 42 ///< USBcan II, USBcan Rugged, Kvaser Memorator
1960#define canHWTYPE_SIMULATED 44 ///< Simulated CAN bus for Kvaser Creator (obsolete).
1961#define canHWTYPE_ACQUISITOR 46 ///< Kvaser Acquisitor (obsolete).
1962#define canHWTYPE_LEAF 48 ///< Kvaser Leaf Family
1963#define canHWTYPE_PC104_PLUS 50 ///< Kvaser PC104+
1964#define canHWTYPE_PCICANX_II 52 ///< Kvaser PCIcanx II
1965#define canHWTYPE_MEMORATOR_II 54 ///< Kvaser Memorator Professional family
1966#define canHWTYPE_MEMORATOR_PRO 54 ///< Kvaser Memorator Professional family
1967#define canHWTYPE_USBCAN_PRO 56 ///< Kvaser USBcan Professional
1968#define canHWTYPE_IRIS 58 ///< Obsolete name, use canHWTYPE_BLACKBIRD instead
1969#define canHWTYPE_BLACKBIRD 58 ///< Kvaser BlackBird
1970#define canHWTYPE_MEMORATOR_LIGHT 60 ///< Kvaser Memorator Light
1971#define canHWTYPE_MINIHYDRA 62 ///< Obsolete name, use canHWTYPE_EAGLE instead
1972#define canHWTYPE_EAGLE 62 ///< Kvaser Eagle family
1973#define canHWTYPE_BAGEL 64 ///< Obsolete name, use canHWTYPE_BLACKBIRD_V2 instead
1974#define canHWTYPE_BLACKBIRD_V2 64 ///< Kvaser BlackBird v2
1975#define canHWTYPE_MINIPCIE 66 ///< Kvaser Mini PCI Express
1976#define canHWTYPE_USBCAN_KLINE 68 ///< USBcan Pro HS/K-Line
1977#define canHWTYPE_ETHERCAN 70 ///< Kvaser Ethercan
1978#define canHWTYPE_USBCAN_LIGHT 72 ///< Kvaser USBcan Light
1979#define canHWTYPE_USBCAN_PRO2 74 ///< Kvaser USBcan Pro 5xHS and variants
1980#define canHWTYPE_PCIE_V2 76 ///< Kvaser PCIEcan 4xHS and variants
1981#define canHWTYPE_MEMORATOR_PRO2 78 ///< Kvaser Memorator Pro 5xHS and variants
1982#define canHWTYPE_LEAF2 80 ///< Kvaser Leaf Pro HS v2 and variants
1983#define canHWTYPE_MEMORATOR_LIGHT2 82 ///< Kvaser Memorator Light (2nd generation)
1984
1985
1986/** @} */
1987
1988/**
1989 * \name canCHANNEL_CAP_xxx
1990 * \anchor canCHANNEL_CAP_xxx
1991 *
1992 * Channel capabilities.
1993 */
1994#define canCHANNEL_CAP_EXTENDED_CAN 0x00000001L ///< Can use extended identifiers
1995#define canCHANNEL_CAP_BUS_STATISTICS 0x00000002L ///< Can report busload etc
1996#define canCHANNEL_CAP_ERROR_COUNTERS 0x00000004L ///< Can return error counters
1997#define canCHANNEL_CAP_CAN_DIAGNOSTICS 0x00000008L ///< Can report CAN diagnostics
1998#define canCHANNEL_CAP_GENERATE_ERROR 0x00000010L ///< Can send error frames
1999#define canCHANNEL_CAP_GENERATE_OVERLOAD 0x00000020L ///< Can send CAN overload frame
2000#define canCHANNEL_CAP_TXREQUEST 0x00000040L ///< Can report when a CAN messsage transmission is initiated
2001#define canCHANNEL_CAP_TXACKNOWLEDGE 0x00000080L ///< Can report when a CAN messages has been transmitted
2002#define canCHANNEL_CAP_VIRTUAL 0x00010000L ///< Virtual CAN channel
2003#define canCHANNEL_CAP_SIMULATED 0x00020000L ///< Simulated CAN channel
2004#define canCHANNEL_CAP_REMOTE 0x00040000L ///< Remote CAN channel (e.g. BlackBird).
2005#define canCHANNEL_CAP_CAN_FD 0x00080000L ///< CAN-FD channel
2006#define canCHANNEL_CAP_CAN_FD_NONISO 0x00100000L ///< Supports Non-ISO CAN-FD channel
2007
2008/**
2009 * \name canCHANNEL_OPMODE_xxx
2010 * \anchor canCHANNEL_OPMODE_xxx
2011 *
2012 * Current WLAN operational mode.
2013 *
2014 * @{
2015 */
2016#define canCHANNEL_OPMODE_NONE 1 ///< Not applicable, or unknown
2017#define canCHANNEL_OPMODE_INFRASTRUCTURE 2 ///< Infrastructure mode
2018#define canCHANNEL_OPMODE_RESERVED 3 ///< Reserved value, do not use
2019#define canCHANNEL_OPMODE_ADHOC 4 ///< Adhoc mode
2020/** @} */
2021
2022/**
2023 * \name canDRIVER_CAP_xxx
2024 * \anchor canDRIVER_CAP_xxx
2025 *
2026 * Driver (transceiver) capabilities.
2027 * @{
2028 */
2029/** Used with \ref canCHANNELDATA_TRANS_CAP */
2030#define canDRIVER_CAP_HIGHSPEED 0x00000001L
2031/** @} */
2032
2033/**
2034 * \ingroup General
2035 * \name canIOCTL_xxx
2036 * \anchor canIOCTL_xxx
2037 *
2038 * These defines are used in \ref canIoCtl().
2039 *
2040 * @{
2041 */
2042
2043
2044 /**
2045 * This define is used in \ref canIoCtl(), \a buf and \a buflen refers to this
2046 * functions arguments.
2047 *
2048 * Tells CANLIB to "prefer" extended identifiers; that is, if you send a
2049 * message with \ref canWrite() and don't specify \ref canMSG_EXT nor \ref canMSG_STD,
2050 * \ref canMSG_EXT will be assumed. The contents of \a buf and \a buflen are
2051 * ignored. \ref canRead() et al will set \ref canMSG_EXT and/or \ref canMSG_STD as usual
2052 * and are not affected by this call.
2053 */
2054#define canIOCTL_PREFER_EXT 1
2055
2056 /**
2057 * This define is used in \ref canIoCtl(), \a buf and \a buflen refers to this
2058 * functions arguments.
2059 *
2060 * Tells CANLIB to "prefer" standard identifiers; that is, if you send a
2061 * message with \ref canWrite() and don't specify \ref canMSG_EXT nor \ref canMSG_STD,
2062 * \ref canMSG_STD will be assumed. The contents of \a buf and \a buflen are
2063 * ignored. \ref canRead() et al will set \ref canMSG_EXT and/or \ref canMSG_STD as usual
2064 * and are not affected by this call.
2065 */
2066#define canIOCTL_PREFER_STD 2
2067// 3,4 reserved.
2068
2069 /**
2070 * This define is used in \ref canIoCtl(), \a buf and \a buflen refers to this
2071 * functions arguments.
2072 *
2073 * Tells CANLIB to clear the CAN error counters. The contents of \a buf and \a
2074 * buflen are ignored.
2075 *
2076 * \note Not all CAN controllers support this operation (and if they don't,
2077 * nothing will happen.)
2078 */
2079#define canIOCTL_CLEAR_ERROR_COUNTERS 5
2080
2081 /**
2082 * This define is used in \ref canIoCtl(), \a buf mentioned below refers to this
2083 * functions argument.
2084 *
2085 * \a buf points to a DWORD which contains the desired time-stamp clock
2086 * resolution in microseconds. The default value is 1000 microseconds, i.e.
2087 * one millisecond.
2088 *
2089 * \note The accuracy of the clock isn't affected.
2090 */
2091#define canIOCTL_SET_TIMER_SCALE 6
2092
2093 /**
2094 * This define is used in \ref canIoCtl(), \a buf mentioned below refers to this
2095 * functions argument.
2096 *
2097 * \a buf points to a DWORD which contains
2098 *
2099 * \li 0: to turn Transmit Acknowledges off.
2100 * \li 1: to turn Transmit Acknowledges on.
2101 * \li 2: to turn Transmit Acknowledges off, even for the driver's internal
2102 * usage. This might enhance performance but will cause some other APIs to
2103 * stop working (for example, the current size of the transmit queue can not
2104 * be read when this mode is active.)
2105 *
2106 * The default value is 0, Transmit Acknowledge is off.
2107 */
2108#define canIOCTL_SET_TXACK 7
2109
2110 /**
2111 * This define is used in \ref canIoCtl(), \a buf mentioned below refers to this
2112 * functions argument.
2113 *
2114 * \a buf points at a \c DWORD which receives the current RX queue level. The
2115 * returned value is approximative (this is because not all hardware supports
2116 * retrieving the queue levels. In that case a best-effort guess is
2117 * returned. Also note that a device with embedded CPU will report its queue
2118 * levels to the host computer after a short delay that depends on the bus
2119 * traffic intensity, and consequently the value returned by the call to
2120 * \ref canIoCtl() might be a few milliseconds old.)
2121 */
2122#define canIOCTL_GET_RX_BUFFER_LEVEL 8
2123
2124 /**
2125 * This define is used in \ref canIoCtl(), \a buf mentioned below refers to this
2126 * functions argument.
2127 *
2128 * \a buf points at a \c DWORD which receives the current TX queue level. The
2129 * returned value is approximative (this is because not all hardware supports
2130 * retrieving the queue levels. In that case a best-effort guess is
2131 * returned. Also note that a device with embedded CPU will report its queue
2132 * levels to the host computer after a short delay that depends on the bus
2133 * traffic intensity, and consequently the value returned by the call to
2134 * \ref canIoCtl() might be a few milliseconds old.)
2135 */
2136#define canIOCTL_GET_TX_BUFFER_LEVEL 9
2137
2138 /**
2139 * This define is used in \ref canIoCtl(), \a buf and \a buflen refers to this
2140 * functions arguments.
2141 *
2142 * Discard the current contents of the RX queue. The values of \a buf and \a
2143 * buflen are ignored.
2144 *
2145 * \note This is the same thing as calling \ref canFlushReceiveQueue()
2146 */
2147#define canIOCTL_FLUSH_RX_BUFFER 10
2148
2149 /**
2150 * This define is used in \ref canIoCtl(), \a buf and \a buflen refers to this
2151 * functions arguments.
2152 *
2153 * Discard the current contents of the TX queue. The values of \a buf and \a
2154 * buflen are ignored.
2155 *
2156 * \note This is the same thing as calling \ref canFlushTransmitQueue().
2157 */
2158#define canIOCTL_FLUSH_TX_BUFFER 11
2159
2160 /**
2161 * This define is used in \ref canIoCtl(), \a buf mentioned below refers to this
2162 * functions argument.
2163 *
2164 * \a buf points to a \c DWORD which contains the desired time-stamp clock
2165 * resolution in microseconds. Note that the accuracy of the clock isn't
2166 * affected. The default value is 1000 microseconds, i.e. one millisecond.
2167 */
2168#define canIOCTL_GET_TIMER_SCALE 12
2169
2170 /**
2171 * This define is used in \ref canIoCtl(), \a buf mentioned below refers to this
2172 * functions argument.
2173 *
2174 * \a buf points to a \c DWORD which contains
2175 *
2176 * \li \c 0 to turn Transmit Requests off.
2177 * \li \c 1 to turn Transmit Requests on.
2178 *
2179 * Default value is \c 0, Transmit Requests off.
2180 */
2181#define canIOCTL_SET_TXRQ 13
2182
2183 /**
2184 * This define is used in \ref canIoCtl(), \a buf mentioned below refers to this
2185 * functions argument.
2186 *
2187 * \a buf points at a \c DWORD which receives a Windows Event handle which can
2188 * be passed to the Win32 API \c WaitForSingleObject. The event is signaled
2189 * when "something" (typically that a CAN message has been received or
2190 * transmitted) happens in the driver.
2191 *
2192 * \note There is no more information available as to what happened when this
2193 * call returns. The call may return on an "internal" event in CANLIB and your
2194 * application must be prepared to handle this (i.e. go to sleep again.)
2195 * \note If \ref canWaitForEvent() returns with success status (\ref canOK), you must call
2196 * \ref canRead() repeatedly until it returns \ref canERR_NOMSG, before calling
2197 * \ref canWaitForEvent() again. This will flush the driver's internal event queues.
2198 * Failure to call \ref canRead() can cause \ref canWaitForEvent() to get stuck in a state
2199 * where it always sleeps for the specified timeout and then returns with
2200 * \ref canERR_TIMEOUT.
2201 *
2202 * \sa \ref canWaitForEvent()
2203 *
2204 * \note You must not set, reset, nor close this handle. Waiting on it is
2205 * the only supported operation.
2206 */
2207#define canIOCTL_GET_EVENTHANDLE 14
2208
2209 /**
2210 * This define is used in \ref canIoCtl(), \a buf mentioned below refers to this
2211 * functions argument.
2212 *
2213 * \note Not yet implemented.
2214 */
2215#define canIOCTL_SET_BYPASS_MODE 15
2216
2217 /**
2218 * This define is used in \ref canIoCtl().
2219 *
2220 * This is only intended for internal use.
2221 */
2222#define canIOCTL_SET_WAKEUP 16
2223
2224#if defined(CANLIB_DECLARE_ALL)
2225
2226 /**
2227 * This define is used in \ref canIoCtl(), \a buf mentioned below refers to this
2228 * functions argument.
2229 *
2230 * \a buf points to a HANDLE which receives the Windows handle related to the
2231 * CANLIB handle.
2232 */
2233# define canIOCTL_GET_DRIVERHANDLE 17
2234
2235 /**
2236 * This define is used in \ref canIoCtl().
2237 *
2238 * This is only intended for internal use.
2239 */
2240# define canIOCTL_MAP_RXQUEUE 18
2241
2242 /**
2243 * This define is used in \ref canIoCtl().
2244 *
2245 * This is only intended for internal use.
2246 */
2247# define canIOCTL_GET_WAKEUP 19
2248
2249 /**
2250 * This define is used in \ref canIoCtl(), \a buf mentioned below refers to this
2251 * functions argument.
2252 *
2253 * \a buf points to a BYTE which contains
2254 *
2255 * \li \c 0 to turn access error reporting off, and
2256 * \li \c 1 to turn access error reporting on.
2257 *
2258 * Default value is \c 0, access error reporting off.
2259 */
2260# define canIOCTL_SET_REPORT_ACCESS_ERRORS 20
2261
2262 /**
2263 * This define is used in \ref canIoCtl(), \a buf mentioned below refers to this
2264 * functions argument.
2265 *
2266 * \a buf points to a BYTE which receives the current setting of the access
2267 * error reporting (0 or 1.)
2268 */
2269# define canIOCTL_GET_REPORT_ACCESS_ERRORS 21
2270
2271 /**
2272 * This define is used in \ref canIoCtl(), \a buf mentioned below refers to this
2273 * functions argument.
2274 *
2275 * Connects the handle to the virtual bus number (0..31) which the \a buf
2276 * points to.
2277 */
2278# define canIOCTL_CONNECT_TO_VIRTUAL_BUS 22
2279
2280 /**
2281 * This define is used in \ref canIoCtl(), \a buf mentioned below refers to this
2282 * functions argument.
2283 *
2284 * Disonnects the handle from the virtual bus number (0..31) which the \a buf
2285 * points to.
2286 */
2287# define canIOCTL_DISCONNECT_FROM_VIRTUAL_BUS 23
2288
2289 /**
2290 * This define is used in \ref canIoCtl(), \a buf mentioned below refers to this
2291 * functions argument.
2292 *
2293 * \a buf points to a \ref canUserIoPortData struct that contains a port number
2294 * and a port value to set. This is used by special hardware only.
2295 */
2296# define canIOCTL_SET_USER_IOPORT 24
2297
2298 /**
2299 * This define is used in \ref canIoCtl(), \a buf mentioned below refers to this
2300 * functions argument.
2301 *
2302 * \a buf points to a \ref canUserIoPortData struct that contains a port
2303 * number. After the call, the struct will contain the current value of the
2304 * I/O port. This is used by special hardware only.
2305 */
2306# define canIOCTL_GET_USER_IOPORT 25
2307
2308 /**
2309 * This define is used in \ref canIoCtl().
2310 *
2311 * This is only intended for internal use.
2312 */
2313# define canIOCTL_SET_BUFFER_WRAPAROUND_MODE 26
2314
2315 /**
2316 * This define is used in \ref canIoCtl(), \a buf mentioned below refers to this
2317 * functions argument.
2318 *
2319 * Use this function code to set the size of the receive buffer for a
2320 * specific handle. \a buf points to an unsigned integer which contains the
2321 * new size (number of messages) of the receive buffer.
2322 *
2323 * \note The receive buffer consumes system nonpaged pool memory, which is a
2324 * limited resource. Do not increase the receive buffer size unless you
2325 * have good reasons to do so.
2326 *
2327 * \note You can't use this function code when the channel is on bus.
2328 */
2329# define canIOCTL_SET_RX_QUEUE_SIZE 27
2330
2331 /**
2332 * This define is used in \ref canIoCtl().
2333 *
2334 * This is only intended for internal use.
2335 */
2336# define canIOCTL_SET_USB_THROTTLE 28
2337
2338 /**
2339 * This define is used in \ref canIoCtl().
2340 *
2341 * This is only intended for internal use.
2342 */
2343# define canIOCTL_GET_USB_THROTTLE 29
2344
2345 /**
2346 * This define is used in \ref canIoCtl(), \a buf mentioned below refers to this
2347 * functions argument.
2348 *
2349 * \a buf points to a DWORD. If the value is zero, the CAN clock will not be
2350 * reset at buson for the handle. Otherwise, the CAN clock will be reset at
2351 * buson.
2352 *
2353 * Default value is \c 1, the CAN clock will be reset at buson.
2354 */
2355# define canIOCTL_SET_BUSON_TIME_AUTO_RESET 30
2356
2357 /**
2358 * This define is used in \ref canIoCtl(), \a buf mentioned below refers to this
2359 * functions argument.
2360 *
2361 * Returns the state of the Transmit Acknowledge as a DWORD in \a buf:
2362 *
2363 * \li 0: Transmit Acknowledges is turned off.
2364 * \li 1: Transmit Acknowledges is turned on.
2365 * \li 2: Transmit Acknowledges is turned off, even for the driver's internal
2366 * usage.
2367 */
2368# define canIOCTL_GET_TXACK 31
2369
2370 /**
2371 * This define is used in \ref canIoCtl(), \a buf mentioned below refers to this
2372 * functions argument.
2373 *
2374 * \a buf points to an unsigned byte. If the value is zero, the local transmit
2375 * echo is turned off for the handle. Otherwise, local transmit echo is turned
2376 * on.
2377 *
2378 * Local transmit echo is turned on by default on all handles. This means
2379 * that if two handles are open on the same channel, and a message is
2380 * transmitted on the first handle, it will be received as a normal message
2381 * on the second handle. Use the \ref canIOCTL_SET_LOCAL_TXECHO function code to
2382 * turn this function off, if it is not desired on a certain handle.
2383 */
2384# define canIOCTL_SET_LOCAL_TXECHO 32
2385
2386 /**
2387 * This define is used in \ref canIoCtl(), \a buf mentioned below refers to this
2388 * functions argument.
2389 *
2390 * \a buf points to an unsigned byte. If the value is zero, the reporting of
2391 * error frames is turned off for the handle. Otherwise, error frame reporting
2392 * is turned on.
2393 *
2394 * Default value is \c 1, error frame reporting is turned on.
2395 */
2396# define canIOCTL_SET_ERROR_FRAMES_REPORTING 33
2397
2398 /**
2399 * This define is used in \ref canIoCtl(), \a buf mentioned below refers to this
2400 * functions argument.
2401 *
2402 * \a buf points to a 32-bit unsigned integer that receives the quality of
2403 * the channel, where the quality is measured in percent of optimal quality.
2404 *
2405 * For a WLAN, -90 dBm and -35 dBm are considered 0% and 100%, respectively.
2406 *
2407 * The quality is 100% for any directly connected channel (USB, PCI etc.).
2408 */
2409# define canIOCTL_GET_CHANNEL_QUALITY 34
2410
2411 /**
2412 * This define is used in \ref canIoCtl(), \a buf mentioned below refers to this
2413 * functions argument.
2414 *
2415 * \a buf points to a \c DWORD that contains the roundtrip time measured in
2416 * milliseconds.
2417 */
2418# define canIOCTL_GET_ROUNDTRIP_TIME 35
2419
2420 /**
2421 * This define is used in \ref canIoCtl(), \a buf mentioned below refers to this
2422 * functions argument.
2423 *
2424 * \a buf points to a \c DWORD that contains the \ref kvBUSTYPE_GROUP_xxx bus type.
2425 */
2426# define canIOCTL_GET_BUS_TYPE 36
2427
2428 /**
2429 * This define is used in \ref canIoCtl(), \a buf mentioned below refers to this
2430 * functions argument.
2431 *
2432 * \a buf points to a CHAR array of at least 32 characters which receives the
2433 * current device name as a \c NULL terminated ASCII string.
2434 *
2435 * If device name is not set or the device does not support this
2436 * functionality, an error will be returned.
2437 */
2438# define canIOCTL_GET_DEVNAME_ASCII 37
2439
2440 /**
2441 * This define is used in \ref canIoCtl(), \a buf mentioned below refers to this
2442 * functions argument.
2443 *
2444 * \a buf points to a \c DWORD that contains the time in milliseconds since the last
2445 * communication occured.
2446 *
2447 * For WLAN devices, this is the time since the last keep-alive message.
2448 */
2449# define canIOCTL_GET_TIME_SINCE_LAST_SEEN 38
2450
2451
2452 /**
2453 * This define is used in \ref canIoCtl(), \a buf mentioned below refers to this
2454 * functions argument.
2455 *
2456 * Obtain the time reference list for MagiSync devices.
2457 *
2458 * \a buf points to an array of pairs of 64-bit ints, one of which
2459 * will contain the reference number and the other one the timestamp
2460 * in nanoseconds.
2461 *
2462 * \note This function is subject to change in future releases and is
2463 * not supported by Kvaser.
2464 */
2465# define canIOCTL_GET_TREF_LIST 39
2466
2467 /**
2468 * This define is used in \ref canIoCtl(), \a buf mentioned below refers to this
2469 * functions argument.
2470 *
2471 * \a buf points to a \c DWORD that contains the number of microseconds
2472 * the minimum CAN message transmit interval should be set to, or 0xffffffff
2473 * to fetch the current setting.
2474 * The minimum interval can not be set to more than one second.
2475 *
2476 * When a CAN channel goes bus on, the minimum interval is set to zero.
2477 * I.e. CAN transmissions happen at the maximum speed the device is capable of.
2478 *
2479 * If the device does not support this functionality, or if an invalid
2480 * minimum interval is requested, an error will be returned.
2481 *
2482 * \note The minimum CAN messages transmit interval applies to the physical CAN
2483 * channel. It will thus affect all messages transmitted, even those sent
2484 * using other CANlib handles to the same physical channel. The interval
2485 * is defined as the time from the successful completion of one transmit
2486 * to the beginning of the next one.
2487 */
2488# define canIOCTL_TX_INTERVAL 40
2489
2490 /**
2491 * Obsolete, use \ref canIOCTL_SET_THROTTLE_SCALED instead
2492 */
2493# define canIOCTL_SET_USB_THROTTLE_SCALED 41
2494
2495 /**
2496 * This define is used in \ref canIoCtl(), \a buf mentioned below refers to this
2497 * functions argument.
2498 *
2499 * This ioctl can be used to set the responsitivity of some devices.
2500 * \a buf points to a \c DWORD that should contain a value between 0 and 100.
2501 * A value of 0 means that the device should be very responsive and a value
2502 * of 100 means that the device generates less cpu load or requires more bandwidth.
2503 * Note that not all
2504 * devices support this. Some hardware will accept this command but neglect it.
2505 * This can be found out by reading the scaled throttle.
2506 */
2507# define canIOCTL_SET_THROTTLE_SCALED 41
2508
2509 /**
2510 * Obsolete, use \ref canIOCTL_GET_THROTTLE_SCALED instead
2511 */
2512# define canIOCTL_GET_USB_THROTTLE_SCALED 42
2513
2514 /**
2515 * This define is used in \ref canIoCtl(), \a buf mentioned below refers to this
2516 * functions argument.
2517 *
2518 * This ioctl can be used to set the responsitivity of some devices.
2519 * \a buf points to a \c DWORD that should contain a value between 0 and 100.
2520 * A value of 0 means that the device should be very responsive and a value
2521 * of 100 means that the device generates less cpu load or requires more bandwidth.
2522 * Note that not all
2523 * devices support this. Some hardware will accept this command but neglect it.
2524 * This can be found out by reading the scaled throttle.
2525 */
2526# define canIOCTL_GET_THROTTLE_SCALED 42
2527
2528 /**
2529 * This define is used in \ref canIoCtl(), \a buf mentioned below refers to this
2530 * functions argument.
2531 *
2532 * Some hardware have bitrate limits, which must be met when using any of \a canSetBusParams(),
2533 * \a canSetBusParamsC200(), \a canGetBusParams() functions
2534 * which can be overriden with this IOCTL.
2535 * \a buf points to a \c long value that contains a user defined bitrate.
2536 * A value of 0 means that the device should use its own default bitrate limit.
2537 */
2538# define canIOCTL_SET_BRLIMIT 43
2539
2540#endif
2541 /** @} */
2542
2543#if defined(CANLIB_DECLARE_ALL)
2544/** Used in \ref canIOCTL_SET_USER_IOPORT and \ref canIOCTL_GET_USER_IOPORT. */
2545typedef struct {
2546 unsigned int portNo; ///< Port number used in e.g. \ref canIOCTL_SET_USER_IOPORT
2547 unsigned int portValue; ///< Port value used in e.g. \ref canIOCTL_SET_USER_IOPORT
2548} canUserIoPortData;
2549
2550#endif
2551
2552#if defined(CANLIB_DECLARE_ALL)
2553/**
2554 * \ingroup Notification and Waiting
2555 *
2556 * \source_cs <b>static Canlib.canStatus canWaitForEvent(int hnd, ulong timeout);</b>
2557 *
2558 * \source_delphi <b>function canWaitForEvent(hnd: canHandle; timeout: Cardinal): canStatus; </b>
2559 * \source_end
2560 *
2561 * Waits for an event (of any kind) to happen at the specified CAN circuit, or
2562 * a timeout to occur. An event in this context means for example the arrival
2563 * of a CAN message or a CAN bus status change, but it can also be an event
2564 * internal to the driver.
2565 *
2566 * \param[in] hnd A handle to an open CAN circuit.
2567 * \param[in] timeout The number of milliseconds to wait before the call
2568 * returns, if no event occurs. 0xFFFFFFFF gives an
2569 * infinite timeout.
2570 *
2571 * \return \ref canOK (zero) if an event happened during the specified time
2572 * period.
2573 * \return \ref canERR_TIMEOUT (negative) if nothing happened during the specified
2574 * time period.
2575 * \return \ref canERR_xxx (negative) if failure.
2576 *
2577 * \sa \ref page_code_snippets_examples,
2578 * \ref page_user_guide_send_recv_asynch_not
2579 * \sa \ref canRead()
2580 */
2581canStatus CANLIBAPI canWaitForEvent (const CanHandle hnd, DWORD timeout);
2582#endif
2583
2584/**
2585 * \ingroup CAN
2586 *
2587 * \source_cs <b>static Canlib.canStatus canSetBusParamsC200(int hnd, byte btr0, byte btr1);</b>
2588 *
2589 * \source_delphi <b>function canSetBusParamsC200(hnd: canHandle; btr0, btr1: byte): canStatus; </b>
2590 * \source_end
2591 *
2592 * This function sets the bus timing parameters using the same
2593 * convention as the 82c200 CAN controller (which is the same as many
2594 * other CAN controllers, for example, the 82527.)
2595 *
2596 * To calculate the bit timing parameters, you can use the bit timing
2597 * calculator that is included with CANLIB SDK. Look in the BIN directory.
2598 *
2599 * 82c200 Bit Timing
2600 *
2601 * \li \a btr0 [b7..b6]: SJW - 1
2602 * \li \a btr0 [b5..b0]: Prescaler -1
2603 * \li \a btr1 [b7]: \c 1: 3 samples, \c 0: 1 samples
2604 * \li \a btr1 [b6..b4]: tseg2 - 1
2605 * \li \a btr1 [b3..b0]: tseg1 - 2
2606 *
2607 * \note CANLIB will always behave as if the clock frequency is 16 MHz. It does
2608 * not matter if the device has a different physical clock, since this will be
2609 * compensated for by the driver.
2610 *
2611 * \param[in] hnd A handle to an open CAN circuit.
2612 * \param[in] btr0 The desired bit timing, formatted as the contents of the
2613 * BTR0 register in the 82c200.
2614 * \param[in] btr1 The desired bit timing, formatted as the contents of the
2615 * BTR1 register in the 82c200.
2616 *
2617 * \return \ref canOK (zero) if success
2618 * \return \ref canERR_xxx (negative) if failure
2619 *
2620 *
2621 * \sa \ref page_code_snippets_bit_rate, \ref page_user_guide_misc_bitrate
2622 * \sa \ref canSetBusParams()
2623 */
2624canStatus CANLIBAPI canSetBusParamsC200 (const CanHandle hnd, BYTE btr0, BYTE btr1);
2625
2626#if defined(CANLIB_DECLARE_ALL)
2627
2628/**
2629 * \ingroup CAN
2630 *
2631 * \win_start
2632 * \source_cs <b>static Canlib.canStatus canSetDriverMode(int hnd, int lineMode, int resNet);</b>
2633 *
2634 * \source_delphi <b>function canSetDriverMode(hnd: canHandle; lineMode, resNet: Integer): canStatus; </b>
2635 * \source_end
2636 *
2637 * This function sets the current CAN bus driver mode. This is
2638 * typically a mode like sleep, wakeup, standby, fast mode, etc. The
2639 * different modes are almost always hardware dependent and requires
2640 * special DRVcan cables. As an example, the DRVcan S implements J2411
2641 * compliant single-wire CAN and supports four line modes, namely
2642 * Normal, Sleep, Fast and Wakeup.
2643 *
2644 * Standard ISO 11898 CAN do not support any of these bus driver modes.
2645 *
2646 * \note The bus driver mode is typically used to control things like one- or
2647 * two-wire mode, sleep mode, and so on. It requires special support in the CAN
2648 * driver circuit.
2649 *
2650 * \param[in] hnd An open handle to a CAN circuit.
2651 * \param[in] lineMode An int which defines the line mode,
2652 * \ref canTRANSCEIVER_LINEMODE_xxx.
2653 * \param[in] resNet An int which defines the resnet mode. Set this parameter to
2654 * \ref canTRANSCEIVER_RESNET_NA unless you have good reasons to set it
2655 * to something else.
2656 *
2657 * \return \ref canOK (zero) if success
2658 * \return \ref canERR_xxx (negative) if failure
2659 *
2660 * \sa \ref canGetDriverMode()
2661 * \win_end
2662 * \linux_start
2663 * Not implemented.
2664 * \linux_end
2665 */
2666canStatus CANLIBAPI canSetDriverMode (const CanHandle hnd, int lineMode, int resNet);
2667
2668/**
2669 * \ingroup CAN
2670 *
2671 * \win_start
2672 * \source_cs <b>static Canlib.canStatus canGetDriverMode(int hnd, out int lineMode, out int resNet);</b>
2673 *
2674 * \source_delphi <b>function canGetDriverMode(hnd: canHandle; var lineMode: Integer; var resNet: Integer): canStatus; </b>
2675 * \source_end
2676 *
2677 * This function retrieves the current CAN bus driver mode. This is typically a
2678 * mode like sleep, wakeup, standby, fast mode, etc. The different modes are
2679 * almost always hardware dependent and requires special DRVcan cables. As an
2680 * example, the DRVcan S implements J2411 compliant single-wire CAN and
2681 * supports four line modes, namely Normal, Sleep, Fast and Wakeup.
2682 *
2683 * Standard ISO 11898 CAN do not support any of these bus driver modes.
2684 *
2685 * \note The bus driver mode is typically used to control things like one- or
2686 * two-wire mode, sleep mode, and so on. It requires special support in the CAN
2687 * driver circuit.
2688 *
2689 * \param[in] hnd An open handle to a CAN circuit.
2690 * \param[out] lineMode A pointer to an int which receives the current line
2691 * mode (\ref canTRANSCEIVER_LINEMODE_xxx).
2692 * \param[out] resNet A pointer to an int which receives the current resnet
2693 * mode. This value is usually
2694 * \ref canTRANSCEIVER_RESNET_NA except for special DRVcan
2695 * cables.
2696 *
2697 * \return \ref canOK (zero) if success
2698 * \return \ref canERR_xxx (negative) if failure
2699 *
2700 * \sa \ref canSetDriverMode()
2701 * \win_end
2702 * \linux_start
2703 * Not implemented.
2704 * \linux_end
2705 *
2706 */
2707canStatus CANLIBAPI canGetDriverMode (const CanHandle hnd, int *lineMode, int *resNet);
2708#endif
2709
2710/**
2711 * \name canVERSION_CANLIB32_xxx
2712 * \anchor canVERSION_CANLIB32_xxx
2713 * @{
2714 * Item codes for canGetVersionEx().
2715 */
2716
2717 /**
2718 * This define is used in \ref canGetVersionEx() and controls which version number
2719 * that returned.
2720 *
2721 * Version number of the canlib32.dll file coded as an unsigned 16-bit word
2722 * with the major version number in the upper byte and the minor version
2723 * number in the lower byte. This version number is not related to the
2724 * product version number of the whole CANLIB. For example, canlib32.dll
2725 * belonging to CANLIB 2.27 would return 0x305.
2726 */
2727#define canVERSION_CANLIB32_VERSION 0
2728
2729 /**
2730 * This define is used in \ref canGetVersionEx() and controls what type of version
2731 * number that is returned.
2732 *
2733 * Product version number of canlib32.dll coded as an unsigned 16-bit word
2734 * with the major version number in the upper byte and the minor version
2735 * number in the lower byte. The product version number corresponds to the
2736 * version number of the whole CANLIB. For example, canlib32.dll belonging to
2737 * CANLIB 2.27 would return 0x21B.
2738 */
2739#define canVERSION_CANLIB32_PRODVER 1
2740
2741 /**
2742 * This define is used in \ref canGetVersionEx() and controls what type of version
2743 * number that is returned.
2744 *
2745 * Product version number of canlib32.dll coded as an unsigned 32-bit word
2746 * where the bytes contain (in order from the most significant to the least
2747 * significant byte) 0, major version number, minor version number, and the
2748 * minor version letter. (The minor version letter is the ASCII code for the
2749 * letter, or 0 (zero) if no letter). For example, CANLIB 3.8 would return
2750 * 0x00030800 and CANLIB 3.8a would return 0x00030861.
2751 */
2752#define canVERSION_CANLIB32_PRODVER32 2
2753
2754 /**
2755 * This define is used in \ref canGetVersionEx() and controls what type of version
2756 * number that is returned.
2757 *
2758 * Returns 1 if the present version is a beta (preview) release, or 0 if it
2759 * is an official release.
2760 */
2761#define canVERSION_CANLIB32_BETA 3
2762/** @} */
2763
2764#if defined(CANLIB_DECLARE_ALL)
2765
2766/**
2767 * \ingroup Information Services
2768 *
2769 * \source_cs <b>static int canGetVersionEx(int itemCode);</b>
2770 *
2771 * \source_delphi <b>function canGetVersionEx(itemCode: Cardinal): Cardinal; </b>
2772 * \source_end
2773 *
2774 * This function returns various version numbers from the driver routines.
2775 *
2776 * \param[in] itemCode Specifies which version number to retrieve. See
2777 * \ref canVERSION_CANLIB32_xxx
2778 *
2779 * \return The return value is desired version number.
2780 *
2781 * \sa \ref page_user_guide_build_driver_version
2782 */
2783unsigned int CANLIBAPI canGetVersionEx (unsigned int itemCode);
2784
2785/**
2786 * \ingroup NamedParameterSettings
2787 *
2788 * \source_cs <b>static Canlib.canStatus canParamGetCount();</b>
2789 *
2790 * \source_delphi <b>function canParamGetCount(): canStatus; </b>
2791 * \source_end
2792 *
2793 * This function returns the number of entries in the table of named
2794 * channels.
2795 *
2796 * \return The number of channels (zero or positive)
2797 * \return \ref canERR_xxx (negative) if failure
2798 *
2799 * \sa \ref page_user_guide_misc_named_parameters
2800 *
2801 */
2802canStatus CANLIBAPI canParamGetCount (void);
2803
2804/**
2805 * \ingroup NamedParameterSettings
2806 *
2807 * \source_cs <b>static Canlib.canStatus canParamCommitChanges();</b>
2808 *
2809 * \source_delphi <b>function canParamCommitChanges(): canStatus; </b>
2810 * \source_end
2811 *
2812 * This function writes the current set of named parameters to the
2813 * Registry. Previous entries are erased.
2814 *
2815 * The named parameters are stored in the
2816 * \c HKEY_LOCAL_MACHINE\\SOFTWARE\\KVASER \c AB\\CANLIB32\\PredefinedBitrates
2817 * key in the Registry.
2818 *
2819 * \note You must have Administrator's rights to write to the Registry.
2820 *
2821 * \return \ref canOK (zero) if success
2822 * \return \ref canERR_xxx (negative) if failure
2823 *
2824 * \sa \ref page_user_guide_misc_named_parameters
2825 *
2826 */
2827canStatus CANLIBAPI canParamCommitChanges (void);
2828
2829/**
2830 * \ingroup NamedParameterSettings
2831 *
2832 * \source_cs <b>static Canlib.canStatus canParamDeleteEntry(int index);</b>
2833 *
2834 * \source_delphi <b>function canParamDeleteEntry(index: Integer): canStatus; </b>
2835 * \source_end
2836 *
2837 * This function deletes the entry in the table of named parameter settings
2838 * with the given index. The entries below (i.e. with higher indices) the
2839 * deleted entry are moved up one step in the table.
2840 *
2841 * The named parameters are stored in the
2842 * \c HKEY_LOCAL_MACHINE\\SOFTWARE\\KVASER \c AB\\CANLIB32\\PredefinedBitrates
2843 * key in the Registry.
2844 *
2845 * \param[in] index The index of the entry to delete.
2846 *
2847 * \return \ref canOK (zero) if success
2848 * \return \ref canERR_xxx (negative) if failure
2849 *
2850 * \sa \ref page_user_guide_misc_named_parameters
2851 * \sa \ref canParamCreateNewEntry(), \ref canParamCommitChanges()
2852 */
2853canStatus CANLIBAPI canParamDeleteEntry (int index);
2854
2855/**
2856 * \ingroup NamedParameterSettings
2857 *
2858 * \source_cs <b>static int canParamCreateNewEntry();</b>
2859 *
2860 * \source_delphi <b>function canParamCreateNewEntry(): canStatus; </b>
2861 * \source_end
2862 *
2863 * This function creates a new entry in the table of named parameter
2864 * settings.
2865 *
2866 * The named parameters are stored in the
2867 * \c HKEY_LOCAL_MACHINE\\SOFTWARE\\KVASER \c AB\\CANLIB32\\PredefinedBitrates
2868 * key in the Registry.
2869 *
2870 * \return The index of the created entry (zero or positive) if success
2871 * \return \ref canERR_xxx (negative) if failure
2872 *
2873 * \sa \ref page_user_guide_misc_named_parameters
2874 * \sa \ref canParamCommitChanges(), \ref canParamDeleteEntry()
2875 *
2876 */
2877canStatus CANLIBAPI canParamCreateNewEntry (void);
2878
2879/**
2880 * \ingroup NamedParameterSettings
2881 *
2882 * \source_cs <b>static Canlib.canStatus canParamSwapEntries(int index1, int index2);</b>
2883 *
2884 * \source_delphi <b>function canParamSwapEntries(index1, index2: Integer): canStatus; </b>
2885 * \source_end
2886 *
2887 * This function swaps two entries in the list of named
2888 * parameters.
2889 *
2890 * The named parameters are stored in the
2891 * \c HKEY_LOCAL_MACHINE\\SOFTWARE\\KVASER \c AB\\CANLIB32\\PredefinedBitrates
2892 * key in the Registry.
2893 *
2894 * \param[in] index1 The first of the two entries that are to be swapped in the
2895 * named parameters list.
2896 * \param[in] index2 The second of the two entries that are to be swapped in the
2897 * named parameters list.
2898 *
2899 * \return \ref canOK (zero) if success
2900 * \return \ref canERR_xxx (negative) if failure
2901 *
2902 * \sa \ref page_user_guide_misc_named_parameters
2903 * \sa \ref canParamCommitChanges()
2904 *
2905 */
2906canStatus CANLIBAPI canParamSwapEntries (int index1, int index2);
2907
2908/**
2909 * \ingroup NamedParameterSettings
2910 *
2911 * \source_cs <b>static Canlib.canStatus canParamGetName(int index, ref string str_buf);</b>
2912 *
2913 * \source_delphi <b>function canParamGetName(index: Integer; buffer: PChar; maxlen: Integer): canStatus; </b>
2914 * \source_end
2915 *
2916 * This function returns the name of a given entry in the list of
2917 * named parameters.
2918 *
2919 * The named parameters are stored in the
2920 * \c HKEY_LOCAL_MACHINE\\SOFTWARE\\KVASER \c AB\\CANLIB32\\PredefinedBitrates
2921 * key in the Registry.
2922 *
2923 * \param[in] index The index of the entry in the named parameters list, whose
2924 * name is to be returned.
2925 * \param[out] buffer A pointer to a buffer that is to receive a
2926 * \c NULL terminated string which contains the name. The
2927 * buffer is allocated and deallocated by the user.
2928 * \param[in] maxlen The length of the buffer.
2929 *
2930 * \return \ref canOK (zero) if success
2931 * \return \ref canERR_xxx (negative) if failure
2932 *
2933 * \sa \ref page_user_guide_misc_named_parameters
2934 * \sa \ref canParamSetName(), \ref canParamCommitChanges()
2935 */
2936canStatus CANLIBAPI canParamGetName (int index, char *buffer, int maxlen);
2937
2938/**
2939 * \ingroup NamedParameterSettings
2940 *
2941 * \source_cs <b>static int canParamGetChannelNumber(int index);</b>
2942 *
2943 * \source_delphi <b>function canParamGetChannelNumber(index: Integer): canStatus; </b>
2944 * \source_end
2945 *
2946 * This function returns the channel number of the entry with the
2947 * given index in the table of named parameter settings.
2948 *
2949 * \param[in] index The index of the entry in the table of named parameter
2950 * settings.
2951 *
2952 * \return The channel number of the entry in question (zero or positive)
2953 * \return \ref canERR_xxx (negative) if failure
2954 *
2955 * \sa \ref page_user_guide_misc_named_parameters
2956 * \sa \ref canParamCommitChanges(), \ref canParamGetChannelNumber()
2957 */
2958canStatus CANLIBAPI canParamGetChannelNumber (int index);
2959
2960/**
2961 * \ingroup NamedParameterSettings
2962 *
2963 * \source_cs <b>static Canlib.canStatus canParamGetBusParams(int index, out int bitrate, out int tseg1, out int tseg2, out int sjw, out int noSamp);</b>
2964 *
2965 * \source_delphi <b>function canParamGetBusParams(index: Integer; var bitrate: LongInt; var tseg1: Cardinal; var tseg2: Cardinal; var sjw: Cardinal; var nosamp: Cardinal): canStatus; </b>
2966 * \source_end
2967 *
2968 * This function retrieves the bus parameters associated with the
2969 * entry with the given index in the table of named parameter
2970 * settings.
2971 *
2972 * \param[in] index The index of the entry in the table of named parameter
2973 * settings.
2974 * \param[out] bitrate Bit rate (bits per second).
2975 * \param[out] tseg1 Time segment 1, that is, the number of quanta from (but
2976 * not including) the Sync Segment to the sampling point.
2977 * \param[out] tseg2 Time segment 2, that is, the number of quanta from the
2978 * sampling point to the end of the bit.
2979 * \param[out] sjw The Synchronization Jump Width; can be 1,2,3, or 4.
2980 * \param[out] noSamp The number of sampling points; can be 1 or 3.
2981 *
2982 * \return \ref canOK (zero) if success
2983 * \return \ref canERR_xxx (negative) if failure
2984 *
2985 * \sa \ref page_user_guide_misc_named_parameters
2986 * \sa \ref canParamCommitChanges(), \ref canParamSetBusParams()
2987 */
2988canStatus CANLIBAPI canParamGetBusParams (int index,
2989 long* bitrate,
2990 unsigned int *tseg1,
2991 unsigned int *tseg2,
2992 unsigned int *sjw,
2993 unsigned int *noSamp);
2994
2995/**
2996 * \ingroup NamedParameterSettings
2997 *
2998 * \source_cs <b>static Canlib.canStatus canParamSetName(int index, string str_buf);</b>
2999 *
3000 * \source_delphi <b>function canParamSetName(index: Integer; buffer: PChar): canStatus; </b>
3001 * \source_end
3002 *
3003 * This function sets or changes the name of a named parameter.
3004 *
3005 * \param[in] index The index of the named parameter whose name is to be
3006 * changed or set.
3007 * \param[out] buffer A pointer to a \c NULL terminated string that contains the
3008 * new name. If the string is longer than the maximum
3009 * allowed name length, it is truncated.
3010 *
3011 * \return \ref canOK (zero) if success
3012 * \return \ref canERR_xxx (negative) if failure
3013 *
3014 * \sa \ref page_user_guide_misc_named_parameters
3015 * \sa \ref canParamCommitChanges(), \ref canParamGetName()
3016 */
3017canStatus CANLIBAPI canParamSetName (int index, const char *buffer);
3018
3019/**
3020 * \ingroup NamedParameterSettings
3021 *
3022 * \source_cs <b>static Canlib.canStatus canParamSetChannelNumber(int index, int channel);</b>
3023 *
3024 * \source_delphi <b>function canParamSetChannelNumber(index, channel: Integer): canStatus; </b>
3025 * \source_end
3026 *
3027 * This function sets the channel number for a specified entry in the list of
3028 * named parameters. Channels are numbered from 0 and up.
3029 *
3030 * \param[in] index The index of the entry in the named parameter list whose
3031 * channel number is to be set.
3032 * \param[in] channel The channel number.
3033 *
3034 * \return \ref canOK (zero) if success
3035 * \return \ref canERR_xxx (negative) if failure
3036 *
3037 * \sa \ref page_user_guide_misc_named_parameters
3038 * \sa \ref canParamCommitChanges(), \ref canParamGetChannelNumber()
3039 */
3040canStatus CANLIBAPI canParamSetChannelNumber (int index, int channel);
3041
3042/**
3043 * \ingroup NamedParameterSettings
3044 *
3045 * \source_cs <b>static Canlib.canStatus canParamSetBusParams(int index, int bitrate, int tseg1, int tseg2, int sjw, int noSamp);</b>
3046 *
3047 * \source_delphi <b>function canParamSetBusParams(index: Integer; bitrate: longint; tseq1, tseq2, sjw, noSamp: Cardinal): canStatus; </b>
3048 * \source_end
3049 *
3050 * This function sets or changes the bus parameters for a given entry in the
3051 * list of named parameters.
3052 *
3053 * \note The bus parameters are not checked for validity.
3054 *
3055 * \param[in] index The index of the entry in the named parameter list whose
3056 * parameters are to be set or changed.
3057 * \param[in] bitrate Bit rate (measured in bits per second); or one of the
3058 * predefined constants \ref canBITRATE_xxx.
3059
3060 * \param[in] tseg1 Time segment 1, that is, the number of quanta from (but not
3061 * including) the Sync Segment to the sampling point.
3062 * \param[in] tseg2 Time segment 2, that is, the number of quanta from the
3063 * sampling point to the end of the bit.
3064
3065 * \param[in] sjw The Synchronization Jump Width; can be 1,2,3, or 4.
3066 * \param[in] noSamp The number of sampling points; can be 1 or 3.
3067 *
3068 * \return \ref canOK (zero) if success
3069 * \return \ref canERR_xxx (negative) if failure
3070 *
3071 * \sa \ref page_user_guide_misc_named_parameters
3072 * \sa \ref canParamCommitChanges(), \ref canParamGetBusParams()
3073 */
3074canStatus CANLIBAPI canParamSetBusParams (int index,
3075 long bitrate,
3076 unsigned int tseg1,
3077 unsigned int tseg2,
3078 unsigned int sjw,
3079 unsigned int noSamp);
3080
3081/**
3082 * \ingroup NamedParameterSettings
3083 *
3084 * \source_cs <b>static Canlib.canStatus canParamFindByName(string str_name);</b>
3085 *
3086 * \source_delphi <b>function canParamFindByName(const Name: PChar):canStatus; </b>
3087 * \source_end
3088 *
3089 * This function returns the index of the parameter setting with the
3090 * given name.
3091 *
3092 * \param[in] name A pointer to a string containing the name of the setting.
3093 *
3094 * \return The index of the setting (zero or positive) if success.
3095 * \return \ref canERR_xxx (negative) if failure
3096 *
3097 * \sa \ref page_user_guide_misc_named_parameters
3098 * \sa \ref canParamCommitChanges()
3099 */
3100canStatus CANLIBAPI canParamFindByName (const char *name);
3101/**
3102 * \ingroup ObjectBuffers
3103 *
3104 * \source_cs <b>static Canlib.canStatus canObjBufFreeAll(int handle);</b>
3105 *
3106 * \source_delphi <b>function canObjBufFreeAll(handle: canHandle): canStatus; </b>
3107 * \source_end
3108 *
3109 * Deallocates all object buffers on the specified handle. The
3110 * buffers cannot be referenced after this operation.
3111 *
3112 * \param[in] hnd An open handle to a CAN circuit.
3113 *
3114 * \return \ref canOK (zero) if success
3115 * \return \ref canERR_xxx (negative) if failure
3116 *
3117 * \sa \ref page_user_guide_send_recv_obj_buf
3118 * \sa \ref canObjBufFree(), \ref canObjBufAllocate()
3119 */
3120canStatus CANLIBAPI canObjBufFreeAll (const CanHandle hnd);
3121
3122/**
3123 * \ingroup ObjectBuffers
3124 *
3125 * \source_cs <b>static Canlib.canStatus canObjBufAllocate(int handle, int type);</b>
3126 *
3127 * \source_delphi <b>function canObjBufAllocate(handle: canHandle; tp: Integer): canStatus; </b>
3128 * \source_end
3129 *
3130 * Allocates an object buffer associated with a handle to a CAN
3131 * circuit.
3132 *
3133 * \param[in] hnd An open handle to a CAN circuit.
3134 * \param[in] type The type of the buffer. Must be one of \ref canOBJBUF_TYPE_xxx
3135 *
3136 * \return A buffer index (zero or positive) if success.
3137 * \return \ref canERR_xxx (negative) if failure
3138 *
3139 * \sa \ref page_user_guide_send_recv_obj_buf
3140 * \sa \ref canObjBufFree(), \ref canObjBufFreeAll()
3141 */
3142canStatus CANLIBAPI canObjBufAllocate (const CanHandle hnd, int type);
3143
3144 /**
3145 * \name canOBJBUF_TYPE_xxx
3146 * \anchor canOBJBUF_TYPE_xxx
3147 *
3148 * Used in \ref canObjBufAllocate().
3149 *
3150 * @{
3151 */
3152#define canOBJBUF_TYPE_AUTO_RESPONSE 0x01 ///< The buffer is an auto-response buffer.
3153#define canOBJBUF_TYPE_PERIODIC_TX 0x02 ///< The buffer is an auto-transmit buffer.
3154 /** @} */
3155
3156/**
3157 * \ingroup ObjectBuffers
3158 *
3159 * \source_cs <b>static Canlib.canStatus canObjBufFree(int handle, int idx);</b>
3160 *
3161 * \source_delphi <b>function canObjBufFree(handle: canHandle; idx: Integer): canStatus; </b>
3162 * \source_end
3163 *
3164 * Deallocates the object buffer with the specified index. The buffer
3165 * can not be referenced after this operation.
3166 *
3167 * \param[in] hnd An open handle to a CAN circuit.
3168 * \param[in] idx The object buffer to deallocate.
3169 *
3170 * \return \ref canOK (zero) if success
3171 * \return \ref canERR_xxx (negative) if failure
3172 *
3173 * \sa \ref page_user_guide_send_recv_obj_buf
3174 * \sa \ref canObjBufFreeAll(), \ref canObjBufAllocate(),
3175 */
3176canStatus CANLIBAPI canObjBufFree (const CanHandle hnd, int idx);
3177
3178// Writes CAN data to the object buffer with the specified index.
3179
3180/**
3181 * \ingroup ObjectBuffers
3182 *
3183 * \source_cs <b>static Canlib.canStatus canObjBufWrite(int handle, int idx, int id, byte[] msg, int dlc, int flags);</b>
3184 *
3185 * \source_delphi <b>function canObjBufWrite(handle: canHandle; idx, id: Integer; var msg; dlc, flags: cardinal): canStatus; </b>
3186 * \source_end
3187 *
3188 * Defines the contents of a specific object buffer.
3189 *
3190 * \param[in] hnd An open handle to a CAN circuit.
3191 * \param[in] idx The index of the object buffer whose contents is to be
3192 * defined.
3193 * \param[in] id The CAN identifier of the message.
3194 * \param[in] msg Points to the contents of the message.
3195 * \param[in] dlc The length of the message. Must be at least 0 and at most 8
3196 * bytes.
3197 * \param[in] flags Message flags; a combination of the \ref canMSG_xxx flags.
3198 *
3199 * \return \ref canOK (zero) if success
3200 * \return \ref canERR_xxx (negative) if failure
3201 *
3202 * \sa \ref page_user_guide_send_recv_obj_buf
3203 */
3204canStatus CANLIBAPI canObjBufWrite (const CanHandle hnd,
3205 int idx,
3206 int id,
3207 void* msg,
3208 unsigned int dlc,
3209 unsigned int flags);
3210
3211/**
3212 * \ingroup ObjectBuffers
3213 *
3214 * \source_cs <b>static Canlib.canStatus canObjBufSetFilter(int handle, int idx, int code, int mask);</b>
3215 *
3216 * \source_delphi <b>function canObjBufSetFilter(handle: canHandle; idx: Integer; code, mask: Cardinal): canStatus; </b>
3217 * \source_end
3218 *
3219 * Defines a message reception filter on the specified object buffer.
3220 * Messages not matching the filter are discarded.
3221 *
3222 * \note For an auto response buffer, set the code and mask that together define
3223 * the identifier(s) that trigger(s) the automatic response.
3224 *
3225 * \param[in] hnd An open handle to a CAN circuit.
3226 * \param[in] idx The index of the object buffer on which the filter is to be
3227 * set.
3228 * \param[in] code The acceptance code in the filter.
3229 * \param[in] mask The acceptance mask in the filter.
3230 *
3231 * \return \ref canOK (zero) if success
3232 * \return \ref canERR_xxx (negative) if failure
3233 *
3234 * \sa \ref page_user_guide_misc_code_and_mask,
3235 * \ref page_user_guide_send_recv_obj_buf
3236 */
3237canStatus CANLIBAPI canObjBufSetFilter (const CanHandle hnd,
3238 int idx,
3239 unsigned int code,
3240 unsigned int mask);
3241
3242/**
3243 * \ingroup ObjectBuffers
3244 *
3245 * \source_cs <b>static Canlib.canStatus canObjBufSetFlags(int handle, int idx, int flags);</b>
3246 *
3247 * \source_delphi <b>function canObjBufSetFlags(handle: canHandle; idx: Integer; flags: Cardinal): canStatus; </b>
3248 * \source_end
3249 *
3250 * Sets object buffer flags on a specified object buffer.
3251 *
3252 * \param[in] hnd An open handle to a CAN circuit.
3253 * \param[in] idx The buffer on which the flags are to be set.
3254 * \param[in] flags Specifies a combination of zero or more of the
3255 * \ref canOBJBUF_AUTO_RESPONSE_xxx flag values
3256 *
3257 * \return \ref canOK (zero) if success
3258 * \return \ref canERR_xxx (negative) if failure
3259 *
3260 * \sa \ref page_user_guide_send_recv_obj_buf
3261 */
3262canStatus CANLIBAPI canObjBufSetFlags (const CanHandle hnd,
3263 int idx,
3264 unsigned int flags);
3265
3266/**
3267 * \name canOBJBUF_AUTO_RESPONSE_xxx
3268 * \anchor canOBJBUF_AUTO_RESPONSE_xxx
3269 *
3270 * These defines are used in \ref canObjBufSetFlags().
3271 *
3272 * @{
3273 */
3274 /**
3275 * This define is used in \ref canObjBufSetFlags().
3276 *
3277 * For auto-response buffers only. When this flag is in effect, the buffer
3278 * will auto-respond to remote requests only. If this flag is not in effect,
3279 * the buffer will auto-respond to both remote requests and ordinary data
3280 * frames.
3281 *
3282 */
3283# define canOBJBUF_AUTO_RESPONSE_RTR_ONLY 0x01
3284 /** @} */
3285
3286/**
3287 * \ingroup ObjectBuffers
3288 *
3289 * \source_cs <b>static Canlib.canStatus canObjBufSetPeriod(int hnd, int idx, int period);</b>
3290 *
3291 * \source_delphi <b>function canObjBufSetPeriod(handle: canHandle; idx: Integer; period: Cardinal): canStatus; </b>
3292 * \source_end
3293 *
3294 * The \ref canObjBufSetPeriod function sets the transmission period for an auto
3295 * transmission object buffer.
3296 *
3297 * \param[in] hnd An open handle to a CAN channel.
3298 * \param[in] idx The index of a CAN object buffer.
3299 * \param[in] period The transmission interval, in microseconds.
3300 *
3301 * \return \ref canOK (zero) if success
3302 * \return \ref canERR_xxx (negative) if failure
3303 *
3304 * \sa \ref page_user_guide_send_recv_obj_buf
3305 */
3306canStatus CANLIBAPI canObjBufSetPeriod (const CanHandle hnd,
3307 int idx,
3308 unsigned int period);
3309
3310/**
3311 * \ingroup ObjectBuffers
3312 *
3313 * \source_cs <b>static Canlib.canStatus canObjBufSetMsgCount(int hnd, int idx, int count);</b>
3314 *
3315 * \source_delphi <b>function canObjBufSetMsgCount(handle: canHandle; idx: Integer; count: Cardinal): canStatus; </b>
3316 * \source_end
3317 *
3318 * The \ref canObjBufSetMsgCount function sets the message count for an auto
3319 * transmit object buffer.
3320 *
3321 * \param[in] hnd An open handle to a CAN channel.
3322 * \param[in] idx The index of a CAN object buffer.
3323 * \param[in] count The message count.
3324 *
3325 * \return \ref canOK (zero) if success
3326 * \return \ref canERR_xxx (negative) if failure
3327 *
3328 * \sa \ref page_user_guide_send_recv_obj_buf
3329 */
3330canStatus CANLIBAPI canObjBufSetMsgCount (const CanHandle hnd,
3331 int idx,
3332 unsigned int count);
3333
3334/**
3335 * \ingroup ObjectBuffers
3336 *
3337 * \source_cs <b>static Canlib.canStatus canObjBufEnable(int handle, int idx);</b>
3338 *
3339 * \source_delphi <b>function canObjBufEnable(handle: canHandle; idx: Integer): canStatus; </b>
3340 * \source_end
3341 *
3342 * Enables the object buffer with the specified index.
3343 *
3344 * \param[in] hnd An open handle to a CAN circuit.
3345 * \param[in] idx The index of the object buffer to enable.
3346 *
3347 * \return \ref canOK (zero) if success
3348 * \return \ref canERR_xxx (negative) if failure
3349 *
3350 * \sa \ref page_user_guide_send_recv_obj_buf
3351 * \sa \ref canObjBufDisable()
3352 */
3353canStatus CANLIBAPI canObjBufEnable (const CanHandle hnd, int idx);
3354
3355/**
3356 * \ingroup ObjectBuffers
3357 *
3358 * \source_cs <b>static Canlib.canStatus canObjBufDisable(int handle, int idx);</b>
3359 *
3360 * \source_delphi <b>function canObjBufDisable(handle: canHandle; idx: Integer): canStatus; </b>
3361 * \source_end
3362 *
3363 * Disables the object buffer with the specified index.
3364 *
3365 * \param[in] hnd An open handle to a CAN circuit.
3366 * \param[in] idx The index of the buffer.
3367 *
3368 * \return \ref canOK (zero) if success
3369 * \return \ref canERR_xxx (negative) if failure
3370 *
3371 * \sa \ref page_user_guide_send_recv_obj_buf
3372 * \sa \ref canObjBufEnable()
3373 */
3374canStatus CANLIBAPI canObjBufDisable (const CanHandle hnd, int idx);
3375
3376/**
3377 * \ingroup ObjectBuffers
3378 *
3379 * \source_cs <b>static Canlib.canStatus canObjBufSendBurst(int hnd, int idx, int burstlen);</b>
3380 *
3381 * \source_delphi <b>function canObjBufSendBurst(handle: canHandle; idx: Integer; burstLen: Cardinal): canStatus; </b>
3382 * \source_end
3383 *
3384 * The canObjBufSendBurst function sends a burst of CAN messages. You have to
3385 * set up an object buffer first with the message to send. The messages will be
3386 * sent as fast as possible from the hardware.
3387 *
3388 * This function is inteneded for certain diagnostic applications.
3389 *
3390 * \param[in] hnd An open handle to a CAN channel.
3391 * \param[in] idx The index of a CAN object buffer.
3392 * \param[in] burstlen The number of messages to send.
3393 *
3394 * \return \ref canOK (zero) if success
3395 * \return \ref canERR_xxx (negative) if failure
3396 *
3397 * \sa \ref page_user_guide_send_recv_obj_buf
3398 */
3399canStatus CANLIBAPI canObjBufSendBurst (const CanHandle hnd,
3400 int idx,
3401 unsigned int burstlen);
3402
3403/**
3404 * \name canVERSION_xxx
3405 * \anchor canVERSION_xxx
3406 *
3407 * These defines are used in \ref canProbeVersion().
3408 *
3409 * @{
3410 */
3411 /**
3412 * This define is used in \ref canProbeVersion(), \a major and \a minor refer to
3413 * this functions arguments.
3414 *
3415 * Require that exactly the version specified by \a major and \a minor be
3416 * present. Earlier and later versions are not accepted. This flag does not
3417 * affect the acceptance of beta versions.
3418 */
3419#define canVERSION_DONT_ACCEPT_LATER 0x01
3420 /**
3421 * This define is used in \ref canProbeVersion(), \a major and \a minor refer to
3422 * this functions arguments.
3423 *
3424 * Return FALSE if a beta version (preview version) of CANLIB is installed,
3425 * regardless of its version number.
3426 */
3427#define canVERSION_DONT_ACCEPT_BETAS 0x02
3428 /** @} */
3429
3430/**
3431 * \ingroup General
3432 *
3433 * \source_cs <b>static bool canProbeVersion(int hnd, int major, int minor, int oem_id, int flags);</b>
3434 *
3435 * \source_delphi <b>function canProbeVersion(handle: canHandle; major, minor, oem_id: Integer; flags: Cardinal): Boolean; </b>
3436 * \source_end
3437 *
3438 * This function checks whether a specific version of CANLIB is installed on
3439 * the system.
3440 *
3441 * The default behaviour of \ref canProbeVersion is to accept
3442 *
3443 * \li the version specified by \a major and \a minor, and
3444 * \li any later version, and
3445 * \li all beta versions.
3446 *
3447 * You get the default behaviour by setting \a flags to 0. Use any
3448 * combination of the \ref canVERSION_xxx flags to modify the behaviour.
3449 *
3450 * \note Different handles might have different driver versions installed. This
3451 * should not normally be the case but it might happen anyway. You should check
3452 * the version for each handle you open, e.g. directly after calling
3453 * \ref canOpenChannel().
3454 *
3455 * \param[in] hnd A handle to an open circuit.
3456 * \param[in] major The major version number of the version to test for.
3457 * \param[in] minor The minor version number of the version to test for.
3458 * \param[in] oem_id Reserved, must be zero.
3459 * \param[in] flags Any combination of the \ref canVERSION_xxx flags, or 0.
3460 *
3461 * \return TRUE if the specified version of CANLIB is installed on the system.
3462 *
3463 * \sa \ref page_user_guide_build_driver_version
3464 * \sa \ref page_code_snippets_examples
3465 * \sa \ref canGetVersion(), \ref canGetVersionEx(), \ref canGetChannelData()
3466 */
3467BOOL CANLIBAPI canProbeVersion (const CanHandle hnd,
3468 int major,
3469 int minor,
3470 int oem_id,
3471 unsigned int flags);
3472#endif
3473
3474/**
3475 * \ingroup CAN
3476 *
3477 * \source_cs <b>static Canlib.canStatus canResetBus(int handle);</b>
3478 *
3479 * \source_delphi <b>function canResetBus(handle: canHandle): canStatus; </b>
3480 * \source_end
3481 *
3482 * This function tries to reset a CAN bus controller by taking the channel off
3483 * bus and then on bus again (if it was on bus before the call to \ref canResetBus().)
3484 *
3485 * This function will affect the hardware (and cause a real reset of the CAN
3486 * chip) only if \a hnd is the only handle open on the channel. If there
3487 * are other open handles, this operation will not affect the hardware.
3488 *
3489 * \param[in] hnd A handle to an open circuit.
3490 *
3491 * \return \ref canOK (zero) if success
3492 * \return \ref canERR_xxx (negative) if failure
3493 *
3494 * \sa \ref canBusOn(), \ref canBusOff()
3495 */
3496canStatus CANLIBAPI canResetBus (const CanHandle hnd);
3497
3498/**
3499 * \ingroup CAN
3500 *
3501 * \source_cs <b>static Canlib.canStatus canWriteWait(int handle, int id, byte[] msg, int dlc, int flag, long timeout);</b>
3502 *
3503 * \source_delphi <b>function canWriteWait(handle: canHandle; id: longint; var msg; dlc, flag, timeout : Cardinal): canStatus; </b>
3504 * \source_end
3505 *
3506 * This function sends a CAN message. It returns when the message is sent, or
3507 * the timeout expires.
3508 *
3509 * This is a convenience function that combines \ref canWrite() and \ref canWriteSync().
3510 *
3511 * If you are using the same channel via multiple handles, note that the
3512 * default behaviour is that the different handles will "hear" each other just as
3513 * if each handle referred to a channel of its own. If you open, say, channel 0
3514 * from thread A and thread B and then send a message from thread A, it will be
3515 * "received" by thread B.
3516 * This behaviour can be changed using \ref canIOCTL_SET_LOCAL_TXECHO.
3517 *
3518 * \param[in] hnd A handle to an open CAN circuit.
3519 * \param[in] id The identifier of the CAN message to send.
3520 * \param[in] msg A pointer to the message data, or \c NULL.
3521 * \param[in] dlc The length of the message. Can be at most 8.
3522 * \param[in] flag A combination of message flags, \ref canMSG_xxx.
3523 * Use this parameter to send extended (29-bit) frames
3524 * and/or remote frames. Use \ref canMSG_EXT and/or
3525 * \ref canMSG_RTR for this purpose.
3526 * \param[in] timeout The timeout, in milliseconds. 0xFFFFFFFF gives an
3527 * infinite timeout.
3528 *
3529 * \return \ref canOK (zero) if success
3530 * \return \ref canERR_xxx (negative) if failure
3531 */
3532canStatus CANLIBAPI canWriteWait (const CanHandle hnd,
3533 long id,
3534 void *msg,
3535 unsigned int dlc,
3536 unsigned int flag,
3537 unsigned long timeout);
3538
3539
3540#if defined(CANLIB_DECLARE_ALL)
3541
3542/**
3543 * \ingroup General
3544 *
3545 * \source_cs <b>static Canlib.canStatus canUnloadLibrary();</b>
3546 *
3547 * \source_delphi <b>function canUnloadLibrary: Integer; </b>
3548 * \source_end
3549 *
3550 * Use this function if you are loading CANLIB32.DLL dynamically (that is,
3551 * using the Win32 API \c LoadLibrary) and need to unload it using the Win32
3552 * API \c FreeLibrary. \ref canUnloadLibrary() will free allocated memory, unload
3553 * the DLLs canlib32.dll has loaded and de-initialize data structures. You must
3554 * call \ref canInitializeLibrary() again to use the API functions in canlib32.dll.
3555 *
3556 * \return \ref canOK (zero) if success
3557 * \return \ref canERR_xxx (negative) if failure
3558 *
3559 * \sa \ref canInitializeLibrary()
3560 */
3561canStatus CANLIBAPI canUnloadLibrary (void);
3562
3563/**
3564 * \ingroup CAN
3565 *
3566 * \source_cs <b>static Canlib.canStatus canSetAcceptanceFilter(int hnd, int code, int mask, int is_extended);</b>
3567 *
3568 * \source_delphi <b>function canSetAcceptanceFilter(handle: canHandle; code, mask: Cardinal; is_extended: Integer): canStatus; </b>
3569 * \source_end
3570 *
3571 * This routine sets the message acceptance filters on a CAN channel.
3572 *
3573 * Format of \a code and \a mask:
3574 *
3575 * \li A binary 1 in a mask means "the corresponding bit in the code is
3576 * relevant"
3577 * \li A binary 0 in a mask means "the corresponding bit in the code is not
3578 * relevant"
3579 * \li A relevant binary 1 in a code means "the corresponding bit in the
3580 * identifier must be 1"
3581 * \li A relevant binary 1 in a code means "the corresponding bit in the
3582 * identifier must be 1"
3583 *
3584 * In other words, the message is accepted if ((code XOR id) AND mask) == 0.
3585 *
3586 * \a extended should be set to:
3587 *
3588 * \li \c 0 (FALSE): if the code and mask shall apply to 11-bit CAN identifiers.
3589 * \li \c 1 (TRUE): if the code and mask shall apply to 29-bit CAN identifiers.
3590 *
3591 * If you want to remove a filter, call \ref canSetAcceptanceFilter() with the mask
3592 * set to \c 0.
3593 *
3594 * On some boards the acceptance filtering is done by the CAN hardware; on
3595 * other boards (typically those with an embedded CPU,) the acceptance
3596 * filtering is done by software. \ref canSetAcceptanceFilter() behaves in the same
3597 * way for all boards, however.
3598 *
3599 * \ref canSetAcceptanceFilter() and \ref canAccept() both serve the same purpose but the
3600 * former can set the code and mask in just one call.
3601 *
3602 * \note You can set the extended code and mask only on CAN boards that support
3603 * extended identifiers.
3604 *
3605 * \note Not all CAN boards support different masks for standard and
3606 * extended CAN identifiers.
3607 *
3608 * \param[in] hnd An open handle to a CAN circuit.
3609 * \param[in] code The acceptance code to set.
3610 * \param[in] mask The acceptance mask to set.
3611 * \param[in] is_extended Select 29-bit CAN identifiers.
3612 *
3613 * \return \ref canOK (zero) if success
3614 * \return \ref canERR_xxx (negative) if failure
3615 *
3616 * \sa \ref page_code_snippets_examples,
3617 * \ref page_user_guide_misc_code_and_mask
3618 * \sa \ref canAccept()
3619 */
3620canStatus CANLIBAPI canSetAcceptanceFilter (const CanHandle hnd,
3621 unsigned int code,
3622 unsigned int mask,
3623 int is_extended);
3624
3625/**
3626 * \ingroup CAN
3627 *
3628 * \source_cs <b>static Canlib.canStatus canFlushReceiveQueue(int hnd);</b>
3629 *
3630 * \source_delphi <b>function canFlushReceiveQueue(handle: canHandle): canStatus; </b>
3631 * \source_end
3632 *
3633 * This function removes all received messages from the handle's receive queue.
3634 * Other handles open to the same channel are not affcted by this
3635 * operation. That is, only the messages belonging to the handle you are
3636 * passing to \ref canFlushReceiveQueue are discarded.
3637 *
3638 * \note This call has the same effect as calling \ref canIoCtl() with a function
3639 * code of \ref canIOCTL_FLUSH_RX_BUFFER.
3640 *
3641 * \param[in] hnd A handle to an open circuit.
3642 *
3643 * \return \ref canOK (zero) if success
3644 * \return \ref canERR_xxx (negative) if failure
3645 *
3646 * \sa \ref canFlushTransmitQueue()
3647 */
3648canStatus CANLIBAPI canFlushReceiveQueue (const CanHandle hnd);
3649
3650/**
3651 * \ingroup CAN
3652 *
3653 * \source_cs <b>static Canlib.canStatus canFlushTransmitQueue(int hnd);</b>
3654 *
3655 * \source_delphi <b>function canFlushTransmitQueue(handle: canHandle): canStatus; </b>
3656 * \source_end
3657 *
3658 * This function removes all messages pending transmission from the
3659 * transmit queue of the circuit.
3660 *
3661 * \note If there are other handles open to the same circuit, they are also
3662 * flushed.
3663 *
3664 * \note This call has the same effect as calling \ref canIoCtl() with a function
3665 * code of \ref canIOCTL_FLUSH_TX_BUFFER.
3666 *
3667 * \param[in] hnd A handle to an open circuit.
3668 *
3669 * \return \ref canOK (zero) if success
3670 * \return \ref canERR_xxx (negative) if failure
3671 *
3672 * \sa \ref canFlushReceiveQueue()
3673 */
3674canStatus CANLIBAPI canFlushTransmitQueue (const CanHandle hnd);
3675
3676/**
3677 * \ingroup General
3678 *
3679 * \source_cs <b>static Canlib.canStatus kvGetApplicationMapping(int busType, string appName, int appChannel, out int resultingChannel);</b>
3680 *
3681 * \source_delphi <b>function kvGetApplicationMapping(busType: Integer; appName: PChar; appChannel: Integer; var resultingChannel: Integer): canStatus; </b>
3682 * \source_end
3683 *
3684 * \note The \ref kvGetApplicationMapping function is presently not implemented.
3685 *
3686 * \param busType
3687 * \param appName
3688 * \param appChannel
3689 * \param resultingChannel
3690 *
3691 * \return \ref canOK (zero) if success
3692 * \return \ref canERR_xxx (negative) if failure
3693 *
3694 */
3695canStatus CANLIBAPI kvGetApplicationMapping (int busType,
3696 char *appName,
3697 int appChannel,
3698 int *resultingChannel);
3699
3700/**
3701 * \ingroup General
3702 *
3703 * \source_cs <b>static Canlib.canStatus kvBeep(int hnd, int freq, int duration);</b>
3704 *
3705 * \source_delphi <b>function kvBeep(handle: canHandle; freq: Integer; duration: Cardinal): canStatus; </b>
3706 * \source_end
3707 *
3708 * The \ref kvBeep function emits a sound of a specific frequency and duration from
3709 * the loudspeaker on the device.
3710 *
3711 * \note This function requires that a loudspeaker be present on the hardware.
3712 *
3713 * \param[in] hnd An open handle to a CAN channel.
3714 * \param[in] freq The frequency (in Hertz) of the sound.
3715 * \param[in] duration The duration of the sound, in milliseconds.
3716 *
3717 * \return \ref canOK (zero) if success
3718 * \return \ref canERR_xxx (negative) if failure
3719 *
3720 */
3721canStatus CANLIBAPI kvBeep (const CanHandle hnd,
3722 int freq,
3723 unsigned int duration);
3724
3725/**
3726 * \ingroup General
3727 *
3728 * \source_cs <b>static Canlib.canStatus kvSelfTest(int hnd, out int presults);</b>
3729 *
3730 * \source_delphi <b>function kvSelfTest(handle: canHandle; var presults: Cardinal): canStatus; </b>
3731 * \source_end
3732 *
3733 * The \ref kvSelfTest function runs a built-in self test in the device. Note that
3734 * not all devices supports built-in self tests.
3735 *
3736 * \param[in] hnd An open hnd to a CAN channel.
3737 * \param[out] presults A pointer to a 32-bit unsigned integer where the
3738 * resuls of the self test will be placed.
3739 *
3740 * \return \ref canOK (zero) if success
3741 * \return \ref canERR_xxx (negative) if failure
3742 *
3743 */
3744canStatus CANLIBAPI kvSelfTest (const CanHandle hnd, unsigned long *presults);
3745
3746 /**
3747 * \anchor kvLED_ACTION_xxx
3748 * \name kvLED_ACTION_xxx
3749 *
3750 * The following constants can be used together with the \ref kvFlashLeds() function.
3751 *
3752 * @{
3753 */
3754#define kvLED_ACTION_ALL_LEDS_ON 0 ///< Turn all LEDs on.
3755#define kvLED_ACTION_ALL_LEDS_OFF 1 ///< Turn all LEDs off.
3756#define kvLED_ACTION_LED_0_ON 2 ///< Turn LED 0 on.
3757#define kvLED_ACTION_LED_0_OFF 3 ///< Turn LED 0 off.
3758#define kvLED_ACTION_LED_1_ON 4 ///< Turn LED 1 on.
3759#define kvLED_ACTION_LED_1_OFF 5 ///< Turn LED 1 off.
3760#define kvLED_ACTION_LED_2_ON 6 ///< Turn LED 2 on.
3761#define kvLED_ACTION_LED_2_OFF 7 ///< Turn LED 2 off.
3762#define kvLED_ACTION_LED_3_ON 8 ///< Turn LED 3 on.
3763#define kvLED_ACTION_LED_3_OFF 9 ///< Turn LED 3 off.
3764 /** @} */
3765
3766/**
3767 * \ingroup General
3768 *
3769 * \source_cs <b>static Canlib.canStatus kvFlashLeds(int hnd, int action, int timeout);</b>
3770 *
3771 * \source_delphi <b>function kvFlashLeds(handle: canHandle; action: Integer; timeout: Integer): canStatus; </b>
3772 * \source_end
3773 *
3774 * The \ref kvFlashLeds function will turn the LEDs on the device on or off.
3775 *
3776 * \param[in] hnd
3777 * \param[in] action One of the \ref kvLED_ACTION_xxx constants, defining
3778 * which LED to turn on or off.
3779 * \param[in] timeout Specifies the time, in milliseconds, during which the
3780 * action is to be carried out. When the timeout expires,
3781 * the LED(s) will return to its ordinary function.
3782 *
3783 * \return \ref canOK (zero) if success
3784 * \return \ref canERR_xxx (negative) if failure
3785 *
3786 */
3787canStatus CANLIBAPI kvFlashLeds (const CanHandle hnd, int action, int timeout);
3788
3789/**
3790 * \ingroup CAN
3791 *
3792 * \source_cs <b>static Canlib.canStatus canRequestChipStatus(int hnd);</b>
3793 *
3794 * \source_delphi <b>function canRequestChipStatus(handle: canHandle): canStatus; </b>
3795 * \source_end
3796 *
3797 * The canRequestChipStatus function requests that the hardware report the chip
3798 * status (bus on/error passive status etc.) to the driver. The chip status can
3799 * later be retrieved using the \ref canReadStatus() function.
3800 *
3801 * \note The \ref canRequestChipStatus() function is asynchronous, that is, it
3802 * completes before the answer is returned from the hardware. The time between
3803 * a call to \ref canRequestChipStatus() and the point in time where the chip status
3804 * is actually available via a call to \ref canReadStatus() is not
3805 * defined. \ref canReadStatus() always returns the latest data reported by the
3806 * hardware.
3807 *
3808 * \param[in] hnd An open handle to a CAN channel.
3809 *
3810 * \return \ref canOK (zero) if success
3811 * \return \ref canERR_xxx (negative) if failure
3812 *
3813 * \sa \ref canReadStatus()
3814 */
3815canStatus CANLIBAPI canRequestChipStatus (const CanHandle hnd);
3816
3817/**
3818 * \ingroup CAN
3819 *
3820 * \source_cs <b>static Canlib.canStatus canRequestBusStatistics(int hnd);</b>
3821 *
3822 * \source_delphi <b>function canRequestBusStatistics(handle: canHandle): canStatus; </b>
3823 * \source_end
3824 *
3825 * The \ref canRequestBusStatistics function requests bus statistics from the
3826 * hardware. The bus statistics figures can be retrieved later by a call to the
3827 * \ref canGetBusStatistics function.
3828 *
3829 * \note The time between a call to \ref canRequestBusStatistics() and the point in
3830 * time where the bus statistics is actually available via a call to
3831 * \ref canGetBusStatistics() is not defined. Typically, you would call
3832 * \ref canRequestBusStatistics() from your application periodically (for example,
3833 * once per second) to request the data from the driver and then call
3834 * \ref canGetBusStatistics() with the same rate to obtain the latest reported data.
3835 *
3836 * \param[in] hnd An open handle to a CAN channel.
3837 *
3838 * \return \ref canOK (zero) if success
3839 * \return \ref canERR_xxx (negative) if failure
3840 *
3841 * \sa \ref canGetBusStatistics()
3842 */
3843canStatus CANLIBAPI canRequestBusStatistics (const CanHandle hnd);
3844
3845 /**
3846 * \ingroup CAN
3847 * This struct is returned by \ref canGetBusStatistics()
3848 *
3849 * The values are cleared when the corresponding channel goes on bus.
3850 */
3851typedef struct canBusStatistics_s {
3852 unsigned long stdData; ///< Number of received standard (11-bit identifiers) data frames.
3853 unsigned long stdRemote; ///< Number of received standard (11-bit identifiers) remote frames.
3854 unsigned long extData; ///< Number of received extended (29-bit identifiers) data frames.
3855 unsigned long extRemote; ///< Number of received extended (29-bit identifiers) remote frames.
3856 unsigned long errFrame; ///< Number of error frames
3857
3858 /**
3859 * The bus load, expressed as an integer in the interval 0 - 10000
3860 * representing 0.00% - 100.00% bus load.
3861 */
3862 unsigned long busLoad;
3863 unsigned long overruns; ///< The number of overruns detected by the hardware, firmware or driver.
3864} canBusStatistics;
3865
3866/**
3867 * \ingroup CAN
3868 *
3869 * \source_cs <b>static Canlib.canStatus canGetBusStatistics(int hnd, out Canlib.canBusStatistics stat);</b>
3870 *
3871 * \source_delphi <b>function canGetBusStatistics(handle: canHandle; var stat: canBusStatistics; bufsiz: Cardinal): canStatus; </b>
3872 * \source_end
3873 *
3874 * The \ref canGetBusStatistics() function retrieves the latest bus statistics
3875 * figures reported by the driver. You request the bus statistics from the
3876 * driver by calling the \ref canRequestBusStatistics() function.
3877 *
3878 * \param[in] hnd An open handle to a CAN channel.
3879 * \param[out] stat A pointer to a \ref canBusStatistics struct that will receive
3880 * the bus statistics figures.
3881 * \param[in] bufsiz The size, in bytes, of the stat buffer.
3882 *
3883 * \return \ref canOK (zero) if success
3884 * \return \ref canERR_xxx (negative) if failure
3885 *
3886 * \sa \ref canRequestBusStatistics()
3887 */
3888canStatus CANLIBAPI canGetBusStatistics (const CanHandle hnd,
3889 canBusStatistics *stat,
3890 size_t bufsiz);
3891
3892/**
3893 * \ingroup CAN
3894 *
3895 * \source_cs <b>static Canlib.canStatus canSetBitrate(int hnd, int bitrate);</b>
3896 *
3897 * \source_delphi <b>function canSetBitrate(handle: canHandle; bitrate: Integer): canStatus; </b>
3898 * \source_end
3899 *
3900 * The \ref canSetBitrate() function sets the bit rate of the specified CAN
3901 * channel. The SJW is left unchanged. The sampling point is recalculated and
3902 * kept as close as possible to the value before the call.
3903 *
3904 * \param[in] hnd An open handle to a CAN channel.
3905 * \param[in] bitrate The new bit rate, in bits/second.
3906 *
3907 * \return \ref canOK (zero) if success
3908 * \return \ref canERR_xxx (negative) if failure
3909 *
3910 * \sa \ref canSetBusParamsC200(), \ref canSetBusParams(), \ref canGetBusParams()
3911 */
3912canStatus CANLIBAPI canSetBitrate (const CanHandle hnd, int bitrate);
3913
3914/**
3915 * \ingroup General
3916 *
3917 * \source_cs <b>static Canlib.canStatus kvAnnounceIdentity(int hnd, object buffer);</b>
3918 *
3919 * \source_delphi <b>function kvAnnounceIdentity(handle: canHandle; var buf; bufsiz: Cardinal): canStatus; </b>
3920 * \source_end
3921 *
3922 * The \ref kvAnnounceIdentity function is used by certain OEM applications.
3923 *
3924 * \param[in] hnd An open handle to a CAN channel.
3925 * \param[out] buf A pointer to the data to be sent to the driver.
3926 * \param[in] bufsiz The size, in bytes, of the buffer that buf points to.
3927 *
3928 * \return \ref canOK (zero) if success
3929 * \return \ref canERR_xxx (negative) if failure
3930 */
3931canStatus CANLIBAPI kvAnnounceIdentity (const CanHandle hnd,
3932 void *buf,
3933 size_t bufsiz);
3934/**
3935 * \ingroup General
3936 *
3937 * The \ref kvAnnounceIdentityEx function is used by certain OEM applications.
3938 *
3939 * \param[in] hnd An open handle to a CAN channel.
3940 * \param[in] type Type of announcement.
3941 * \param[out] buf A pointer to the data to be sent to the driver.
3942 * \param[in] bufsiz The size, in bytes, of the buffer that buf points to.
3943 *
3944 * \return \ref canOK (zero) if success
3945 * \return \ref canERR_xxx (negative) if failure
3946 */
3947canStatus CANLIBAPI kvAnnounceIdentityEx (const CanHandle hnd,
3948 int type,
3949 void *buf,
3950 size_t bufsiz);
3951
3952/**
3953 * \ingroup CAN
3954 *
3955 * \source_cs <b>static Canlib.canStatus canGetHandleData(int hnd, int item, out object buffer);</b>
3956 *
3957 * \source_delphi <b>function canGetHandleData(handle: canHandle; item: Integer; var Buffer; bufsize: Cardinal): canStatus; </b>
3958 * \source_end
3959 *
3960 * \note This function can be used to retrieve certain pieces of information about an open handle to a CANlib channel.
3961 *
3962 * \param[in] hnd An open handle to a CAN channel.
3963 * \param[in] item This parameter specifies what data to obtain for the specified handle. The value is one of the constants \ref canCHANNELDATA_xxx
3964 * \param[out] buffer The address of a buffer which is to receive the data.
3965 * \param[in] bufsize The size of the buffer to which the buffer parameter points.
3966 *
3967 * \return \ref canOK (zero) if success
3968 * \return \ref canERR_xxx (negative) if failure
3969 *
3970 * \sa \ref canGetChannelData()
3971 */
3972canStatus CANLIBAPI canGetHandleData (const CanHandle hnd,
3973 int item,
3974 void *buffer,
3975 size_t bufsize);
3976
3977/** Used for time domain handling. */
3978typedef void *kvTimeDomain;
3979
3980/** Contains status codes according to \ref canSTAT_xxx. */
3981typedef canStatus kvStatus;
3982
3983/**
3984 * \ingroup TimeDomainHandling
3985 *
3986 * Used for time domain handling.
3987 */
3988typedef struct kvTimeDomainData_s {
3989 int nMagiSyncGroups; ///< number of MagiSync&tm; groups
3990 int nMagiSyncedMembers; ///< number of MagiSync&tm; members
3991 int nNonMagiSyncCards; ///< number of non MagiSync&tm; interfaces
3992 int nNonMagiSyncedMembers; ///< number of non MagiSync&tm; members
3993} kvTimeDomainData;
3994
3995/**
3996 * \ingroup TimeDomainHandling
3997 *
3998 * \source_cs <b>static Canlib.canStatus kvTimeDomainCreate(out object domain);</b>
3999 *
4000 * \source_delphi <b>function kvTimeDomainCreate(var domain: kvTimeDomain): kvStatus; </b>
4001 * \source_end
4002 *
4003 * This routine creates an empty time domain.
4004 *
4005 * The variable is set by this function and then used in later calls to
4006 * other functions using a \ref kvTimeDomain.
4007 *
4008 * Time domains created by \ref kvTimeDomainCreate() can be destroyed with a
4009 * call to \ref kvTimeDomainDelete().
4010 *
4011 * \note A time domain is a set of channels with a common time base.
4012 *
4013 * \param[in] domain A pointer to a caller allocated, opaque variable of type
4014 * \ref kvTimeDomain that holds data to identify a particlar
4015 * time domain.
4016 *
4017 * \return \ref canOK (zero) if success
4018 * \return \ref canERR_xxx (negative) if failure
4019 *
4020 * \sa \ref page_code_snippets_examples
4021 * \sa \ref kvTimeDomainDelete()
4022 */
4023kvStatus CANLIBAPI kvTimeDomainCreate (kvTimeDomain *domain);
4024
4025/**
4026 * \ingroup TimeDomainHandling
4027 *
4028 * \source_cs <b>static Canlib.canStatus kvTimeDomainDelete(object domain);</b>
4029 *
4030 * \source_delphi <b>function kvTimeDomainDelete(domain: kvTimeDomain): kvStatus; </b>
4031 * \source_end
4032 *
4033 * This is a cleanup routine that deletes all members of a domain and then
4034 * deletes the domain itself.
4035 *
4036 * \note A time domain is a set of channels with a common time base.
4037 *
4038 * \param[in] domain An opaque variable set by \ref kvTimeDomainCreate() that
4039 * identifies the domain to be deleted.
4040 *
4041 * \return \ref canOK (zero) if success
4042 * \return \ref canERR_xxx (negative) if failure
4043 *
4044 * \sa \ref page_code_snippets_examples
4045 * \sa \ref kvTimeDomainCreate()
4046 */
4047kvStatus CANLIBAPI kvTimeDomainDelete (kvTimeDomain domain);
4048
4049/**
4050 * \ingroup TimeDomainHandling
4051 *
4052 * \source_cs <b>static Canlib.canStatus kvTimeDomainResetTime(object domain);</b>
4053 *
4054 * \source_delphi <b>function kvTimeDomainResetTime(domain: kvTimeDomain): kvStatus; </b>
4055 * \source_end
4056 *
4057 * This routine resets the time on all members of a time domain.
4058 *
4059 * After a call to this routine timestamps from all channels with MagiSync&tm;
4060 * running have no offset at all any longer. The same applies for channels that
4061 * reside on the same physical interface.
4062 *
4063 * \note A time domain is a set of channels with a common time base.
4064 *
4065 * \param[in] domain An opaque variable set by \ref kvTimeDomainCreate() that
4066 * identifies the domain to reset the time on.
4067 *
4068 * \return \ref canOK (zero) if success
4069 * \return \ref canERR_xxx (negative) if failure
4070 *
4071 * \sa \ref page_code_snippets_examples
4072 * \sa \ref kvTimeDomainCreate()
4073 */
4074kvStatus CANLIBAPI kvTimeDomainResetTime (kvTimeDomain domain);
4075
4076/**
4077 * \ingroup TimeDomainHandling
4078 *
4079 * \source_cs <b>static Canlib.canStatus kvTimeDomainGetData(object domain, Canlib.kvTimeDomainData data);</b>
4080 *
4081 * \source_delphi <b>function kvTimeDomainGetData(domain: kvTimeDomain; var data: kvTimeDomainData; bufsiz: Cardinal): kvStatus; </b>
4082 * \source_end
4083 *
4084 * This routine collects some data on a time domain.
4085 *
4086 * \note A time domain is a set of channels with a common time base.
4087 *
4088 * \param[in] domain An opaque variable set by \ref kvTimeDomainCreate() that
4089 * identifies the domain to add a handle to.
4090 * \param[out] data A pointer to a \ref kvTimeDomainData that is to be filled by
4091 * the function.
4092 * \param[in] bufsiz The size in bytes of the \ref kvTimeDomainData struct.
4093 *
4094 * \return \ref canOK (zero) if success
4095 * \return \ref canERR_xxx (negative) if failure
4096 *
4097 * \sa \ref page_code_snippets_examples
4098 * \sa \ref kvTimeDomainCreate()
4099 */
4100kvStatus CANLIBAPI kvTimeDomainGetData (kvTimeDomain domain,
4101 kvTimeDomainData *data,
4102 size_t bufsiz);
4103
4104/**
4105 * \ingroup TimeDomainHandling
4106 *
4107 * \source_cs <b>static Canlib.canStatus kvTimeDomainAddHandle(object domain, int handle);</b>
4108 *
4109 * \source_delphi <b>function kvTimeDomainAddHandle(domain: kvTimeDomain; handle: canHandle): kvStatus; </b>
4110 * \source_end
4111 *
4112 * This routine adds an open channel handle to a domain.
4113 *
4114 * \note A time domain is a set of channels with a common time base.
4115 *
4116 * \param[in] domain An opaque variable set by \ref kvTimeDomainCreate()
4117 * that identifies the domain to add a handle to.
4118 * \param[in] hnd A handle to an open channel.
4119 *
4120 * \return \ref canOK (zero) if success
4121 * \return \ref canERR_xxx (negative) if failure
4122 *
4123 * \sa \ref page_code_snippets_examples
4124 * \sa \ref kvTimeDomainCreate(), \ref kvTimeDomainRemoveHandle()
4125 */
4126kvStatus CANLIBAPI kvTimeDomainAddHandle(kvTimeDomain domain,
4127 const CanHandle hnd);
4128
4129/**
4130 * \ingroup TimeDomainHandling
4131 *
4132 * \source_cs <b>static Canlib.canStatus kvTimeDomainRemoveHandle(object domain, int handle);</b>
4133 *
4134 * \source_delphi <b>function kvTimeDomainRemoveHandle(domain: kvTimeDomain; handle: canHandle): kvStatus; </b>
4135 * \source_end
4136 *
4137 * This routine removes an open channel handle from a domain.
4138 *
4139 * \note A time domain is a set of channels with a common time base.
4140 *
4141 * \param[in] domain An opaque variable set by \ref kvTimeDomainCreate()
4142 * that identifies the domain to remove a handle from.
4143 * \param[in] hnd A handle to an open channel.
4144 *
4145 * \return \ref canOK (zero) if success
4146 * \return \ref canERR_xxx (negative) if failure
4147 *
4148 * \sa \ref kvTimeDomainCreate(), \ref kvTimeDomainAddHandle()
4149 */
4150kvStatus CANLIBAPI kvTimeDomainRemoveHandle (kvTimeDomain domain,
4151 const CanHandle hnd);
4152/**
4153 * \name kvCallback_t
4154 * \anchor kvCallback_t
4155 * \ref kvCallback_t is used by the function \ref kvSetNotifyCallback()
4156 *
4157 * The callback function is called with the following arguments:
4158 * \li hnd - the handle of the CAN channel where the event happened.
4159 * \li context - the context pointer you passed to \ref kvSetNotifyCallback().
4160 * \li notifyEvent - one of the \ref canNOTIFY_xxx notification codes.
4161 *
4162 * \note It is really the \ref canNOTIFY_xxx codes, and not the \ref
4163 * \ref canEVENT_xxx codes that the \ref canSetNotify() API is using.
4164 *
4165 * \param[in] hnd An open handle to a CAN channel.
4166 * \param[in] context Arbitrary user-defined context data which
4167 * is passed to the callback function.
4168 * \param[in] notifyEvent One or more of the \ref canEVENT_xxx flags.
4169 *
4170 */
4171typedef void (CANLIBAPI *kvCallback_t) (CanHandle hnd, void* context, unsigned int notifyEvent);
4172
4173/**
4174 * \ingroup General
4175 *
4176 * \source_cs <b>static Canlib.canStatus kvSetNotifyCallback(int hnd, Canlib.kvCallbackDelegate callback, IntPtr context, uint notifyFlags);</b>
4177 *
4178 * \source_delphi <b>function kvSetNotifyCallback(handle: canHandle; callback: kvCallback_t; context: Pointer; notifyFlags: Cardinal): canStatus; </b>
4179 * \source_end
4180 *
4181 * The \ref kvSetNotifyCallback() function registers a callback function which is
4182 * called when certain events occur.
4183 *
4184 * You can register at most one callback function per handle at any time.
4185 *
4186 * To remove the callback, call \ref kvSetNotifyCallback() with a \c NULL pointer in
4187 * the callback argument.
4188 *
4189 * \note The callback function is called in the context of a high-priority
4190 * thread created by CANLIB. You should take precaution not to do any time
4191 * consuming tasks in the callback. You must also arrange the synchronization
4192 * between the callback and your other threads yourself.
4193 *
4194 * \param[in] hnd An open handle to a CAN channel.
4195 * \param[in] callback A pointer to a callback function of type
4196 * \ref kvCallback_t
4197 * \param[in] context A pointer to arbitrary user-defined context data which
4198 * is passed to the callback function.
4199 * \param[in] notifyFlags One or more of the \ref canNOTIFY_xxx flags.
4200 *
4201 * \return \ref canOK (zero) if success
4202 * \return \ref canERR_xxx (negative) if failure
4203 *
4204 * \sa \ref canSetNotify()
4205 */
4206kvStatus CANLIBAPI kvSetNotifyCallback (const CanHandle hnd,
4207 kvCallback_t callback,
4208 void* context,
4209 unsigned int notifyFlags);
4210
4211/**
4212 * \name kvBUSTYPE_xxx
4213 * \anchor kvBUSTYPE_xxx
4214 *
4215 * Bus types, returned by \ref kvGetSupportedInterfaceInfo().
4216 * @{
4217 */
4218#define kvBUSTYPE_NONE 0 ///< Unkown bus type.
4219#define kvBUSTYPE_PCI 1 ///< Bus of type PCI.
4220#define kvBUSTYPE_PCMCIA 2 ///< Bus of type PCMCIA
4221#define kvBUSTYPE_USB 3 ///< Bus of type USB
4222#define kvBUSTYPE_WLAN 4 ///< Bus of type WLAN
4223#define kvBUSTYPE_PCI_EXPRESS 5 ///< Bus of type PCI Express
4224#define kvBUSTYPE_ISA 6 ///< Bus of type ISA
4225#define kvBUSTYPE_VIRTUAL 7 ///< Bus of type virtual
4226#define kvBUSTYPE_PC104_PLUS 8 ///< Bus of type PC104+
4227#define kvBUSTYPE_LAN 9 ///< Bus of type LAN
4228/** @} */
4229
4230/**
4231 * \name kvBUSTYPE_GROUP_xxx
4232 * \anchor kvBUSTYPE_GROUP_xxx
4233 *
4234 * Bus type group, returned when using \ref canCHANNELDATA_BUS_TYPE
4235 * This is a grouping of the individual \ref kvBUSTYPE_xxx.
4236 * @{
4237 */
4238#define kvBUSTYPE_GROUP_VIRTUAL 1 ///< \ref kvBUSTYPE_VIRTUAL
4239#define kvBUSTYPE_GROUP_LOCAL 2 ///< \ref kvBUSTYPE_USB
4240#define kvBUSTYPE_GROUP_REMOTE 3 ///< \ref kvBUSTYPE_WLAN, \ref kvBUSTYPE_LAN
4241#define kvBUSTYPE_GROUP_INTERNAL 4 ///< \ref kvBUSTYPE_PCI, \ref kvBUSTYPE_PCMCIA, ...
4242/** @} */
4243
4244/**
4245 * \ingroup General
4246 *
4247 * \source_cs <b>static Canlib.canStatus kvGetSupportedInterfaceInfo(int index, out string hwName, out int hwType, out int hwBusType);</b>
4248 *
4249 * \source_delphi <b>function kvGetSupportedInterfaceInfo(index: Integer; hwName: PChar; nameLen: Cardinal; var hwType: Integer; var hwBusType: Integer): kvStatus; </b>
4250 * \source_end
4251 *
4252 * The \ref kvGetSupportedInterfaceInfo function returns information about the
4253 * different supported hardware types in the installed version of CANLIB.
4254 *
4255 * This function is used to enumerate all the supported hardware types in the
4256 * installed version of CANLIB. It does not return a complete list of all
4257 * supported devices, nor does it return a list of the presently installed
4258 * hardware. The returned data indicates which device families are supported.
4259 *
4260 * For example, a returned set of data might be:
4261 * \li \a hwType = \ref canHWTYPE_MEMORATOR_PRO
4262 * \li \a hwBusType = \ref kvBUSTYPE_USB
4263 * \li \a hwName = \c "Kvaser Memorator Professional"
4264 *
4265 * This means that
4266 * \li the presently installed version of CANLIB supports members in the Kvaser
4267 * Memorator Pro family (e.g. the HS/HS and the HS/LS),
4268 * \li the members of the Kvaser Memorator Pro family are USB devices,
4269 * \li the members of the Kvaser Memorator Pro family use the
4270 * \ref canHWTYPE_MEMORATOR_PRO hardware type.
4271 *
4272 * The \ref kvGetSupportedInterfaceInfo() function is intended to help
4273 * application designers build a bus-oriented display of the different
4274 * installed and/or supported Kvaser devices in the computer.
4275 *
4276 * \param[in] index Use this parameter to enumerate the different supported
4277 * hardware types. Start with index = 0, and then call
4278 * \ref kvGetSupportedInterfaceInfo again() with index =
4279 * 1,2,3,... until the function returns an error code.
4280 * \param[out] hwName A pointer to a buffer that will receive the name of the
4281 * hardware family, as a zero-terminated ASCII string.
4282 * \param[in] nameLen The length of the hwName buffer.
4283 * \param[out] hwType Pointer to a 32-bit integer that will receive the
4284 * hardware type (one of the \ref canHWTYPE_xxx
4285 * constants.)
4286 * \param[out] hwBusType Pointer to a 32-bit integer that will receive the bus
4287 * type (one of the \ref kvBUSTYPE_xxx constants.)
4288 *
4289 * \return \ref canOK (zero) if success
4290 * \return \ref canERR_xxx (negative) if failure
4291 *
4292 * \sa \ref canBusOn(), \ref canResetBus()
4293 */
4294kvStatus CANLIBAPI kvGetSupportedInterfaceInfo (int index,
4295 char *hwName,
4296 size_t nameLen,
4297 int *hwType,
4298 int *hwBusType);
4299
4300/**
4301 * \ingroup General
4302 *
4303 * \source_cs <b>static Canlib.canStatus kvReadTimer(int hnd, out int time);</b>
4304 *
4305 * \source_delphi <b>function kvReadTimer(handle: canHandle; var time: Cardinal): kvStatus; </b>
4306 * \source_end
4307 *
4308 * The \ref kvReadTimer reads the hardware clock on the specified device and returns
4309 * the value.
4310 *
4311 * When the call to \ref kvReadTimer() returns, the time value is already
4312 * obsolete. The time required for the device firmware, any intermediary buses
4313 * (like USB,) and the operating system to return the time value is not
4314 * defined.
4315 *
4316 * This call should be used instead of \ref canReadTimer() because it can return an
4317 * error code if it fails.
4318 *
4319 * \param[in] hnd An open handle to a CAN channel.
4320 * \param[out] time A pointer to a 32-bit unsigned integer that will receive
4321 * the time value.
4322 *
4323 * \return \ref canOK (zero) if success
4324 * \return \ref canERR_xxx (negative) if failure
4325 *
4326 * \sa \ref canReadTimer(), \ref kvReadTimer64()
4327 */
4328kvStatus CANLIBAPI kvReadTimer (const CanHandle hnd, unsigned int *time);
4329
4330#if defined(KVINT64)
4331/**
4332 * \ingroup General
4333 *
4334 * \source_cs <b>static Canlib.canStatus kvReadTimer64(int hnd, out long time);</b>
4335 *
4336 * \source_delphi <b>function kvReadTimer64(handle: canHandle; var time: Int64): kvStatus; </b>
4337 * \source_end
4338 *
4339 * The \ref kvReadTimer64 reads the hardware clock on the specified device and
4340 * returns the value.
4341 *
4342 * When the call to \ref kvReadTimer64() returns, the time value is already
4343 * obsolete. The time required for the device firmware, any intermediary buses
4344 * (like USB,) and the operating system to return the time value is not
4345 * defined.
4346 *
4347 * This call should be used instead of \ref canReadTimer() because it can return an
4348 * error code if it fails.
4349 *
4350 * \param[in] hnd An open handle to a CAN channel.
4351 * \param[out] time A pointer to a 64-bit signed integer that will receive the
4352 * time value.
4353 *
4354 * \return \ref canOK (zero) if success
4355 * \return \ref canERR_xxx (negative) if failure
4356 *
4357 * \sa \ref kvReadTimer(), \ref canReadTimer()
4358 */
4359kvStatus CANLIBAPI kvReadTimer64 (const CanHandle hnd, KVINT64 *time);
4360#endif
4361
4362/**
4363 * \ingroup General
4364 *
4365 * \source_cs <b>static Canlib.canStatus kvReadDeviceCustomerData(int hnd, int userNumber, int itemNumber, byte[] data, int bufsize);</b>
4366 *
4367 * \source_delphi <b>function kvReadDeviceCustomerData(hnd: canHandle;userNumber, itemNumber: Integer; var data; bufsize: Cardinal): kvStatus; </b>
4368 * \source_end
4369 *
4370 * Reading customer data works with Kvaser Leaf (of all
4371 * types), Kvaser USBcan Professional, Kvaser Memorator Professional, Kvaser Eagle and
4372 * Kvaser Memorator Light. To write customer data use external tools.
4373 *
4374 * \param[in] hnd An open handle to a CAN channel.
4375 * \param[in] userNumber Assigned by Kvaser.
4376 * \param[in] itemNumber Must be zero (reserved)
4377 * \param[out] data A pointer to a buffer of up to 8 bytes where
4378 * the result will be placed.
4379 * \param[in] bufsiz The size of the buffer that data points at.
4380 *
4381 * \return \ref canOK (zero) if success
4382 * \return \ref canERR_xxx (negative) if failure
4383 */
4384kvStatus CANLIBAPI kvReadDeviceCustomerData (const CanHandle hnd,
4385 int userNumber,
4386 int itemNumber,
4387 void *data,
4388 size_t bufsiz);
4389
4390//ĤĤĤĤĤĤĤĤĤĤĤĤĤĤĤĤĤĤĤĤĤĤĤĤĤĤĤĤĤĤĤĤĤĤĤĤĤĤč
4391//
4392// APIs for t-script
4393//
4394
4395/**
4396 * \ingroup tScript
4397 * \name kvENVVAR_TYPE_xxx
4398 * \anchor kvENVVAR_TYPE_xxx
4399 *
4400 * These defines are used in \ref kvScriptEnvvarOpen().
4401 * @{
4402 */
4403 /**
4404 * This define is used in \ref kvScriptEnvvarOpen().
4405 *
4406 * It defines the type of the envvar as \c int.
4407 */
4408#define kvENVVAR_TYPE_INT 1
4409
4410 /**
4411 * This define is used in \ref kvScriptEnvvarOpen().
4412 *
4413 * It defines the type of the envvar as \c float.
4414 */
4415#define kvENVVAR_TYPE_FLOAT 2
4416
4417 /**
4418 * This define is used in \ref kvScriptEnvvarOpen().
4419 *
4420 * It defines the type of the envvar as \c string.
4421 */
4422#define kvENVVAR_TYPE_STRING 3
4423 /** @} */
4424/**
4425 * \ingroup tScript
4426 * \name kvEVENT_xxx
4427 * \anchor kvEVENT_xxx
4428 *
4429 * These defines are used in \ref kvScriptSendEvent().
4430 * @{
4431 */
4432
4433 /**
4434 * This define is used in \ref kvScriptSendEvent().
4435 *
4436 * It defines an event of type "key pressed".
4437 */
4438#define kvEVENT_TYPE_KEY 1
4439 /** @} */
4440 /**
4441 * \ingroup tScript
4442 *
4443 * A handle to a t-script envvar.
4444 * Returned by the function \ref kvScriptEnvvarOpen().
4445 */
4446typedef __int64 kvEnvHandle;
4447
4448/**
4449 * \ingroup tScript
4450 *
4451 * \source_cs <b>static Canlib.canStatus kvScriptStart(int hnd, int slotNo);</b>
4452 *
4453 * \source_delphi <b>function kvScriptStart(const hnd: canHandle; slotNo: integer): kvStatus; </b>
4454 * \source_end
4455 *
4456 * The \ref kvScriptStart() function starts a loaded script.
4457 *
4458 * \param[in] hnd An open handle to a CAN channel.
4459 * \param[in] slotNo The slot with the loaded script we want to start.
4460 *
4461 * \return \ref canOK (zero) if success
4462 * \return \ref canERR_xxx (negative) if failure
4463 *
4464 * \sa \ref page_code_snippets_examples
4465 * \sa \ref kvScriptLoadFile(), \ref kvScriptStop()
4466 */
4467kvStatus CANLIBAPI kvScriptStart (const CanHandle hnd, int slotNo);
4468
4469/**
4470 * Script stop modes. Used by \ref kvScriptStop().
4471 * \anchor kvSCRIPT_STOP_xxx
4472 * \name kvSCRIPT_STOP_xxx
4473 * @{
4474 */
4475#define kvSCRIPT_STOP_NORMAL 0 /**< Stop a running script */
4476#define kvSCRIPT_STOP_FORCED -9 /**< Request termination of a hanged script */
4477/** @} */
4478
4479
4480/**
4481 * \ingroup tScript
4482 *
4483 * \source_cs <b>static Canlib.canStatus kvScriptStop(int hnd, int slotNo, int mode);</b>
4484 *
4485 * \source_delphi <b>function kvScriptStop(const hnd: canHandle; slotNo: integer; mode: integer): kvStatus; </b>
4486 * \source_end
4487 *
4488 * The \ref kvScriptStop() function stops a started script.
4489 *
4490 * \param[in] hnd An open handle to a CAN channel.
4491 * \param[in] slotNo The slot with the loaded and running script we want to stop.
4492 * \param[in] mode Stop mode of type \ref kvSCRIPT_STOP_xxx
4493 *
4494 * \return \ref canOK (zero) if success
4495 * \return \ref canERR_xxx (negative) if failure
4496 *
4497 * \sa \ref page_code_snippets_examples
4498 * \sa \ref kvScriptLoadFile(), \ref kvScriptStart()
4499 */
4500kvStatus CANLIBAPI kvScriptStop (const CanHandle hnd, int slotNo, int mode);
4501
4502/**
4503 * \ingroup tScript
4504 *
4505 * \source_cs <b>static Canlib.canStatus kvScriptUnload(int hnd, int slotNo);</b>
4506 *
4507 * \source_delphi <b>function kvScriptUnload(const hnd: canHandle; slotNo: integer): kvStatus; </b>
4508 * \source_end
4509 *
4510 * The \ref kvScriptUnload() function unloads a stopped script.
4511 *
4512 * \param[in] hnd An open handle to a CAN channel.
4513 * \param[in] slotNo The slot with the loaded and stopped script we want to unload.
4514 *
4515 * \return \ref canOK (zero) if success
4516 * \return \ref canERR_xxx (negative) if failure
4517 *
4518 * \sa \ref page_code_snippets_examples
4519 * \sa \ref kvScriptLoadFile(), \ref kvScriptStop()
4520 */
4521kvStatus CANLIBAPI kvScriptUnload (const CanHandle hnd, int slotNo);
4522
4523/**
4524 * \ingroup tScript
4525 *
4526 * \source_cs <b>static Canlib.canStatus kvScriptSendEvent(int hnd, int slotNo, int eventType, int eventNo, uint data);</b>
4527 *
4528 * \source_delphi <b>function kvScriptSendEvent(const hnd: canHandle; slotNo: integer; eventType: integer; eventNo: integer; data: Cardinal): kvStatus; </b>
4529 * \source_end
4530 *
4531 * The \ref kvScriptSendEvent() function sends an event of a type, and an event
4532 * number and associated data to a script running in a specific slot.
4533 *
4534 * \param[in] hnd An open handle to a CAN channel.
4535 * \param[in] slotNo The slot where the script was loaded and is running.
4536 * \param[in] eventType The event to send, of type \ref kvEVENT_xxx
4537 * \param[in] eventNo The event's number.
4538 * \param[in] data The event's data.
4539 *
4540 * \return \ref canOK (zero) if success
4541 * \return \ref canERR_xxx (negative) if failure
4542 *
4543 * \sa \ref page_code_snippets_examples
4544 */
4545kvStatus CANLIBAPI kvScriptSendEvent (const CanHandle hnd,
4546 int slotNo,
4547 int eventType,
4548 int eventNo,
4549 unsigned int data);
4550
4551/**
4552 * \ingroup tScript
4553 *
4554 * \source_cs <b>static long kvScriptEnvvarOpen(int hnd, string envvarName, out int envvarType, out int envvarSize);</b>
4555 *
4556 * \source_delphi <b>function kvScriptEnvvarOpen(const hnd: canHandle; envvarName: PChar; var envvarType: Integer; var envvarSize: Integer): \ref kvEnvHandle; </b>
4557 * \source_end
4558 *
4559 * The \ref kvScriptEnvvarOpen() opens an existing envvar and returns a handle to it.
4560 *
4561 * \param[in] hnd An open handle to a CAN channel.
4562 * \param[in] envvarName The envvar's name; a pointer to a \c NULL terminated
4563 * array of chars.
4564 * \param[out] envvarType A pointer to a 32-bit integer that will receive the
4565 * \ref kvENVVAR_TYPE_xxx type.
4566 * \param[out] envvarSize A pointer to a 32-bit integer that will receive the
4567 * size of the envvar in bytes.
4568 *
4569 * \return A \ref kvEnvHandle handle (positive) to an envvar if success
4570 * \return \ref canERR_xxx (negative) if failure
4571 *
4572 * \sa \ref page_code_snippets_examples
4573 * \sa \ref kvScriptEnvvarClose()
4574 */
4575kvEnvHandle CANLIBAPI kvScriptEnvvarOpen (const CanHandle hnd,
4576 char* envvarName,
4577 int *envvarType,
4578 int *envvarSize); // returns scriptHandle
4579
4580/**
4581 * \ingroup tScript
4582 *
4583 * \source_cs <b>static Canlib.canStatus kvScriptEnvvarClose(long eHnd);</b>
4584 *
4585 * \source_delphi <b>function kvScriptEnvvarClose(const eHnd: kvEnvHandle): kvStatus; </b>
4586 * \source_end
4587 *
4588 * The \ref kvScriptEnvvarClose() function closes an open envvar.
4589 *
4590 * \param[in] eHnd An open handle to an envvar.
4591 *
4592 * \return \ref canOK (zero) if success
4593 * \return \ref canERR_xxx (negative) if failure
4594 *
4595 * \sa \ref kvScriptEnvvarOpen()
4596 */
4597kvStatus CANLIBAPI kvScriptEnvvarClose (kvEnvHandle eHnd);
4598
4599/**
4600 * \ingroup tScript
4601 *
4602 * \source_cs <b>static Canlib.canStatus kvScriptEnvvarSetInt(long eHnd, int val);</b>
4603 *
4604 * \source_delphi <b>function kvScriptEnvvarSetInt(const eHnd: kvEnvHandle; val: Integer): kvStatus; </b>
4605 * \source_end
4606 *
4607 * The \ref kvScriptEnvvarSetInt() sets the value of an \c int envvar.
4608 *
4609 * \param[in] eHnd An open handle to an envvar.
4610 * \param[in] val The new value.
4611 *
4612 * \return \ref canOK (zero) if success
4613 * \return \ref canERR_xxx (negative) if failure
4614 *
4615 * \sa \ref page_code_snippets_examples
4616 * \sa \ref kvScriptEnvvarOpen(), \ref kvScriptEnvvarGetInt(), \ref kvScriptEnvvarSetFloat(),
4617 * \ref kvScriptEnvvarSetData()
4618 */
4619kvStatus CANLIBAPI kvScriptEnvvarSetInt (kvEnvHandle eHnd, int val);
4620
4621/**
4622 * \ingroup tScript
4623 *
4624 * \source_cs <b>static Canlib.canStatus kvScriptEnvvarGetInt(long eHnd, out int val);</b>
4625 *
4626 * \source_delphi <b>function kvScriptEnvvarGetInt(const eHnd: kvEnvHandle; var val: Integer): kvStatus; </b>
4627 * \source_end
4628 *
4629 * The \ref kvScriptEnvvarGetInt() function retrieves the value of an \c int envvar.
4630 *
4631 * \param[in] eHnd An open handle to an envvar.
4632 * \param[out] val The current value.
4633 *
4634 * \return \ref canOK (zero) if success
4635 * \return \ref canERR_xxx (negative) if failure
4636 *
4637 * \sa \ref page_code_snippets_examples
4638 * \sa \ref kvScriptEnvvarOpen(), \ref kvScriptEnvvarSetInt(), \ref kvScriptEnvvarGetFloat(),
4639 * \ref kvScriptEnvvarGetData()
4640 *
4641 */
4642kvStatus CANLIBAPI kvScriptEnvvarGetInt (kvEnvHandle eHnd, int *val);
4643
4644/**
4645 * \ingroup tScript
4646 *
4647 * \source_cs <b>static Canlib.canStatus kvScriptEnvvarSetFloat(long eHnd, float val);</b>
4648 *
4649 * \source_delphi <b>function kvScriptEnvvarSetFloat(const eHnd: kvEnvHandle; val: Single): kvStatus; </b>
4650 * \source_end
4651 *
4652 * The \ref kvScriptEnvvarSetFloat() sets the value of a \c float envvar.
4653 *
4654 * \param[in] eHnd An open handle to an envvar.
4655 * \param[in] val The new value.
4656 *
4657 * \return \ref canOK (zero) if success
4658 * \return \ref canERR_xxx (negative) if failure
4659 *
4660 * \sa \ref page_code_snippets_examples
4661 * \sa \ref kvScriptEnvvarOpen(), \ref kvScriptEnvvarGetFloat(), \ref kvScriptEnvvarSetInt(),
4662 * \ref kvScriptEnvvarSetData()
4663 */
4664kvStatus CANLIBAPI kvScriptEnvvarSetFloat (kvEnvHandle eHnd, float val);
4665
4666/**
4667 * \ingroup tScript
4668 *
4669 * \source_cs <b>static Canlib.canStatus kvScriptEnvvarGetFloat(long eHnd, out float val);</b>
4670 *
4671 * \source_delphi <b>function kvScriptEnvvarGetFloat(const eHnd: kvEnvHandle; var val: Single): kvStatus; </b>
4672 * \source_end
4673 *
4674 * The \ref kvScriptEnvvarGetFloat() function retrieves the value of a \c float envvar.
4675 *
4676 * \param[in] eHnd An open handle to an envvar.
4677 * \param[out] val A pointer to a \c float where the retrieved result should be
4678 * stored.
4679 *
4680 * \return \ref canOK (zero) if success
4681 * \return \ref canERR_xxx (negative) if failure
4682 *
4683 * \sa \ref page_code_snippets_examples
4684 * \sa \ref kvScriptEnvvarOpen(), \ref kvScriptEnvvarSetFloat(), \ref kvScriptEnvvarGetInt(),
4685 * \ref kvScriptEnvvarGetData()
4686 */
4687kvStatus CANLIBAPI kvScriptEnvvarGetFloat (kvEnvHandle eHnd, float *val);
4688
4689/**
4690 * \ingroup tScript
4691 *
4692 * \source_cs <b>static Canlib.canStatus kvScriptEnvvarSetData(long eHnd, byte[] buf, int start_index, int data_len);</b>
4693 *
4694 * \source_delphi <b>function kvScriptEnvvarSetData(const eHnd: kvEnvHandle; var buf; start_index: Integer; data_len: Integer): kvStatus; </b>
4695 * \source_end
4696 *
4697 * The \ref kvScriptEnvvarSetData() function sets a range of data bytes in an envvar.
4698 *
4699 * \param[in] eHnd An open handle to an envvar.
4700 * \param[in] buf A pointer to a data area with the new values.
4701 * \param[in] start_index The start index of the envvar's data range that we
4702 * want to update.
4703 * \param[in] data_len The length in bytes of the envvar's data range that
4704 * we want to update.
4705 *
4706 * \return \ref canOK (zero) if success
4707 * \return \ref canERR_xxx (negative) if failure
4708 *
4709 * \sa \ref page_code_snippets_examples
4710 * \sa \ref kvScriptEnvvarOpen(), \ref kvScriptEnvvarGetData(), \ref kvScriptEnvvarSetInt(),
4711 * \ref kvScriptEnvvarSetFloat()
4712 */
4713kvStatus CANLIBAPI kvScriptEnvvarSetData (kvEnvHandle eHnd,
4714 void *buf,
4715 int start_index,
4716 int data_len);
4717
4718/**
4719 * \ingroup tScript
4720 *
4721 * \source_cs <b>static Canlib.canStatus kvScriptEnvvarGetData(long eHnd, out byte[] buf, int start_index, int data_len);</b>
4722 *
4723 * \source_delphi <b>function kvScriptEnvvarGetData(const eHnd: kvEnvHandle; var buf; start_index: Integer; data_len: Integer): kvStatus; </b>
4724 * \source_end
4725 *
4726 * The \ref kvScriptEnvvarGetData() function retrieves a range of data bytes from an envvar.
4727 *
4728 * \param[in] eHnd An open handle to an envvar.
4729 * \param[out] buf A pointer to a data area where the retrieved data
4730 * range should be stored.
4731 * \param[in] start_index The start index of the data range.
4732 * \param[in] data_len The length in bytes of the data range.
4733 *
4734 * \return \ref canOK (zero) if success
4735 * \return \ref canERR_xxx (negative) if failure
4736 *
4737 * \sa \ref page_code_snippets_examples
4738 * \sa \ref kvScriptEnvvarOpen(), \ref kvScriptEnvvarSetData(), \ref kvScriptEnvvarGetInt(),
4739 * \ref kvScriptEnvvarGetFloat()
4740 */
4741kvStatus CANLIBAPI kvScriptEnvvarGetData (kvEnvHandle eHnd,
4742 void *buf,
4743 int start_index,
4744 int data_len);
4745
4746/**
4747 * \ingroup tScript
4748 *
4749 * \source_cs <b>static Canlib.canStatus kvScriptLoadFileOnDevice(int hnd, int slotNo, ref string localFile);</b>
4750 *
4751 * \source_delphi <b>function kvScriptLoadFileOnDevice(hnd: canHandle; slotNo: Integer; localFile: PChar): kvStatus; </b>
4752 * \source_end
4753 *
4754 * The \ref kvScriptLoadFileOnDevice() function loads a compiled script file (.txe)
4755 * stored on the device (SD card) into a script slot on the device.
4756 *
4757 * \param[in] hnd An open handle to a CAN channel.
4758 * \param[in] slotNo The slot where to load the script.
4759 * \param[in] localFile The script file name; a pointer to a \c NULL terminated
4760 * array of chars.
4761 *
4762 * \return \ref canOK (zero) if success
4763 * \return \ref canERR_xxx (negative) if failure
4764 *
4765 * \sa \ref page_code_snippets_examples
4766 * \sa \ref kvScriptLoadFile(), \ref kvFileCopyToDevice(), \ref kvScriptStart(),
4767 * \ref kvScriptStop()
4768 */
4769kvStatus CANLIBAPI kvScriptLoadFileOnDevice (const CanHandle hnd,
4770 int slotNo,
4771 char *localFile);
4772
4773/**
4774 * \ingroup tScript
4775 *
4776 * \source_cs <b>static Canlib.canStatus kvScriptLoadFile(int hnd, int slotNo, ref string filePathOnPC);</b>
4777 *
4778 * \source_delphi <b>function kvScriptLoadFile(hnd: canHandle; slotNo: Integer; filePathOnPC: PChar): kvStatus; </b>
4779 * \source_end
4780 *
4781 * The \ref kvScriptLoadFile() function loads a compiled script file (.txe) stored
4782 * on the host (PC) into a script slot on the device.
4783 *
4784 * \param[in] hnd An open handle to a CAN channel.
4785 * \param[in] slotNo The slot where to load the script.
4786 * \param[in] filePathOnPC The script file name; a pointer to a \c NULL
4787 * terminated array of chars.
4788 *
4789 * \return \ref canOK (zero) if success
4790 * \return \ref canERR_xxx (negative) if failure
4791 *
4792 * \sa \ref page_code_snippets_examples
4793 * \sa \ref kvScriptLoadFileOnDevice(), \ref kvFileCopyToDevice(), \ref kvScriptStart(),
4794 * \ref kvScriptStop()
4795 */
4796kvStatus CANLIBAPI kvScriptLoadFile (const CanHandle hnd,
4797 int slotNo,
4798 char *filePathOnPC);
4799
4800
4801
4802
4803/**
4804 * \ingroup General
4805 * \name kvSCRIPT_REQUEST_TEXT_xxx
4806 * \anchor kvSCRIPT_REQUEST_TEXT_xxx
4807 *
4808 * These defines are used in \ref kvScriptRequestText() for printf message subscribe/unsubscribe.
4809 *
4810 * @{
4811 */
4812
4813/**
4814 * Cancel subscription of printf messages from script slots.
4815 */
4816#define kvSCRIPT_REQUEST_TEXT_UNSUBSCRIBE 1
4817
4818/**
4819 * Subscribe to printf messages from script slots.
4820 */
4821#define kvSCRIPT_REQUEST_TEXT_SUBSCRIBE 2
4822
4823/**
4824 * Select all script slots.
4825 */
4826#define kvSCRIPT_REQUEST_TEXT_ALL_SLOTS 255
4827
4828/** @} */
4829
4830
4831/**
4832 * \ingroup tScript
4833 *
4834 * \source_cs <b>static Canlib.canStatus kvScriptRequestText(int hnd, int slot, int request);</b>
4835 *
4836 * \source_delphi <b>function kvScriptRequestText(hnd: canHandle; slotNo: cardinal; request: cardinal): kvStatus; </b>
4837 * \source_end
4838 *
4839 * The \ref kvScriptRequestText() Sets up a printf subscription to a
4840 * selected script slot.
4841 * Read the printf messages with \ref kvScriptGetText().
4842 *
4843 * \param[in] hnd An open handle to a CAN channel.
4844 * \param[in] slot The slot to subscribe to.
4845 * \param[in] request Subscription request i.e. \ref kvSCRIPT_REQUEST_TEXT_xxx.
4846 *
4847 * \return \ref canOK (zero) if success
4848 * \return \ref canERR_xxx (negative) if failure
4849 *
4850 */
4851kvStatus CANLIBAPI kvScriptRequestText(const CanHandle hnd,
4852 unsigned int slot,
4853 unsigned int request);
4854
4855
4856
4857/**
4858 * \ingroup tScript
4859 *
4860 * \source_cs <b>static Canlib.canStatus kvScriptGetText(int hnd, out int slot, out ulong time, out int flags, out string buf);</b>
4861 *
4862 * \source_delphi <b>function kvScriptGetText(hnd: canHandle; var slot: integer; var time: Cardinal; var flags: Cardinal; buf: PChar; bufsize: Cardinal): kvStatus; </b>
4863 * \source_end
4864 *
4865 * The \ref kvScriptGetText() Reads a printf from a subscribed script slot.
4866 * Set up a subscription with \ref kvScriptRequestText().
4867 *
4868 * \param[in] hnd An open handle to a CAN channel.
4869 * \param[out] slot The slot where the printf originated.
4870 * \param[out] time The printf timestamp.
4871 * \param[out] flags Printf flags. A combination of \ref canSTAT_xxx flags.
4872 * \param[out] buf Buffer to hold the printf string.
4873 * \param[in] bufsize Size of the buffer.
4874 *
4875 * \return \ref canOK (zero) if success
4876 * \return \ref canERR_xxx (negative) if failure
4877 *
4878 */
4879kvStatus CANLIBAPI kvScriptGetText(const CanHandle hnd,
4880 int *slot,
4881 unsigned long *time,
4882 unsigned int *flags,
4883 char *buf,
4884 size_t bufsize
4885 );
4886
4887
4888
4889/**
4890 * Script status flag bits. Used by \ref kvScriptStatus().
4891 * \anchor kvSCRIPT_STATUS_xxx
4892 * \name kvSCRIPT_STATUS_xxx
4893 * @{
4894 */
4895#define kvSCRIPT_STATUS_LOADED 1 /**< The slot is loaded with a script */
4896#define kvSCRIPT_STATUS_RUNNING 2 /**< The slot is running a script. */
4897/** @} */
4898
4899
4900/**
4901 * \ingroup tScript
4902 *
4903 * \source_cs <b>static Canlib.canStatus kvScriptStatus(int hnd, int slot, out unsigned int status);</b>
4904 * \source_delphi <b>function kvScriptStatus(hnd: canHandle; var slot: integer; var time: integer): kvStatus;</b>
4905 * \source_end
4906 *
4907 * The \ref kvScriptStatus() function reads the current status of a script slot.
4908 *
4909 * \param[in] hnd An open handle to a CAN channel.
4910 * \param[in] slot The slot which status we want.
4911 * \param[out] status The script status, as \ref kvSCRIPT_STATUS_xxx flag bits
4912 *
4913 * \return \ref canOK (zero) if success
4914 * \return \ref canERR_xxx (negative) if failure
4915 */
4916kvStatus CANLIBAPI kvScriptStatus(const CanHandle hnd,
4917 int slot,
4918 unsigned int *status);
4919
4920
4921
4922
4923/**
4924 * \ingroup tScript
4925 *
4926 * \source_cs <b>static Canlib.canStatus kvFileCopyToDevice(int hnd, string hostFileName, string deviceFileName);</b>
4927 *
4928 * \source_delphi <b>function kvFileCopyToDevice(hnd: canHandle; hostFileName: PChar; deviceFileName: PChar): kvStatus; </b>
4929 * \source_end
4930 *
4931 * The \ref kvFileCopyToDevice() function copies an arbitrary file from the host to
4932 * the device.
4933 *
4934 * \param[in] hnd An open handle to a CAN channel.
4935 * \param[in] hostFileName The host file name; a pointer to a \c NULL terminated
4936 * array of chars.
4937 * \param[in] deviceFileName The target device file name; a pointer to a \c NULL
4938 * terminated array of chars.
4939 *
4940 * \return \ref canOK (zero) if success
4941 * \return \ref canERR_xxx (negative) if failure
4942 *
4943 * \sa \ref kvFileCopyFromDevice(), \ref kvFileDelete()
4944 */
4945kvStatus CANLIBAPI kvFileCopyToDevice (const CanHandle hnd,
4946 char *hostFileName,
4947 char *deviceFileName);
4948
4949/**
4950 * \ingroup tScript
4951 *
4952 * \source_cs <b>static Canlib.canStatus kvFileCopyFromDevice(int hnd, string deviceFileName, string hostFileName);</b>
4953 *
4954 * \source_delphi <b>function kvFileCopyFromDevice(hnd: canHandle; deviceFileName: PChar; hostFileName: PChar): kvStatus; </b>
4955 * \source_end
4956 *
4957 * The \ref kvFileCopyFromDevice() function copies an arbitrary file from the device
4958 * to the host.
4959 *
4960 * \param[in] hnd An open handle to a CAN channel.
4961 * \param[in] deviceFileName The device file name; a pointer to a \c NULL
4962 * terminated array of chars.
4963 * \param[in] hostFileName The target host file name; a pointer to a \c NULL terminated
4964 * array of chars.
4965 *
4966 * \return \ref canOK (zero) if success
4967 * \return \ref canERR_xxx (negative) if failure
4968 *
4969 * \sa \ref kvFileCopyToDevice()
4970 */
4971kvStatus CANLIBAPI kvFileCopyFromDevice (const CanHandle hnd,
4972 char *deviceFileName,
4973 char *hostFileName);
4974
4975/**
4976 * \ingroup tScript
4977 *
4978 * \source_cs <b>static Canlib.canStatus kvFileDelete(int hnd, string deviceFileName);</b>
4979 *
4980 * \source_delphi <b>function kvFileDelete(hnd: canHandle; deviceFileName: PChar): kvStatus; </b>
4981 * \source_end
4982 *
4983 * The \ref kvFileDelete() function deletes a file on the device.
4984 *
4985 * \note Deleting system files is not recommended.
4986 *
4987 * \param[in] hnd An open handle to a CAN channel.
4988 * \param[in] deviceFileName The file on the device to delete; a pointer
4989 * to a \c NULL terminated array of chars.
4990 *
4991 * \return \ref canOK (zero) if success
4992 * \return \ref canERR_xxx (negative) if failure
4993 *
4994 * \sa \ref kvFileCopyToDevice()
4995 */
4996kvStatus CANLIBAPI kvFileDelete (const CanHandle hnd, char *deviceFileName);
4997
4998/**
4999 * \ingroup tScript
5000 *
5001 * \source_cs <b>static Canlib.canStatus kvFileGetName(int hnd, int fileNo, out string name);</b>
5002 *
5003 * \source_delphi <b>function kvFileGetName(hnd: canHandle; fileNo: Integer; name: PChar; namelen: Integer): kvStatus; </b>
5004 * \source_end
5005 *
5006 * The \ref kvFileGetName() function returns the name of the file with
5007 * number \a fileNo.
5008 *
5009 * \param[in] hnd An open handle to a CAN channel.
5010 * \param[in] fileNo The number of the file.
5011 * \param[out] name A buffer that will contain the name of the
5012 * file. The name is a zero-terminated ASCII string.
5013 * \param[in] namelen The length, in bytes, of the \a name buffer.
5014 *
5015 * \return \ref canOK (zero) if success
5016 * \return \ref canERR_xxx (negative) if failure
5017 *
5018 * \sa \ref kvFileGetCount(), \ref kvFileGetSystemData()
5019 */
5020kvStatus CANLIBAPI kvFileGetName (const CanHandle hnd,
5021 int fileNo,
5022 char *name,
5023 int namelen);
5024
5025/**
5026 * \ingroup tScript
5027 *
5028 * \source_cs <b>static Canlib.canStatus kvFileGetCount(int hnd, out int count);</b>
5029 *
5030 * \source_delphi <b>function kvFileGetCount(hnd: canHandle; var count: Integer): kvStatus; </b>
5031 * \source_end
5032 *
5033 * The \ref kvFileGetCount() function returns the number of files.
5034 *
5035 * \param[in] hnd An open handle to a CAN channel.
5036 * \param[out] count A pointer to a 32-bit integer that will receive
5037 * the file count.
5038 *
5039 * \return \ref canOK (zero) if success
5040 * \return \ref canERR_xxx (negative) if failure
5041 *
5042 * \sa \ref kvFileGetName(), \ref kvFileGetSystemData()
5043 */
5044kvStatus CANLIBAPI kvFileGetCount (const CanHandle hnd, int *count);
5045
5046/**
5047 * \ingroup tScript
5048 *
5049 * \source_cs <b>static Canlib.canStatus kvFileGetSystemData(int hnd, int itemCode, out int result);</b>
5050 *
5051 * \source_delphi <b>function kvFileGetSystemData(hnd: canHandle; itemCode: Integer; var result: Integer): kvStatus; </b>
5052 * \source_end
5053 *
5054 * The \ref kvFileGetSystemData() function is used for reading disk parameters,
5055 * e.g. size, max number of (user) files, etc.
5056 *
5057 * \note Not yet implemented
5058 *
5059 * \param[in] hnd An open handle to a CAN channel.
5060 * \param[in] itemCode The item we want information on.
5061 * \param[out] result A pointer to a 32-bit integer that will
5062 * receive the result.
5063 *
5064 * \return \ref canOK (zero) if success
5065 * \return \ref canERR_xxx (negative) if failure
5066 *
5067 */
5068kvStatus CANLIBAPI kvFileGetSystemData (const CanHandle hnd,
5069 int itemCode,
5070 int *result);
5071
5072/**
5073 * \ingroup General
5074 * \anchor kvDEVICE_MODE_xxx
5075 * \name kvDEVICE_MODE_xxx
5076 *
5077 * These defines are used in \ref kvDeviceSetMode() and \ref kvDeviceGetMode().
5078 *
5079 * \note The mode is device specific, which means that not all modes are
5080 * implemented in all products.
5081 *
5082 * @{
5083 */
5084 /**
5085 * This define is used in \ref kvDeviceSetMode() and \ref kvDeviceGetMode().
5086 *
5087 * Device is running or should be running in interface mode.
5088 */
5089#define kvDEVICE_MODE_INTERFACE 0x00
5090 /**
5091 * This define is used in \ref kvDeviceSetMode() and \ref kvDeviceGetMode().
5092 *
5093 * Device is running or should be running in logger mode.
5094 */
5095#define kvDEVICE_MODE_LOGGER 0x01
5096 /** @} */
5097
5098
5099/**
5100 * \ingroup General
5101 *
5102 * \source_cs <b>static Canlib.canStatus kvDeviceSetMode(int hnd, int mode);</b>
5103 *
5104 * \source_delphi <b>function kvDeviceSetMode(hnd: canHandle; mode: Integer): kvStatus; </b>
5105 * \source_end
5106 *
5107 * The \ref kvDeviceSetMode() sets the mode.
5108 *
5109 * \note The mode is device specific, which means that not all modes are
5110 * implemented in all products.
5111 *
5112 * \param[in] hnd An open handle to a CAN channel.
5113 * \param[in] mode One of the \ref kvDEVICE_MODE_xxx constants,
5114 * defining which mode to use.
5115 *
5116 * \return \ref canOK (zero) if success
5117 * \return \ref canERR_xxx (negative) if failure
5118 *
5119 * \sa \ref kvDeviceGetMode()
5120 */
5121kvStatus CANLIBAPI kvDeviceSetMode (const CanHandle hnd, int mode);
5122
5123/**
5124 * \ingroup General
5125 *
5126 * \source_cs <b>static Canlib.canStatus kvDeviceGetMode(int hnd, out int result);</b>
5127 *
5128 * \source_delphi <b>function kvDeviceGetMode(hnd: canHandle; var mode: Integer): kvStatus; </b>
5129 * \source_end
5130 *
5131 * The \ref kvDeviceGetMode() reads the current device's specific mode.
5132 *
5133 * \note The mode is device specific, which means that not all modes are
5134 * implemented in all products.
5135 *
5136 * \param[in] hnd An open handle to a CAN channel.
5137 * \param[out] result A pointer to a 32-bit integer that will receive the
5138 * \ref kvDEVICE_MODE_xxx value.
5139 *
5140 * \return \ref canOK (zero) if success
5141 * \return \ref canERR_xxx (negative) if failure
5142 *
5143 * \sa \ref kvDeviceSetMode()
5144 */
5145kvStatus CANLIBAPI kvDeviceGetMode (const CanHandle hnd, int *result);
5146
5147
5148/**
5149 * \ingroup General
5150 *
5151 * \source_cs <b>static Canlib.canStatus kvPingRequest(int hnd, out uint requestTime);</b>
5152 *
5153 * \source_delphi <b>function kvPingRequest(hnd: canHandle; var requestTime: Cardinal): kvStatus; </b>
5154 * \source_end
5155 *
5156 * This function sends an active ping to a device. The ping time can later be
5157 * retrieved using \ref kvPingGetLatest().
5158 *
5159 * \param[in] hnd A handle to an open circuit.
5160 * \param[out] requestTime Time of request in microseconds. Used for matching answer to request.
5161 *
5162 * \return \ref canOK (zero) if success
5163 * \return \ref canERR_xxx (negative) if failure
5164 */
5165kvStatus CANLIBAPI kvPingRequest (const CanHandle hnd,
5166 unsigned int *requestTime);
5167
5168/**
5169 * \ingroup General
5170 *
5171 * \source_cs <b>static Canlib.canStatus kvPingGetLatest(int hnd, out uint requestTime, out uint pingTime);</b>
5172 *
5173 * \source_delphi <b>function kvPingGetLatest(hnd: canHandle; var requestTime: Cardinal; var pingTime: Cardinal): kvStatus; </b>
5174 * \source_end
5175 *
5176 * This retrieves the latest ping time issued by an earlier call to \ref kvPingRequest()
5177 *
5178 * \param[in] hnd A handle to an open circuit.
5179 * \param[out] requestTime Time of request in microseconds. Used for matching answer to request.
5180 * \param[out] pingTime Latest value of ping time in milliseconds.
5181 *
5182 * \return \ref canOK (zero) if success
5183 * \return \ref canERR_xxx (negative) if failure
5184 */
5185 kvStatus CANLIBAPI kvPingGetLatest (const CanHandle hnd,
5186 unsigned int *requestTime,
5187 unsigned int *pingTime);
5188
5189
5190/**
5191 * \ingroup Internal
5192 * \anchor Internal
5193 * \name Unimplemented internal
5194 *
5195 * The following are not yet implemented. Do not use it.
5196 *
5197 * @{
5198 */
5199//
5200//
5201//
5202#if defined(_CANEVT_H_)
5203canStatus CANLIBAPI canReadEvent (const CanHandle hnd, CanEvent *event);
5204#endif
5205
5206/** This function is not implemented, do not use it. */
5207void CANLIBAPI canSetDebug(int d);
5208/** This function is not implemented, do not use it. */
5209canStatus CANLIBAPI canSetNotifyEx (const CanHandle hnd,
5210 HANDLE event,
5211 unsigned int flags);
5212/** This function is not implemented, do not use it. */
5213canStatus CANLIBAPI canSetTimer (const CanHandle hnd,
5214 DWORD interval,
5215 DWORD flags);
5216/** This is reserved for \ref canSetTimer() but not implemented, do not use it. */
5217#define canTIMER_CYCLIC 0x01
5218/** This is reserved for \ref canSetTimer() but not implemented, do not use it. */
5219#define canTIMER_EXPENSIVE 0x02
5220/** This function is not implemented, do not use it. */
5221int CANLIBAPI canSplitHandle (CanHandle hnd, int channel);
5222/** This function is not implemented, do not use it. */
5223int CANLIBAPI canOpenMultiple (DWORD bitmask, int flags);
5224/** @} */
5225#endif
5226
5227#ifdef __cplusplus
5228}
5229#endif
5230
5231# include "obsolete.h"
5232
5233#endif
Note: See TracBrowser for help on using the repository browser.