j1587lib.h
Go to the documentation of this file.
1 /*
2  * Copyright 2007-2011 by KVASER AB, SWEDEN
3  *
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 
10 #ifndef __J1587LIB_H
11 #define __J1587LIB_H
12 
39 #include <windows.h>
40 
44 typedef int J1587Handle;
45 
49 #define j1587INVALID_HANDLE ((J1587Handle)(-1))
50 
56 #define canTRANSCEIVER_TYPE_LINX_LIN 64
57 #define canTRANSCEIVER_TYPE_LINX_J1708 66
58 #define canTRANSCEIVER_TYPE_LINX_K 68
59 #define canTRANSCEIVER_TYPE_LINX_SWC 70
60 #define canTRANSCEIVER_TYPE_LINX_LS 72
61 
68 #define EEPROM_OP_MODE_NONE 0x00
69 #define EEPROM_OP_MODE_J1587_NORMAL 0x01
70 #define EEPROM_OP_MODE_J1587_NODE 0x02
71 
78 #define j1587FLAG_CHECKSUM 0x80
79 #define j1587FLAG_FRAMEDELAY 0x40
80 #define j1587FLAG_BYTEDELAY 0x20
81 #define j1587FLAG_STOPBIT 0x10
82 #define j1587FLAG_OVERRUN 0x08
83 
90 typedef enum {
91  j1587OK = 0,
115 } J1587Status;
121 #define J1587LIB_VERSION 1
122 
123 // sizeof(J1587MessageInfo) should be 16
124 #include <pshpack1.h>
125 
126 
127 
135 typedef struct {
139  unsigned char version;
140 
144  unsigned char flags;
145 
151  unsigned char frameDelay;
152 
153  union {
158  unsigned char checkSum;
162  unsigned char retries;
163  };
164 
169  unsigned long timestamp;
170 
175  unsigned long frameLength;
176 
181  unsigned short bitrate;
182 
186  unsigned short reserved;
188 #include <poppack.h>
189 
190 
191 // Define J1587LIBAPI unless it's done already.
192 // (j1587lib.c provides its own definition of J1587LIBAPI before including this file.)
193 //
194 #ifndef J1587LIBAPI
195 # if defined(__BORLANDC__)
196 # define J1587LIBAPI __stdcall
197 # elif defined(_MSC_VER) || defined(__MWERKS__) || defined(__GNUC__)
198 # define J1587LIBAPI __stdcall
199 # endif
200 #endif
201 
202 #ifdef __cplusplus
203 extern "C" {
204 #endif
205 
210 void J1587LIBAPI j1587InitializeLibrary(void);
211 
212 
234 J1587Handle J1587LIBAPI j1587OpenChannel(int channel, int flags);
235 
241 #define J1587_NORMAL 1
242 #define J1587_NODE 2
243 #define J1587_READ 4
244 #define J1587_WRITE 8
245 
259 J1587Status J1587LIBAPI j1587Close(J1587Handle h);
260 
294  unsigned char *bootVerMajor,
295  unsigned char *bootVerMinor,
296  unsigned char *bootVerBuild,
297  unsigned char *appVerMajor,
298  unsigned char *appVerMinor,
299  unsigned char *appVerBuild);
300 
313 J1587Status J1587LIBAPI j1587SetBitrate(J1587Handle h, unsigned int bps);
314 
325 J1587Status J1587LIBAPI j1587BusOn(J1587Handle h);
326 
337 J1587Status J1587LIBAPI j1587BusOff(J1587Handle h);
338 
351 unsigned long J1587LIBAPI j1587ReadTimer(J1587Handle h);
352 
366 J1587Status J1587LIBAPI j1587WriteMessageWait(J1587Handle h, const void *msg,
367  unsigned int length,
368  unsigned int priority,
369  DWORD timeout);
370 
388 J1587Status J1587LIBAPI j1587ReadMessageWait(J1587Handle h, void *msg,
389  unsigned int *msgLength,
390  J1587MessageInfo *msgInfo,
391  DWORD timeout);
392 
409 J1587Status J1587LIBAPI j1587WriteSync (J1587Handle h,
410  J1587MessageInfo *msgInfo,
411  DWORD timeout);
412 
431 J1587Status J1587LIBAPI j1587Configure(J1587Handle h, unsigned int flags);
432 
433 
434 
440 #define J1587_INTER_CHAR_DELAY_MASK 0x0f
441 #define J1587_REPORT_BAD_CHECKSUM 0x10
442 #define J1587_REPORT_FRAME_DELAY 0x20
443 #define J1587_REPORT_CHAR_DELAY 0x40
444 
457 J1587Status J1587LIBAPI j1587GetCanHandle(J1587Handle h, unsigned int *canHandle);
458 
459 #ifdef __cplusplus
460 }
461 #endif
462 
463 #endif // __J1587LIB_H
Definition: j1587lib.h:135
unsigned long frameLength
Definition: j1587lib.h:175
DeviceIOControl failed; use Win32 GetLastError()
Definition: j1587lib.h:109
The license is not valid.
Definition: j1587lib.h:111
unsigned char version
Definition: j1587lib.h:139
J1587Handle j1587OpenChannel(int channel, int flags)
J1587Status j1587BusOn(J1587Handle h)
Timeout occurred.
Definition: j1587lib.h:101
unsigned short bitrate
Definition: j1587lib.h:181
Out of memory.
Definition: j1587lib.h:99
Library not initialized.
Definition: j1587lib.h:102
J1587Status j1587WriteSync(J1587Handle h, J1587MessageInfo *msgInfo, DWORD timeout)
unsigned char frameDelay
Definition: j1587lib.h:151
J1587Status j1587ReadMessageWait(J1587Handle h, void *msg, unsigned int *msgLength, J1587MessageInfo *msgInfo, DWORD timeout)
Access denied.
Definition: j1587lib.h:113
J1587Status j1587BusOff(J1587Handle h)
J1587Status j1587GetFirmwareVersion(J1587Handle h, unsigned char *bootVerMajor, unsigned char *bootVerMinor, unsigned char *bootVerBuild, unsigned char *appVerMajor, unsigned char *appVerMinor, unsigned char *appVerBuild)
Error in parameter.
Definition: j1587lib.h:97
Definition: j1587lib.h:105
J1587Status j1587Configure(J1587Handle h, unsigned int flags)
There was an error response from the J1587 interface.
Definition: j1587lib.h:106
void j1587InitializeLibrary(void)
No channels avaliable.
Definition: j1587lib.h:100
Definition: j1587lib.h:93
Definition: j1587lib.h:95
J1587Status j1587SetBitrate(J1587Handle h, unsigned int bps)
The J1587 interface response wasn&#39;t the expected one.
Definition: j1587lib.h:107
Definition: j1587lib.h:94
CAN driver type not supported.
Definition: j1587lib.h:108
Can&#39;t get handle.
Definition: j1587lib.h:103
J1587Status
Definition: j1587lib.h:90
Function not supported in this version.
Definition: j1587lib.h:114
unsigned char flags
Definition: j1587lib.h:144
J1587Status j1587Close(J1587Handle h)
No messages available.
Definition: j1587lib.h:92
Handle is invalid.
Definition: j1587lib.h:104
Internal error in the driver.
Definition: j1587lib.h:112
unsigned short reserved
Definition: j1587lib.h:186
unsigned long timestamp
Definition: j1587lib.h:169
unsigned long j1587ReadTimer(J1587Handle h)
Definition: j1587lib.h:96
OK - no error.
Definition: j1587lib.h:91
Specified hw not found.
Definition: j1587lib.h:98
J1587Status j1587WriteMessageWait(J1587Handle h, const void *msg, unsigned int length, unsigned int priority, DWORD timeout)
int J1587Handle
Definition: j1587lib.h:44
The card was removed or not inserted.
Definition: j1587lib.h:110