source: pacpussensors/trunk/CanGateway/driver/kvaser/linlib.h@ 89

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

Add KVASER CAN driver support for CanGateway component. Tested only for Windows.

File size: 26.4 KB
Line 
1/**
2 * \section LICENSE
3 * Copyright 2003-2013 by KVASER AB, SWEDEN
4 * WWW: http://www.kvaser.com
5 *
6 * This software is furnished under a license and may be used and copied
7 * only in accordance with the terms of such license.
8 *
9 * \section DESCRIPTION
10 *
11 * Definitions for the LINlib API.
12 *
13 * \file linlib.h
14 * \author Kvaser AB
15 */
16
17#ifndef __LINLIB_H
18#define __LINLIB_H
19
20/**
21 * \defgroup LIN LIN
22 * @{
23 */
24
25 /**
26 * LIN handle
27 */
28typedef int LinHandle;
29
30/**
31 * Invalid LIN handle
32 */
33#define linINVALID_HANDLE ((LinHandle)(-1))
34
35#if !WIN32
36# define CompilerAssert(exp) extern char _CompilerAssert[(exp) ? 1 : -1]
37#endif
38
39
40/**
41 * \name Return codes from the LINlib functions
42 * \anchor linERR_xxx
43 * @{
44 */
45typedef enum {
46 linOK = 0, ///< OK - no error
47 linERR_NOMSG = -1, ///< No messages available
48 linERR_NOTRUNNING = -3,
49 linERR_RUNNING = -4,
50 linERR_MASTERONLY = -5,
51 linERR_SLAVEONLY = -6,
52 linERR_PARAM = -7, ///< Error in parameter
53 linERR_NOTFOUND = -8, ///< Specified hardware not found. This error is reported when the LIN transceiver isn't powered up
54 linERR_NOMEM = -9, ///< Out of memory
55 linERR_NOCHANNELS = -10, ///< No channels avaliable
56 linERR_TIMEOUT = -11, ///< Timeout occurred
57 linERR_NOTINITIALIZED = -12, ///< Library not initialized
58 linERR_NOHANDLES = -13, ///< Can't get handle
59 linERR_INVHANDLE = -14, ///< Handle is invalid
60 linERR_CANERROR = -15,
61 linERR_ERRRESP = -16, ///< There was an error response from the LIN interface
62 linERR_WRONGRESP = -17, ///< The LIN interface response wasn't the expected one
63 linERR_DRIVER = -18, ///< CAN driver type not supported
64 linERR_DRIVERFAILED = -19, ///< DeviceIOControl failed; use the Win32 GetLastError API to get the real (WIn32) error code.
65 linERR_NOCARD = -20, ///< The card was removed or not inserted
66 linERR_LICENSE = -21, ///< The license is not valid
67 linERR_INTERNAL = -22, ///< Internal error in the driver
68 linERR_NO_ACCESS = -23, ///< Access denied
69 linERR_VERSION = -24 ///< Function not supported in this version
70} LinStatus;
71/** @} */
72
73
74// sizeof(LinMessageInfo) should be 68 for correct alignment
75#if WIN32
76#include <pshpack1.h>
77#endif
78
79/**
80 * In certain LIN bus API calls, the following structure is used to provide more
81 * information about the LIN messages.
82 *
83 * \note The precision of the timing data given in us (microseconds) can be less
84 * than one microsecond; for low bitrates the lowest bits might always be zero.
85 *
86 * \note The min and max values listed inside [] of the message timing values
87 * can be calculated from the LIN specification by using the shortest (0 bytes)
88 * or longest (8 bytes) messages at the lowest or highest allowed bitrate.
89 *
90 * \note The LIN interface will accept messages that are a bit out-of-bounds as
91 * well.
92 */
93typedef struct {
94 /**
95 * Kvaser DRV Lin timestamp - Timestamp in milliseconds of the falling edge of
96 * the synch break of the message. Uses the canlib CAN timer.
97 *
98 * Kvaser LIN Leaf timestamp - Timestamp in milliseconds of the falling edge
99 * of the synch break of the message. Uses the canlib CAN timer.
100 *
101 * \note All Kvaser Leaf with Kvaser MagiSync&tm; are synchronized
102 * (also with CAN channels).
103 */
104 unsigned long timestamp;
105
106 /**
107 * Length of the synch break in microseconds.
108 * [650 .. 13000], [400 .. 8000] for a wakeup signal.
109 */
110 unsigned long synchBreakLength;
111
112 /**
113 * The total frame length in microseconds; from the synch break to the
114 * end of the crc. [2200 .. 173600]
115 */
116 unsigned long frameLength;
117
118 /**
119 * The bitrate of the message in bits per seconds.
120 * Range [1000 .. 20000] (plus some margin)
121 */
122 unsigned long bitrate;
123
124 /**
125 * The checksum as read from the LIN bus. Might not
126 * match the data in case of \ref LIN_CSUM_ERROR.
127 */
128 unsigned char checkSum;
129
130 /**
131 * The id with parity of the message as read from the
132 * LIN bus. Might be invalid in case of \ref LIN_PARITY_ERROR.
133 */
134 unsigned char idPar;
135
136 unsigned short z; ///< Dummy for alignment
137
138 /**
139 * Time in microseconds of the falling edges in the
140 * synch byte relative the falling edge of the start bit.
141 */
142 unsigned long synchEdgeTime[4];
143
144 /**
145 * Start time in microseconds of each data byte. In case of 8-byte messages,
146 * the crc time isn't included (but can be deduced from frameLength).
147 */
148 unsigned long byteTime[8];
149} LinMessageInfo;
150
151#if WIN32
152#include <poppack.h>
153#endif
154
155
156/**
157 * \name LIN message flags
158 * \anchor LIN_xxx
159 * The following flags can be returned from \ref linReadMessage() and
160 * \ref linReadMessageWait().
161 *
162 * @{
163 */
164#define LIN_TX 1 ///< The message was something we transmitted on the bus
165#define LIN_RX 2 ///< The message was something we received from the bus
166#define LIN_WAKEUP_FRAME 4 ///< A wake up frame was received. Id/msg/dlc are undefined
167#define LIN_NODATA 8 ///< No data, only a header
168#define LIN_CSUM_ERROR 16 ///< Checksum error
169#define LIN_PARITY_ERROR 32 ///< ID parity error
170#define LIN_SYNCH_ERROR 64 ///< A synch error
171#define LIN_BIT_ERROR 128 ///< Bit error when transmitting
172/** @} */
173
174/**
175 * Macro for determining if a flag field contains a LIN error flag bit.
176 */
177#define LINERROR(f) ((f) & (LIN_NODATA | LIN_CSUM_ERROR | LIN_SYNCH_ERROR | LIN_BIT_ERROR))
178
179
180// Define LINLIBAPI unless it's done already.
181// (linlib.c provides its own definition of LINLIBAPI before including this file.)
182//
183#if WIN32
184#ifndef LINLIBAPI
185# if defined(__BORLANDC__)
186# define LINLIBAPI __stdcall
187# elif defined(_MSC_VER) || defined(__MWERKS__) || defined(__GNUC__)
188# define LINLIBAPI __stdcall
189# endif
190#endif
191#else
192#define LINLIBAPI
193#endif
194
195#ifdef __cplusplus
196extern "C" {
197#endif
198
199/**
200 * This function initializes the LIN library and must be called before any other
201 * LIN function is called. If this function isn't called, subsequent calls to
202 * the other LIN functions will return \ref linERR_NOTINITIALIZED.
203 *
204 * \sa \ref linOpenChannel()
205 */
206void LINLIBAPI linInitializeLibrary(void);
207
208
209/**
210 * Retrieves the transceiver information for a CAN channel. The application
211 * typically uses this call to find out whether a particular CAN channel has a
212 * LIN interface connected to it.
213 * For a Kvaser LIN Leaf it retrieves the transceiver type and device information.
214 *
215 * This function call will open the CAN channel, but no CAN messages are
216 * transmitted on it. In other words, it's risk-free to use even if no LIN
217 * interface is connected, or if the channel is connected to a CAN system.
218 *
219 * \note Attempts to use the channel for LIN communication will be meaningful
220 * only if \ref linGetTransceiverData() stores \ref canTRANSCEIVER_TYPE_LIN in \a ttype.
221 *
222 * \note A LIN interface need not be powered for this call to succeed.
223 *
224 * \note The information may not always be accurate. Especially after changing
225 * transceiver on a running LAPcan card, you should go on bus and off bus again
226 * to be sure the transceiver information is updated.
227 *
228 * \param[in] channel The number of a CAN channel for which the transceiver
229 * data will be retrieved.
230 * \param[out] eanNo A pointer to an array of 8 bytes where the EAN number of
231 * the LIN interface will be stored.
232 * \param[out] serNo A pointer to an array of 8 bytes where the serial number
233 * of the LIN interface will be stored.
234 * \param[out] ttype A pointer to an integer where the transceiver type will
235 * be stored.
236 *
237 * \return \ref linOK (zero) if success
238 * \return \ref linERR_xxx (negative) if failure
239 *
240 * \sa \ref linGetFirmwareVersion()
241 */
242LinStatus LINLIBAPI linGetTransceiverData(int channel, unsigned char eanNo[8],
243 unsigned char serNo[8], int *ttype);
244
245/**
246 * Open a channel to a LIN interface.
247 *
248 * \note For DRV Lin: The cable must be powered and connected to a LAPcan channel.
249 *
250 * \note For Kvaser LIN Leaf: The Leaf must be powered from the LIN side.
251 *
252 * \param[in] channel The number of the channel. Channel numbering is hardware
253 * dependent.
254 * This is the same channel number as used by \ref canOpenChannel().
255 * \param[in] flags Either one of the following values: \ref LIN_MASTER or
256 * \ref LIN_SLAVE.
257 *
258 * \return If the call succeeds, a handle to the opened channel is returned.
259 * The handle is an integer greater than or equal to zero.
260 *
261 * \return If the call fails, the return value is a negative integer indicating
262 * an error code. See \ref linERR_xxx for a list of possible error codes.
263 *
264 * \sa \ref linClose()
265 */
266LinHandle LINLIBAPI linOpenChannel(int channel, int flags);
267
268
269/**
270 * \name Flags for linOpenChannel()
271 * @{
272 */
273#define LIN_MASTER 1 ///< The LIN interface will be a LIN master
274#define LIN_SLAVE 2 ///< The LIN interface will be a LIN slave
275/** @} */
276
277
278/**
279 * Closes an open handle to a LIN channel. The handle becomes invalid and can
280 * not be used in subsequent calls to the LIN functions.
281 *
282 * \param[in] h A handle to an open LIN channel.
283 *
284 * \return \ref linOK (zero) if success
285 * \return \ref linERR_xxx (negative) if failure
286 *
287 * \sa \ref linOpenChannel()
288 */
289LinStatus LINLIBAPI linClose(LinHandle h);
290
291/**
292 * This function retrieves the firmware version from the LIN interface.
293 *
294 *
295 * \note The version numbers aren't valid until \ref linBusOn() has been called.
296 *
297 * \note The firmware in the LIN interface is divided into two parts, the boot
298 * code and the application. The boot code is used only when reprogramming
299 * (reflashing) the LIN interface. The application handles all LIN communication.
300 *
301 * \note Version numbers are, since the precambric era, divided into a major
302 * version number, a minor version number and a build number. These are usually
303 * written like, for example, 3.2.12. Here the major number is 3, the minor
304 * number 2 and the build number 12.
305 *
306 * \param[in] h A handle to an open LIN channel.
307 * \param[out] bootVerMajor A pointer to a byte where the major version number
308 * of the boot code is stored.
309 * \param[out] bootVerMinor A pointer to a byte where the minor version number
310 * of the boot code is stored.
311 * \param[out] bootVerBuild A pointer to a byte where the build number of the
312 * boot code is stored.
313 * \param[out] appVerMajor A pointer to a byte where the major version number
314 * of the application code is stored.
315 * \param[out] appVerMinor A pointer to a byte where the minor version number
316 * of the application code is stored.
317 * \param[out] appVerBuild A pointer to a byte where the build number of the application is stored.
318 *
319 * \return \ref linOK (zero) if success
320 * \return \ref linERR_xxx (negative) if failure
321 */
322LinStatus LINLIBAPI linGetFirmwareVersion(LinHandle h,
323 unsigned char *bootVerMajor,
324 unsigned char *bootVerMinor,
325 unsigned char *bootVerBuild,
326 unsigned char *appVerMajor,
327 unsigned char *appVerMinor,
328 unsigned char *appVerBuild);
329
330/**
331 * This function sets the bit rate for a master, or the initial bit rate for a
332 * slave. The LIN interface should not be on-bus when this function is called.
333 *
334 * \note The LIN Interface should not be on bus.
335 *
336 * \note Supported bit rates are 1000 - 20000 bits per second.
337 *
338 * \param[in] h A handle to an open LIN channel.
339 * \param[in] bps Bit rate in bits per second.
340 *
341 * \return \ref linOK (zero) if success
342 * \return \ref linERR_xxx (negative) if failure
343 */
344LinStatus LINLIBAPI linSetBitrate(LinHandle h, unsigned int bps);
345
346/**
347 * This function activates the LIN interface.
348 *
349 * \note It will be reset, so any setups done earlier will be lost.
350 *
351 * \param[in] h A handle to an open LIN channel.
352 *
353 * \return \ref linOK (zero) if success
354 * \return \ref linERR_xxx (negative) if failure
355 *
356 * \sa \ref linBusOff()
357 */
358LinStatus LINLIBAPI linBusOn(LinHandle h);
359
360/**
361 * This function deactivates the LIN interface. It will not participate further
362 * in the LIN bus traffic.
363 *
364 * \param[in] h A handle to an open LIN channel.
365 *
366 * \return \ref linOK (zero) if success
367 * \return \ref linERR_xxx (negative) if failure
368 *
369 * \sa \ref linBusOn()
370 */
371LinStatus LINLIBAPI linBusOff(LinHandle h);
372
373/**
374 * Return the current timer value (used for timestamps)
375 *
376 * \note For convenience, this call returns the timer value instead of passing
377 * it in a parameter. This means that if the call fails, it will still return
378 * a value (which then is the error code, type casted to a long unsigned
379 * integer - e.g. 0xFFFFFFF2 for \ref linERR_INVHANDLE. Watch out.
380 *
381 * \param[in] h A handle to an open LIN channel.
382 * \return If the call succeeds, the present timer value is returned.
383 */
384unsigned long LINLIBAPI linReadTimer(LinHandle h);
385
386/**
387 * Write a LIN message.
388 * It is advisable to wait until the message is echoed by \ref linReadMessage()
389 * before transmitting a new message, or in case of a schedule table being used,
390 * transmit the next message when the previous one is known to be complete.
391 *
392 * \note Only available in master mode.
393 *
394 * \param[in] h A handle to an open LIN channel.
395 * \param[in] id The identifier of the LIN message.
396 * \param[in] msg A pointer to a buffer containing the data of the LIN
397 * message.
398 * \param[in] dlc The length of the LIN message.
399 *
400 * \return \ref linOK (zero) if success
401 * \return \ref linERR_xxx (negative) if failure
402 *
403 * \sa \ref linWriteSync()
404 */
405LinStatus LINLIBAPI linWriteMessage(LinHandle h, unsigned int id, const void *msg,
406 unsigned int dlc);
407
408/**
409 * This function writes a LIN message header to the LIN bus. A slave in the
410 * system is then expected to fill in the header with data.
411 *
412 * \note This call is only available in master mode.
413 *
414 * \param[in] h A handle to an open LIN channel.
415 * \param[in] id The identifier of the LIN message.
416 *
417 * \return \ref linOK (zero) if success
418 * \return \ref linERR_xxx (negative) if failure
419 */
420LinStatus LINLIBAPI linRequestMessage(LinHandle h, unsigned int id);
421
422/**
423 * Read a message from the LIN interface. If a message is available for
424 * reception, \ref linOK is returned. This is a non-blocking call. If no message
425 * is available in the LIN interface, an error code is returned.
426 *
427 * \note This call will also return echoes of what the LIN interface is
428 * transmitting with \ref linWriteMessage. In other words, the LIN interface can hear
429 * itself.
430 *
431 * \param[in] h A handle to an open LIN channel.
432 * \param[out] id A pointer to an integer where the identifier of the
433 * received LIN message will be stored.
434 * \param[out] msg A pointer to a buffer where the data of the LIN message
435 * will be stored.
436 * \param[out] dlc A pointer to an integer where the length of the received
437 * LIN message will be stored.
438 * \param[out] flags A combination of zero or more of the \ref LIN_xxx flags.
439 * \param[out] msgInfo A pointer to a \ref LinMessageInfo struct where data about the
440 * received LIN message will be stored.
441 *
442 * \return \ref linOK (zero) if success
443 * \return \ref linERR_xxx (negative) if failure
444 *
445 * \sa \ref linReadMessageWait()
446 */
447LinStatus LINLIBAPI linReadMessage(LinHandle h, unsigned int *id, void *msg,
448 unsigned int *dlc, unsigned int *flags,
449 LinMessageInfo *msgInfo);
450
451/**
452 * Read a message from the LIN interface. If a message is available for
453 * reception, \ref linOK is returned. This is a blocking call. It waits until a
454 * message is received in the LIN interface, or the specified timeout period
455 * elapses.
456 *
457 * \note This call will also return echoes of what the LIN interface is
458 * transmitting with \ref linWriteMessage(). In other words, the LIN interface can
459 * hear itself.
460 *
461 * \param[in] h A handle to an open LIN channel.
462 * \param[in] timeout The maximum number of milliseconds to wait for a message
463 * to be received by the LIN interface.
464 * \param[out] id A pointer to an integer where the identifier of the
465 * received LIN message will be stored.
466 * \param[out] msg A pointer to a buffer where the data of the LIN message
467 * will be stored.
468 * \param[out] dlc A pointer to an integer where the length of the received
469 * LIN message will be stored.
470 * \param[out] flags A combination of zero or more of the \ref LIN_xxx flags.
471 * \param[out] msgInfo A pointer to a \ref LinMessageInfo struct where data about the
472 * received LIN message will be stored.
473 *
474 * \return \ref linOK (zero) if success
475 * \return \ref linERR_xxx (negative) if failure
476 *
477 * \sa \ref linReadMessage()
478 */
479LinStatus LINLIBAPI linReadMessageWait(LinHandle h, unsigned int *id, void *msg,
480 unsigned int *dlc, unsigned int *flags,
481 LinMessageInfo *msgInfo, unsigned long timeout);
482
483/**
484 * This function updates a message buffer in a slave. The contents of the
485 * message buffer will be used the next time the slave is polled for the
486 * specified LIN message id.
487 *
488 * \note The LIN Interface must be on bus.
489 *
490 * \param[in] h A handle to an open LIN channel.
491 * \param[in] id The identifier of the LIN message.
492 * \param[in] msg A pointer to a buffer containing the data of the LIN message.
493 * \param[in] dlc The length of the LIN message.
494 *
495 * \return \ref linOK (zero) if success
496 * \return \ref linERR_xxx (negative) if failure
497 *
498 * \sa \ref linClearMessage()
499 */
500LinStatus LINLIBAPI linUpdateMessage(LinHandle h, unsigned int id, const void *msg,
501 unsigned int dlc);
502
503
504/**
505 * Using this function, it is possible to use the LIN interface to create
506 * corrupted LIN messages. You call the function once for each LIN identifier
507 * that should be affected.
508 *
509 * To return to normal mode, either restart the LIN interface (by going off bus
510 * and on the bus again) or call the function with delay and \a cFlags set to zero.
511 *
512 * \note The LIN Interface must be on bus for this command to work.
513 * \note It is supported in firmware version 2.4.1 and later.
514 *
515 * \param[in] h A handle to an open LIN channel.
516 * \param[in] id The identifier of the LIN message.
517 * \param[in] cFlags One or more of the \ref LIN_MSG_DISTURB_xxx flags.
518 * \param[in] delay The delay parameter will result in a delay of this many
519 * bittimes after the header and before the first data byte.
520 *
521 * \return \ref linOK (zero) if success
522 * \return \ref linERR_xxx (negative) if failure
523 *
524 * \sa \ref linSetupLIN()
525 */
526LinStatus LINLIBAPI linSetupIllegalMessage(LinHandle h, unsigned int id,
527 unsigned int cFlags, unsigned int delay);
528
529/**
530 * \name LIN illegal message flags
531 * \anchor LIN_MSG_DISTURB_xxx
532 * @{
533 */
534/**
535 * The checksum of transmitted messages will be inverted (and consequently illegal.)
536 */
537#define LIN_MSG_DISTURB_CSUM 1
538/**
539 * The two parity bits will be inverted (and consequently illegal.)
540 * Used only in master mode.
541 */
542#define LIN_MSG_DISTURB_PARITY 2
543/** @} */
544
545
546/**
547 * \name LIN message parity
548 * \anchor LIN_MSG_USE_xxx
549 * @{
550 */
551/**
552 * Use enhanced (2.x) parity for the specified msg
553 */
554#define LIN_MSG_USE_STANDARD_PARITY 0x04
555/**
556 * Use standard (1.x) parity for the specified msg
557 */
558#define LIN_MSG_USE_ENHANCED_PARITY 0x08
559/** @} */
560
561/**
562 * This function changes various settings on a LIN Interface that is on bus.
563 * When going on bus, the bit rate and the flag values listed below are set to
564 * the default value (either as hard-coded in the firmware, or as stored in the
565 * non-volatile memory of the LIN Interface).
566 *
567 * With this function, you can do one or more of the following things:
568 * - Select checksum according to LIN 2.0
569 * - Turn variable message length off. The message length then will depend on
570 * the message ID.
571 *
572 * In master mode it is also possible to change the bit rate without going off
573 * bus first.
574 *
575 * \note The LIN Interface must be on bus for this command to work.
576 * \note It is supported in firmware version 2.5.1 and later.
577 * \note For LIN 2.0 compliance, you must specify both \ref LIN_ENHANCED_CHECKSUM
578 * and \ref LIN_VARIABLE_DLC.
579 *
580 * \param[in] h A handle to an open LIN channel.
581 * \param[in] lFlags One or more of the following flags:
582 * \ref LIN_ENHANCED_CHECKSUM, \ref LIN_VARIABLE_DLC
583 * \param bps Specifies the bit rate in bits per second. This parameter
584 * can be used only in master mode. The bit rate is set
585 * without going off bus.
586 *
587 * \return \ref linOK (zero) if success
588 * \return \ref linERR_xxx (negative) if failure
589 *
590 * \sa \ref linSetupIllegalMessage()
591 */
592LinStatus LINLIBAPI linSetupLIN(LinHandle h, unsigned int lFlags, unsigned int bps);
593
594
595/**
596 * \name LIN setup
597 * @{
598 */
599/**
600 * When specified, the LIN interface will use the "enhanced" checksum according
601 * to LIN 2.0. Note that (as per the LIN 2.0 spec) the enhanced checksum is not
602 * used on the diagnostic frames even if the \ref LIN_ENHANCED_CHECKSUM setting
603 * is in effect.
604 *
605 * The default value is OFF.
606 */
607#define LIN_ENHANCED_CHECKSUM 1
608/**
609 * When specified, turns variable message length on, so the the message length
610 * will depend on the message ID.
611 *
612 * The default value is ON.
613 */
614#define LIN_VARIABLE_DLC 2
615/** @} */
616
617/**
618 * Write a wakeup frame.
619 *
620 * If count is zero, one single wakeup frame is transmitted. If count > 1,
621 * several wakeup frames are transmitted spaced with 'interval' bittimes.
622 * The LIN interface will interrupt the sequence when a LIN message or another
623 * command is received. The stream of wakeups will be recived as incoming
624 * messages with the LIN_RX flag bit set.
625 *
626 * \param[in] h A handle to an open LIN channel.
627 * \param[in] count The number of wakeup frames to send.
628 * \param[in] interval The time, in bit times, between the wakeup frames.
629 *
630 * \return \ref linOK (zero) if success
631 * \return \ref linERR_xxx (negative) if failure
632 */
633LinStatus LINLIBAPI linWriteWakeup(LinHandle h, unsigned int count,
634 unsigned int interval);
635
636
637/**
638 * Clear a message buffer for a LIN slave. The message buffer will not answer
639 * next time it is polled.
640 *
641 * \param[in] h A handle to an open LIN channel.
642 * \param[in] id The LIN message id for which the corresponding buffer
643 * will be cleared.
644 *
645 * \return \ref linOK (zero) if success
646 * \return \ref linERR_xxx (negative) if failure
647 */
648LinStatus LINLIBAPI linClearMessage(LinHandle h, unsigned int id);
649
650/**
651 * Call this function to make sure all messages transmitted to the
652 * LIN Interface has been received by it.
653 *
654 * When messages are transmitted to the LIN Interface, they are queued by
655 * Windows before appearing on the CAN bus.
656 *
657 * The function returns \ref linOK if all writes are done, \ref linERR_TIMEOUT in
658 * case of timeout or possibly some other error code.
659 *
660 * If the LIN Interface is in master mode and a LIN message has been
661 * transmitted with \ref linWriteMessage(), this function will return when
662 * the LIN Interface has received the message. If another LIN messa ge is being
663 * received or transmitted, the message will not be transmitted on the
664 * LIN bus at once. And even if the LIN Interface is idle, the header of the new
665 * message will just have been started when \ref linWriteSync() retur ns.
666 *
667 * After calling \ref linUpdateMessage() and \ref linClearMessage() for a slave,
668 * this function is enough to know that the LIN Interface is updated.
669 *
670 * After \ref linWriteMessage(), it is advisable to wait until the message is
671 * echoed by \ref linReadMessage() before transmitting a new message, or in
672 * case of a schedule table being used, transmit the next message when
673 * the previous one is known to be complete.
674 *
675 * When, in master mode, a message should be transmitted after a poll
676 * (reception) is done, it might be necessary to call \ref linWriteMessage()
677 * before the result is received via \ref linReadMessage() as the LIN Interface waits
678 * up to the maximum frame length before knowing a received message is
679 * complete. A new message to transmit will force completion if the
680 * currently received one.
681 *
682 * \param[in] h A handle to an open LIN channel.
683 * \param[in] timeout The maximum number of milliseconds to wait for the queued
684 * messages to be transmitted by the LIN interface.
685 *
686 * \return \ref linOK (zero) if success
687 * \return \ref linERR_xxx (negative) if failure
688 *
689 * \sa \ref linWriteMessage()
690 */
691LinStatus LINLIBAPI linWriteSync(LinHandle h, unsigned long timeout);
692
693/**
694 * Return the CAN handle given an open LIN handle
695 *
696 * \param[in] h A handle to an open LIN channel.
697 * \param[out] canHandle A pointer to an integer where the CAN handle will be
698 * stored.
699 *
700 * \return \ref linOK (zero) if success
701 * \return \ref linERR_xxx (negative) if failure
702 */
703LinStatus LINLIBAPI linGetCanHandle(LinHandle h, unsigned int *canHandle);
704
705#ifdef __cplusplus
706}
707#endif
708
709/** @} */
710
711#endif // __LINLIB_H
Note: See TracBrowser for help on using the repository browser.