[97] | 1 | /**
|
---|
| 2 | * \section LICENSE
|
---|
| 3 | * <pre style="white-space: pre-wrap">
|
---|
| 4 | * This software is dual licensed under the following two licenses:
|
---|
| 5 | * BSD-new and GPLv2. You may use either one. See the included
|
---|
| 6 | * COPYING file for details.
|
---|
| 7 | *
|
---|
| 8 | * License: BSD-new
|
---|
| 9 | * ===============================================================================
|
---|
| 10 | * Redistribution and use in source and binary forms, with or without
|
---|
| 11 | * modification, are permitted provided that the following conditions are met:
|
---|
| 12 | * * Redistributions of source code must retain the above copyright
|
---|
| 13 | * notice, this list of conditions and the following disclaimer.
|
---|
| 14 | * * Redistributions in binary form must reproduce the above copyright
|
---|
| 15 | * notice, this list of conditions and the following disclaimer in the
|
---|
| 16 | * documentation and/or other materials provided with the distribution.
|
---|
| 17 | * * Neither the name of the <organization> nor the
|
---|
| 18 | * names of its contributors may be used to endorse or promote products
|
---|
| 19 | * derived from this software without specific prior written permission.
|
---|
| 20 | *
|
---|
| 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
---|
| 22 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
---|
| 23 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
---|
| 24 | * DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
|
---|
| 25 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
---|
| 26 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
---|
| 27 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
---|
| 28 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
---|
| 29 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
---|
| 30 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
| 31 | *
|
---|
| 32 | *
|
---|
| 33 | * License: GPLv2
|
---|
| 34 | * ===============================================================================
|
---|
| 35 | * This program is free software; you can redistribute it and/or
|
---|
| 36 | * modify it under the terms of the GNU General Public License
|
---|
| 37 | * as published by the Free Software Foundation; either version 2
|
---|
| 38 | * of the License, or (at your option) any later version.
|
---|
| 39 | *
|
---|
| 40 | * This program is distributed in the hope that it will be useful,
|
---|
| 41 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 42 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 43 | * GNU General Public License for more details.
|
---|
| 44 | *
|
---|
| 45 | * You should have received a copy of the GNU General Public License
|
---|
| 46 | * along with this program; if not, write to the Free Software
|
---|
| 47 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
---|
| 48 | *
|
---|
| 49 | * ---------------------------------------------------------------------------
|
---|
| 50 | * </pre>
|
---|
| 51 | *
|
---|
| 52 | * \section DESCRIPTION
|
---|
| 53 | *
|
---|
| 54 | * Definitions for the CANLIB API.
|
---|
| 55 | *
|
---|
| 56 | * \file canlib.h
|
---|
| 57 | * \author Kvaser AB
|
---|
| 58 | *
|
---|
| 59 | * \defgroup General General
|
---|
| 60 | * \defgroup CAN CAN
|
---|
| 61 | * \defgroup ObjectBuffers Object buffers
|
---|
| 62 | */
|
---|
| 63 |
|
---|
| 64 | #ifndef _CANLIB_H_
|
---|
| 65 | #define _CANLIB_H_
|
---|
| 66 |
|
---|
| 67 | #include <stdlib.h>
|
---|
| 68 |
|
---|
| 69 | # define CANLIB_DECLARE_ALL
|
---|
| 70 | typedef unsigned char BYTE;
|
---|
| 71 | typedef unsigned int DWORD;
|
---|
| 72 | typedef unsigned int HANDLE;
|
---|
| 73 | typedef unsigned int BOOL;
|
---|
| 74 | #include "canstat.h"
|
---|
| 75 |
|
---|
| 76 | /** Handle to an opened circuit. */
|
---|
| 77 | typedef int canHandle;
|
---|
| 78 | /** Handle to an opened circuit. */
|
---|
| 79 | typedef canHandle CanHandle;
|
---|
| 80 |
|
---|
| 81 | /**
|
---|
| 82 | * \ingroup CAN
|
---|
| 83 | */
|
---|
| 84 | typedef struct canNotifyData {
|
---|
| 85 | void *tag;
|
---|
| 86 | int eventType;
|
---|
| 87 | union {
|
---|
| 88 | struct {
|
---|
| 89 | unsigned long time;
|
---|
| 90 | } busErr;
|
---|
| 91 | struct {
|
---|
| 92 | long id;
|
---|
| 93 | unsigned long time;
|
---|
| 94 | } rx;
|
---|
| 95 | struct {
|
---|
| 96 | long id;
|
---|
| 97 | unsigned long time;
|
---|
| 98 | } tx;
|
---|
| 99 | struct {
|
---|
| 100 | unsigned char busStatus;
|
---|
| 101 | unsigned char txErrorCounter;
|
---|
| 102 | unsigned char rxErrorCounter;
|
---|
| 103 | unsigned long time;
|
---|
| 104 | } status;
|
---|
| 105 | } info;
|
---|
| 106 | } canNotifyData;
|
---|
| 107 |
|
---|
| 108 |
|
---|
| 109 | /** Notify message sent to the application window */
|
---|
| 110 | # define WM__CANLIB 648
|
---|
| 111 |
|
---|
| 112 | /**
|
---|
| 113 | * \name canOPEN_xxx
|
---|
| 114 | * \anchor canOPEN_xxx
|
---|
| 115 | *
|
---|
| 116 | * These defines are used in \ref canOpenChannel().
|
---|
| 117 | *
|
---|
| 118 | * @{
|
---|
| 119 | */
|
---|
| 120 |
|
---|
| 121 | // The canWANT_xxx names are also obsolete, use canOPEN_xxx instead for new developments.
|
---|
| 122 | #define canWANT_EXCLUSIVE 0x0008
|
---|
| 123 | #define canWANT_EXTENDED 0x0010
|
---|
| 124 | #define canWANT_VIRTUAL 0x0020
|
---|
| 125 |
|
---|
| 126 | /**
|
---|
| 127 | * Don't allow sharing of this circuit between applications.
|
---|
| 128 | *
|
---|
| 129 | * This define is used in \ref canOpenChannel()
|
---|
| 130 | */
|
---|
| 131 | #define canOPEN_EXCLUSIVE 0x0008
|
---|
| 132 |
|
---|
| 133 | /**
|
---|
| 134 | * This flag causes two things to happen:
|
---|
| 135 | *
|
---|
| 136 | * \li The call will fail if the specified circuit doesn't allow extended CAN
|
---|
| 137 | * (CAN 2.0B).
|
---|
| 138 | *
|
---|
| 139 | * \li If no frame-type flag is specified in a call to \ref canWrite, it is assumed
|
---|
| 140 | * that extended CAN should be used.
|
---|
| 141 | *
|
---|
| 142 | * This define is used in \ref canOpenChannel().
|
---|
| 143 | */
|
---|
| 144 | #define canOPEN_REQUIRE_EXTENDED 0x0010
|
---|
| 145 |
|
---|
| 146 | /**
|
---|
| 147 | * Allow opening of virtual channels as well as physical channels.
|
---|
| 148 | *
|
---|
| 149 | * This define is used in \ref canOpenChannel().
|
---|
| 150 | *
|
---|
| 151 | * \sa \ref page_user_guide_virtual_info
|
---|
| 152 | */
|
---|
| 153 | # define canOPEN_ACCEPT_VIRTUAL 0x0020
|
---|
| 154 |
|
---|
| 155 |
|
---|
| 156 | /**
|
---|
| 157 | * The channel will accept messages with DLC (Data Length Code) greater than
|
---|
| 158 | * 8. If this flag is not used, a message with DLC > 8 will always be
|
---|
| 159 | * reported or transmitted as a message with DLC = 8. If the
|
---|
| 160 | * \ref canOPEN_ACCEPT_LARGE_DLC flag is used, the message will be sent and/or
|
---|
| 161 | * received with the true DLC, which can be at most 15.
|
---|
| 162 | *
|
---|
| 163 | * \note The length of the message is always at most 8.
|
---|
| 164 | *
|
---|
| 165 | * This define is used in \ref canOpenChannel().
|
---|
| 166 | */
|
---|
| 167 | # define canOPEN_ACCEPT_LARGE_DLC 0x0200 // DLC can be greater than 8
|
---|
| 168 |
|
---|
| 169 | /**
|
---|
| 170 | * The channel will use the CAN FD protocol.
|
---|
| 171 | *
|
---|
| 172 | * This define is used in \ref canOpenChannel().
|
---|
| 173 | */
|
---|
| 174 | # define canOPEN_CAN_FD 0x0400
|
---|
| 175 |
|
---|
| 176 | /**
|
---|
| 177 | * The channel will use the CAN FD NON-ISO protocol.
|
---|
| 178 | *
|
---|
| 179 | * This define is used in \ref canOpenChannel().
|
---|
| 180 | */
|
---|
| 181 | # define canOPEN_CAN_FD_NONISO 0x0800
|
---|
| 182 | /** @} */
|
---|
| 183 |
|
---|
| 184 | /**
|
---|
| 185 | * \ingroup CAN
|
---|
| 186 | * \name canFILTER_xxx
|
---|
| 187 | * \anchor canFILTER_xxx
|
---|
| 188 | *
|
---|
| 189 | * Flags for \ref canAccept().
|
---|
| 190 | *
|
---|
| 191 | * @{
|
---|
| 192 | */
|
---|
| 193 | #define canFILTER_ACCEPT 1
|
---|
| 194 | #define canFILTER_REJECT 2
|
---|
| 195 | /** Sets the code for standard (11-bit) identifiers. */
|
---|
| 196 | #define canFILTER_SET_CODE_STD 3
|
---|
| 197 | /** Sets the mask for standard (11-bit) identifiers. */
|
---|
| 198 | #define canFILTER_SET_MASK_STD 4
|
---|
| 199 | /** Sets the code for extended (29-bit) identifiers. */
|
---|
| 200 | #define canFILTER_SET_CODE_EXT 5
|
---|
| 201 | /** Sets the mask for extended (29-bit) identifiers. */
|
---|
| 202 | #define canFILTER_SET_MASK_EXT 6
|
---|
| 203 |
|
---|
| 204 | #define canFILTER_NULL_MASK 0L
|
---|
| 205 | /** @} */
|
---|
| 206 |
|
---|
| 207 |
|
---|
| 208 | /**
|
---|
| 209 | * \ingroup CAN
|
---|
| 210 | * \name canDRIVER_xxx
|
---|
| 211 | * \anchor canDRIVER_xxx
|
---|
| 212 | *
|
---|
| 213 | * CAN driver types - not all are supported on all cards.
|
---|
| 214 | *
|
---|
| 215 | * @{
|
---|
| 216 | */
|
---|
| 217 |
|
---|
| 218 | /**
|
---|
| 219 | * The "normal" driver type (push-pull). This is the default.
|
---|
| 220 | */
|
---|
| 221 | #define canDRIVER_NORMAL 4
|
---|
| 222 |
|
---|
| 223 | /**
|
---|
| 224 | * Sets the CAN controller in Silent Mode; that is, it doesn't send anything,
|
---|
| 225 | * not even ACK bits, on the bus. Reception works as usual.
|
---|
| 226 | *
|
---|
| 227 | * \note The values 2,3,5,6,7 are reserved values for compatibility reasons.
|
---|
| 228 | */
|
---|
| 229 | #define canDRIVER_SILENT 1
|
---|
| 230 |
|
---|
| 231 | /**
|
---|
| 232 | * Self-reception. Not implemented.
|
---|
| 233 | */
|
---|
| 234 | #define canDRIVER_SELFRECEPTION 8
|
---|
| 235 |
|
---|
| 236 | /**
|
---|
| 237 | * The driver is turned off. Not implemented in all types of hardware.
|
---|
| 238 | */
|
---|
| 239 | #define canDRIVER_OFF 0
|
---|
| 240 |
|
---|
| 241 | /** @} */
|
---|
| 242 |
|
---|
| 243 |
|
---|
| 244 | /**
|
---|
| 245 | * \ingroup CAN
|
---|
| 246 | * \anchor BAUD_xxx
|
---|
| 247 | * \anchor canBITRATE_xxx
|
---|
| 248 | * \name canBITRATE_xxx
|
---|
| 249 | *
|
---|
| 250 | * Common bus speeds. Used in \ref canSetBusParams() and \ref canSetBusParamsC200().
|
---|
| 251 | * The values are translated in canlib, \ref canTranslateBaud().
|
---|
| 252 | *
|
---|
| 253 | * \note The \ref BAUD_xxx names are only retained for compability.
|
---|
| 254 | *
|
---|
| 255 | * \sa \ref page_user_guide_misc_bitrate
|
---|
| 256 | *
|
---|
| 257 | * @{
|
---|
| 258 | */
|
---|
| 259 |
|
---|
| 260 |
|
---|
| 261 | /** Used in \ref canSetBusParams() and \ref canSetBusParamsC200(). Indicate a bitrate of 1 Mbit/s. */
|
---|
| 262 | #define canBITRATE_1M (-1)
|
---|
| 263 | /** Used in \ref canSetBusParams() and \ref canSetBusParamsC200(). Indicate a bitrate of 500 kbit/s. */
|
---|
| 264 | #define canBITRATE_500K (-2)
|
---|
| 265 | /** Used in \ref canSetBusParams() and \ref canSetBusParamsC200(). Indicate a bitrate of 250 kbit/s. */
|
---|
| 266 | #define canBITRATE_250K (-3)
|
---|
| 267 | /** Used in \ref canSetBusParams() and \ref canSetBusParamsC200(). Indicate a bitrate of 125 kbit/s. */
|
---|
| 268 | #define canBITRATE_125K (-4)
|
---|
| 269 | /** Used in \ref canSetBusParams() and \ref canSetBusParamsC200(). Indicate a bitrate of 100 kbit/s. */
|
---|
| 270 | #define canBITRATE_100K (-5)
|
---|
| 271 | /** Used in \ref canSetBusParams() and \ref canSetBusParamsC200(). Indicate a bitrate of 62 kbit/s. */
|
---|
| 272 | #define canBITRATE_62K (-6)
|
---|
| 273 | /** Used in \ref canSetBusParams() and \ref canSetBusParamsC200(). Indicate a bitrate of 50 kbit/s. */
|
---|
| 274 | #define canBITRATE_50K (-7)
|
---|
| 275 | /** Used in \ref canSetBusParams() and \ref canSetBusParamsC200(). Indicate a bitrate of 83 kbit/s. */
|
---|
| 276 | #define canBITRATE_83K (-8)
|
---|
| 277 | /** Used in \ref canSetBusParams() and \ref canSetBusParamsC200(). Indicate a bitrate of 10 kbit/s. */
|
---|
| 278 | #define canBITRATE_10K (-9)
|
---|
| 279 |
|
---|
| 280 | // CAN FD Bit Rates
|
---|
| 281 | /** Used in \ref canSetBusParamsFd(). Indicates a bitrate of 0.5 Mbit/s and sampling point at 80%. */
|
---|
| 282 | #define canFD_BITRATE_500K_80P (-1001)
|
---|
| 283 | /** Used in \ref canSetBusParamsFd(). Indicates a bitrate of 1.0 Mbit/s and sampling point at 80%. */
|
---|
| 284 | #define canFD_BITRATE_1M_80P (-1002)
|
---|
| 285 | /** Used in \ref canSetBusParamsFd(). Indicates a bitrate of 2.0 Mbit/s and sampling point at 80%. */
|
---|
| 286 | #define canFD_BITRATE_2M_80P (-1003)
|
---|
| 287 |
|
---|
| 288 | /** The \ref BAUD_xxx names are deprecated, use \ref canBITRATE_1M instead. */
|
---|
| 289 | #define BAUD_1M (-1)
|
---|
| 290 | /** The \ref BAUD_xxx names are deprecated, use \ref canBITRATE_500K instead. */
|
---|
| 291 | #define BAUD_500K (-2)
|
---|
| 292 | /** The \ref BAUD_xxx names are deprecated, use \ref canBITRATE_250K instead. */
|
---|
| 293 | #define BAUD_250K (-3)
|
---|
| 294 | /** The \ref BAUD_xxx names are deprecated, use \ref canBITRATE_125K instead. */
|
---|
| 295 | #define BAUD_125K (-4)
|
---|
| 296 | /** The \ref BAUD_xxx names are deprecated, use \ref canBITRATE_100K instead. */
|
---|
| 297 | #define BAUD_100K (-5)
|
---|
| 298 | /** The \ref BAUD_xxx names are deprecated, use \ref canBITRATE_62K instead. */
|
---|
| 299 | #define BAUD_62K (-6)
|
---|
| 300 | /** The \ref BAUD_xxx names are deprecated, use \ref canBITRATE_50K instead. */
|
---|
| 301 | #define BAUD_50K (-7)
|
---|
| 302 | /** The \ref BAUD_xxx names are deprecated, use \ref canBITRATE_83K instead. */
|
---|
| 303 | #define BAUD_83K (-8)
|
---|
| 304 | /** @} */
|
---|
| 305 |
|
---|
| 306 |
|
---|
| 307 | //
|
---|
| 308 | // Define CANLIBAPI unless it's done already.
|
---|
| 309 | // (canlib.c provides its own definitions of CANLIBAPI, DLLIMPORT
|
---|
| 310 | // and DLLEXPORT before including this file.)
|
---|
| 311 | //
|
---|
| 312 | #ifndef CANLIBAPI
|
---|
| 313 | # define CANLIBAPI
|
---|
| 314 | # define __stdcall
|
---|
| 315 | #endif
|
---|
| 316 |
|
---|
| 317 |
|
---|
| 318 | #ifdef __cplusplus
|
---|
| 319 | extern "C" {
|
---|
| 320 | #endif
|
---|
| 321 |
|
---|
| 322 | /**
|
---|
| 323 | * \ingroup General
|
---|
| 324 | *
|
---|
| 325 | * \source_cs <b>static void canInitializeLibrary(void);</b>
|
---|
| 326 | *
|
---|
| 327 | * \source_delphi <b>procedure canInitializeLibrary; </b>
|
---|
| 328 | * \source_end
|
---|
| 329 | * This function must be called before any other functions is used. It will
|
---|
| 330 | * initialize the driver.
|
---|
| 331 | *
|
---|
| 332 | * You may call \ref canInitializeLibrary() more than once. The actual
|
---|
| 333 | * initialization will take place only once.
|
---|
| 334 | *
|
---|
| 335 | * Any errors encountered during library initialization will be "silent" and an
|
---|
| 336 | * appropriate \ref canERR_xxx error code will be returned later on when
|
---|
| 337 | * \ref canOpenChannel() (or any other API call that requires initialization) is
|
---|
| 338 | * called.
|
---|
| 339 | *
|
---|
| 340 | * \note This call replaces the \ref canLocateHardware() API call and serves the
|
---|
| 341 | * same purpose.
|
---|
| 342 | *
|
---|
| 343 | * \sa \ref page_code_snippets_examples
|
---|
| 344 | *
|
---|
| 345 | */
|
---|
| 346 | void CANLIBAPI canInitializeLibrary (void);
|
---|
| 347 |
|
---|
| 348 | /**
|
---|
| 349 | * \ingroup CAN
|
---|
| 350 | *
|
---|
| 351 | * \source_cs <b>static Canlib.canStatus canClose(int handle);</b>
|
---|
| 352 | *
|
---|
| 353 | * \source_delphi <b>function canClose(handle: canHandle): canStatus;</b>
|
---|
| 354 | * \source_end
|
---|
| 355 | *
|
---|
| 356 | * Closes the channel associated with the handle. If no other threads
|
---|
| 357 | * are using the CAN circuit, it is taken off bus. The handle can not be
|
---|
| 358 | * used for further references to the channel, so any variable containing
|
---|
| 359 | * it should be zeroed.
|
---|
| 360 | *
|
---|
| 361 | * \ref canClose() will almost always return \ref canOK; the specified handle is closed
|
---|
| 362 | * on an best-effort basis.
|
---|
| 363 | *
|
---|
| 364 | * \param[in] hnd An open handle to a CAN channel.
|
---|
| 365 | *
|
---|
| 366 | * \return \ref canOK (zero) if success
|
---|
| 367 | * \return \ref canERR_xxx (negative) if failure
|
---|
| 368 | *
|
---|
| 369 | * \sa \ref page_code_snippets_examples
|
---|
| 370 | * \sa \ref canOpenChannel(), \ref canBusOn(), \ref canBusOff()
|
---|
| 371 | */
|
---|
| 372 | canStatus CANLIBAPI canClose (const CanHandle hnd);
|
---|
| 373 |
|
---|
| 374 | /**
|
---|
| 375 | * \ingroup CAN
|
---|
| 376 | *
|
---|
| 377 | * \source_cs <b>static Canlib.canStatus canBusOn(int handle);</b>
|
---|
| 378 | *
|
---|
| 379 | * \source_delphi <b>function canBusOn(handle: canHandle): canStatus; </b>
|
---|
| 380 | * \source_end
|
---|
| 381 | *
|
---|
| 382 | * Takes the specified channel on-bus.
|
---|
| 383 | *
|
---|
| 384 | * If you are using multiple handles to the same physical channel, for example
|
---|
| 385 | * if you are writing a threaded application, you must call \ref canBusOn() once for
|
---|
| 386 | * each handle. The same applies to \ref canBusOff() - the physical channel will not
|
---|
| 387 | * go off bus until the last handle to the channel goes off bus.
|
---|
| 388 | *
|
---|
| 389 | * \param[in] hnd An open handle to a CAN channel.
|
---|
| 390 | *
|
---|
| 391 | * \return \ref canOK (zero) if success
|
---|
| 392 | * \return \ref canERR_xxx (negative) if failure
|
---|
| 393 | *
|
---|
| 394 | * \sa \ref page_code_snippets_examples
|
---|
| 395 | * \sa \ref canBusOff(), \ref canResetBus()
|
---|
| 396 | *
|
---|
| 397 | */
|
---|
| 398 | canStatus CANLIBAPI canBusOn (const CanHandle hnd);
|
---|
| 399 |
|
---|
| 400 | /**
|
---|
| 401 | * \ingroup CAN
|
---|
| 402 | *
|
---|
| 403 | * \source_cs <b>static Canlib.canStatus canBusOff(int handle);</b>
|
---|
| 404 | *
|
---|
| 405 | * \source_delphi <b>function canBusOff(handle: canHandle): canStatus; </b>
|
---|
| 406 | * \source_end
|
---|
| 407 | *
|
---|
| 408 | * Takes the specified channel off-bus.
|
---|
| 409 | *
|
---|
| 410 | * \param[in] hnd An open handle to a CAN channel.
|
---|
| 411 | *
|
---|
| 412 | * \return \ref canOK (zero) if success
|
---|
| 413 | * \return \ref canERR_xxx (negative) if failure
|
---|
| 414 | *
|
---|
| 415 | * \sa \ref page_code_snippets_examples
|
---|
| 416 | * \sa \ref canBusOn(), \ref canResetBus()
|
---|
| 417 | *
|
---|
| 418 | */
|
---|
| 419 | canStatus CANLIBAPI canBusOff (const CanHandle hnd);
|
---|
| 420 |
|
---|
| 421 | /**
|
---|
| 422 | * \ingroup CAN
|
---|
| 423 | *
|
---|
| 424 | * \source_cs <b>static Canlib.canStatus canSetBusParams(int handle, int freq, int tseg1, int tseg2, int sjw, int noSamp, int syncmode); </b>
|
---|
| 425 | *
|
---|
| 426 | * \source_delphi <b>function canSetBusParams(handle: canHandle; freq: Longint; tseg1, tseg2, sjw, noSamp, syncmode: Cardinal): canStatus; </b>
|
---|
| 427 | * \source_end
|
---|
| 428 | *
|
---|
| 429 | * This function sets the bus timing parameters for the specified CAN controller.
|
---|
| 430 | *
|
---|
| 431 | * The library provides default values for \a tseg1, \a tseg2, \a sjw and \a
|
---|
| 432 | * noSamp when \a freq is specified to one of the
|
---|
| 433 | * pre-defined constants, \ref canBITRATE_xxx.
|
---|
| 434 | *
|
---|
| 435 | * If \a freq is any other value, no default values are supplied by the
|
---|
| 436 | * library.
|
---|
| 437 | *
|
---|
| 438 | * If you are using multiple handles to the same physical channel, for example
|
---|
| 439 | * if you are writing a threaded application, you must call \ref canBusOff() once
|
---|
| 440 | * for each handle. The same applies to \ref canBusOn() - the physical channel will
|
---|
| 441 | * not go off bus until the last handle to the channel goes off bus.
|
---|
| 442 | *
|
---|
| 443 | * \note Use \ref canSetBusParamsC200() to set the bus timing parameters in the
|
---|
| 444 | * ubiquitous 82c200 bit-timing register format.
|
---|
| 445 | *
|
---|
| 446 | * \param[in] hnd An open handle to a CAN controller.
|
---|
| 447 | * \param[in] freq Bit rate (measured in bits per second); or one of the
|
---|
| 448 | * predefined constants \ref canBITRATE_xxx, which are described below.
|
---|
| 449 | * \param[in] tseg1 Time segment 1, that is, the number of quanta from (but not
|
---|
| 450 | * including) the Sync Segment to the sampling point.
|
---|
| 451 | * \param[in] tseg2 Time segment 2, that is, the number of quanta from the sampling
|
---|
| 452 | * point to the end of the bit.
|
---|
| 453 | * \param[in] sjw The Synchronization Jump Width; can be 1,2,3, or 4.
|
---|
| 454 | * \param[in] noSamp The number of sampling points; can be 1 or 3.
|
---|
| 455 | * \param[in] syncmode Unsupported and ignored.
|
---|
| 456 | *
|
---|
| 457 | * \return \ref canOK (zero) if success
|
---|
| 458 | * \return \ref canERR_xxx (negative) if failure
|
---|
| 459 | *
|
---|
| 460 | * \sa \ref page_code_snippets_bit_rate, \ref page_user_guide_misc_bitrate,
|
---|
| 461 | * \ref page_user_guide_init_bit_rate, \ref page_code_snippets_examples
|
---|
| 462 | * \sa \ref canSetBusParamsC200(), \ref canGetBusParams()
|
---|
| 463 | *
|
---|
| 464 | */
|
---|
| 465 | canStatus CANLIBAPI canSetBusParams (const CanHandle hnd,
|
---|
| 466 | long freq,
|
---|
| 467 | unsigned int tseg1,
|
---|
| 468 | unsigned int tseg2,
|
---|
| 469 | unsigned int sjw,
|
---|
| 470 | unsigned int noSamp,
|
---|
| 471 | unsigned int syncmode);
|
---|
| 472 |
|
---|
| 473 | /**
|
---|
| 474 | * \ingroup CAN
|
---|
| 475 | *
|
---|
| 476 | * \source_cs <b>static Canlib.canStatus canSetBusParamsFd(int hnd, int freq_brs, int tseg1_brs, int tseg2_brs, int sjw_brs);</b>
|
---|
| 477 | *
|
---|
| 478 | * \source_delphi <b>function canSetBusParamsFd(hnd: canHandle; freq_brs: Longint; tseg1_brs, tseg2_brs, sjw_brs): canStatus;</b>
|
---|
| 479 | * \source_end
|
---|
| 480 | *
|
---|
| 481 | * This function sets the bus timing parameters for the specified
|
---|
| 482 | * CAN FD controller.
|
---|
| 483 | *
|
---|
| 484 | * The library provides default values for \a tseg1_brs, \a tseg2_brs,
|
---|
| 485 | * \a sjw_brs and \a freq_brs is specified to one of the pre-defined
|
---|
| 486 | * constants, \ref canBITRATE_xxx.
|
---|
| 487 | *
|
---|
| 488 | * If \a freq_brs is any other value, no default values are supplied
|
---|
| 489 | * by the library.
|
---|
| 490 | *
|
---|
| 491 | * \param[in] hnd An open handle to a CAN controller.
|
---|
| 492 | * \param[in] freq_brs Bit rate (measured in bits per second); or one of the
|
---|
| 493 | * predefined constants \ref canBITRATE_xxx, which are described below.
|
---|
| 494 | * \param[in] tseg1_brs Time segment 1, that is, the number of quanta from (but not
|
---|
| 495 | * including) the Sync Segment to the sampling point.
|
---|
| 496 | * \param[in] tseg2_brs Time segment 2, that is, the number of quanta from the sampling
|
---|
| 497 | * point to the end of the bit.
|
---|
| 498 | * \param[in] sjw_brs The Synchronization Jump Width; can be 1,2,3, or 4.
|
---|
| 499 | *
|
---|
| 500 | * \return \ref canOK (zero) if success
|
---|
| 501 | * \return \ref canERR_xxx (negative) if failure
|
---|
| 502 | */
|
---|
| 503 | canStatus CANLIBAPI canSetBusParamsFd(const CanHandle hnd,
|
---|
| 504 | long freq_brs,
|
---|
| 505 | unsigned int tseg1_brs,
|
---|
| 506 | unsigned int tseg2_brs,
|
---|
| 507 | unsigned int sjw_brs);
|
---|
| 508 |
|
---|
| 509 | /**
|
---|
| 510 | * \ingroup CAN
|
---|
| 511 | * \name canFD_SSP_xxx
|
---|
| 512 | * \anchor canFD_SSP_xxx
|
---|
| 513 | *
|
---|
| 514 | * Flags for \ref canFdSecondarySamplePoint().
|
---|
| 515 | *
|
---|
| 516 | * @{
|
---|
| 517 | */
|
---|
| 518 | /** Secondary sample point is automatically adjusted dynamically. */
|
---|
| 519 | #define canFD_SSP_AUTO 0
|
---|
| 520 | /** Set secondary sample point. */
|
---|
| 521 | #define canFD_SSP_SET 1
|
---|
| 522 | /** Get secondary sample point. */
|
---|
| 523 | #define canFD_SSP_GET 2
|
---|
| 524 | /** @} */
|
---|
| 525 |
|
---|
| 526 | /**
|
---|
| 527 | * \ingroup CAN
|
---|
| 528 | *
|
---|
| 529 | * \source_cs <b>static Canlib.canStatus canFdSecondarySamplePoint(int hnd, ref int ns, int mode);</b>
|
---|
| 530 | *
|
---|
| 531 | * \source_delphi <b>function canFdSecondarySamplePoint(hnd: canHandle; var ns: Cardinal; mode: Cardinal): canStatus;</b>
|
---|
| 532 | * \source_end
|
---|
| 533 | *
|
---|
| 534 | * This function sets or retrieves the secondary sampling point for
|
---|
| 535 | * the specified CAN FD controller.
|
---|
| 536 | *
|
---|
| 537 | * If \a mode is canFD_SSP_AUTO, the \a ns argument is ignored, and
|
---|
| 538 | * the secondary sampling point is automatically adjusted dynamically.
|
---|
| 539 | * If \a mode is canFD_SSP_SET, the secondary sampling point is set to
|
---|
| 540 | * \a ns, and if \a mode is canFD_SSP_GET, it is retrived and stored
|
---|
| 541 | * in \a ns.
|
---|
| 542 | *
|
---|
| 543 | * \param[in] hnd An open handle to a CAN controller.
|
---|
| 544 | * \param[in,out] ns Secondary sampling point delay, in nanoseconds.
|
---|
| 545 | * \param[in] mode One of canFD_SSP_AUTO, canFD_SSP_GET, or
|
---|
| 546 | * canFD_SSP_SET.
|
---|
| 547 | *
|
---|
| 548 | * \return \ref canOK (zero) if success
|
---|
| 549 | * \return \ref canERR_xxx (negative) if failure
|
---|
| 550 | */
|
---|
| 551 | canStatus CANLIBAPI canFdSecondarySamplePoint(const CanHandle hnd,
|
---|
| 552 | unsigned int *ns,
|
---|
| 553 | int mode);
|
---|
| 554 |
|
---|
| 555 | /**
|
---|
| 556 | * \ingroup CAN
|
---|
| 557 | *
|
---|
| 558 | * \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>
|
---|
| 559 | *
|
---|
| 560 | * \source_delphi <b>function canGetBusParams(handle: canHandle; var freq: Longint; var tseg1, tseg2, sjw, noSamp, syncmode: Cardinal): canStatus; </b>
|
---|
| 561 | * \source_end
|
---|
| 562 | *
|
---|
| 563 | * This function retrieves the current bus parameters for the specified
|
---|
| 564 | * channel.
|
---|
| 565 | *
|
---|
| 566 | * The anatomy of a CAN bit is discussed in detail at Kvaser's
|
---|
| 567 | * web site at <a href="http://www.kvaser.com">www.kvaser.com</a>.
|
---|
| 568 | *
|
---|
| 569 | * \param[in] hnd An open handle to a CAN controller.
|
---|
| 570 | * \param[out] freq Bit rate (bits per second).
|
---|
| 571 | * \param[out] tseg1 Time segment 1, that is, the number of quanta from (but not
|
---|
| 572 | * including) the Sync Segment to the sampling point.
|
---|
| 573 | * \param[out] tseg2 Time segment 2, that is, the number of quanta from the sampling
|
---|
| 574 | * point to the end of the bit.
|
---|
| 575 | * \param[out] sjw The Synchronization Jump Width; can be 1,2,3, or 4.
|
---|
| 576 | * \param[out] noSamp The number of sampling points; can be 1 or 3.
|
---|
| 577 | * \param[out] syncmode Unsupported, always read as zero.
|
---|
| 578 | *
|
---|
| 579 | * \return \ref canOK (zero) if success
|
---|
| 580 | * \return \ref canERR_xxx (negative) if failure
|
---|
| 581 | *
|
---|
| 582 | * \sa \ref page_code_snippets_bit_rate, \ref page_user_guide_init_bit_rate
|
---|
| 583 | * \sa \ref canSetBusParams(), \ref canSetBusParamsC200()
|
---|
| 584 | *
|
---|
| 585 | */
|
---|
| 586 | canStatus CANLIBAPI canGetBusParams (const CanHandle hnd,
|
---|
| 587 | long *freq,
|
---|
| 588 | unsigned int *tseg1,
|
---|
| 589 | unsigned int *tseg2,
|
---|
| 590 | unsigned int *sjw,
|
---|
| 591 | unsigned int *noSamp,
|
---|
| 592 | unsigned int *syncmode);
|
---|
| 593 |
|
---|
| 594 |
|
---|
| 595 | /**
|
---|
| 596 | * \ingroup CAN
|
---|
| 597 | *
|
---|
| 598 | * \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>
|
---|
| 599 | *
|
---|
| 600 | * \source_delphi <b>function canGetBusParamsFd(hnd: canHandle; var freq_brs: Longint; var tseg1_brs, tseg2_brs, sjw_brs): canStatus;</b>
|
---|
| 601 | * \source_end
|
---|
| 602 | *
|
---|
| 603 | * This function retrieves the current bus parameters for the specified
|
---|
| 604 | * CAN FD channel.
|
---|
| 605 | *
|
---|
| 606 | * \param[in] hnd An open handle to a CAN FD controller.
|
---|
| 607 | * \param[out] freq_brs Bit rate (bits per second).
|
---|
| 608 | * \param[out] tseg1_brs Time segment 1, that is, the number of quanta from (but not
|
---|
| 609 | * including) the Sync Segment to the sampling point.
|
---|
| 610 | * \param[out] tseg2_brs Time segment 2, that is, the number of quanta from the sampling
|
---|
| 611 | * point to the end of the bit.
|
---|
| 612 | * \param[out] sjw_brs The Synchronization Jump Width; can be 1,2,3, or 4.
|
---|
| 613 | *
|
---|
| 614 | * \return \ref canOK (zero) if success
|
---|
| 615 | * \return \ref canERR_xxx (negative) if failure
|
---|
| 616 | */
|
---|
| 617 | canStatus CANLIBAPI canGetBusParamsFd(const CanHandle hnd,
|
---|
| 618 | long *freq_brs,
|
---|
| 619 | unsigned int *tseg1_brs,
|
---|
| 620 | unsigned int *tseg2_brs,
|
---|
| 621 | unsigned int *sjw_brs);
|
---|
| 622 | /**
|
---|
| 623 | * \ingroup CAN
|
---|
| 624 | *
|
---|
| 625 | * \source_cs <b>static Canlib.canStatus canSetBusOutputControl(int handle, int drivertype);</b>
|
---|
| 626 | *
|
---|
| 627 | * \source_delphi <b>function canSetBusOutputControl(handle: canHandle; drivertype: Cardinal): canStatus; </b>
|
---|
| 628 | * \source_end
|
---|
| 629 | *
|
---|
| 630 | * This function sets the driver type for a CAN controller. This corresponds
|
---|
| 631 | * loosely to the bus output control register in the CAN controller, hence the
|
---|
| 632 | * name of this function. CANLIB does not allow for direct manipulation of the
|
---|
| 633 | * bus output control register; instead, symbolic constants are used to select
|
---|
| 634 | * the desired driver type.
|
---|
| 635 | *
|
---|
| 636 | * \note Not all CAN driver types are supported on all cards.
|
---|
| 637 | *
|
---|
| 638 | * \param[in] hnd A handle to an open circuit.
|
---|
| 639 | * \param[out] drivertype Can driver type, \ref canDRIVER_xxx)
|
---|
| 640 | *
|
---|
| 641 | * \return \ref canOK (zero) if success
|
---|
| 642 | * \return \ref canERR_xxx (negative) if failure
|
---|
| 643 | *
|
---|
| 644 | * \sa \ref canGetBusOutputControl()
|
---|
| 645 | */
|
---|
| 646 | canStatus CANLIBAPI canSetBusOutputControl (const CanHandle hnd,
|
---|
| 647 | const unsigned int drivertype);
|
---|
| 648 |
|
---|
| 649 | /**
|
---|
| 650 | * \ingroup CAN
|
---|
| 651 | *
|
---|
| 652 | * \source_cs <b>static Canlib.canStatus canGetBusOutputControl(int handle, out int drivertype);</b>
|
---|
| 653 | *
|
---|
| 654 | * \source_delphi <b>function canGetBusOutputControl(handle: canHandle; var drivertype: Cardinal): canStatus; </b>
|
---|
| 655 | * \source_end
|
---|
| 656 | *
|
---|
| 657 | * This function retrieves the current CAN controller driver type.
|
---|
| 658 | * This corresponds loosely to the bus output control register in the
|
---|
| 659 | * CAN controller, hence the name of this function. CANLIB does not
|
---|
| 660 | * allow for direct manipulation of the bus output control register;
|
---|
| 661 | * instead, symbolic constants are used to select the desired driver
|
---|
| 662 | * type.
|
---|
| 663 | *
|
---|
| 664 | * \note Don't confuse the CAN controller driver type with the bus driver
|
---|
| 665 | * type. The CAN controller is not connected directly to the CAN bus;
|
---|
| 666 | * instead, it is connected to a bus transceiver circuit which interfaces
|
---|
| 667 | * directly to the bus. The "CAN controller driver type" we are talking
|
---|
| 668 | * about here refers to the mode which the CAN controller uses to drive
|
---|
| 669 | * the bus transceiver circuit.
|
---|
| 670 | *
|
---|
| 671 | * \note Silent Mode is not supported by all CAN controllers.
|
---|
| 672 | *
|
---|
| 673 | * \param[in] hnd An open handle to a CAN circuit.
|
---|
| 674 | * \param[in] drivertype A pointer to an unsigned int which receives the
|
---|
| 675 | * current driver type. The driver type can be either
|
---|
| 676 | * \ref canDRIVER_NORMAL or \ref canDRIVER_SILENT.
|
---|
| 677 | *
|
---|
| 678 | * \return \ref canOK (zero) if success
|
---|
| 679 | * \return \ref canERR_xxx (negative) if failure
|
---|
| 680 | *
|
---|
| 681 | * \sa \ref canSetBusOutputControl()
|
---|
| 682 | */
|
---|
| 683 | canStatus CANLIBAPI canGetBusOutputControl (const CanHandle hnd,
|
---|
| 684 | unsigned int *drivertype);
|
---|
| 685 |
|
---|
| 686 | /**
|
---|
| 687 | * \ingroup CAN
|
---|
| 688 | *
|
---|
| 689 | * \source_cs <b>static Canlib.canStatus canAccept(int handle, int envelope, int flag);</b>
|
---|
| 690 | *
|
---|
| 691 | * \source_delphi <b>function canAccept(handle: canHandle; envelope: Longint; flag: Cardinal): canStatus; </b>
|
---|
| 692 | * \source_end
|
---|
| 693 | *
|
---|
| 694 | * This routine sets the message acceptance filters on a CAN channel.
|
---|
| 695 | *
|
---|
| 696 | * On some boards the acceptance filtering is done by the CAN hardware; on
|
---|
| 697 | * other boards (typically those with an embedded CPU,) the acceptance
|
---|
| 698 | * filtering is done by software. \ref canAccept() behaves in the same way for all
|
---|
| 699 | * boards, however.
|
---|
| 700 | *
|
---|
| 701 | * \ref canSetAcceptanceFilter() and \ref canAccept() both serve the same purpose but the
|
---|
| 702 | * former can set the code and mask in just one call.
|
---|
| 703 | *
|
---|
| 704 | * If you want to remove a filter, call \ref canAccept() with the mask set to 0.
|
---|
| 705 | *
|
---|
| 706 | * \note You can set the extended code and mask only on CAN boards that support
|
---|
| 707 | * extended identifiers.
|
---|
| 708 | *
|
---|
| 709 | * \note Not all CAN boards support different masks for standard and extended
|
---|
| 710 | * CAN identifiers.
|
---|
| 711 | *
|
---|
| 712 | * \param[in] hnd An open handle to a CAN circuit.
|
---|
| 713 | * \param[in] envelope The mask or code to set.
|
---|
| 714 | * \param[in] flag Any of \ref canFILTER_SET_CODE_STD,
|
---|
| 715 | * \ref canFILTER_SET_MASK_STD,
|
---|
| 716 | * \ref canFILTER_SET_CODE_EXT or
|
---|
| 717 | * \ref canFILTER_SET_MASK_EXT
|
---|
| 718 | *
|
---|
| 719 | * \return \ref canOK (zero) if success
|
---|
| 720 | * \return \ref canERR_xxx (negative) if failure
|
---|
| 721 | *
|
---|
| 722 | * \sa \ref page_user_guide_misc_code_and_mask,
|
---|
| 723 | * \ref page_user_guide_send_recv_filters,
|
---|
| 724 | * \ref page_code_snippets_examples
|
---|
| 725 | */
|
---|
| 726 | canStatus CANLIBAPI canAccept (const CanHandle hnd,
|
---|
| 727 | const long envelope,
|
---|
| 728 | const unsigned int flag);
|
---|
| 729 |
|
---|
| 730 | /**
|
---|
| 731 | * \ingroup CAN
|
---|
| 732 | *
|
---|
| 733 | * \source_cs <b>static Canlib.canStatus canReadStatus(int handle, out long flags);</b>
|
---|
| 734 | *
|
---|
| 735 | * \source_delphi <b>function canReadStatus(handle: canHandle; var flags: Longint): canStatus; </b>
|
---|
| 736 | * \source_end
|
---|
| 737 | *
|
---|
| 738 | * Returns the status for the specified circuit. flags points to a longword
|
---|
| 739 | * which receives a combination of the \ref canSTAT_xxx flags.
|
---|
| 740 | *
|
---|
| 741 | * \note \ref canReadStatus() returns the latest known status of the specified
|
---|
| 742 | * circuit. If a status change happens precisely when \ref canReadStatus() is
|
---|
| 743 | * called, it may not be reflected in the returned result.
|
---|
| 744 | *
|
---|
| 745 | * \param[in] hnd A handle to an open circuit.
|
---|
| 746 | * \param[out] flags Pointer to a \c DWORD which receives the status flags;
|
---|
| 747 | * this is a combination of any of the \ref canSTAT_xxx.
|
---|
| 748 | *
|
---|
| 749 | * \return \ref canOK (zero) if success
|
---|
| 750 | * \return \ref canERR_xxx (negative) if failure
|
---|
| 751 | *
|
---|
| 752 | */
|
---|
| 753 | canStatus CANLIBAPI canReadStatus (const CanHandle hnd,
|
---|
| 754 | unsigned long *const flags);
|
---|
| 755 |
|
---|
| 756 | /**
|
---|
| 757 | * \ingroup CAN
|
---|
| 758 | *
|
---|
| 759 | * \source_cs <b>static Canlib.canStatus canReadErrorCounters(int handle, out int txErr, out int rxErr, out int ovErr);</b>
|
---|
| 760 | *
|
---|
| 761 | * \source_delphi <b>function canReadErrorCounters(handle: canHandle; var txErr, rxErr, ovErr: Cardinal): canStatus; </b>
|
---|
| 762 | * \source_end
|
---|
| 763 | *
|
---|
| 764 | * Reads the error counters of the CAN controller.
|
---|
| 765 | *
|
---|
| 766 | * \ref canReadErrorCounters() returns the latest known values of the error counters
|
---|
| 767 | * in the specified circuit. If the error counters change values precisely when
|
---|
| 768 | * \ref canReadErrorCounters() is called, it may not be reflected in the returned
|
---|
| 769 | * result.
|
---|
| 770 | *
|
---|
| 771 | * It is allowed to pass \c NULL as the value of the \a txErr, \a rxErr, and \a
|
---|
| 772 | * ovErr parameters.
|
---|
| 773 | *
|
---|
| 774 | * Use \ref canIoCtl() to clear the counters.
|
---|
| 775 | *
|
---|
| 776 | * \note Not all CAN controllers provide access to the error counters;
|
---|
| 777 | * in this case, an educated guess is returned.
|
---|
| 778 | *
|
---|
| 779 | * \param[in] hnd A handle to an open circuit.
|
---|
| 780 | * \param[out] txErr A pointer to a \c DWORD which receives the transmit error
|
---|
| 781 | * counter.
|
---|
| 782 | * \param[out] rxErr A pointer to a \c DWORD which receives the receive error
|
---|
| 783 | * counter.
|
---|
| 784 | * \param[out] ovErr A pointer to a \c DWORD which receives the number of
|
---|
| 785 | * overrun errors.
|
---|
| 786 | *
|
---|
| 787 | * \return \ref canOK (zero) if success
|
---|
| 788 | * \return \ref canERR_xxx (negative) if failure
|
---|
| 789 | *
|
---|
| 790 | * \sa \ref canIoCtl()
|
---|
| 791 | */
|
---|
| 792 | canStatus CANLIBAPI canReadErrorCounters (const CanHandle hnd,
|
---|
| 793 | unsigned int *txErr,
|
---|
| 794 | unsigned int *rxErr,
|
---|
| 795 | unsigned int *ovErr);
|
---|
| 796 |
|
---|
| 797 | /**
|
---|
| 798 | * \ingroup CAN
|
---|
| 799 | *
|
---|
| 800 | * \source_cs <b>static Canlib.canStatus canWrite(int handle, int id, byte[] msg, int dlc, int flag);</b>
|
---|
| 801 | *
|
---|
| 802 | * \source_delphi <b>function canWrite(handle: canHandle; id: Longint; msg: Pointer; dlc: Cardinal; flag: Cardinal): canStatus; </b>
|
---|
| 803 | * \source_end
|
---|
| 804 | *
|
---|
| 805 | * This function sends a CAN message. The call returns immediately after queuing
|
---|
| 806 | * the message to the driver.
|
---|
| 807 | *
|
---|
| 808 | * If you are using the same channel via multiple handles, note that the
|
---|
| 809 | * default behaviour is that the different handles will "hear" each other just as
|
---|
| 810 | * if each handle referred to a channel of its own. If you open, say, channel 0
|
---|
| 811 | * from thread A and thread B and then send a message from thread A, it will be
|
---|
| 812 | * "received" by thread B.
|
---|
| 813 | * This behaviour can be changed using \ref canIOCTL_SET_LOCAL_TXECHO.
|
---|
| 814 | *
|
---|
| 815 | * \note The message has been queued for transmission when this calls return.
|
---|
| 816 | * It has not necessarily been sent.
|
---|
| 817 | *
|
---|
| 818 | * \param[in] hnd A handle to an open CAN circuit.
|
---|
| 819 | * \param[in] id The identifier of the CAN message to send.
|
---|
| 820 | * \param[in] msg A pointer to the message data, or \c NULL.
|
---|
| 821 | * \param[in] dlc The length of the message. Can be at most 8.
|
---|
| 822 | * \param[in] flag A combination of message flags, \ref canMSG_xxx.
|
---|
| 823 | * Use this parameter to send extended (29-bit) frames
|
---|
| 824 | * and/or remote frames. Use \ref canMSG_EXT and/or
|
---|
| 825 | * \ref canMSG_RTR for this purpose.
|
---|
| 826 | *
|
---|
| 827 | * \return \ref canOK (zero) if success
|
---|
| 828 | * \return \ref canERR_xxx (negative) if failure
|
---|
| 829 | *
|
---|
| 830 | * \sa \ref page_user_guide_send_recv_sending, \ref page_code_snippets_examples
|
---|
| 831 | * \sa \ref canWriteSync(), \ref canWriteWait()
|
---|
| 832 | *
|
---|
| 833 | */
|
---|
| 834 | canStatus CANLIBAPI canWrite (const CanHandle hnd,
|
---|
| 835 | long id,
|
---|
| 836 | void *msg,
|
---|
| 837 | unsigned int dlc,
|
---|
| 838 | unsigned int flag);
|
---|
| 839 |
|
---|
| 840 | /**
|
---|
| 841 | * \ingroup CAN
|
---|
| 842 | *
|
---|
| 843 | * \source_cs <b>static Canlib.canStatus canWriteSync(int handle, long timeout);</b>
|
---|
| 844 | *
|
---|
| 845 | * \source_delphi <b>function canWriteSync(handle: canHandle; timeout: Longint): canStatus; </b>
|
---|
| 846 | * \source_end
|
---|
| 847 | *
|
---|
| 848 | * Waits until all CAN messages for the specified handle are sent, or the
|
---|
| 849 | * timeout period expires.
|
---|
| 850 | *
|
---|
| 851 | * \param[in] hnd A handle to an open CAN circuit.
|
---|
| 852 | * \param[in] timeout The timeout in milliseconds. 0xFFFFFFFF gives an
|
---|
| 853 | * infinite timeout.
|
---|
| 854 | *
|
---|
| 855 | * \return \ref canOK (zero) if the queue emptied before the timeout period came to
|
---|
| 856 | * its end.
|
---|
| 857 | * \return \ref canERR_TIMEOUT (negative) not all messages were transmitted when
|
---|
| 858 | * the timeout occurred.
|
---|
| 859 | * \return \ref canERR_PARAM (negative) This could be caused by an erroneous
|
---|
| 860 | * parameter, or if you have turned TXACKs off (by using \ref canIoCtl())
|
---|
| 861 | * because if you do you can't use this call. The driver simply doesn't
|
---|
| 862 | * know when all the messages are sent!
|
---|
| 863 | * \return \ref canERR_xxx (negative) if failure
|
---|
| 864 | *
|
---|
| 865 | * \sa \ref canWrite(), \ref canWriteWait()
|
---|
| 866 | */
|
---|
| 867 | canStatus CANLIBAPI canWriteSync (const CanHandle hnd, unsigned long timeout);
|
---|
| 868 |
|
---|
| 869 | /**
|
---|
| 870 | * \ingroup CAN
|
---|
| 871 | *
|
---|
| 872 | * \source_cs <b>static Canlib.canStatus canRead(int handle, out int id, byte[] msg, out int dlc, out int flag, out long time);</b>
|
---|
| 873 | *
|
---|
| 874 | * \source_delphi <b>function canRead(handle: canHandle; var id: Longint; msg: Pointer; var dlc: Cardinal; var flag: Cardinal; var time: Longint): canStatus; </b>
|
---|
| 875 | * \source_end
|
---|
| 876 | *
|
---|
| 877 | * Reads a message from the receive buffer. If no message is available, the
|
---|
| 878 | * function returns immediately with return code \ref canERR_NOMSG.
|
---|
| 879 | *
|
---|
| 880 | * If you are using the same channel via multiple handles, note that the
|
---|
| 881 | * default behaviour is that the different handles will "hear" each other just as
|
---|
| 882 | * if each handle referred to a channel of its own. If you open, say, channel 0
|
---|
| 883 | * from thread A and thread B and then send a message from thread A, it will be
|
---|
| 884 | * "received" by thread B.
|
---|
| 885 | * This behaviour can be changed using \ref canIOCTL_SET_LOCAL_TXECHO.
|
---|
| 886 | *
|
---|
| 887 | * It is allowed to pass \c NULL as the value of \a id, \a msg, \a dlc, \a
|
---|
| 888 | * flag, and \a time.
|
---|
| 889 | *
|
---|
| 890 | * \param[in] hnd A handle to an open circuit.
|
---|
| 891 | * \param[out] id Pointer to a buffer which receives the CAN identifier.
|
---|
| 892 | * This buffer will only get the identifier. To determine
|
---|
| 893 | * whether this identifier was standard (11-bit) or extended
|
---|
| 894 | * (29-bit), and/or whether it was remote or not, or if it
|
---|
| 895 | * was an error frame, examine the contents of the flag
|
---|
| 896 | * argument.
|
---|
| 897 | * \param[out] msg Pointer to the buffer which receives the message data.
|
---|
| 898 | * This buffer must be large enough (i.e. 8 bytes.) Only the
|
---|
| 899 | * message data is copied; the rest of the buffer is left
|
---|
| 900 | * as-is.
|
---|
| 901 | * \param[out] dlc Pointer to a buffer which receives the message length.
|
---|
| 902 | * \param[out] flag Pointer to a buffer which receives the message flags,
|
---|
| 903 | * which is a combination of the \ref canMSG_xxx and
|
---|
| 904 | * \ref canMSGERR_xxx values.
|
---|
| 905 | * \param[out] time Pointer to a buffer which receives the message time stamp.
|
---|
| 906 | *
|
---|
| 907 | * \return \ref canOK (zero) if a message was read.
|
---|
| 908 | * \return \ref canERR_NOMSG (negative) if there was no message available.
|
---|
| 909 | * \return \ref canERR_xxx (negative) if failure
|
---|
| 910 | *
|
---|
| 911 | * \sa \ref page_user_guide_send_recv_reading, \ref
|
---|
| 912 | * page_user_guide_send_recv_mailboxes, \ref page_code_snippets_examples,
|
---|
| 913 | * \ref page_user_guide_time_accuracy_and_resolution
|
---|
| 914 | * \sa \ref canReadSpecific(), \ref canReadSpecificSkip(), \ref canReadSync(),
|
---|
| 915 | * \ref canReadSyncSpecific(), \ref canReadWait()
|
---|
| 916 | *
|
---|
| 917 | */
|
---|
| 918 | canStatus CANLIBAPI canRead (const CanHandle hnd,
|
---|
| 919 | long *id,
|
---|
| 920 | void *msg,
|
---|
| 921 | unsigned int *dlc,
|
---|
| 922 | unsigned int *flag,
|
---|
| 923 | unsigned long *time);
|
---|
| 924 |
|
---|
| 925 | /**
|
---|
| 926 | * \ingroup CAN
|
---|
| 927 | *
|
---|
| 928 | * \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>
|
---|
| 929 | *
|
---|
| 930 | * \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>
|
---|
| 931 | * \source_end
|
---|
| 932 | *
|
---|
| 933 | * Reads a message from the receive buffer. If no message is available, the
|
---|
| 934 | * function waits until a message arrives or a timeout occurs.
|
---|
| 935 | *
|
---|
| 936 | * If you are using the same channel via multiple handles, note that the
|
---|
| 937 | * default behaviour is that the different handles will "hear" each other just as
|
---|
| 938 | * if each handle referred to a channel of its own. If you open, say, channel 0
|
---|
| 939 | * from thread A and thread B and then send a message from thread A, it will be
|
---|
| 940 | * "received" by thread B.
|
---|
| 941 | * This behaviour can be changed using \ref canIOCTL_SET_LOCAL_TXECHO.
|
---|
| 942 | *
|
---|
| 943 | * It is allowed to pass \c NULL as the value of \a id, \a msg, \a dlc, \a
|
---|
| 944 | * flag, and \a time.
|
---|
| 945 | *
|
---|
| 946 | * \param[in] hnd A handle to an open circuit.
|
---|
| 947 | * \param[out] id Pointer to a buffer which receives the CAN identifier.
|
---|
| 948 | * This buffer will only get the identifier. To determine
|
---|
| 949 | * whether this identifier was standard (11-bit) or extended
|
---|
| 950 | * (29-bit), and/or whether it was remote or not, or if it
|
---|
| 951 | * was an error frame, examine the contents of the flag
|
---|
| 952 | * argument.
|
---|
| 953 | * \param[out] msg Pointer to the buffer which receives the message data.
|
---|
| 954 | * This buffer must be large enough (i.e. 8 bytes.).
|
---|
| 955 | * \param[out] dlc Pointer to a buffer which receives the message length.
|
---|
| 956 | * \param[out] flag Pointer to a buffer which receives the message flags,
|
---|
| 957 | * which is a combination of the \ref canMSG_xxx and
|
---|
| 958 | * \ref canMSGERR_xxx values.
|
---|
| 959 | * \param[out] time Pointer to a buffer which receives the message time stamp.
|
---|
| 960 | * \param[in] timeout If no message is immediately available, this parameter
|
---|
| 961 | * gives the number of milliseconds to wait for a message
|
---|
| 962 | * before returning. 0xFFFFFFFF gives an infinite timeout.
|
---|
| 963 | *
|
---|
| 964 | * \return \ref canOK (zero) if a message was read.
|
---|
| 965 | * \return \ref canERR_NOMSG (negative) if there was no message available.
|
---|
| 966 | * \return \ref canERR_xxx (negative) if failure
|
---|
| 967 | *
|
---|
| 968 | * \sa \ref canRead(),\win_start \ref canReadSpecific(), \ref canReadSpecificSkip(),
|
---|
| 969 | * \ref canReadSyncSpecific(),\win_end \ref canReadSync()
|
---|
| 970 | *
|
---|
| 971 | * \sa \ref page_user_guide_time_accuracy_and_resolution
|
---|
| 972 | */
|
---|
| 973 | canStatus CANLIBAPI canReadWait (const CanHandle hnd,
|
---|
| 974 | long *id,
|
---|
| 975 | void *msg,
|
---|
| 976 | unsigned int *dlc,
|
---|
| 977 | unsigned int *flag,
|
---|
| 978 | unsigned long *time,
|
---|
| 979 | unsigned long timeout);
|
---|
| 980 |
|
---|
| 981 | #if defined(CANLIB_DECLARE_ALL)
|
---|
| 982 | /**
|
---|
| 983 | * \ingroup CAN
|
---|
| 984 | *
|
---|
| 985 | * \source_cs <b>static Canlib.canStatus canReadSync(int handle, long timeout);</b>
|
---|
| 986 | *
|
---|
| 987 | * \source_delphi <b>function canReadSync(handle: canHandle; timeout: Longint): canStatus; </b>
|
---|
| 988 | * \source_end
|
---|
| 989 | *
|
---|
| 990 | * Waits until the receive buffer contains at least one message or a timeout
|
---|
| 991 | * occurs.
|
---|
| 992 | *
|
---|
| 993 | * If you are using the same channel via multiple handles, note that the
|
---|
| 994 | * default behaviour is that the different handles will "hear" each other just as
|
---|
| 995 | * if each handle referred to a channel of its own. If you open, say, channel 0
|
---|
| 996 | * from thread A and thread B and then send a message from thread A, it will be
|
---|
| 997 | * "received" by thread B.
|
---|
| 998 | * This behaviour can be changed using \ref canIOCTL_SET_LOCAL_TXECHO.
|
---|
| 999 | *
|
---|
| 1000 | * \param[in] hnd A handle to an open circuit.
|
---|
| 1001 | * \param[in] timeout The timeout in milliseconds. 0xFFFFFFFF gives an
|
---|
| 1002 | * infinite timeout.
|
---|
| 1003 | *
|
---|
| 1004 | * \return \ref canOK (zero) if the queue contains the desired message.
|
---|
| 1005 | * \return \ref canERR_TIMEOUT (negative) if a timeout occurs before a message
|
---|
| 1006 | * arrived.
|
---|
| 1007 | * \return \ref canERR_xxx (negative) if the call fails.
|
---|
| 1008 | *
|
---|
| 1009 | * \sa \ref canRead(), \win_start \ref canReadSpecific(), \ref canReadSpecificSkip(),
|
---|
| 1010 | * \ref canReadSyncSpecific(),\win_end \ref canReadWait()
|
---|
| 1011 | */
|
---|
| 1012 | canStatus CANLIBAPI canReadSync (const CanHandle hnd, unsigned long timeout);
|
---|
| 1013 |
|
---|
| 1014 | #endif
|
---|
| 1015 |
|
---|
| 1016 | /**
|
---|
| 1017 | * \ingroup CAN
|
---|
| 1018 | *
|
---|
| 1019 | * \todo Rewrite, this is just guessing from windows version
|
---|
| 1020 | *
|
---|
| 1021 | * \source_cs <b>static Canlib.canStatus canSetNotify(int handle, IntPtr win_handle, int aNotifyFlags);</b>
|
---|
| 1022 | *
|
---|
| 1023 | * \source_delphi <b>function canSetNotify(handle: canHandle; aHWnd: HWND; aNotifyFlags: Cardinal): canStatus; </b>
|
---|
| 1024 | * \source_end
|
---|
| 1025 | *
|
---|
| 1026 | * This function associates a callback function with the CAN circuit.
|
---|
| 1027 | *
|
---|
| 1028 | * \param[in] hnd A handle to an open CAN circuit.
|
---|
| 1029 | * \param[in] callback Handle to callback routine.
|
---|
| 1030 | * \param[in] notifyFlags The events specified with \ref canNOTIFY_xxx, for
|
---|
| 1031 | * which callback should be called.
|
---|
| 1032 | * \param[in] tag Pointer to user defined data. Passed to callback in the \ref canNotifyData struct.
|
---|
| 1033 | *
|
---|
| 1034 | * \return \ref canOK (zero) if success
|
---|
| 1035 | * \return \ref canERR_xxx (negative) if failure
|
---|
| 1036 | *
|
---|
| 1037 | */
|
---|
| 1038 | canStatus CANLIBAPI canSetNotify (const CanHandle hnd,
|
---|
| 1039 | void (*callback)(canNotifyData *),
|
---|
| 1040 | unsigned int notifyFlags,
|
---|
| 1041 | void *tag);
|
---|
| 1042 |
|
---|
| 1043 | /**
|
---|
| 1044 | * \ingroup CAN
|
---|
| 1045 | *
|
---|
| 1046 | * Returns raw handle/file descriptor for use in system calls.
|
---|
| 1047 | * \note Use this function with caution.
|
---|
| 1048 | *
|
---|
| 1049 | * \param[in] hnd CanHandle
|
---|
| 1050 | * \param[out] pvFd Pointer to raw can data.
|
---|
| 1051 | *
|
---|
| 1052 | * \return \ref canOK (zero) if success
|
---|
| 1053 | * \return \ref canERR_xxx (negative) if failure
|
---|
| 1054 | *
|
---|
| 1055 | */
|
---|
| 1056 | canStatus CANLIBAPI canGetRawHandle (const CanHandle hnd, void *pvFd);
|
---|
| 1057 |
|
---|
| 1058 | /**
|
---|
| 1059 | * \ingroup CAN
|
---|
| 1060 | *
|
---|
| 1061 | * \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>
|
---|
| 1062 | *
|
---|
| 1063 | * \source_delphi <b>function canTranslateBaud(var freq: longint; var tseg1, tseg2, sjw, noSamp, syncMode: Cardinal): canStatus; </b>
|
---|
| 1064 | * \source_end
|
---|
| 1065 | *
|
---|
| 1066 | * This function translates the \ref canBITRATE_xxx constants to their corresponding
|
---|
| 1067 | * bus parameter values. At return, this \a freq contains the actual bit rate
|
---|
| 1068 | * (in bits per second). \a TSeg1 is the number of quanta (less one) in a bit
|
---|
| 1069 | * before the sampling point. \a TSeg2 is the number of quanta after the
|
---|
| 1070 | * sampling point.
|
---|
| 1071 | *
|
---|
| 1072 | * \param[in] freq A pointer to a \c DWORD which contains the \ref canBITRATE_xxx
|
---|
| 1073 | * constant to translate
|
---|
| 1074 | * \param[in] tseg1 A pointer to a buffer which receives the Time segment 1,
|
---|
| 1075 | * that is, the number of quanta from (but not including)
|
---|
| 1076 | * the Sync Segment to the sampling point.
|
---|
| 1077 | * \param[in] tseg2 A pointer to a buffer which receives the Time segment 2,
|
---|
| 1078 | * that is, the number of quanta from the sampling point to
|
---|
| 1079 | * the end of the bit.
|
---|
| 1080 | * \param[in] sjw A pointer to a buffer which receives the Synchronization
|
---|
| 1081 | * Jump Width; can be 1,2,3, or 4.
|
---|
| 1082 | * \param[in] nosamp A pointer to a buffer which receives the number of
|
---|
| 1083 | * sampling points; can be 1 or 3.
|
---|
| 1084 | * \param[in] syncMode Unsupported, always read as zero.
|
---|
| 1085 | *
|
---|
| 1086 | * \return \ref canOK (zero) if success
|
---|
| 1087 | * \return \ref canERR_xxx (negative) if failure
|
---|
| 1088 | *
|
---|
| 1089 | * \sa \ref canSetBusParams()
|
---|
| 1090 | */
|
---|
| 1091 | canStatus CANLIBAPI canTranslateBaud (long *const freq,
|
---|
| 1092 | unsigned int *const tseg1,
|
---|
| 1093 | unsigned int *const tseg2,
|
---|
| 1094 | unsigned int *const sjw,
|
---|
| 1095 | unsigned int *const nosamp,
|
---|
| 1096 | unsigned int *const syncMode);
|
---|
| 1097 |
|
---|
| 1098 | /**
|
---|
| 1099 | * \ingroup General
|
---|
| 1100 | *
|
---|
| 1101 | * \source_cs <b>static Canlib.canStatus canGetErrorText(Canlib.canStatus err, out string buf_str);</b>
|
---|
| 1102 | *
|
---|
| 1103 | * \source_delphi <b>function canGetErrorText(err: canStatus; buf: PChar; bufsiz: Cardinal): canStatus; </b>
|
---|
| 1104 | * \source_end
|
---|
| 1105 | *
|
---|
| 1106 | * This function translates an error code (\ref canERR_xxx)
|
---|
| 1107 | * to a human-readable, English text.
|
---|
| 1108 | *
|
---|
| 1109 | * \param[in] err The error code.
|
---|
| 1110 | * \param[in,out] buf The buffer which is to receive the text, which is a
|
---|
| 1111 | * zero-terminated string (provided the buffer is large enough.)
|
---|
| 1112 | * \param[in] bufsiz The length of the input buffer.
|
---|
| 1113 | *
|
---|
| 1114 | * \return \ref canOK (zero) if success
|
---|
| 1115 | * \return \ref canERR_xxx (negative) if failure
|
---|
| 1116 | *
|
---|
| 1117 | * \sa \ref page_code_snippets_examples
|
---|
| 1118 | *
|
---|
| 1119 | */
|
---|
| 1120 | canStatus CANLIBAPI canGetErrorText (canStatus err, char *buf, unsigned int bufsiz);
|
---|
| 1121 |
|
---|
| 1122 | /**
|
---|
| 1123 | * \ingroup General
|
---|
| 1124 | *
|
---|
| 1125 | * \source_cs <b>static short canGetVersion();</b>
|
---|
| 1126 | *
|
---|
| 1127 | * \source_delphi <b>function canGetVersion: Word; </b>
|
---|
| 1128 | * \source_end
|
---|
| 1129 | *
|
---|
| 1130 | * \win_start
|
---|
| 1131 | * This API call returns the version of the CANLIB API DLL (canlib32.dll). The
|
---|
| 1132 | * most significant byte is the major version number and the least significant
|
---|
| 1133 | * byte is the minor version number.
|
---|
| 1134 | *
|
---|
| 1135 | * The actual version of the different driver files can be obtained by studying
|
---|
| 1136 | * the version resources in each of the files.
|
---|
| 1137 | *
|
---|
| 1138 | * \note The version number of the canlib32.dll file is not related to the
|
---|
| 1139 | * product version of CANLIB you are using. CANLIB consists of several
|
---|
| 1140 | * driver and DLL files. To obtain the product version, use
|
---|
| 1141 | * \ref canGetVersionEx().
|
---|
| 1142 | *
|
---|
| 1143 | * \return version number of canlib32.dll
|
---|
| 1144 | *
|
---|
| 1145 | * \sa \ref page_user_guide_build_driver_version
|
---|
| 1146 | * \sa \ref canGetVersionEx(), \ref canProbeVersion()
|
---|
| 1147 | *
|
---|
| 1148 | * \win_end
|
---|
| 1149 | *
|
---|
| 1150 | * \linux_start
|
---|
| 1151 | * This API call returns the version of the CANLIB API library (libcanlib.so.x.y). The
|
---|
| 1152 | * most significant byte is the major version number and the least significant
|
---|
| 1153 | * byte is the minor version number.
|
---|
| 1154 | *
|
---|
| 1155 | * \return version number of libcanlib.so.x.y
|
---|
| 1156 | *
|
---|
| 1157 | * \linux_end
|
---|
| 1158 | *
|
---|
| 1159 | *
|
---|
| 1160 | */
|
---|
| 1161 | unsigned short CANLIBAPI canGetVersion (void);
|
---|
| 1162 |
|
---|
| 1163 | /**
|
---|
| 1164 | * \ingroup General
|
---|
| 1165 | *
|
---|
| 1166 | * \source_cs <b>static Canlib.canStatus canIoCtl(int handle, int func, int val);<br>
|
---|
| 1167 | static Canlib.canStatus canIoCtl(int handle, int func, out int val);<br>
|
---|
| 1168 | static Canlib.canStatus canIoCtl(int handle, int func, out string str_buf);<br>
|
---|
| 1169 | static Canlib.canStatus canIoCtl(int handle, int func, ref object obj_buf);</b>
|
---|
| 1170 | *
|
---|
| 1171 | * \source_delphi <b>function canIoCtl(handle: canHandle; func: Cardinal; buf: Pointer; buflen: Cardinal): canStatus; </b>
|
---|
| 1172 | * \source_end
|
---|
| 1173 | *
|
---|
| 1174 | * This API call performs several different functions; these are described
|
---|
| 1175 | * below. The functions are handle-specific unless otherwise noted; this means
|
---|
| 1176 | * that they affect only the handle you pass to \ref canIoCtl(), whereas other open
|
---|
| 1177 | * handles will remain unaffected. The contents of \a buf after the call is
|
---|
| 1178 | * dependent on the function code you specified.
|
---|
| 1179 | *
|
---|
| 1180 | * \param[in] hnd A handle to an open circuit.
|
---|
| 1181 | * \param[in] func A \ref canIOCTL_xxx function code
|
---|
| 1182 | * \param[in,out] buf Pointer to a buffer containing function-dependent data;
|
---|
| 1183 | or a \c NULL pointer for certain function codes. The
|
---|
| 1184 | buffer can be used for both input and output
|
---|
| 1185 | depending on the function code. See \ref canIOCTL_xxx.
|
---|
| 1186 | * \param[in] buflen The length of the buffer.
|
---|
| 1187 | *
|
---|
| 1188 | * \return \ref canOK (zero) if success
|
---|
| 1189 | * \return \ref canERR_xxx (negative) if failure
|
---|
| 1190 | *
|
---|
| 1191 | */
|
---|
| 1192 | canStatus CANLIBAPI canIoCtl (const CanHandle hnd,
|
---|
| 1193 | unsigned int func,
|
---|
| 1194 | void *buf,
|
---|
| 1195 | unsigned int buflen);
|
---|
| 1196 |
|
---|
| 1197 | /* Note the difference from the windows version */
|
---|
| 1198 |
|
---|
| 1199 | /**
|
---|
| 1200 | * \ingroup CAN
|
---|
| 1201 | *
|
---|
| 1202 | * \source_cs <b>static canStatus canReadTimer(int hnd, long time);</b>
|
---|
| 1203 | *
|
---|
| 1204 | * \source_delphi <b>function canReadTimer(handle: canHandle; time: longint): canStatus; </b>
|
---|
| 1205 | * \source_end
|
---|
| 1206 | *
|
---|
| 1207 | * Reads the current time from the clock used to timestamp the
|
---|
| 1208 | * messages for the indicated circuit.
|
---|
| 1209 | *
|
---|
| 1210 | * This API may return \ref canERR_INVHANDLE and/or \ref canERR_NOTINITIALIZED!
|
---|
| 1211 | * This happens if \a hnd is invalid, or if the library was not initialized.
|
---|
| 1212 | *
|
---|
| 1213 | * \note The clock used to timestamp the messages may not be available for
|
---|
| 1214 | * direct reading on all platforms. In such cases, the PC's clock is used
|
---|
| 1215 | * to return an approximation of the current time. Note that clock drift might
|
---|
| 1216 | * occur in this case.
|
---|
| 1217 | *
|
---|
| 1218 | * \param[in] hnd A handle to an open circuit.
|
---|
| 1219 | * \param[out] time The current time, with the prevailing time resolution.
|
---|
| 1220 | *
|
---|
| 1221 | * \return \ref canOK (zero) if success
|
---|
| 1222 | * \return \ref canERR_xxx (negative) if failure
|
---|
| 1223 | *
|
---|
| 1224 | * \sa \ref page_user_guide_time_accuracy_and_resolution
|
---|
| 1225 | * \sa \ref kvReadTimer()
|
---|
| 1226 | */
|
---|
| 1227 | canStatus CANLIBAPI canReadTimer (const CanHandle hnd, unsigned long *time);
|
---|
| 1228 |
|
---|
| 1229 | /**
|
---|
| 1230 | * \ingroup CAN
|
---|
| 1231 | *
|
---|
| 1232 | * \source_cs <b>static int canOpenChannel(int channel, int flags);</b>
|
---|
| 1233 | *
|
---|
| 1234 | * \source_delphi <b>function canOpenChannel(channel: Integer; flags: Integer): canHandle; </b>
|
---|
| 1235 | * \source_end
|
---|
| 1236 | *
|
---|
| 1237 | * Opens a CAN channel (circuit) and returns a handle which is used
|
---|
| 1238 | * in subsequent calls to CANLIB.
|
---|
| 1239 | *
|
---|
| 1240 | *
|
---|
| 1241 | * Channel numbering is dependent on the installed hardware. The first channel
|
---|
| 1242 | * always has number 0.
|
---|
| 1243 | *
|
---|
| 1244 | * For example,
|
---|
| 1245 | *
|
---|
| 1246 | * \li If you have a single LAPcan, the channels are numbered 0 and 1.
|
---|
| 1247 | *
|
---|
| 1248 | * \li If you have a USBcan Professional, the channels are numbered 0-1
|
---|
| 1249 | * according to the labels on the cables.
|
---|
| 1250 | *
|
---|
| 1251 | * \li The virtual channels come after all physical channels.
|
---|
| 1252 | *
|
---|
| 1253 | * If you are using multiple threads, note that the returned handle is usable
|
---|
| 1254 | * only in the context of the thread that created it. That is, you must call
|
---|
| 1255 | * \ref canOpenChannel() in each of the threads in your application that uses the
|
---|
| 1256 | * CAN bus. You can open the same channel from multiple threads, but you must
|
---|
| 1257 | * call \ref canOpenChannel() once per thread.
|
---|
| 1258 | *
|
---|
| 1259 | * If you are using the same channel via multiple handles, note that the
|
---|
| 1260 | * default behaviour is that the different handles will "hear" each other just as
|
---|
| 1261 | * if each handle referred to a channel of its own. If you open, say, channel 0
|
---|
| 1262 | * from thread A and thread B and then send a message from thread A, it will be
|
---|
| 1263 | * "received" by thread B.
|
---|
| 1264 | * This behaviour can be changed using \ref canIOCTL_SET_LOCAL_TXECHO.
|
---|
| 1265 | *
|
---|
| 1266 | * \note The handle returned may be zero which is perfectly valid.
|
---|
| 1267 | *
|
---|
| 1268 | * \note This call replaces the \ref canOpen() API call and serves the same purpose.
|
---|
| 1269 | *
|
---|
| 1270 | * \param[in] channel The number of the channel. Channel numbering is hardware
|
---|
| 1271 | * dependent.
|
---|
| 1272 | * \param[in] flags A combination of \ref canOPEN_xxx flags
|
---|
| 1273 | *
|
---|
| 1274 | * \return Returns a handle to the opened circuit, or \ref canERR_xxx
|
---|
| 1275 | * (negative) if the call failed.
|
---|
| 1276 | *
|
---|
| 1277 | * \sa \ref page_code_snippets_examples, \ref page_user_guide_virtual_info
|
---|
| 1278 | * \sa \ref canGetNumberOfChannels(), \ref canGetChannelData(), \ref canIoCtl()
|
---|
| 1279 | *
|
---|
| 1280 | */
|
---|
| 1281 | CanHandle CANLIBAPI canOpenChannel (int channel, int flags);
|
---|
| 1282 |
|
---|
| 1283 | /**
|
---|
| 1284 | * \ingroup General
|
---|
| 1285 | *
|
---|
| 1286 | * \source_cs <b>static Canlib.canStatus canGetNumberOfChannels(out int channelCount);</b>
|
---|
| 1287 | *
|
---|
| 1288 | * \source_delphi <b>function canGetNumberOfChannels(var channelCount: Integer): canStatus; </b>
|
---|
| 1289 | * \source_end
|
---|
| 1290 | *
|
---|
| 1291 | * This function returns the number of available CAN channels in the
|
---|
| 1292 | * computer. The virtual channels are included in this number.
|
---|
| 1293 | *
|
---|
| 1294 | * \param[out] channelCount A pointer to a \c DWORD which will receive the current
|
---|
| 1295 | * number of channels.
|
---|
| 1296 | *
|
---|
| 1297 | * \return \ref canOK (zero) if success
|
---|
| 1298 | * \return \ref canERR_xxx (negative) if failure
|
---|
| 1299 | *
|
---|
| 1300 | * \sa \ref page_code_snippets_examples, \ref page_user_guide_virtual_info
|
---|
| 1301 | * \sa \ref canGetChannelData()
|
---|
| 1302 | */
|
---|
| 1303 | canStatus CANLIBAPI canGetNumberOfChannels (int *channelCount);
|
---|
| 1304 |
|
---|
| 1305 | /**
|
---|
| 1306 | * \ingroup General
|
---|
| 1307 | *
|
---|
| 1308 | * \source_cs <b>static Canlib.canStatus canGetChannelData(int channel, int item, out object buffer);</b>
|
---|
| 1309 | *
|
---|
| 1310 | * \source_delphi <b>function canGetChannelData(channel, item: Integer; var buffer; bufsize: Cardinal): canStatus; </b>
|
---|
| 1311 | * \source_end
|
---|
| 1312 | *
|
---|
| 1313 | * This function can be used to retrieve certain pieces of information about a channel.
|
---|
| 1314 | *
|
---|
| 1315 | * \note You must pass a channel number and not a channel handle.
|
---|
| 1316 | *
|
---|
| 1317 | * \param[in] channel The number of the channel you are interested in. Channel
|
---|
| 1318 | * numbers are integers in the interval beginning at 0
|
---|
| 1319 | * (zero) and ending at the value returned by
|
---|
| 1320 | * \ref canGetNumberOfChannels() minus 1.
|
---|
| 1321 | * \param[in] item This parameter specifies what data to obtain for the
|
---|
| 1322 | * specified channel. The value is one of the constants
|
---|
| 1323 | * \ref canCHANNELDATA_xxx.
|
---|
| 1324 | * \param[in,out] buffer The address of a buffer which is to receive the data.
|
---|
| 1325 | * \param[in] bufsize The size of the buffer to which the buffer parameter
|
---|
| 1326 | * points.
|
---|
| 1327 | *
|
---|
| 1328 | * \return \ref canOK (zero) if success
|
---|
| 1329 | * \return \ref canERR_xxx (negative) if failure
|
---|
| 1330 | *
|
---|
| 1331 | * \sa \ref page_code_snippets_examples
|
---|
| 1332 | * \sa \ref canGetNumberOfChannels()
|
---|
| 1333 | */
|
---|
| 1334 | canStatus CANLIBAPI canGetChannelData (int channel,
|
---|
| 1335 | int item,
|
---|
| 1336 | void *buffer,
|
---|
| 1337 | size_t bufsize);
|
---|
| 1338 |
|
---|
| 1339 | /**
|
---|
| 1340 | * \ingroup General
|
---|
| 1341 | * \anchor canCHANNELDATA_xxx
|
---|
| 1342 | * \name canCHANNELDATA_xxx
|
---|
| 1343 | *
|
---|
| 1344 | * These defines are used in \ref canGetChannelData().
|
---|
| 1345 | *
|
---|
| 1346 | * @{
|
---|
| 1347 | */
|
---|
| 1348 |
|
---|
| 1349 | /**
|
---|
| 1350 | * This define is used in \ref canGetChannelData(), \a buffer
|
---|
| 1351 | * mentioned below refers to this functions argument.
|
---|
| 1352 | *
|
---|
| 1353 | * \a buffer points to a 32-bit unsigned integer that receives the
|
---|
| 1354 | * capabilities of the CAN controller; this is a combination of the \ref
|
---|
| 1355 | * canCHANNEL_CAP_xxx flags.
|
---|
| 1356 | */
|
---|
| 1357 | #define canCHANNELDATA_CHANNEL_CAP 1
|
---|
| 1358 |
|
---|
| 1359 | /**
|
---|
| 1360 | * This define is used in \ref canGetChannelData(), \a buffer
|
---|
| 1361 | * mentioned below refers to this functions argument.
|
---|
| 1362 | *
|
---|
| 1363 | * \a buffer points to a 32-bit unsigned integer that receives the
|
---|
| 1364 | * capabilities of the CAN transceiver; this is a combination of the
|
---|
| 1365 | * \ref canDRIVER_CAP_xxx flags.
|
---|
| 1366 | */
|
---|
| 1367 | #define canCHANNELDATA_TRANS_CAP 2
|
---|
| 1368 |
|
---|
| 1369 | /**
|
---|
| 1370 | * This define is used in \ref canGetChannelData(), \a buffer
|
---|
| 1371 | * mentioned below refers to this functions argument.
|
---|
| 1372 | *
|
---|
| 1373 | * \note Currently not implemented.
|
---|
| 1374 | */
|
---|
| 1375 | #define canCHANNELDATA_CHANNEL_FLAGS 3 // available, etc
|
---|
| 1376 |
|
---|
| 1377 | /**
|
---|
| 1378 | * This define is used in \ref canGetChannelData(), \a buffer
|
---|
| 1379 | * mentioned below refers to this functions argument.
|
---|
| 1380 | *
|
---|
| 1381 | * \a buffer points to a 32-bit unsigned integer that receives the hardware
|
---|
| 1382 | * type of the card. This value is any one of the \ref canHWTYPE_xxx
|
---|
| 1383 | * constants.
|
---|
| 1384 | */
|
---|
| 1385 | #define canCHANNELDATA_CARD_TYPE 4
|
---|
| 1386 |
|
---|
| 1387 | /**
|
---|
| 1388 | * This define is used in \ref canGetChannelData(), \a buffer
|
---|
| 1389 | * mentioned below refers to this functions argument.
|
---|
| 1390 | *
|
---|
| 1391 | * \a buffer points to a 32-bit unsigned integer that receives the card's
|
---|
| 1392 | * number in the computer. Each card type is numbered separately. For
|
---|
| 1393 | * example, the first LAPcan card in a machine will have number 0, the second
|
---|
| 1394 | * LAPcan number 1, etc.
|
---|
| 1395 | */
|
---|
| 1396 | #define canCHANNELDATA_CARD_NUMBER 5
|
---|
| 1397 |
|
---|
| 1398 | /**
|
---|
| 1399 | * This define is used in \ref canGetChannelData(), \a buffer
|
---|
| 1400 | * mentioned below refers to this functions argument.
|
---|
| 1401 | *
|
---|
| 1402 | * \a buffer points to a 32-bit unsigned integer which receives the channel
|
---|
| 1403 | * number on the card.
|
---|
| 1404 | */
|
---|
| 1405 | #define canCHANNELDATA_CHAN_NO_ON_CARD 6
|
---|
| 1406 |
|
---|
| 1407 | /**
|
---|
| 1408 | * This define is used in \ref canGetChannelData(), \a buffer
|
---|
| 1409 | * mentioned below refers to this functions argument.
|
---|
| 1410 | *
|
---|
| 1411 | * \a buffer points to a 64-bit (8 bytes) area which receives the serial
|
---|
| 1412 | * number of the card. If the card doesn't have a serial number, 0 is
|
---|
| 1413 | * returned. The serial number is an 8-byte unsigned integer. Currently, no
|
---|
| 1414 | * products are using all 8 bytes; at most 4 bytes are used.
|
---|
| 1415 | */
|
---|
| 1416 | #define canCHANNELDATA_CARD_SERIAL_NO 7
|
---|
| 1417 |
|
---|
| 1418 | /**
|
---|
| 1419 | * This define is used in \ref canGetChannelData(), \a buffer
|
---|
| 1420 | * mentioned below refers to this functions argument.
|
---|
| 1421 | *
|
---|
| 1422 | * \a buffer points to a 64-bit (8 bytes) area which receives the serial
|
---|
| 1423 | * number of the transceiver. The serial number is an 8-byte unsigned
|
---|
| 1424 | * integer. If the transceiver doesn't have a serial number, 0 is returned.
|
---|
| 1425 | */
|
---|
| 1426 | #define canCHANNELDATA_TRANS_SERIAL_NO 8
|
---|
| 1427 |
|
---|
| 1428 | /**
|
---|
| 1429 | * This define is used in \ref canGetChannelData(), \a buffer
|
---|
| 1430 | * mentioned below refers to this functions argument.
|
---|
| 1431 | *
|
---|
| 1432 | * \a buffer points to a 64-bit (8 bytes) area which receives the firmware
|
---|
| 1433 | * revision number on the card. This number consists of four 16-bit words:
|
---|
| 1434 | * the major revision, the minor revision, the release number and the build
|
---|
| 1435 | * number, listed in order from the most significant to the least
|
---|
| 1436 | * significant.
|
---|
| 1437 | */
|
---|
| 1438 | #define canCHANNELDATA_CARD_FIRMWARE_REV 9
|
---|
| 1439 |
|
---|
| 1440 | /**
|
---|
| 1441 | * This define is used in \ref canGetChannelData(), \a buffer
|
---|
| 1442 | * mentioned below refers to this functions argument.
|
---|
| 1443 | *
|
---|
| 1444 | * \a buffer points to a 64-bit (8 bytes) area which receives the hardware
|
---|
| 1445 | * revision number on the card. This number consists of four 16-bit words;
|
---|
| 1446 | * the two most significant are always 0, and the two least significant are
|
---|
| 1447 | * the major revision and the minor revision, listed in order from the most
|
---|
| 1448 | * significant to the least significant.
|
---|
| 1449 | */
|
---|
| 1450 | #define canCHANNELDATA_CARD_HARDWARE_REV 10
|
---|
| 1451 |
|
---|
| 1452 | /**
|
---|
| 1453 | * This define is used in \ref canGetChannelData(), \a buffer
|
---|
| 1454 | * mentioned below refers to this functions argument.
|
---|
| 1455 | *
|
---|
| 1456 | * \a buffer points to a 8-byte area which receives the UPC (EAN) number for
|
---|
| 1457 | * the card. If there is no UPC number, the buffer is filled with zeros. The
|
---|
| 1458 | * UPC (EAN) number is coded as a BCD string with the LSB first, so
|
---|
| 1459 | * e.g. 733-0130-00122-0 is coded as 0x30001220 0x00073301.
|
---|
| 1460 | */
|
---|
| 1461 | #define canCHANNELDATA_CARD_UPC_NO 11
|
---|
| 1462 |
|
---|
| 1463 | /**
|
---|
| 1464 | * This define is used in \ref canGetChannelData(), \a buffer
|
---|
| 1465 | * mentioned below refers to this functions argument.
|
---|
| 1466 | *
|
---|
| 1467 | * \a buffer points to a 8-byte area which receives the UPC (EAN) number for
|
---|
| 1468 | * the transceiver. If there is no UPC number, the buffer is filled with
|
---|
| 1469 | * zeros. The UPC (EAN) number is coded as a BCD string with the LSB first,
|
---|
| 1470 | * so e.g. 733-0130-00122-0 is coded as 0x30001220 0x00073301.
|
---|
| 1471 | */
|
---|
| 1472 | #define canCHANNELDATA_TRANS_UPC_NO 12
|
---|
| 1473 |
|
---|
| 1474 | /**
|
---|
| 1475 | * This define is used in \ref canGetChannelData(), \a buffer
|
---|
| 1476 | * mentioned below refers to this functions argument.
|
---|
| 1477 | *
|
---|
| 1478 | * \a buffer points to an area which receives a zero-terminated string with a
|
---|
| 1479 | * clear-text name of the channel.
|
---|
| 1480 | *
|
---|
| 1481 | * \note Use of this item code is no longer recommended. The returned
|
---|
| 1482 | * channel name doesn't contain the exact hardware type (it just contains
|
---|
| 1483 | * the device family) and uses zero-based channel numbering, which is not
|
---|
| 1484 | * user friendly. Instead, use e.g. \ref canCHANNELDATA_DEVDESCR_ASCII and
|
---|
| 1485 | * \ref canCHANNELDATA_CHAN_NO_ON_CARD to build your own channel name.
|
---|
| 1486 | *
|
---|
| 1487 | *\win_start
|
---|
| 1488 | * \sa \ref canCHANNELDATA_DEVNAME_ASCII
|
---|
| 1489 | *\win_end
|
---|
| 1490 | */
|
---|
| 1491 | #define canCHANNELDATA_CHANNEL_NAME 13
|
---|
| 1492 | #if defined(CANLIB_DECLARE_ALL)
|
---|
| 1493 |
|
---|
| 1494 | /**
|
---|
| 1495 | * This define is used in \ref canGetChannelData(), \a buffer
|
---|
| 1496 | * mentioned below refers to this functions argument.
|
---|
| 1497 | *
|
---|
| 1498 | * \a buffer points to an array of 4 16-bit unsigned integers which receives
|
---|
| 1499 | * the file version number of the second-level DLL driver file, i.e. the DLL
|
---|
| 1500 | * that interfaces between CANLIB32.DLL and the driver proper.
|
---|
| 1501 | *
|
---|
| 1502 | * Contents depening on index:
|
---|
| 1503 | *
|
---|
| 1504 | * \li 0: 0
|
---|
| 1505 | * \li 1: The build number
|
---|
| 1506 | * \li 2: The minor revision number
|
---|
| 1507 | * \li 3: The major revision number
|
---|
| 1508 | */
|
---|
| 1509 | # define canCHANNELDATA_DLL_FILE_VERSION 14
|
---|
| 1510 |
|
---|
| 1511 | /**
|
---|
| 1512 | * This define is used in \ref canGetChannelData(), \a buffer
|
---|
| 1513 | * mentioned below refers to this functions argument.
|
---|
| 1514 | *
|
---|
| 1515 | * \a buffer points to an array of 4 16-bit unsigned integers which receives
|
---|
| 1516 | * the product version number of the second-level DLL driver file, i.e. the
|
---|
| 1517 | * DLL that interfaces between CANLIB32.DLL and the driver proper.
|
---|
| 1518 | *
|
---|
| 1519 | * Contents depening on index:
|
---|
| 1520 | *
|
---|
| 1521 | * \li 0: 0
|
---|
| 1522 | * \li 1: 1
|
---|
| 1523 | * \li 2: The minor revision number
|
---|
| 1524 | * \li 3: The major revision number
|
---|
| 1525 | */
|
---|
| 1526 | # define canCHANNELDATA_DLL_PRODUCT_VERSION 15
|
---|
| 1527 |
|
---|
| 1528 | /**
|
---|
| 1529 | * This define is used in \ref canGetChannelData(), \a buffer
|
---|
| 1530 | * mentioned below refers to this functions argument.
|
---|
| 1531 | *
|
---|
| 1532 | * \a buffer points to a 32-bit unsigned integer which receives a number that
|
---|
| 1533 | * identifies the second-level DLL driver file, i.e. the DLL that interfaces
|
---|
| 1534 | * between CANLIB32.DLL and the driver proper.
|
---|
| 1535 | *
|
---|
| 1536 | * Values:
|
---|
| 1537 | *
|
---|
| 1538 | * \li 1: kvalapw.dll - used with CANLIB up to 2.29.
|
---|
| 1539 | *
|
---|
| 1540 | * \li 2: kvalapw2.dll - used with CANLIB from 3.0 and on.
|
---|
| 1541 | */
|
---|
| 1542 | # define canCHANNELDATA_DLL_FILETYPE 16
|
---|
| 1543 |
|
---|
| 1544 | /**
|
---|
| 1545 | * This define is used in \ref canGetChannelData(), \a buffer
|
---|
| 1546 | * mentioned below refers to this functions argument.
|
---|
| 1547 | *
|
---|
| 1548 | * \a buffer points to a 32-bit unsigned integer which receives the CAN
|
---|
| 1549 | * transceiver type of the specified channel. This value is one of the
|
---|
| 1550 | * \ref canTRANSCEIVER_TYPE_xxx
|
---|
| 1551 | */
|
---|
| 1552 | # define canCHANNELDATA_TRANS_TYPE 17
|
---|
| 1553 |
|
---|
| 1554 | /**
|
---|
| 1555 | * This define is used in \ref canGetChannelData(), \a buffer
|
---|
| 1556 | * mentioned below refers to this functions argument.
|
---|
| 1557 | *
|
---|
| 1558 | * \a buffer points to a 32-bit unsigned integer which receives an address
|
---|
| 1559 | * indicating where the device is located on its underlying bus. The
|
---|
| 1560 | * interpretation of this number is bus-specific. If the address is unknown
|
---|
| 1561 | * or the bus driver does not support an address, the bus driver leaves this
|
---|
| 1562 | * member at its default value of 0xFFFFFFFF.
|
---|
| 1563 | *
|
---|
| 1564 | * The following list describes the information certain bus drivers store in
|
---|
| 1565 | * the Address field for their child devices:
|
---|
| 1566 | *
|
---|
| 1567 | * \li ISA: Does not supply an address. Defaults to 0xFFFFFFFF.
|
---|
| 1568 | *
|
---|
| 1569 | * \li PC Card (PCMCIA): The socket number (typically 0x00 or 0x40)
|
---|
| 1570 | *
|
---|
| 1571 | * \li PCI: The device number in the high word and the function number in the
|
---|
| 1572 | * low word.
|
---|
| 1573 | *
|
---|
| 1574 | * \li USB: The port number.
|
---|
| 1575 | */
|
---|
| 1576 | # define canCHANNELDATA_DEVICE_PHYSICAL_POSITION 18
|
---|
| 1577 |
|
---|
| 1578 | /**
|
---|
| 1579 | * This define is used in \ref canGetChannelData(), \a buffer
|
---|
| 1580 | * mentioned below refers to this functions argument.
|
---|
| 1581 | *
|
---|
| 1582 | * \a buffer points to a 32-bit unsigned integer which receives a number
|
---|
| 1583 | * associated with the device that can be displayed in the user
|
---|
| 1584 | * interface. This number is typically a user-perceived slot number, such as
|
---|
| 1585 | * a number printed next to the slot on the board, or some other number that
|
---|
| 1586 | * makes locating the physical device easier for the user. For buses with no
|
---|
| 1587 | * such convention, or when the UI number is unknown, 0xFFFFFFFF is returned.
|
---|
| 1588 | */
|
---|
| 1589 | # define canCHANNELDATA_UI_NUMBER 19
|
---|
| 1590 |
|
---|
| 1591 | /**
|
---|
| 1592 | * This define is used in \ref canGetChannelData(), \a buffer
|
---|
| 1593 | * mentioned below refers to this functions argument.
|
---|
| 1594 | *
|
---|
| 1595 | * \a buffer points to a 32-bit unsigned integer which is set to 0, if the
|
---|
| 1596 | * legacy time synchronization is not currently enabled for the specified
|
---|
| 1597 | * channel, and 1, if the legacy time synchronization is currently enabled
|
---|
| 1598 | * for the specified channel.
|
---|
| 1599 | *
|
---|
| 1600 | * Legacy time synchronization is a mechanism that will keep the PC and CAN
|
---|
| 1601 | * channel clocks in sync. The synchronization is done in the driver, which
|
---|
| 1602 | * periodically calculates the difference between the PC clock and the CAN
|
---|
| 1603 | * device clock and compensates for the clock drift by recalculating the CAN
|
---|
| 1604 | * message time stamps. You need to enable clock synchronization in the
|
---|
| 1605 | * Control Panel using the Kvaser Hardware applet.
|
---|
| 1606 | *
|
---|
| 1607 | * \note Legacy time synchronization is implemented only on LAPcan and LAPcan
|
---|
| 1608 | * II. It is not related to Kvaser MagiSync&tm; which is implemented in the
|
---|
| 1609 | * high-end members of the Kvaser Leaf family. Kvaser MagiSync&tm; is always
|
---|
| 1610 | * enabled and allows for much more accurate time synchronization.
|
---|
| 1611 | *
|
---|
| 1612 | */
|
---|
| 1613 | # define canCHANNELDATA_TIMESYNC_ENABLED 20
|
---|
| 1614 |
|
---|
| 1615 | /**
|
---|
| 1616 | * This define is used in \ref canGetChannelData(), \a buffer
|
---|
| 1617 | * mentioned below refers to this functions argument.
|
---|
| 1618 | *
|
---|
| 1619 | * \a buffer points to an array of four 16-bit unsigned integers which
|
---|
| 1620 | * receives the file version number of the kernel-mode driver.
|
---|
| 1621 | *
|
---|
| 1622 | * Contents depening on index:
|
---|
| 1623 | *
|
---|
| 1624 | * \li 0: The build number
|
---|
| 1625 | * \li 1: 0
|
---|
| 1626 | * \li 2: The minor revision number
|
---|
| 1627 | * \li 3: The major revision number
|
---|
| 1628 | */
|
---|
| 1629 | # define canCHANNELDATA_DRIVER_FILE_VERSION 21
|
---|
| 1630 |
|
---|
| 1631 | /**
|
---|
| 1632 | * This define is used in \ref canGetChannelData(), \a buffer
|
---|
| 1633 | * mentioned below refers to this functions argument.
|
---|
| 1634 | *
|
---|
| 1635 | * \a buffer points to an array of four 16-bit unsigned integers which
|
---|
| 1636 | * receives the product version number of the kernel-mode driver.
|
---|
| 1637 | *
|
---|
| 1638 | * Contents depening on index:
|
---|
| 1639 | *
|
---|
| 1640 | * \li 0: 0
|
---|
| 1641 | * \li 1: 0
|
---|
| 1642 | * \li 2: The minor revision number
|
---|
| 1643 | * \li 3: The major revision number
|
---|
| 1644 | */
|
---|
| 1645 | # define canCHANNELDATA_DRIVER_PRODUCT_VERSION 22
|
---|
| 1646 |
|
---|
| 1647 | /**
|
---|
| 1648 | * This define is used in \ref canGetChannelData(), \a buffer
|
---|
| 1649 | * mentioned below refers to this functions argument.
|
---|
| 1650 | *
|
---|
| 1651 | * \a buffer points to a buffer which receives the device manufacturer's name
|
---|
| 1652 | * as a zero-terminated Unicode string.
|
---|
| 1653 | */
|
---|
| 1654 | # define canCHANNELDATA_MFGNAME_UNICODE 23
|
---|
| 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 buffer which receives the device manufacturer's name
|
---|
| 1661 | * as a zero-terminated ASCII string.
|
---|
| 1662 | */
|
---|
| 1663 | # define canCHANNELDATA_MFGNAME_ASCII 24
|
---|
| 1664 |
|
---|
| 1665 | /**
|
---|
| 1666 | * This define is used in \ref canGetChannelData(), \a buffer
|
---|
| 1667 | * mentioned below refers to this functions argument.
|
---|
| 1668 | *
|
---|
| 1669 | * \a buffer points to a buffer which receives the product name of the device
|
---|
| 1670 | * as a zero-terminated Unicode string.
|
---|
| 1671 | */
|
---|
| 1672 | # define canCHANNELDATA_DEVDESCR_UNICODE 25
|
---|
| 1673 |
|
---|
| 1674 | /**
|
---|
| 1675 | * This define is used in \ref canGetChannelData(), \a buffer
|
---|
| 1676 | * mentioned below refers to this functions argument.
|
---|
| 1677 | *
|
---|
| 1678 | * \a buffer points to a buffer which receives the product name of the device
|
---|
| 1679 | * as a zero-terminated ASCII string.
|
---|
| 1680 | */
|
---|
| 1681 | # define canCHANNELDATA_DEVDESCR_ASCII 26
|
---|
| 1682 |
|
---|
| 1683 | /**
|
---|
| 1684 | * This define is used in \ref canGetChannelData(), \a buffer
|
---|
| 1685 | * mentioned below refers to this functions argument.
|
---|
| 1686 | *
|
---|
| 1687 | * \a buffer points to a buffer which receives the name of the device
|
---|
| 1688 | * driver (e.g. "kcans") as a zero-terminated ASCII string.
|
---|
| 1689 | *
|
---|
| 1690 | * \note The device driver names have no special meanings and may change
|
---|
| 1691 | * from a release to another.
|
---|
| 1692 | */
|
---|
| 1693 | # define canCHANNELDATA_DRIVER_NAME 27
|
---|
| 1694 |
|
---|
| 1695 | #endif
|
---|
| 1696 |
|
---|
| 1697 | /** @} */
|
---|
| 1698 |
|
---|
| 1699 |
|
---|
| 1700 | /**
|
---|
| 1701 | * \name canCHANNEL_IS_xxx
|
---|
| 1702 | * \anchor canCHANNEL_IS_xxx
|
---|
| 1703 | *
|
---|
| 1704 | * These channelFlags are used in \ref canGetChannelData() and in conjunction with \ref
|
---|
| 1705 | * canCHANNELDATA_CHANNEL_FLAGS.
|
---|
| 1706 | * @{
|
---|
| 1707 | */
|
---|
| 1708 | /** Used with \ref canCHANNELDATA_CHANNEL_FLAGS, indicates that the channel is
|
---|
| 1709 | opened exclusively. */
|
---|
| 1710 | #define canCHANNEL_IS_EXCLUSIVE 0x0001
|
---|
| 1711 | /** Used with \ref canCHANNELDATA_CHANNEL_FLAGS, indicates that the channel is
|
---|
| 1712 | opened. */
|
---|
| 1713 | #define canCHANNEL_IS_OPEN 0x0002
|
---|
| 1714 |
|
---|
| 1715 | /** Used with \ref canCHANNELDATA_CHANNEL_FLAGS, indicates that the channel is
|
---|
| 1716 | * opened as CAN FD. */
|
---|
| 1717 |
|
---|
| 1718 | #define canCHANNEL_IS_CANFD 0x0004
|
---|
| 1719 | /** @} */
|
---|
| 1720 |
|
---|
| 1721 |
|
---|
| 1722 | /**
|
---|
| 1723 | * \name canHWTYPE_xxx
|
---|
| 1724 | * \anchor canHWTYPE_xxx
|
---|
| 1725 | *
|
---|
| 1726 | * The following constants can be returned from \ref canGetChannelData(), using the
|
---|
| 1727 | * \ref canCHANNELDATA_CARD_TYPE item code. They identify the hardware type for
|
---|
| 1728 | * the channel specified in the call to \ref canGetChannelData().
|
---|
| 1729 | *
|
---|
| 1730 | * \note They indicate a hardware type, but not necessarily a specific
|
---|
| 1731 | * product. For example, \ref canHWTYPE_LAPCAN is returned both for LAPcan and
|
---|
| 1732 | * LAPcan II. (You can use \ref canGetChannelData() to obtain the UPC/EAN code for
|
---|
| 1733 | * the device. This number uniquely identifies the product.)
|
---|
| 1734 | *
|
---|
| 1735 | * @{
|
---|
| 1736 | */
|
---|
| 1737 | #define canHWTYPE_NONE 0 ///< Unknown or undefined
|
---|
| 1738 | #define canHWTYPE_VIRTUAL 1 ///< The virtual CAN bus
|
---|
| 1739 | #define canHWTYPE_LAPCAN 2 ///< LAPcan Family
|
---|
| 1740 | #define canHWTYPE_CANPARI 3 ///< CANpari (obsolete).
|
---|
| 1741 | #define canHWTYPE_PCCAN 8 ///< PCcan Family
|
---|
| 1742 | #define canHWTYPE_PCICAN 9 ///< PCIcan Family
|
---|
| 1743 | #define canHWTYPE_USBCAN 11 ///< USBcan (obsolete).
|
---|
| 1744 | #define canHWTYPE_PCICAN_II 40 ///< PCIcan II family
|
---|
| 1745 | #define canHWTYPE_USBCAN_II 42 ///< USBcan II, USBcan Rugged, Kvaser Memorator
|
---|
| 1746 | #define canHWTYPE_SIMULATED 44 ///< Simulated CAN bus for Kvaser Creator (obsolete).
|
---|
| 1747 | #define canHWTYPE_ACQUISITOR 46 ///< Kvaser Acquisitor (obsolete).
|
---|
| 1748 | #define canHWTYPE_LEAF 48 ///< Kvaser Leaf Family
|
---|
| 1749 | #define canHWTYPE_PC104_PLUS 50 ///< Kvaser PC104+
|
---|
| 1750 | #define canHWTYPE_PCICANX_II 52 ///< Kvaser PCIcanx II
|
---|
| 1751 | #define canHWTYPE_MEMORATOR_II 54 ///< Kvaser Memorator Professional family
|
---|
| 1752 | #define canHWTYPE_MEMORATOR_PRO 54 ///< Kvaser Memorator Professional family
|
---|
| 1753 | #define canHWTYPE_USBCAN_PRO 56 ///< Kvaser USBcan Professional
|
---|
| 1754 | #define canHWTYPE_IRIS 58 ///< Obsolete name, use canHWTYPE_BLACKBIRD instead
|
---|
| 1755 | #define canHWTYPE_BLACKBIRD 58 ///< Kvaser BlackBird
|
---|
| 1756 | #define canHWTYPE_MEMORATOR_LIGHT 60 ///< Kvaser Memorator Light
|
---|
| 1757 | #define canHWTYPE_MINIHYDRA 62 ///< Obsolete name, use canHWTYPE_EAGLE instead
|
---|
| 1758 | #define canHWTYPE_EAGLE 62 ///< Kvaser Eagle family
|
---|
| 1759 | #define canHWTYPE_BAGEL 64 ///< Obsolete name, use canHWTYPE_BLACKBIRD_V2 instead
|
---|
| 1760 | #define canHWTYPE_BLACKBIRD_V2 64 ///< Kvaser BlackBird v2
|
---|
| 1761 | #define canHWTYPE_MINIPCIE 66 ///< Kvaser Mini PCI Express
|
---|
| 1762 | #define canHWTYPE_USBCAN_KLINE 68 ///< USBcan Pro HS/K-Line
|
---|
| 1763 | #define canHWTYPE_ETHERCAN 70 ///< Kvaser Ethercan
|
---|
| 1764 | #define canHWTYPE_USBCAN_LIGHT 72 ///< Kvaser USBcan Light
|
---|
| 1765 | #define canHWTYPE_USBCAN_PRO2 74 ///< Kvaser USBcan Pro 5xHS and variants
|
---|
| 1766 | #define canHWTYPE_PCIE_V2 76 ///< Kvaser PCIEcan 4xHS and variants
|
---|
| 1767 | #define canHWTYPE_MEMORATOR_PRO2 78 ///< Kvaser Memorator Pro 5xHS and variants
|
---|
| 1768 | #define canHWTYPE_LEAF2 80 ///< Kvaser Leaf Pro HS v2 and variants
|
---|
| 1769 | #define canHWTYPE_MEMORATOR_LIGHT2 82 ///< Kvaser Memorator Light (2nd generation)
|
---|
| 1770 |
|
---|
| 1771 |
|
---|
| 1772 | /** @} */
|
---|
| 1773 |
|
---|
| 1774 | /**
|
---|
| 1775 | * \name canCHANNEL_CAP_xxx
|
---|
| 1776 | * \anchor canCHANNEL_CAP_xxx
|
---|
| 1777 | *
|
---|
| 1778 | * Channel capabilities.
|
---|
| 1779 | */
|
---|
| 1780 | #define canCHANNEL_CAP_EXTENDED_CAN 0x00000001L ///< Can use extended identifiers
|
---|
| 1781 | #define canCHANNEL_CAP_BUS_STATISTICS 0x00000002L ///< Can report busload etc
|
---|
| 1782 | #define canCHANNEL_CAP_ERROR_COUNTERS 0x00000004L ///< Can return error counters
|
---|
| 1783 | #define canCHANNEL_CAP_CAN_DIAGNOSTICS 0x00000008L ///< Can report CAN diagnostics
|
---|
| 1784 | #define canCHANNEL_CAP_GENERATE_ERROR 0x00000010L ///< Can send error frames
|
---|
| 1785 | #define canCHANNEL_CAP_GENERATE_OVERLOAD 0x00000020L ///< Can send CAN overload frame
|
---|
| 1786 | #define canCHANNEL_CAP_TXREQUEST 0x00000040L ///< Can report when a CAN messsage transmission is initiated
|
---|
| 1787 | #define canCHANNEL_CAP_TXACKNOWLEDGE 0x00000080L ///< Can report when a CAN messages has been transmitted
|
---|
| 1788 | #define canCHANNEL_CAP_VIRTUAL 0x00010000L ///< Virtual CAN channel
|
---|
| 1789 | #define canCHANNEL_CAP_SIMULATED 0x00020000L ///< Simulated CAN channel
|
---|
| 1790 | #define canCHANNEL_CAP_REMOTE 0x00040000L ///< Remote CAN channel (e.g. BlackBird).
|
---|
| 1791 | #define canCHANNEL_CAP_CAN_FD 0x00080000L ///< CAN-FD channel
|
---|
| 1792 | #define canCHANNEL_CAP_CAN_FD_NONISO 0x00100000L ///< Supports Non-ISO CAN-FD channel
|
---|
| 1793 |
|
---|
| 1794 | /** @} */
|
---|
| 1795 |
|
---|
| 1796 | /**
|
---|
| 1797 | * \name canDRIVER_CAP_xxx
|
---|
| 1798 | * \anchor canDRIVER_CAP_xxx
|
---|
| 1799 | *
|
---|
| 1800 | * Driver (transceiver) capabilities.
|
---|
| 1801 | * @{
|
---|
| 1802 | */
|
---|
| 1803 | /** Used with \ref canCHANNELDATA_TRANS_CAP */
|
---|
| 1804 | #define canDRIVER_CAP_HIGHSPEED 0x00000001L
|
---|
| 1805 | /** @} */
|
---|
| 1806 |
|
---|
| 1807 | /**
|
---|
| 1808 | * \ingroup General
|
---|
| 1809 | * \name canIOCTL_xxx
|
---|
| 1810 | * \anchor canIOCTL_xxx
|
---|
| 1811 | *
|
---|
| 1812 | * These defines are used in \ref canIoCtl().
|
---|
| 1813 | *
|
---|
| 1814 | * @{
|
---|
| 1815 | */
|
---|
| 1816 |
|
---|
| 1817 |
|
---|
| 1818 | /**
|
---|
| 1819 | * This define is used in \ref canIoCtl(), \a buf and \a buflen refers to this
|
---|
| 1820 | * functions arguments.
|
---|
| 1821 | *
|
---|
| 1822 | * Tells CANLIB to "prefer" extended identifiers; that is, if you send a
|
---|
| 1823 | * message with \ref canWrite() and don't specify \ref canMSG_EXT nor \ref canMSG_STD,
|
---|
| 1824 | * \ref canMSG_EXT will be assumed. The contents of \a buf and \a buflen are
|
---|
| 1825 | * ignored. \ref canRead() et al will set \ref canMSG_EXT and/or \ref canMSG_STD as usual
|
---|
| 1826 | * and are not affected by this call.
|
---|
| 1827 | */
|
---|
| 1828 | #define canIOCTL_PREFER_EXT 1
|
---|
| 1829 |
|
---|
| 1830 | /**
|
---|
| 1831 | * This define is used in \ref canIoCtl(), \a buf and \a buflen refers to this
|
---|
| 1832 | * functions arguments.
|
---|
| 1833 | *
|
---|
| 1834 | * Tells CANLIB to "prefer" standard identifiers; that is, if you send a
|
---|
| 1835 | * message with \ref canWrite() and don't specify \ref canMSG_EXT nor \ref canMSG_STD,
|
---|
| 1836 | * \ref canMSG_STD will be assumed. The contents of \a buf and \a buflen are
|
---|
| 1837 | * ignored. \ref canRead() et al will set \ref canMSG_EXT and/or \ref canMSG_STD as usual
|
---|
| 1838 | * and are not affected by this call.
|
---|
| 1839 | */
|
---|
| 1840 | #define canIOCTL_PREFER_STD 2
|
---|
| 1841 | // 3,4 reserved.
|
---|
| 1842 |
|
---|
| 1843 | /**
|
---|
| 1844 | * This define is used in \ref canIoCtl(), \a buf and \a buflen refers to this
|
---|
| 1845 | * functions arguments.
|
---|
| 1846 | *
|
---|
| 1847 | * Tells CANLIB to clear the CAN error counters. The contents of \a buf and \a
|
---|
| 1848 | * buflen are ignored.
|
---|
| 1849 | *
|
---|
| 1850 | * \note Not all CAN controllers support this operation (and if they don't,
|
---|
| 1851 | * nothing will happen.)
|
---|
| 1852 | */
|
---|
| 1853 | #define canIOCTL_CLEAR_ERROR_COUNTERS 5
|
---|
| 1854 |
|
---|
| 1855 | /**
|
---|
| 1856 | * This define is used in \ref canIoCtl(), \a buf mentioned below refers to this
|
---|
| 1857 | * functions argument.
|
---|
| 1858 | *
|
---|
| 1859 | * \a buf points to a DWORD which contains the desired time-stamp clock
|
---|
| 1860 | * resolution in microseconds. The default value is 1000 microseconds, i.e.
|
---|
| 1861 | * one millisecond.
|
---|
| 1862 | *
|
---|
| 1863 | * \note The accuracy of the clock isn't affected.
|
---|
| 1864 | */
|
---|
| 1865 | #define canIOCTL_SET_TIMER_SCALE 6
|
---|
| 1866 |
|
---|
| 1867 | /**
|
---|
| 1868 | * This define is used in \ref canIoCtl(), \a buf mentioned below refers to this
|
---|
| 1869 | * functions argument.
|
---|
| 1870 | *
|
---|
| 1871 | * \a buf points to a DWORD which contains
|
---|
| 1872 | *
|
---|
| 1873 | * \li 0: to turn Transmit Acknowledges off.
|
---|
| 1874 | * \li 1: to turn Transmit Acknowledges on.
|
---|
| 1875 | * \li 2: to turn Transmit Acknowledges off, even for the driver's internal
|
---|
| 1876 | * usage. This might enhance performance but will cause some other APIs to
|
---|
| 1877 | * stop working (for example, the current size of the transmit queue can not
|
---|
| 1878 | * be read when this mode is active.)
|
---|
| 1879 | *
|
---|
| 1880 | * The default value is 0, Transmit Acknowledge is off.
|
---|
| 1881 | */
|
---|
| 1882 | #define canIOCTL_SET_TXACK 7
|
---|
| 1883 |
|
---|
| 1884 | /**
|
---|
| 1885 | * This define is used in \ref canIoCtl(), \a buf mentioned below refers to this
|
---|
| 1886 | * functions argument.
|
---|
| 1887 | *
|
---|
| 1888 | * \a buf points at a \c DWORD which receives the current RX queue level. The
|
---|
| 1889 | * returned value is approximative (this is because not all hardware supports
|
---|
| 1890 | * retrieving the queue levels. In that case a best-effort guess is
|
---|
| 1891 | * returned. Also note that a device with embedded CPU will report its queue
|
---|
| 1892 | * levels to the host computer after a short delay that depends on the bus
|
---|
| 1893 | * traffic intensity, and consequently the value returned by the call to
|
---|
| 1894 | * \ref canIoCtl() might be a few milliseconds old.)
|
---|
| 1895 | */
|
---|
| 1896 | #define canIOCTL_GET_RX_BUFFER_LEVEL 8
|
---|
| 1897 |
|
---|
| 1898 | /**
|
---|
| 1899 | * This define is used in \ref canIoCtl(), \a buf mentioned below refers to this
|
---|
| 1900 | * functions argument.
|
---|
| 1901 | *
|
---|
| 1902 | * \a buf points at a \c DWORD which receives the current TX queue level. The
|
---|
| 1903 | * returned value is approximative (this is because not all hardware supports
|
---|
| 1904 | * retrieving the queue levels. In that case a best-effort guess is
|
---|
| 1905 | * returned. Also note that a device with embedded CPU will report its queue
|
---|
| 1906 | * levels to the host computer after a short delay that depends on the bus
|
---|
| 1907 | * traffic intensity, and consequently the value returned by the call to
|
---|
| 1908 | * \ref canIoCtl() might be a few milliseconds old.)
|
---|
| 1909 | */
|
---|
| 1910 | #define canIOCTL_GET_TX_BUFFER_LEVEL 9
|
---|
| 1911 |
|
---|
| 1912 | /**
|
---|
| 1913 | * This define is used in \ref canIoCtl(), \a buf and \a buflen refers to this
|
---|
| 1914 | * functions arguments.
|
---|
| 1915 | *
|
---|
| 1916 | * Discard the current contents of the RX queue. The values of \a buf and \a
|
---|
| 1917 | * buflen are ignored.
|
---|
| 1918 | *
|
---|
| 1919 | * \note This is the same thing as calling \ref canFlushReceiveQueue()
|
---|
| 1920 | */
|
---|
| 1921 | #define canIOCTL_FLUSH_RX_BUFFER 10
|
---|
| 1922 |
|
---|
| 1923 | /**
|
---|
| 1924 | * This define is used in \ref canIoCtl(), \a buf and \a buflen refers to this
|
---|
| 1925 | * functions arguments.
|
---|
| 1926 | *
|
---|
| 1927 | * Discard the current contents of the TX queue. The values of \a buf and \a
|
---|
| 1928 | * buflen are ignored.
|
---|
| 1929 | *
|
---|
| 1930 | * \note This is the same thing as calling \ref canFlushTransmitQueue().
|
---|
| 1931 | */
|
---|
| 1932 | #define canIOCTL_FLUSH_TX_BUFFER 11
|
---|
| 1933 |
|
---|
| 1934 | /**
|
---|
| 1935 | * This define is used in \ref canIoCtl(), \a buf mentioned below refers to this
|
---|
| 1936 | * functions argument.
|
---|
| 1937 | *
|
---|
| 1938 | * \a buf points to a \c DWORD which contains the desired time-stamp clock
|
---|
| 1939 | * resolution in microseconds. Note that the accuracy of the clock isn't
|
---|
| 1940 | * affected. The default value is 1000 microseconds, i.e. one millisecond.
|
---|
| 1941 | */
|
---|
| 1942 | #define canIOCTL_GET_TIMER_SCALE 12
|
---|
| 1943 |
|
---|
| 1944 | /**
|
---|
| 1945 | * This define is used in \ref canIoCtl(), \a buf mentioned below refers to this
|
---|
| 1946 | * functions argument.
|
---|
| 1947 | *
|
---|
| 1948 | * \a buf points to a \c DWORD which contains
|
---|
| 1949 | *
|
---|
| 1950 | * \li \c 0 to turn Transmit Requests off.
|
---|
| 1951 | * \li \c 1 to turn Transmit Requests on.
|
---|
| 1952 | *
|
---|
| 1953 | * Default value is \c 0, Transmit Requests off.
|
---|
| 1954 | */
|
---|
| 1955 | #define canIOCTL_SET_TXRQ 13
|
---|
| 1956 |
|
---|
| 1957 | /**
|
---|
| 1958 | * This define is used in \ref canIoCtl(), \a buf mentioned below refers to this
|
---|
| 1959 | * functions argument.
|
---|
| 1960 | *
|
---|
| 1961 | * \a buf points at a \c DWORD which receives a Windows Event handle which can
|
---|
| 1962 | * be passed to the Win32 API \c WaitForSingleObject. The event is signaled
|
---|
| 1963 | * when "something" (typically that a CAN message has been received or
|
---|
| 1964 | * transmitted) happens in the driver.
|
---|
| 1965 | *
|
---|
| 1966 | * \note There is no more information available as to what happened when this
|
---|
| 1967 | * call returns. The call may return on an "internal" event in CANLIB and your
|
---|
| 1968 | * application must be prepared to handle this (i.e. go to sleep again.)
|
---|
| 1969 | * \note If \ref canWaitForEvent() returns with success status (\ref canOK), you must call
|
---|
| 1970 | * \ref canRead() repeatedly until it returns \ref canERR_NOMSG, before calling
|
---|
| 1971 | * \ref canWaitForEvent() again. This will flush the driver's internal event queues.
|
---|
| 1972 | * Failure to call \ref canRead() can cause \ref canWaitForEvent() to get stuck in a state
|
---|
| 1973 | * where it always sleeps for the specified timeout and then returns with
|
---|
| 1974 | * \ref canERR_TIMEOUT.
|
---|
| 1975 | *
|
---|
| 1976 | * \sa \ref canWaitForEvent()
|
---|
| 1977 | *
|
---|
| 1978 | * \note You must not set, reset, nor close this handle. Waiting on it is
|
---|
| 1979 | * the only supported operation.
|
---|
| 1980 | */
|
---|
| 1981 | #define canIOCTL_GET_EVENTHANDLE 14
|
---|
| 1982 |
|
---|
| 1983 | /**
|
---|
| 1984 | * This define is used in \ref canIoCtl(), \a buf mentioned below refers to this
|
---|
| 1985 | * functions argument.
|
---|
| 1986 | *
|
---|
| 1987 | * \note Not yet implemented.
|
---|
| 1988 | */
|
---|
| 1989 | #define canIOCTL_SET_BYPASS_MODE 15
|
---|
| 1990 |
|
---|
| 1991 | /**
|
---|
| 1992 | * This define is used in \ref canIoCtl().
|
---|
| 1993 | *
|
---|
| 1994 | * This is only intended for internal use.
|
---|
| 1995 | */
|
---|
| 1996 | #define canIOCTL_SET_WAKEUP 16
|
---|
| 1997 |
|
---|
| 1998 | #if defined(CANLIB_DECLARE_ALL)
|
---|
| 1999 |
|
---|
| 2000 | /**
|
---|
| 2001 | * This define is used in \ref canIoCtl(), \a buf mentioned below refers to this
|
---|
| 2002 | * functions argument.
|
---|
| 2003 | *
|
---|
| 2004 | * \a buf points to a HANDLE which receives the Windows handle related to the
|
---|
| 2005 | * CANLIB handle.
|
---|
| 2006 | */
|
---|
| 2007 | # define canIOCTL_GET_DRIVERHANDLE 17
|
---|
| 2008 |
|
---|
| 2009 | /**
|
---|
| 2010 | * This define is used in \ref canIoCtl().
|
---|
| 2011 | *
|
---|
| 2012 | * This is only intended for internal use.
|
---|
| 2013 | */
|
---|
| 2014 | # define canIOCTL_MAP_RXQUEUE 18
|
---|
| 2015 |
|
---|
| 2016 | /**
|
---|
| 2017 | * This define is used in \ref canIoCtl().
|
---|
| 2018 | *
|
---|
| 2019 | * This is only intended for internal use.
|
---|
| 2020 | */
|
---|
| 2021 | # define canIOCTL_GET_WAKEUP 19
|
---|
| 2022 |
|
---|
| 2023 | /**
|
---|
| 2024 | * This define is used in \ref canIoCtl(), \a buf mentioned below refers to this
|
---|
| 2025 | * functions argument.
|
---|
| 2026 | *
|
---|
| 2027 | * \a buf points to a BYTE which contains
|
---|
| 2028 | *
|
---|
| 2029 | * \li \c 0 to turn access error reporting off, and
|
---|
| 2030 | * \li \c 1 to turn access error reporting on.
|
---|
| 2031 | *
|
---|
| 2032 | * Default value is \c 0, access error reporting off.
|
---|
| 2033 | */
|
---|
| 2034 | # define canIOCTL_SET_REPORT_ACCESS_ERRORS 20
|
---|
| 2035 |
|
---|
| 2036 | /**
|
---|
| 2037 | * This define is used in \ref canIoCtl(), \a buf mentioned below refers to this
|
---|
| 2038 | * functions argument.
|
---|
| 2039 | *
|
---|
| 2040 | * \a buf points to a BYTE which receives the current setting of the access
|
---|
| 2041 | * error reporting (0 or 1.)
|
---|
| 2042 | */
|
---|
| 2043 | # define canIOCTL_GET_REPORT_ACCESS_ERRORS 21
|
---|
| 2044 |
|
---|
| 2045 | /**
|
---|
| 2046 | * This define is used in \ref canIoCtl(), \a buf mentioned below refers to this
|
---|
| 2047 | * functions argument.
|
---|
| 2048 | *
|
---|
| 2049 | * Connects the handle to the virtual bus number (0..31) which the \a buf
|
---|
| 2050 | * points to.
|
---|
| 2051 | */
|
---|
| 2052 | # define canIOCTL_CONNECT_TO_VIRTUAL_BUS 22
|
---|
| 2053 |
|
---|
| 2054 | /**
|
---|
| 2055 | * This define is used in \ref canIoCtl(), \a buf mentioned below refers to this
|
---|
| 2056 | * functions argument.
|
---|
| 2057 | *
|
---|
| 2058 | * Disonnects the handle from the virtual bus number (0..31) which the \a buf
|
---|
| 2059 | * points to.
|
---|
| 2060 | */
|
---|
| 2061 | # define canIOCTL_DISCONNECT_FROM_VIRTUAL_BUS 23
|
---|
| 2062 |
|
---|
| 2063 | /**
|
---|
| 2064 | * This define is used in \ref canIoCtl(), \a buf mentioned below refers to this
|
---|
| 2065 | * functions argument.
|
---|
| 2066 | *
|
---|
| 2067 | * \a buf points to a \ref canUserIoPortData struct that contains a port number
|
---|
| 2068 | * and a port value to set. This is used by special hardware only.
|
---|
| 2069 | */
|
---|
| 2070 | # define canIOCTL_SET_USER_IOPORT 24
|
---|
| 2071 |
|
---|
| 2072 | /**
|
---|
| 2073 | * This define is used in \ref canIoCtl(), \a buf mentioned below refers to this
|
---|
| 2074 | * functions argument.
|
---|
| 2075 | *
|
---|
| 2076 | * \a buf points to a \ref canUserIoPortData struct that contains a port
|
---|
| 2077 | * number. After the call, the struct will contain the current value of the
|
---|
| 2078 | * I/O port. This is used by special hardware only.
|
---|
| 2079 | */
|
---|
| 2080 | # define canIOCTL_GET_USER_IOPORT 25
|
---|
| 2081 |
|
---|
| 2082 | /**
|
---|
| 2083 | * This define is used in \ref canIoCtl().
|
---|
| 2084 | *
|
---|
| 2085 | * This is only intended for internal use.
|
---|
| 2086 | */
|
---|
| 2087 | # define canIOCTL_SET_BUFFER_WRAPAROUND_MODE 26
|
---|
| 2088 |
|
---|
| 2089 | /**
|
---|
| 2090 | * This define is used in \ref canIoCtl(), \a buf mentioned below refers to this
|
---|
| 2091 | * functions argument.
|
---|
| 2092 | *
|
---|
| 2093 | * Use this function code to set the size of the receive buffer for a
|
---|
| 2094 | * specific handle. \a buf points to an unsigned integer which contains the
|
---|
| 2095 | * new size (number of messages) of the receive buffer.
|
---|
| 2096 | *
|
---|
| 2097 | * \note The receive buffer consumes system nonpaged pool memory, which is a
|
---|
| 2098 | * limited resource. Do not increase the receive buffer size unless you
|
---|
| 2099 | * have good reasons to do so.
|
---|
| 2100 | *
|
---|
| 2101 | * \note You can't use this function code when the channel is on bus.
|
---|
| 2102 | */
|
---|
| 2103 | # define canIOCTL_SET_RX_QUEUE_SIZE 27
|
---|
| 2104 |
|
---|
| 2105 | /**
|
---|
| 2106 | * This define is used in \ref canIoCtl().
|
---|
| 2107 | *
|
---|
| 2108 | * This is only intended for internal use.
|
---|
| 2109 | */
|
---|
| 2110 | # define canIOCTL_SET_USB_THROTTLE 28
|
---|
| 2111 |
|
---|
| 2112 | /**
|
---|
| 2113 | * This define is used in \ref canIoCtl().
|
---|
| 2114 | *
|
---|
| 2115 | * This is only intended for internal use.
|
---|
| 2116 | */
|
---|
| 2117 | # define canIOCTL_GET_USB_THROTTLE 29
|
---|
| 2118 |
|
---|
| 2119 | /**
|
---|
| 2120 | * This define is used in \ref canIoCtl(), \a buf mentioned below refers to this
|
---|
| 2121 | * functions argument.
|
---|
| 2122 | *
|
---|
| 2123 | * \a buf points to a DWORD. If the value is zero, the CAN clock will not be
|
---|
| 2124 | * reset at buson for the handle. Otherwise, the CAN clock will be reset at
|
---|
| 2125 | * buson.
|
---|
| 2126 | *
|
---|
| 2127 | * Default value is \c 1, the CAN clock will be reset at buson.
|
---|
| 2128 | */
|
---|
| 2129 | # define canIOCTL_SET_BUSON_TIME_AUTO_RESET 30
|
---|
| 2130 |
|
---|
| 2131 | /**
|
---|
| 2132 | * This define is used in \ref canIoCtl(), \a buf mentioned below refers to this
|
---|
| 2133 | * functions argument.
|
---|
| 2134 | *
|
---|
| 2135 | * Returns the state of the Transmit Acknowledge as a DWORD in \a buf:
|
---|
| 2136 | *
|
---|
| 2137 | * \li 0: Transmit Acknowledges is turned off.
|
---|
| 2138 | * \li 1: Transmit Acknowledges is turned on.
|
---|
| 2139 | * \li 2: Transmit Acknowledges is turned off, even for the driver's internal
|
---|
| 2140 | * usage.
|
---|
| 2141 | */
|
---|
| 2142 | # define canIOCTL_GET_TXACK 31
|
---|
| 2143 |
|
---|
| 2144 | /**
|
---|
| 2145 | * This define is used in \ref canIoCtl(), \a buf mentioned below refers to this
|
---|
| 2146 | * functions argument.
|
---|
| 2147 | *
|
---|
| 2148 | * \a buf points to an unsigned byte. If the value is zero, the local transmit
|
---|
| 2149 | * echo is turned off for the handle. Otherwise, local transmit echo is turned
|
---|
| 2150 | * on.
|
---|
| 2151 | *
|
---|
| 2152 | * Local transmit echo is turned on by default on all handles. This means
|
---|
| 2153 | * that if two handles are open on the same channel, and a message is
|
---|
| 2154 | * transmitted on the first handle, it will be received as a normal message
|
---|
| 2155 | * on the second handle. Use the \ref canIOCTL_SET_LOCAL_TXECHO function code to
|
---|
| 2156 | * turn this function off, if it is not desired on a certain handle.
|
---|
| 2157 | */
|
---|
| 2158 | # define canIOCTL_SET_LOCAL_TXECHO 32
|
---|
| 2159 |
|
---|
| 2160 | #endif
|
---|
| 2161 | /** @} */
|
---|
| 2162 |
|
---|
| 2163 | #if defined(CANLIB_DECLARE_ALL)
|
---|
| 2164 | /** Used in \ref canIOCTL_SET_USER_IOPORT and \ref canIOCTL_GET_USER_IOPORT. */
|
---|
| 2165 | typedef struct {
|
---|
| 2166 | unsigned int portNo; ///< Port number used in e.g. \ref canIOCTL_SET_USER_IOPORT
|
---|
| 2167 | unsigned int portValue; ///< Port value used in e.g. \ref canIOCTL_SET_USER_IOPORT
|
---|
| 2168 | } canUserIoPortData;
|
---|
| 2169 |
|
---|
| 2170 | #endif
|
---|
| 2171 |
|
---|
| 2172 | #if defined(CANLIB_DECLARE_ALL)
|
---|
| 2173 | #endif
|
---|
| 2174 |
|
---|
| 2175 | /**
|
---|
| 2176 | * \ingroup CAN
|
---|
| 2177 | *
|
---|
| 2178 | * \source_cs <b>static Canlib.canStatus canSetBusParamsC200(int hnd, byte btr0, byte btr1);</b>
|
---|
| 2179 | *
|
---|
| 2180 | * \source_delphi <b>function canSetBusParamsC200(hnd: canHandle; btr0, btr1: byte): canStatus; </b>
|
---|
| 2181 | * \source_end
|
---|
| 2182 | *
|
---|
| 2183 | * This function sets the bus timing parameters using the same
|
---|
| 2184 | * convention as the 82c200 CAN controller (which is the same as many
|
---|
| 2185 | * other CAN controllers, for example, the 82527.)
|
---|
| 2186 | *
|
---|
| 2187 | * To calculate the bit timing parameters, you can use the bit timing
|
---|
| 2188 | * calculator that is included with CANLIB SDK. Look in the BIN directory.
|
---|
| 2189 | *
|
---|
| 2190 | * 82c200 Bit Timing
|
---|
| 2191 | *
|
---|
| 2192 | * \li \a btr0 [b7..b6]: SJW - 1
|
---|
| 2193 | * \li \a btr0 [b5..b0]: Prescaler -1
|
---|
| 2194 | * \li \a btr1 [b7]: \c 1: 3 samples, \c 0: 1 samples
|
---|
| 2195 | * \li \a btr1 [b6..b4]: tseg2 - 1
|
---|
| 2196 | * \li \a btr1 [b3..b0]: tseg1 - 2
|
---|
| 2197 | *
|
---|
| 2198 | * \note CANLIB will always behave as if the clock frequency is 16 MHz. It does
|
---|
| 2199 | * not matter if the device has a different physical clock, since this will be
|
---|
| 2200 | * compensated for by the driver.
|
---|
| 2201 | *
|
---|
| 2202 | * \param[in] hnd A handle to an open CAN circuit.
|
---|
| 2203 | * \param[in] btr0 The desired bit timing, formatted as the contents of the
|
---|
| 2204 | * BTR0 register in the 82c200.
|
---|
| 2205 | * \param[in] btr1 The desired bit timing, formatted as the contents of the
|
---|
| 2206 | * BTR1 register in the 82c200.
|
---|
| 2207 | *
|
---|
| 2208 | * \return \ref canOK (zero) if success
|
---|
| 2209 | * \return \ref canERR_xxx (negative) if failure
|
---|
| 2210 | *
|
---|
| 2211 | *
|
---|
| 2212 | * \sa \ref page_code_snippets_bit_rate, \ref page_user_guide_misc_bitrate
|
---|
| 2213 | * \sa \ref canSetBusParams()
|
---|
| 2214 | */
|
---|
| 2215 | canStatus CANLIBAPI canSetBusParamsC200 (const CanHandle hnd, BYTE btr0, BYTE btr1);
|
---|
| 2216 |
|
---|
| 2217 | #if defined(CANLIB_DECLARE_ALL)
|
---|
| 2218 | #endif
|
---|
| 2219 |
|
---|
| 2220 |
|
---|
| 2221 | #if defined(CANLIB_DECLARE_ALL)
|
---|
| 2222 | /**
|
---|
| 2223 | * \ingroup ObjectBuffers
|
---|
| 2224 | *
|
---|
| 2225 | * \source_cs <b>static Canlib.canStatus canObjBufFreeAll(int handle);</b>
|
---|
| 2226 | *
|
---|
| 2227 | * \source_delphi <b>function canObjBufFreeAll(handle: canHandle): canStatus; </b>
|
---|
| 2228 | * \source_end
|
---|
| 2229 | *
|
---|
| 2230 | * Deallocates all object buffers on the specified handle. The
|
---|
| 2231 | * buffers cannot be referenced after this operation.
|
---|
| 2232 | *
|
---|
| 2233 | * \param[in] hnd An open handle to a CAN circuit.
|
---|
| 2234 | *
|
---|
| 2235 | * \return \ref canOK (zero) if success
|
---|
| 2236 | * \return \ref canERR_xxx (negative) if failure
|
---|
| 2237 | *
|
---|
| 2238 | * \sa \ref page_user_guide_send_recv_obj_buf
|
---|
| 2239 | * \sa \ref canObjBufFree(), \ref canObjBufAllocate()
|
---|
| 2240 | */
|
---|
| 2241 | canStatus CANLIBAPI canObjBufFreeAll (const CanHandle hnd);
|
---|
| 2242 |
|
---|
| 2243 | /**
|
---|
| 2244 | * \ingroup ObjectBuffers
|
---|
| 2245 | *
|
---|
| 2246 | * \source_cs <b>static Canlib.canStatus canObjBufAllocate(int handle, int type);</b>
|
---|
| 2247 | *
|
---|
| 2248 | * \source_delphi <b>function canObjBufAllocate(handle: canHandle; tp: Integer): canStatus; </b>
|
---|
| 2249 | * \source_end
|
---|
| 2250 | *
|
---|
| 2251 | * Allocates an object buffer associated with a handle to a CAN
|
---|
| 2252 | * circuit.
|
---|
| 2253 | *
|
---|
| 2254 | * \param[in] hnd An open handle to a CAN circuit.
|
---|
| 2255 | * \param[in] type The type of the buffer. Must be one of \ref canOBJBUF_TYPE_xxx
|
---|
| 2256 | *
|
---|
| 2257 | * \return A buffer index (zero or positive) if success.
|
---|
| 2258 | * \return \ref canERR_xxx (negative) if failure
|
---|
| 2259 | *
|
---|
| 2260 | * \sa \ref page_user_guide_send_recv_obj_buf
|
---|
| 2261 | * \sa \ref canObjBufFree(), \ref canObjBufFreeAll()
|
---|
| 2262 | */
|
---|
| 2263 | canStatus CANLIBAPI canObjBufAllocate (const CanHandle hnd, int type);
|
---|
| 2264 |
|
---|
| 2265 | /**
|
---|
| 2266 | * \name canOBJBUF_TYPE_xxx
|
---|
| 2267 | * \anchor canOBJBUF_TYPE_xxx
|
---|
| 2268 | *
|
---|
| 2269 | * Used in \ref canObjBufAllocate().
|
---|
| 2270 | *
|
---|
| 2271 | * @{
|
---|
| 2272 | */
|
---|
| 2273 | #define canOBJBUF_TYPE_AUTO_RESPONSE 0x01 ///< The buffer is an auto-response buffer.
|
---|
| 2274 | #define canOBJBUF_TYPE_PERIODIC_TX 0x02 ///< The buffer is an auto-transmit buffer.
|
---|
| 2275 | /** @} */
|
---|
| 2276 |
|
---|
| 2277 | /**
|
---|
| 2278 | * \ingroup ObjectBuffers
|
---|
| 2279 | *
|
---|
| 2280 | * \source_cs <b>static Canlib.canStatus canObjBufFree(int handle, int idx);</b>
|
---|
| 2281 | *
|
---|
| 2282 | * \source_delphi <b>function canObjBufFree(handle: canHandle; idx: Integer): canStatus; </b>
|
---|
| 2283 | * \source_end
|
---|
| 2284 | *
|
---|
| 2285 | * Deallocates the object buffer with the specified index. The buffer
|
---|
| 2286 | * can not be referenced after this operation.
|
---|
| 2287 | *
|
---|
| 2288 | * \param[in] hnd An open handle to a CAN circuit.
|
---|
| 2289 | * \param[in] idx The object buffer to deallocate.
|
---|
| 2290 | *
|
---|
| 2291 | * \return \ref canOK (zero) if success
|
---|
| 2292 | * \return \ref canERR_xxx (negative) if failure
|
---|
| 2293 | *
|
---|
| 2294 | * \sa \ref page_user_guide_send_recv_obj_buf
|
---|
| 2295 | * \sa \ref canObjBufFreeAll(), \ref canObjBufAllocate(),
|
---|
| 2296 | */
|
---|
| 2297 | canStatus CANLIBAPI canObjBufFree (const CanHandle hnd, int idx);
|
---|
| 2298 |
|
---|
| 2299 | // Writes CAN data to the object buffer with the specified index.
|
---|
| 2300 |
|
---|
| 2301 | /**
|
---|
| 2302 | * \ingroup ObjectBuffers
|
---|
| 2303 | *
|
---|
| 2304 | * \source_cs <b>static Canlib.canStatus canObjBufWrite(int handle, int idx, int id, byte[] msg, int dlc, int flags);</b>
|
---|
| 2305 | *
|
---|
| 2306 | * \source_delphi <b>function canObjBufWrite(handle: canHandle; idx, id: Integer; var msg; dlc, flags: cardinal): canStatus; </b>
|
---|
| 2307 | * \source_end
|
---|
| 2308 | *
|
---|
| 2309 | * Defines the contents of a specific object buffer.
|
---|
| 2310 | *
|
---|
| 2311 | * \param[in] hnd An open handle to a CAN circuit.
|
---|
| 2312 | * \param[in] idx The index of the object buffer whose contents is to be
|
---|
| 2313 | * defined.
|
---|
| 2314 | * \param[in] id The CAN identifier of the message.
|
---|
| 2315 | * \param[in] msg Points to the contents of the message.
|
---|
| 2316 | * \param[in] dlc The length of the message. Must be at least 0 and at most 8
|
---|
| 2317 | * bytes.
|
---|
| 2318 | * \param[in] flags Message flags; a combination of the \ref canMSG_xxx flags.
|
---|
| 2319 | *
|
---|
| 2320 | * \return \ref canOK (zero) if success
|
---|
| 2321 | * \return \ref canERR_xxx (negative) if failure
|
---|
| 2322 | *
|
---|
| 2323 | * \sa \ref page_user_guide_send_recv_obj_buf
|
---|
| 2324 | */
|
---|
| 2325 | canStatus CANLIBAPI canObjBufWrite (const CanHandle hnd,
|
---|
| 2326 | int idx,
|
---|
| 2327 | int id,
|
---|
| 2328 | void* msg,
|
---|
| 2329 | unsigned int dlc,
|
---|
| 2330 | unsigned int flags);
|
---|
| 2331 |
|
---|
| 2332 | /**
|
---|
| 2333 | * \ingroup ObjectBuffers
|
---|
| 2334 | *
|
---|
| 2335 | * \source_cs <b>static Canlib.canStatus canObjBufSetFilter(int handle, int idx, int code, int mask);</b>
|
---|
| 2336 | *
|
---|
| 2337 | * \source_delphi <b>function canObjBufSetFilter(handle: canHandle; idx: Integer; code, mask: Cardinal): canStatus; </b>
|
---|
| 2338 | * \source_end
|
---|
| 2339 | *
|
---|
| 2340 | * Defines a message reception filter on the specified object buffer.
|
---|
| 2341 | * Messages not matching the filter are discarded.
|
---|
| 2342 | *
|
---|
| 2343 | * \note For an auto response buffer, set the code and mask that together define
|
---|
| 2344 | * the identifier(s) that trigger(s) the automatic response.
|
---|
| 2345 | *
|
---|
| 2346 | * \param[in] hnd An open handle to a CAN circuit.
|
---|
| 2347 | * \param[in] idx The index of the object buffer on which the filter is to be
|
---|
| 2348 | * set.
|
---|
| 2349 | * \param[in] code The acceptance code in the filter.
|
---|
| 2350 | * \param[in] mask The acceptance mask in the filter.
|
---|
| 2351 | *
|
---|
| 2352 | * \return \ref canOK (zero) if success
|
---|
| 2353 | * \return \ref canERR_xxx (negative) if failure
|
---|
| 2354 | *
|
---|
| 2355 | * \sa \ref page_user_guide_misc_code_and_mask,
|
---|
| 2356 | * \ref page_user_guide_send_recv_obj_buf
|
---|
| 2357 | */
|
---|
| 2358 | canStatus CANLIBAPI canObjBufSetFilter (const CanHandle hnd,
|
---|
| 2359 | int idx,
|
---|
| 2360 | unsigned int code,
|
---|
| 2361 | unsigned int mask);
|
---|
| 2362 |
|
---|
| 2363 | /**
|
---|
| 2364 | * \ingroup ObjectBuffers
|
---|
| 2365 | *
|
---|
| 2366 | * \source_cs <b>static Canlib.canStatus canObjBufSetFlags(int handle, int idx, int flags);</b>
|
---|
| 2367 | *
|
---|
| 2368 | * \source_delphi <b>function canObjBufSetFlags(handle: canHandle; idx: Integer; flags: Cardinal): canStatus; </b>
|
---|
| 2369 | * \source_end
|
---|
| 2370 | *
|
---|
| 2371 | * Sets object buffer flags on a specified object buffer.
|
---|
| 2372 | *
|
---|
| 2373 | * \param[in] hnd An open handle to a CAN circuit.
|
---|
| 2374 | * \param[in] idx The buffer on which the flags are to be set.
|
---|
| 2375 | * \param[in] flags Specifies a combination of zero or more of the
|
---|
| 2376 | * \ref canOBJBUF_AUTO_RESPONSE_xxx flag values
|
---|
| 2377 | *
|
---|
| 2378 | * \return \ref canOK (zero) if success
|
---|
| 2379 | * \return \ref canERR_xxx (negative) if failure
|
---|
| 2380 | *
|
---|
| 2381 | * \sa \ref page_user_guide_send_recv_obj_buf
|
---|
| 2382 | */
|
---|
| 2383 | canStatus CANLIBAPI canObjBufSetFlags (const CanHandle hnd,
|
---|
| 2384 | int idx,
|
---|
| 2385 | unsigned int flags);
|
---|
| 2386 |
|
---|
| 2387 | /**
|
---|
| 2388 | * \name canOBJBUF_AUTO_RESPONSE_xxx
|
---|
| 2389 | * \anchor canOBJBUF_AUTO_RESPONSE_xxx
|
---|
| 2390 | *
|
---|
| 2391 | * These defines are used in \ref canObjBufSetFlags().
|
---|
| 2392 | *
|
---|
| 2393 | * @{
|
---|
| 2394 | */
|
---|
| 2395 | /**
|
---|
| 2396 | * This define is used in \ref canObjBufSetFlags().
|
---|
| 2397 | *
|
---|
| 2398 | * For auto-response buffers only. When this flag is in effect, the buffer
|
---|
| 2399 | * will auto-respond to remote requests only. If this flag is not in effect,
|
---|
| 2400 | * the buffer will auto-respond to both remote requests and ordinary data
|
---|
| 2401 | * frames.
|
---|
| 2402 | *
|
---|
| 2403 | */
|
---|
| 2404 | # define canOBJBUF_AUTO_RESPONSE_RTR_ONLY 0x01
|
---|
| 2405 | /** @} */
|
---|
| 2406 |
|
---|
| 2407 | /**
|
---|
| 2408 | * \ingroup ObjectBuffers
|
---|
| 2409 | *
|
---|
| 2410 | * \source_cs <b>static Canlib.canStatus canObjBufSetPeriod(int hnd, int idx, int period);</b>
|
---|
| 2411 | *
|
---|
| 2412 | * \source_delphi <b>function canObjBufSetPeriod(handle: canHandle; idx: Integer; period: Cardinal): canStatus; </b>
|
---|
| 2413 | * \source_end
|
---|
| 2414 | *
|
---|
| 2415 | * The \ref canObjBufSetPeriod function sets the transmission period for an auto
|
---|
| 2416 | * transmission object buffer.
|
---|
| 2417 | *
|
---|
| 2418 | * \param[in] hnd An open handle to a CAN channel.
|
---|
| 2419 | * \param[in] idx The index of a CAN object buffer.
|
---|
| 2420 | * \param[in] period The transmission interval, in microseconds.
|
---|
| 2421 | *
|
---|
| 2422 | * \return \ref canOK (zero) if success
|
---|
| 2423 | * \return \ref canERR_xxx (negative) if failure
|
---|
| 2424 | *
|
---|
| 2425 | * \sa \ref page_user_guide_send_recv_obj_buf
|
---|
| 2426 | */
|
---|
| 2427 | canStatus CANLIBAPI canObjBufSetPeriod (const CanHandle hnd,
|
---|
| 2428 | int idx,
|
---|
| 2429 | unsigned int period);
|
---|
| 2430 |
|
---|
| 2431 | /**
|
---|
| 2432 | * \ingroup ObjectBuffers
|
---|
| 2433 | *
|
---|
| 2434 | * \source_cs <b>static Canlib.canStatus canObjBufSetMsgCount(int hnd, int idx, int count);</b>
|
---|
| 2435 | *
|
---|
| 2436 | * \source_delphi <b>function canObjBufSetMsgCount(handle: canHandle; idx: Integer; count: Cardinal): canStatus; </b>
|
---|
| 2437 | * \source_end
|
---|
| 2438 | *
|
---|
| 2439 | * The \ref canObjBufSetMsgCount function sets the message count for an auto
|
---|
| 2440 | * transmit object buffer.
|
---|
| 2441 | *
|
---|
| 2442 | * \param[in] hnd An open handle to a CAN channel.
|
---|
| 2443 | * \param[in] idx The index of a CAN object buffer.
|
---|
| 2444 | * \param[in] count The message count.
|
---|
| 2445 | *
|
---|
| 2446 | * \return \ref canOK (zero) if success
|
---|
| 2447 | * \return \ref canERR_xxx (negative) if failure
|
---|
| 2448 | *
|
---|
| 2449 | * \sa \ref page_user_guide_send_recv_obj_buf
|
---|
| 2450 | */
|
---|
| 2451 | canStatus CANLIBAPI canObjBufSetMsgCount (const CanHandle hnd,
|
---|
| 2452 | int idx,
|
---|
| 2453 | unsigned int count);
|
---|
| 2454 |
|
---|
| 2455 | /**
|
---|
| 2456 | * \ingroup ObjectBuffers
|
---|
| 2457 | *
|
---|
| 2458 | * \source_cs <b>static Canlib.canStatus canObjBufEnable(int handle, int idx);</b>
|
---|
| 2459 | *
|
---|
| 2460 | * \source_delphi <b>function canObjBufEnable(handle: canHandle; idx: Integer): canStatus; </b>
|
---|
| 2461 | * \source_end
|
---|
| 2462 | *
|
---|
| 2463 | * Enables the object buffer with the specified index.
|
---|
| 2464 | *
|
---|
| 2465 | * \param[in] hnd An open handle to a CAN circuit.
|
---|
| 2466 | * \param[in] idx The index of the object buffer to enable.
|
---|
| 2467 | *
|
---|
| 2468 | * \return \ref canOK (zero) if success
|
---|
| 2469 | * \return \ref canERR_xxx (negative) if failure
|
---|
| 2470 | *
|
---|
| 2471 | * \sa \ref page_user_guide_send_recv_obj_buf
|
---|
| 2472 | * \sa \ref canObjBufDisable()
|
---|
| 2473 | */
|
---|
| 2474 | canStatus CANLIBAPI canObjBufEnable (const CanHandle hnd, int idx);
|
---|
| 2475 |
|
---|
| 2476 | /**
|
---|
| 2477 | * \ingroup ObjectBuffers
|
---|
| 2478 | *
|
---|
| 2479 | * \source_cs <b>static Canlib.canStatus canObjBufDisable(int handle, int idx);</b>
|
---|
| 2480 | *
|
---|
| 2481 | * \source_delphi <b>function canObjBufDisable(handle: canHandle; idx: Integer): canStatus; </b>
|
---|
| 2482 | * \source_end
|
---|
| 2483 | *
|
---|
| 2484 | * Disables the object buffer with the specified index.
|
---|
| 2485 | *
|
---|
| 2486 | * \param[in] hnd An open handle to a CAN circuit.
|
---|
| 2487 | * \param[in] idx The index of the buffer.
|
---|
| 2488 | *
|
---|
| 2489 | * \return \ref canOK (zero) if success
|
---|
| 2490 | * \return \ref canERR_xxx (negative) if failure
|
---|
| 2491 | *
|
---|
| 2492 | * \sa \ref page_user_guide_send_recv_obj_buf
|
---|
| 2493 | * \sa \ref canObjBufEnable()
|
---|
| 2494 | */
|
---|
| 2495 | canStatus CANLIBAPI canObjBufDisable (const CanHandle hnd, int idx);
|
---|
| 2496 |
|
---|
| 2497 | /**
|
---|
| 2498 | * \ingroup ObjectBuffers
|
---|
| 2499 | *
|
---|
| 2500 | * \source_cs <b>static Canlib.canStatus canObjBufSendBurst(int hnd, int idx, int burstlen);</b>
|
---|
| 2501 | *
|
---|
| 2502 | * \source_delphi <b>function canObjBufSendBurst(handle: canHandle; idx: Integer; burstLen: Cardinal): canStatus; </b>
|
---|
| 2503 | * \source_end
|
---|
| 2504 | *
|
---|
| 2505 | * The canObjBufSendBurst function sends a burst of CAN messages. You have to
|
---|
| 2506 | * set up an object buffer first with the message to send. The messages will be
|
---|
| 2507 | * sent as fast as possible from the hardware.
|
---|
| 2508 | *
|
---|
| 2509 | * This function is inteneded for certain diagnostic applications.
|
---|
| 2510 | *
|
---|
| 2511 | * \param[in] hnd An open handle to a CAN channel.
|
---|
| 2512 | * \param[in] idx The index of a CAN object buffer.
|
---|
| 2513 | * \param[in] burstlen The number of messages to send.
|
---|
| 2514 | *
|
---|
| 2515 | * \return \ref canOK (zero) if success
|
---|
| 2516 | * \return \ref canERR_xxx (negative) if failure
|
---|
| 2517 | *
|
---|
| 2518 | * \sa \ref page_user_guide_send_recv_obj_buf
|
---|
| 2519 | */
|
---|
| 2520 | canStatus CANLIBAPI canObjBufSendBurst (const CanHandle hnd,
|
---|
| 2521 | int idx,
|
---|
| 2522 | unsigned int burstlen);
|
---|
| 2523 |
|
---|
| 2524 | #endif
|
---|
| 2525 |
|
---|
| 2526 | /**
|
---|
| 2527 | * \ingroup CAN
|
---|
| 2528 | *
|
---|
| 2529 | * \source_cs <b>static Canlib.canStatus canResetBus(int handle);</b>
|
---|
| 2530 | *
|
---|
| 2531 | * \source_delphi <b>function canResetBus(handle: canHandle): canStatus; </b>
|
---|
| 2532 | * \source_end
|
---|
| 2533 | *
|
---|
| 2534 | * This function tries to reset a CAN bus controller by taking the channel off
|
---|
| 2535 | * bus and then on bus again (if it was on bus before the call to \ref canResetBus().)
|
---|
| 2536 | *
|
---|
| 2537 | * This function will affect the hardware (and cause a real reset of the CAN
|
---|
| 2538 | * chip) only if \a hnd is the only handle open on the channel. If there
|
---|
| 2539 | * are other open handles, this operation will not affect the hardware.
|
---|
| 2540 | *
|
---|
| 2541 | * \param[in] hnd A handle to an open circuit.
|
---|
| 2542 | *
|
---|
| 2543 | * \return \ref canOK (zero) if success
|
---|
| 2544 | * \return \ref canERR_xxx (negative) if failure
|
---|
| 2545 | *
|
---|
| 2546 | * \sa \ref canBusOn(), \ref canBusOff()
|
---|
| 2547 | */
|
---|
| 2548 | canStatus CANLIBAPI canResetBus (const CanHandle hnd);
|
---|
| 2549 |
|
---|
| 2550 | /**
|
---|
| 2551 | * \ingroup CAN
|
---|
| 2552 | *
|
---|
| 2553 | * \source_cs <b>static Canlib.canStatus canWriteWait(int handle, int id, byte[] msg, int dlc, int flag, long timeout);</b>
|
---|
| 2554 | *
|
---|
| 2555 | * \source_delphi <b>function canWriteWait(handle: canHandle; id: longint; var msg; dlc, flag, timeout : Cardinal): canStatus; </b>
|
---|
| 2556 | * \source_end
|
---|
| 2557 | *
|
---|
| 2558 | * This function sends a CAN message. It returns when the message is sent, or
|
---|
| 2559 | * the timeout expires.
|
---|
| 2560 | *
|
---|
| 2561 | * This is a convenience function that combines \ref canWrite() and \ref canWriteSync().
|
---|
| 2562 | *
|
---|
| 2563 | * If you are using the same channel via multiple handles, note that the
|
---|
| 2564 | * default behaviour is that the different handles will "hear" each other just as
|
---|
| 2565 | * if each handle referred to a channel of its own. If you open, say, channel 0
|
---|
| 2566 | * from thread A and thread B and then send a message from thread A, it will be
|
---|
| 2567 | * "received" by thread B.
|
---|
| 2568 | * This behaviour can be changed using \ref canIOCTL_SET_LOCAL_TXECHO.
|
---|
| 2569 | *
|
---|
| 2570 | * \param[in] hnd A handle to an open CAN circuit.
|
---|
| 2571 | * \param[in] id The identifier of the CAN message to send.
|
---|
| 2572 | * \param[in] msg A pointer to the message data, or \c NULL.
|
---|
| 2573 | * \param[in] dlc The length of the message. Can be at most 8.
|
---|
| 2574 | * \param[in] flag A combination of message flags, \ref canMSG_xxx.
|
---|
| 2575 | * Use this parameter to send extended (29-bit) frames
|
---|
| 2576 | * and/or remote frames. Use \ref canMSG_EXT and/or
|
---|
| 2577 | * \ref canMSG_RTR for this purpose.
|
---|
| 2578 | * \param[in] timeout The timeout, in milliseconds. 0xFFFFFFFF gives an
|
---|
| 2579 | * infinite timeout.
|
---|
| 2580 | *
|
---|
| 2581 | * \return \ref canOK (zero) if success
|
---|
| 2582 | * \return \ref canERR_xxx (negative) if failure
|
---|
| 2583 | */
|
---|
| 2584 | canStatus CANLIBAPI canWriteWait (const CanHandle hnd,
|
---|
| 2585 | long id,
|
---|
| 2586 | void *msg,
|
---|
| 2587 | unsigned int dlc,
|
---|
| 2588 | unsigned int flag,
|
---|
| 2589 | unsigned long timeout);
|
---|
| 2590 |
|
---|
| 2591 |
|
---|
| 2592 | #if defined(CANLIB_DECLARE_ALL)
|
---|
| 2593 |
|
---|
| 2594 | /**
|
---|
| 2595 | * \ingroup CAN
|
---|
| 2596 | *
|
---|
| 2597 | * \source_cs <b>static Canlib.canStatus canFlushReceiveQueue(int hnd);</b>
|
---|
| 2598 | *
|
---|
| 2599 | * \source_delphi <b>function canFlushReceiveQueue(handle: canHandle): canStatus; </b>
|
---|
| 2600 | * \source_end
|
---|
| 2601 | *
|
---|
| 2602 | * This function removes all received messages from the handle's receive queue.
|
---|
| 2603 | * Other handles open to the same channel are not affcted by this
|
---|
| 2604 | * operation. That is, only the messages belonging to the handle you are
|
---|
| 2605 | * passing to \ref canFlushReceiveQueue are discarded.
|
---|
| 2606 | *
|
---|
| 2607 | * \note This call has the same effect as calling \ref canIoCtl() with a function
|
---|
| 2608 | * code of \ref canIOCTL_FLUSH_RX_BUFFER.
|
---|
| 2609 | *
|
---|
| 2610 | * \param[in] hnd A handle to an open circuit.
|
---|
| 2611 | *
|
---|
| 2612 | * \return \ref canOK (zero) if success
|
---|
| 2613 | * \return \ref canERR_xxx (negative) if failure
|
---|
| 2614 | *
|
---|
| 2615 | * \sa \ref canFlushTransmitQueue()
|
---|
| 2616 | */
|
---|
| 2617 | canStatus CANLIBAPI canFlushReceiveQueue (const CanHandle hnd);
|
---|
| 2618 |
|
---|
| 2619 | /**
|
---|
| 2620 | * \ingroup CAN
|
---|
| 2621 | *
|
---|
| 2622 | * \source_cs <b>static Canlib.canStatus canFlushTransmitQueue(int hnd);</b>
|
---|
| 2623 | *
|
---|
| 2624 | * \source_delphi <b>function canFlushTransmitQueue(handle: canHandle): canStatus; </b>
|
---|
| 2625 | * \source_end
|
---|
| 2626 | *
|
---|
| 2627 | * This function removes all messages pending transmission from the
|
---|
| 2628 | * transmit queue of the circuit.
|
---|
| 2629 | *
|
---|
| 2630 | * \note If there are other handles open to the same circuit, they are also
|
---|
| 2631 | * flushed.
|
---|
| 2632 | *
|
---|
| 2633 | * \note This call has the same effect as calling \ref canIoCtl() with a function
|
---|
| 2634 | * code of \ref canIOCTL_FLUSH_TX_BUFFER.
|
---|
| 2635 | *
|
---|
| 2636 | * \param[in] hnd A handle to an open circuit.
|
---|
| 2637 | *
|
---|
| 2638 | * \return \ref canOK (zero) if success
|
---|
| 2639 | * \return \ref canERR_xxx (negative) if failure
|
---|
| 2640 | *
|
---|
| 2641 | * \sa \ref canFlushReceiveQueue()
|
---|
| 2642 | */
|
---|
| 2643 | canStatus CANLIBAPI canFlushTransmitQueue (const CanHandle hnd);
|
---|
| 2644 |
|
---|
| 2645 |
|
---|
| 2646 | /** Contains status codes according to \ref canSTAT_xxx. */
|
---|
| 2647 | typedef canStatus kvStatus;
|
---|
| 2648 |
|
---|
| 2649 | /**
|
---|
| 2650 | * \name kvCallback_t
|
---|
| 2651 | * \anchor kvCallback_t
|
---|
| 2652 | * \ref kvCallback_t is used by the function \ref kvSetNotifyCallback()
|
---|
| 2653 | *
|
---|
| 2654 | * The callback function is called with the following arguments:
|
---|
| 2655 | * \li hnd - the handle of the CAN channel where the event happened.
|
---|
| 2656 | * \li context - the context pointer you passed to \ref kvSetNotifyCallback().
|
---|
| 2657 | * \li notifyEvent - one of the \ref canNOTIFY_xxx notification codes.
|
---|
| 2658 | *
|
---|
| 2659 | * \note It is really the \ref canNOTIFY_xxx codes, and not the \ref
|
---|
| 2660 | * \ref canEVENT_xxx codes that the \ref canSetNotify() API is using.
|
---|
| 2661 | *
|
---|
| 2662 | * \param[in] hnd An open handle to a CAN channel.
|
---|
| 2663 | * \param[in] context Arbitrary user-defined context data which
|
---|
| 2664 | * is passed to the callback function.
|
---|
| 2665 | * \param[in] notifyEvent One or more of the \ref canEVENT_xxx flags.
|
---|
| 2666 | *
|
---|
| 2667 | */
|
---|
| 2668 | typedef void (CANLIBAPI *kvCallback_t) (CanHandle hnd, void* context, unsigned int notifyEvent);
|
---|
| 2669 |
|
---|
| 2670 | /**
|
---|
| 2671 | * \ingroup General
|
---|
| 2672 | *
|
---|
| 2673 | * \source_cs <b>static Canlib.canStatus kvSetNotifyCallback(int hnd, Canlib.kvCallbackDelegate callback, IntPtr context, uint notifyFlags);</b>
|
---|
| 2674 | *
|
---|
| 2675 | * \source_delphi <b>function kvSetNotifyCallback(handle: canHandle; callback: kvCallback_t; context: Pointer; notifyFlags: Cardinal): canStatus; </b>
|
---|
| 2676 | * \source_end
|
---|
| 2677 | *
|
---|
| 2678 | * The \ref kvSetNotifyCallback() function registers a callback function which is
|
---|
| 2679 | * called when certain events occur.
|
---|
| 2680 | *
|
---|
| 2681 | * You can register at most one callback function per handle at any time.
|
---|
| 2682 | *
|
---|
| 2683 | * To remove the callback, call \ref kvSetNotifyCallback() with a \c NULL pointer in
|
---|
| 2684 | * the callback argument.
|
---|
| 2685 | *
|
---|
| 2686 | * \note The callback function is called in the context of a high-priority
|
---|
| 2687 | * thread created by CANLIB. You should take precaution not to do any time
|
---|
| 2688 | * consuming tasks in the callback. You must also arrange the synchronization
|
---|
| 2689 | * between the callback and your other threads yourself.
|
---|
| 2690 | *
|
---|
| 2691 | * \param[in] hnd An open handle to a CAN channel.
|
---|
| 2692 | * \param[in] callback A pointer to a callback function of type
|
---|
| 2693 | * \ref kvCallback_t
|
---|
| 2694 | * \param[in] context A pointer to arbitrary user-defined context data which
|
---|
| 2695 | * is passed to the callback function.
|
---|
| 2696 | * \param[in] notifyFlags One or more of the \ref canNOTIFY_xxx flags.
|
---|
| 2697 | *
|
---|
| 2698 | * \return \ref canOK (zero) if success
|
---|
| 2699 | * \return \ref canERR_xxx (negative) if failure
|
---|
| 2700 | *
|
---|
| 2701 | * \sa \ref canSetNotify()
|
---|
| 2702 | */
|
---|
| 2703 | kvStatus CANLIBAPI kvSetNotifyCallback (const CanHandle hnd,
|
---|
| 2704 | kvCallback_t callback,
|
---|
| 2705 | void* context,
|
---|
| 2706 | unsigned int notifyFlags);
|
---|
| 2707 |
|
---|
| 2708 | /** @} */
|
---|
| 2709 | #endif
|
---|
| 2710 |
|
---|
| 2711 | #ifdef __cplusplus
|
---|
| 2712 | }
|
---|
| 2713 | #endif
|
---|
| 2714 |
|
---|
| 2715 |
|
---|
| 2716 | #endif
|
---|