linlib.h
Go to the documentation of this file.
1 /*
2  * Copyright 2003-2017 by KVASER AB, SWEDEN
3  * WWW: http://www.kvaser.com
4  *
5  * This software is furnished under a license and may be used and copied
6  * only in accordance with the terms of such license.
7  */
8 
26 #ifndef __LINLIB_H
27 #define __LINLIB_H
28 
32 typedef int LinHandle;
33 
37 #define linINVALID_HANDLE ((LinHandle)(-1))
38 
39 
49 typedef enum {
50  linOK = 0,
51  linERR_NOMSG = -1,
52 
59 
66 
72 
78 
79 
80  linERR_PARAM = -7,
82  linERR_NOMEM = -9,
91  linERR_DRIVER = -18,
93  linERR_NOCARD = -20,
100 } LinStatus;
104 // sizeof(LinMessageInfo) should be 68 for correct alignment
105 #include <pshpack1.h>
106 
121 typedef struct {
132  unsigned long timestamp;
133 
138  unsigned long synchBreakLength;
139 
144  unsigned long frameLength;
145 
150  unsigned long bitrate;
151 
156  unsigned char checkSum;
157 
162  unsigned char idPar;
163 
164  unsigned short z;
165 
172  unsigned long synchEdgeTime[4];
173 
180  unsigned long byteTime[8];
182 
183 #include <poppack.h>
184 
185 
194 #define LIN_TX 1
195 #define LIN_RX 2
196 #define LIN_WAKEUP_FRAME 4
197 #define LIN_NODATA 8
198 #define LIN_CSUM_ERROR 16
199 #define LIN_PARITY_ERROR 32
200 #define LIN_SYNCH_ERROR 64
201 #define LIN_BIT_ERROR 128
202 
224 #define linCHANNELDATA_CARD_FIRMWARE_REV 9
225 
231 #define LINERROR(f) ((f) & (LIN_NODATA | LIN_CSUM_ERROR | LIN_SYNCH_ERROR | LIN_BIT_ERROR))
232 
233 
234 // Define LINLIBAPI unless it's done already.
235 // (linlib.c provides its own definition of LINLIBAPI before including this file.)
236 //
237 #ifndef LINLIBAPI
238 # if defined(__BORLANDC__)
239 # define LINLIBAPI __stdcall
240 # elif defined(_MSC_VER) || defined(__MWERKS__) || defined(__GNUC__)
241 # define LINLIBAPI __stdcall
242 # endif
243 #endif
244 
245 #ifdef __cplusplus
246 extern "C" {
247 #endif
248 
257 void LINLIBAPI linInitializeLibrary(void);
258 
265 void LINLIBAPI linUnloadLibrary(void);
266 
267 
303 LinStatus LINLIBAPI linGetTransceiverData(int channel, unsigned char eanNo[8],
304  unsigned char serNo[8], int *ttype);
305 
326 LinHandle LINLIBAPI linOpenChannel(int channel, int flags);
327 
328 
337 #define LIN_MASTER 1
338 #define LIN_SLAVE 2
339 
354 LinStatus LINLIBAPI linClose(LinHandle h);
355 
356 
371 LinStatus LINLIBAPI linGetVersion(int *major, int *minor, int *build);
372 
373 
409  unsigned char *bootVerMajor,
410  unsigned char *bootVerMinor,
411  unsigned char *bootVerBuild,
412  unsigned char *appVerMajor,
413  unsigned char *appVerMinor,
414  unsigned char *appVerBuild);
415 
416 
417 
438 LinStatus LINLIBAPI linGetChannelData(int channel, int item, void *buffer, size_t bufsize);
439 
456 LinStatus LINLIBAPI linSetBitrate(LinHandle h, unsigned int bps);
457 
472 LinStatus LINLIBAPI linBusOn(LinHandle h);
473 
487 LinStatus LINLIBAPI linBusOff(LinHandle h);
488 
501 unsigned long LINLIBAPI linReadTimer(LinHandle h);
502 
524 LinStatus LINLIBAPI linWriteMessage(LinHandle h, unsigned int id, const void *msg,
525  unsigned int dlc);
526 
542 LinStatus LINLIBAPI linRequestMessage(LinHandle h, unsigned int id);
543 
570 LinStatus LINLIBAPI linReadMessage(LinHandle h, unsigned int *id, void *msg,
571  unsigned int *dlc, unsigned int *flags,
572  LinMessageInfo *msgInfo);
573 
603 LinStatus LINLIBAPI linReadMessageWait(LinHandle h, unsigned int *id, void *msg,
604  unsigned int *dlc, unsigned int *flags,
605  LinMessageInfo *msgInfo, unsigned long timeout);
606 
626 LinStatus LINLIBAPI linUpdateMessage(LinHandle h, unsigned int id, const void *msg,
627  unsigned int dlc);
628 
629 
653 LinStatus LINLIBAPI linSetupIllegalMessage(LinHandle h, unsigned int id,
654  unsigned int cFlags, unsigned int delay);
655 
664 #define LIN_MSG_DISTURB_CSUM 1
665 
669 #define LIN_MSG_DISTURB_PARITY 2
670 
681 #define LIN_MSG_USE_STANDARD_PARITY 0x04
682 
685 #define LIN_MSG_USE_ENHANCED_PARITY 0x08
686 
721 LinStatus LINLIBAPI linSetupLIN(LinHandle h, unsigned int lFlags, unsigned int bps);
722 
723 
736 #define LIN_ENHANCED_CHECKSUM 1
737 
743 #define LIN_VARIABLE_DLC 2
744 
766 LinStatus LINLIBAPI linWriteWakeup(LinHandle h, unsigned int count,
767  unsigned int interval);
768 
769 
782 LinStatus LINLIBAPI linClearMessage(LinHandle h, unsigned int id);
783 
826 LinStatus LINLIBAPI linWriteSync(LinHandle h, unsigned long timeout);
827 
839 LinStatus LINLIBAPI linGetCanHandle(LinHandle h, unsigned int *canHandle);
840 
889 #ifdef __cplusplus
890 }
891 #endif
892 
893 #endif // __LINLIB_H
Library not initialized.
Definition: linlib.h:85
LinStatus
Definition: linlib.h:49
LinStatus linGetTransceiverData(int channel, unsigned char eanNo[8], unsigned char serNo[8], int *ttype)
DeviceIOControl failed; use the Win32 GetLastError API to get the real (WIn32) error code...
Definition: linlib.h:92
LinStatus linGetChannelData(int channel, int item, void *buffer, size_t bufsize)
LinStatus linSetBitrate(LinHandle h, unsigned int bps)
Definition: linlib.h:58
LinStatus linGetVersion(int *major, int *minor, int *build)
LinStatus linBusOff(LinHandle h)
unsigned long frameLength
Definition: linlib.h:144
unsigned long bitrate
Definition: linlib.h:150
LinStatus linReadMessageWait(LinHandle h, unsigned int *id, void *msg, unsigned int *dlc, unsigned int *flags, LinMessageInfo *msgInfo, unsigned long timeout)
LinStatus linGetCanHandle(LinHandle h, unsigned int *canHandle)
LinStatus linSetupIllegalMessage(LinHandle h, unsigned int id, unsigned int cFlags, unsigned int delay)
Internal error in the driver.
Definition: linlib.h:88
The LIN interface response wasn&#39;t the expected one.
Definition: linlib.h:90
void linInitializeLibrary(void)
Internal error in the driver.
Definition: linlib.h:95
The requested feature or function is not implemented in the device you are trying to use it on...
Definition: linlib.h:99
LinStatus linUpdateMessage(LinHandle h, unsigned int id, const void *msg, unsigned int dlc)
LinStatus linGetFirmwareVersion(LinHandle h, unsigned char *bootVerMajor, unsigned char *bootVerMinor, unsigned char *bootVerBuild, unsigned char *appVerMajor, unsigned char *appVerMinor, unsigned char *appVerBuild)
int LinHandle
Definition: linlib.h:32
Timeout occurred.
Definition: linlib.h:84
LinStatus linWriteWakeup(LinHandle h, unsigned int count, unsigned int interval)
LinStatus linSetupLIN(LinHandle h, unsigned int lFlags, unsigned int bps)
Definition: linlib.h:65
The card was removed or not inserted.
Definition: linlib.h:93
The license is not valid.
Definition: linlib.h:94
unsigned long timestamp
Definition: linlib.h:132
Function not supported in this version.
Definition: linlib.h:98
CAN driver type not supported.
Definition: linlib.h:91
unsigned long synchBreakLength
Definition: linlib.h:138
Out of memory.
Definition: linlib.h:82
Access denied.
Definition: linlib.h:96
LinStatus linReadMessage(LinHandle h, unsigned int *id, void *msg, unsigned int *dlc, unsigned int *flags, LinMessageInfo *msgInfo)
unsigned char idPar
Definition: linlib.h:162
No channels avaliable.
Definition: linlib.h:83
LinStatus linWriteMessage(LinHandle h, unsigned int id, const void *msg, unsigned int dlc)
Error in parameter.
Definition: linlib.h:80
OK - no error.
Definition: linlib.h:50
LinStatus linRequestMessage(LinHandle h, unsigned int id)
Handle is invalid.
Definition: linlib.h:87
unsigned char checkSum
Definition: linlib.h:156
LinStatus linWriteSync(LinHandle h, unsigned long timeout)
There was an error response from the LIN interface.
Definition: linlib.h:89
Specified hardware not found. This error is reported when the LIN transceiver isn&#39;t powered up...
Definition: linlib.h:81
Definition: linlib.h:121
unsigned long linReadTimer(LinHandle h)
unsigned short z
Dummy for alignment.
Definition: linlib.h:164
LinHandle linOpenChannel(int channel, int flags)
Definition: linlib.h:71
Definition: linlib.h:77
No messages available.
Definition: linlib.h:51
Function not supported in this version.
Definition: linlib.h:97
int canHandle
Definition: canlib.h:118
void linUnloadLibrary(void)
LinStatus linClearMessage(LinHandle h, unsigned int id)
LinStatus linBusOn(LinHandle h)
Can&#39;t get handle.
Definition: linlib.h:86