source: pacpussensors/trunk/CanGateway/driver/kvaser/windows/canstat.h@ 134

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

move files in windows folder

File size: 19.5 KB
Line 
1/**
2 * \section LICENSE
3 * Copyright 1994-2013 by KVASER AB, SWEDEN
4 *
5 * WWW: http://www.kvaser.com
6 *
7 * This software is furnished under a license and may be used and copied
8 * only in accordance with the terms of such license.
9 *
10 * \section DESCRIPTION
11 *
12 * Definitions for the CANLIB API.
13 *
14 * \file canlib.h
15 * \author Kvaser AB
16 *
17 * \note MATLAB users on Windows: if you define WIN32_LEAN_AND_MEAN before
18 * including this file, you will see a lot less warnings.
19 *
20 * \defgroup General General
21 * \defgroup CAN CAN
22 * \defgroup ObjectBuffers Object buffers
23 * \win_start
24 * \defgroup TimeDomainHandling Time Domain Handling
25 * \defgroup NamedParameterSettings Named Parameter Settings
26 * \defgroup tScript t-script
27 * \win_end
28 */
29#ifndef _CANSTAT_H_
30#define _CANSTAT_H_
31
32//
33// Don't forget to update canGetErrorText in canlib.c if this is changed!
34//
35
36/**
37 * \name canERR_xxx
38 * \anchor canERR_xxx
39 *
40 * Generally, a return code greater than or equal to zero means success. A
41 * value less than zero means failure.
42 *
43 * You should avoid testing for a specific error code unless it is explicitly
44 * stated in the documentation for the API in question that this specific error
45 * code is returned. Instead, check if the error code is less than zero. Use
46 * \ref canGetErrorText() to obtain an error message suitable for a message to the
47 * user, or for a line in an error log file.
48 */
49typedef enum {
50 /**
51 * <b>Normal successful completion</b>; The driver is just fine, and really
52 * believes it carried out your command to everyone's satisfaction.
53 */
54 canOK = 0,
55 /**
56 * <b>Error in one or more parameters</b>; a parameter \ref canERR_xxx
57 * specified in the call was invalid, out of range, or so. This status code
58 * will also be returned when the call is not implemented.
59 */
60 canERR_PARAM = -1,
61 /**
62 * <b>There were no messages to read</b>; A function tried to read a message,
63 * but there was no message to read.
64 */
65 canERR_NOMSG = -2,
66 /**
67 * <b>Specified device or channel not found.</b> There is no hardware
68 * available that matches the given search criteria. For example, you may
69 * have specified \ref canOPEN_REQUIRE_EXTENDED but there's no controller
70 * capable of extended CAN. You may have specified a channel number that is
71 * out of the range for the hardware in question. You may have requested
72 * exclusive access to a channel, but the channel is already occupied.
73 */
74 canERR_NOTFOUND = -3,
75 /**
76 * <b>Out of memory</b>; A memory allocation failed.
77 */
78 canERR_NOMEM = -4,
79 /**
80 * <b>No channels available</b>; There is indeed hardware matching the
81 * criteria you specified, but there are no channels available, or the
82 * channel you specified is already occupied.
83 */
84 canERR_NOCHANNELS = -5,
85
86 canERR_INTERRUPTED = -6, ///< Interrupted by signals
87 /**
88 * <b>Timeout occurred</b>; A function waited for something to happen (for
89 * example, the arrival of a message), but that something didn't happen.
90 */
91 canERR_TIMEOUT = -7,
92 /**
93 * <b>The library is not initialized</b>; The driver is not
94 * initialized. \ref canInitializeLibrary() was probably not called?
95 */
96 canERR_NOTINITIALIZED = -8,
97 /**
98 * <b>Out of handles</b>; No handles are available inside canlib32. The
99 * application has too many handles open (i.e. has called \ref canOpenChannel() too
100 * many times, or there's a memory leak somewhere.)
101 *
102 * \note We are not talking about Windows handles here, it's CANLIB's own
103 * internal handles.
104 */
105 canERR_NOHANDLES = -9,
106 /**
107 * <b>Handle is invalid</b>; The CANLIB handle you specified (if the API call
108 * includes a handle) is not valid. Ensure you are passing the handle and
109 * not, for example, a channel number.
110 */
111 canERR_INVHANDLE = -10,
112 canERR_INIFILE = -11, ///< Error in the ini-file (16-bit only)
113 /**
114 * <b>Driver type not supported</b>; CAN driver mode is not supported by the
115 * present hardware.
116 */
117 canERR_DRIVER = -12,
118 /**
119 * <b>Transmit buffer overflow</b>; The transmit queue was full, so the
120 * message was dropped.
121 */
122 canERR_TXBUFOFL = -13,
123 canERR_RESERVED_1 = -14, ///< Reserved
124 /**
125 * <b>A hardware error has occurred</b>; Something probably related to the
126 * hardware happened. This could mean that the device does not respond (IRQ
127 * or address conflict?), or that the response was invalid or unexpected
128 * (faulty card?).
129 */
130 canERR_HARDWARE = -15,
131 /**
132 * <b>A driver DLL can't be found or loaded</b>; (One of) the DLL(s)
133 * specified in the registry failed to load. This could be a driver
134 * installation problem.
135 */
136 canERR_DYNALOAD = -16,
137 /**
138 * <b>A DLL seems to have wrong version</b>; DLL version mismatch. (One of)
139 * the DLL(s) specified in the registry is - probably - too old, or - less
140 * likely - too new.
141 */
142 canERR_DYNALIB = -17,
143 /**
144 * <b>Error when initializing a DLL</b>; Something failed when a device
145 * driver was being initialized. In other words, we can open the driver but
146 * it makes a lot of fuss about something we don't understand.
147 */
148 canERR_DYNAINIT = -18,
149 canERR_NOT_SUPPORTED = -19, ///< Operation not supported by hardware or firmware
150 canERR_RESERVED_5 = -20, ///< Reserved
151 canERR_RESERVED_6 = -21, ///< Reserved
152 canERR_RESERVED_2 = -22, ///< Reserved
153 /**
154 * <b>Can't find or load kernel driver</b>; A device driver (kernel mode
155 * driver for NT, VxD for W95/98) failed to load; or the DLL could not open
156 * the device. Privileges? Driver file missing?
157 */
158 canERR_DRIVERLOAD = -23,
159 /**
160 * <b>DeviceIOControl failed</b>; Use Win32 GetLastError() to learn what
161 * really happened.
162 */
163 canERR_DRIVERFAILED = -24,
164 canERR_NOCONFIGMGR = -25, ///< Can't find req'd config s/w (e.g. CS/SS)
165 canERR_NOCARD = -26, ///< The card was removed or not inserted
166 canERR_RESERVED_7 = -27, ///< Reserved
167 /**
168 * <b>Error (missing data) in the Registry</b>; A registry key is missing,
169 * invalid, malformed, has gone for lunch or what not. can_verify.exe might
170 * provide some insight.
171 */
172 canERR_REGISTRY = -28,
173 canERR_LICENSE = -29, ///< The license is not valid.
174 /**
175 * <b>Internal error in the driver</b>; Indicates an error condition in the
176 * driver or DLL, which couldn't be properly handled. Please contact the
177 * friendly support at support@kvaser.com.
178 */
179 canERR_INTERNAL = -30,
180 /**
181 * <b>Access denied</b>; This means that you tried to set the bit rate on a
182 * handle to which you haven't got init access or you tried to open a channel
183 * that already is open with init access. See \ref canOpenChannel() for more
184 * information about init access.
185 */
186 canERR_NO_ACCESS = -31,
187 /**
188 * <b>Not implemented</b>; The requested feature or function is not
189 * implemented in the device you are trying to use it on.
190 */
191 canERR_NOT_IMPLEMENTED = -32,
192 /**
193 * <b>Device File error</b>; An error has occured when trying to access a
194 * file on the device.
195 */
196 canERR_DEVICE_FILE = -33,
197 /**
198 * <b>Host File error</b>; An error has occured when trying to access a file on the host.
199 *
200 */
201 canERR_HOST_FILE = -34,
202 /**
203 * <b>Disk error</b>; A disk error has occurred. Verify that the disk is
204 * initialized.
205 */
206 canERR_DISK = -35,
207 /**
208 * <b>CRC error</b>; The CRC calculation did not match the expected result.
209 */
210 canERR_CRC = -36,
211 /**
212 * <b>Configuration Error</b>; The configuration is corrupt.
213 */
214 canERR_CONFIG = -37,
215 /**
216 * <b>Memo Error</b>; Other configuration error.
217 */
218 canERR_MEMO_FAIL = -38,
219 /**
220 * <b>Script Fail</b>; A script has failed.
221 *
222 * \note This code represents several different failures, for example:
223 * - Trying to load a corrupt file or not a .txe file
224 * - Trying to start a t script that has not been loaded
225 * - Trying to load a t script compiled with the wrong version of the t compiler
226 * - Trying to unload a t script that has not been stopped
227 * - Trying to use an envvar that does not exist
228 */
229 canERR_SCRIPT_FAIL = -39,
230
231 /**
232 * <b>The t script version dosen't match the version(s) that the device firmware supports.</b>;
233 */
234 canERR_SCRIPT_WRONG_VERSION = -40,
235
236
237 // The last entry - a dummy so we know where NOT to place a comma.
238 canERR__RESERVED = -41 ///< Reserved
239} canStatus;
240
241
242/**
243 * \name Convenience
244 * @{
245 */
246#define CANSTATUS_SUCCESS(X) ((X) == canOK)
247#define CANSTATUS_FAILURE(X) ((X) != canOK)
248/** @} */
249
250/**
251 * \name canEVENT_xxx WM__CANLIB notification codes
252 * \anchor canEVENT_xxx
253 * Appears in the notification \c WM__CANLIB message.
254 * @{
255 */
256#define canEVENT_RX 32000 ///< when the queue of received CAN messages goes from empty to non-empty
257#define canEVENT_TX 32001 ///< when a CAN message has been transmitted
258#define canEVENT_ERROR 32002 ///< when a CAN bus error is reported by the CAN controller
259#define canEVENT_STATUS 32003 ///< when the CAN controller changes state
260#define canEVENT_ENVVAR 32004 ///< An envvar changed
261# define canEVENT_BUSONOFF 32005 ///< Bus on/off status changed
262# define canEVENT_REMOVED 32006 ///< Device removed
263/** @} */
264
265/**
266 * \name canNOTIFY_xxx
267 * \anchor canNOTIFY_xxx
268 *
269 * These are notification codes used in calls to \ref canSetNotify() and \ref kvSetNotifyCallback().
270 *
271 * This can be \ref canNOTIFY_NONE (zero), meaning that no event notification is to
272 * occur, or a combination of any of the following constants
273 *
274 * @{
275 */
276#define canNOTIFY_NONE 0 ///< Turn notifications off.
277#define canNOTIFY_RX 0x0001 ///< CAN message reception notification
278#define canNOTIFY_TX 0x0002 ///< CAN message transmission notification
279#define canNOTIFY_ERROR 0x0004 ///< CAN bus error notification
280#define canNOTIFY_STATUS 0x0008 ///< CAN chip status change
281#define canNOTIFY_ENVVAR 0x0010 ///< An environment variable was changed by a script
282# define canNOTIFY_BUSONOFF 0x0020 ///< Notify on bus on/off status changed
283# define canNOTIFY_REMOVED 0x0040 ///< Notify on device removed
284/** @} */
285
286
287/**
288 * \ingroup InformationServices
289 * \name canSTAT_xxx
290 * \anchor canSTAT_xxx
291 *
292 * The following circuit status flags are returned by \ref canReadStatus(). Note
293 * that more than one flag might be set at any one time.
294 *
295 * \note Usually both \ref canSTAT_HW_OVERRUN and \ref canSTAT_SW_OVERRUN are set
296 * when overrun has occurred. This is because the kernel driver can't see the
297 * difference between a software overrun and a hardware overrun. So the code
298 * should always test for both types of overrun using the \ref canSTAT_OVERRUN
299 * "flag".
300 *
301 * @{
302 */
303#define canSTAT_ERROR_PASSIVE 0x00000001 ///< The circuit is error passive
304#define canSTAT_BUS_OFF 0x00000002 ///< The circuit is Off Bus
305#define canSTAT_ERROR_WARNING 0x00000004 ///< At least one error counter > 96
306#define canSTAT_ERROR_ACTIVE 0x00000008 ///< The circuit is error active.
307#define canSTAT_TX_PENDING 0x00000010 ///< There are messages pending transmission
308#define canSTAT_RX_PENDING 0x00000020 ///< There are messages in the receive buffer
309#define canSTAT_RESERVED_1 0x00000040
310#define canSTAT_TXERR 0x00000080 ///< There has been at least one TX error
311#define canSTAT_RXERR 0x00000100 ///< There has been at least one RX error of some sort
312#define canSTAT_HW_OVERRUN 0x00000200 ///< The has been at least one HW buffer overflow
313#define canSTAT_SW_OVERRUN 0x00000400 ///< The has been at least one SW buffer overflow
314#define canSTAT_OVERRUN (canSTAT_HW_OVERRUN | canSTAT_SW_OVERRUN) ///< For convenience.
315/** @} */
316
317/**
318 * \name Message information flags, < 0x100
319 * \anchor canMSG_xxx
320 *
321 * The following flags can be returned from \ref canRead() et al, or passed to
322 * \ref canWrite().
323 *
324 * All flags and/or combinations of them are meaningful for received messages.
325 *
326 * \ref canMSG_RTR, \ref canMSG_STD, \ref canMSG_EXT, \ref canMSG_WAKEUP and
327 * \ref canMSG_ERROR_FRAME are meaningful also for transmitted messages.
328 *
329 * @{
330 */
331#define canMSG_MASK 0x00ff ///< Used to mask the non-info bits
332#define canMSG_RTR 0x0001 ///< Message is a remote request
333#define canMSG_STD 0x0002 ///< Message has a standard ID
334#define canMSG_EXT 0x0004 ///< Message has an extended ID
335#define canMSG_WAKEUP 0x0008 ///< Message to be sent / was received in wakeup mode
336
337/**
338 * NERR was active during the message
339 *
340 * The NERR flag is set by the CAN transceiver when certain CAN bus wire faults
341 * occur, namely:
342 * \li CANH wire interrupted
343 * \li CANL wire interrupted
344 * \li CANH short-circuited to battery
345 * \li CANH short-circuited to VCC
346 * \li CANL short-circuited to ground
347 * \li CANH short-circuited to ground
348 * \li CANL short-circuited to battery
349 * \li CANL short-circuited to VCC
350 * \li CANL and CANH mutually short-circuited
351 *
352 * See the TJA1054 data sheet (available from Philips) for more detailed
353 * information.
354 */
355#define canMSG_NERR 0x0010
356#define canMSG_ERROR_FRAME 0x0020 ///< Message is an error frame
357#define canMSG_TXACK 0x0040 ///< Message is a TX ACK (msg is really sent)
358#define canMSG_TXRQ 0x0080 ///< Message is a TX REQUEST (msg is transfered to the chip)
359
360// qqq add documentation
361#define canFDMSG_MASK 0xff0000
362#define canFDMSG_EDL 0x010000 ///< Message is an FD message (CAN FD)
363#define canFDMSG_BRS 0x020000 ///< Message is sent/received with bit rate switch (CAN FD)
364#define canFDMSG_ESI 0x040000 ///< Sender of the message is in error passive mode (CAN FD)
365
366/** @} */
367
368/**
369 * \name Message error flags, >= 0x0100
370 * \anchor canMSGERR_xxx
371 *
372 * \note Not all hardware platforms can detect the difference between hardware
373 * overruns and software overruns, so your application should test for both
374 * conditions. You can use the symbol \ref canMSGERR_OVERRUN for this purpose.
375 *
376 * @{
377 */
378#define canMSGERR_MASK 0xff00 ///< Used to mask the non-error bits
379// 0x0100 reserved
380#define canMSGERR_HW_OVERRUN 0x0200 ///< HW buffer overrun
381#define canMSGERR_SW_OVERRUN 0x0400 ///< SW buffer overrun
382#define canMSGERR_STUFF 0x0800 ///< Stuff error
383#define canMSGERR_FORM 0x1000 ///< Form error
384#define canMSGERR_CRC 0x2000 ///< CRC error
385#define canMSGERR_BIT0 0x4000 ///< Sent dom, read rec
386#define canMSGERR_BIT1 0x8000 ///< Sent rec, read dom
387
388// Convenience values for the message error flags.
389#define canMSGERR_OVERRUN 0x0600 ///< Any overrun condition.
390#define canMSGERR_BIT 0xC000 ///< Any bit error.
391#define canMSGERR_BUSERR 0xF800 ///< Any RX error
392/** @} */
393
394/**
395 * \name canTRANSCEIVER_LINEMODE_xxx
396 * \anchor canTRANSCEIVER_LINEMODE_xxx
397 *
398 * The following values can be used with \ref canSetDriverMode() to set different
399 * driver (i.e. transceiver) modes. Use \ref canGetDriverMode() to obtain the
400 * current driver mode for a particular CAN channel.
401 * @{
402 */
403#define canTRANSCEIVER_LINEMODE_NA 0 ///< Not Affected/Not available.
404#define canTRANSCEIVER_LINEMODE_SWC_SLEEP 4 ///< SWC Sleep Mode.
405#define canTRANSCEIVER_LINEMODE_SWC_NORMAL 5 ///< SWC Normal Mode.
406#define canTRANSCEIVER_LINEMODE_SWC_FAST 6 ///< SWC High-Speed Mode.
407#define canTRANSCEIVER_LINEMODE_SWC_WAKEUP 7 ///< SWC Wakeup Mode.
408#define canTRANSCEIVER_LINEMODE_SLEEP 8 ///< Sleep mode for those supporting it.
409#define canTRANSCEIVER_LINEMODE_NORMAL 9 ///< Normal mode (the inverse of sleep mode) for those supporting it.
410#define canTRANSCEIVER_LINEMODE_STDBY 10 ///< Standby for those who support it
411#define canTRANSCEIVER_LINEMODE_TT_CAN_H 11 ///< Truck & Trailer: operating mode single wire using CAN high
412#define canTRANSCEIVER_LINEMODE_TT_CAN_L 12 ///< Truck & Trailer: operating mode single wire using CAN low
413#define canTRANSCEIVER_LINEMODE_OEM1 13 ///< Reserved for OEM apps
414#define canTRANSCEIVER_LINEMODE_OEM2 14 ///< Reserved for OEM apps
415#define canTRANSCEIVER_LINEMODE_OEM3 15 ///< Reserved for OEM apps
416#define canTRANSCEIVER_LINEMODE_OEM4 16 ///< Reserved for OEM apps
417
418/** @} */
419
420/**
421 * \anchor canTRANSCEIVER_RESNET_xxx
422 *
423 */
424#define canTRANSCEIVER_RESNET_NA 0
425#define canTRANSCEIVER_RESNET_MASTER 1
426#define canTRANSCEIVER_RESNET_MASTER_STBY 2
427#define canTRANSCEIVER_RESNET_SLAVE 3
428
429/**
430 * \name Transceiver (logical) types
431 * \anchor canTRANSCEIVER_TYPE_xxx
432 *
433 * The following constants can be returned from \ref canGetChannelData(), using the
434 * \ref canCHANNELDATA_TRANS_TYPE item code. They identify the bus transceiver
435 * type for the channel specified in the call to \ref canGetChannelData.
436 *
437 * \note They indicate a hardware type, but not necessarily a specific circuit
438 * or product.
439 *
440 * @{
441 */
442// Also see src\include\hwnames.h and registered document 048.
443#define canTRANSCEIVER_TYPE_UNKNOWN 0 ///< Unknown or undefined
444#define canTRANSCEIVER_TYPE_251 1 ///< 82c251
445#define canTRANSCEIVER_TYPE_252 2 ///< 82c252, TJA1053, TJA1054
446#define canTRANSCEIVER_TYPE_DNOPTO 3 ///< Optoisolated 82C251
447#define canTRANSCEIVER_TYPE_W210 4 ///<
448#define canTRANSCEIVER_TYPE_SWC_PROTO 5 ///< AU5790 prototype
449#define canTRANSCEIVER_TYPE_SWC 6 ///< AU5790
450#define canTRANSCEIVER_TYPE_EVA 7 ///<
451#define canTRANSCEIVER_TYPE_FIBER 8 ///< 82c251 with fibre extension
452#define canTRANSCEIVER_TYPE_K251 9 ///< K-line + 82c251
453#define canTRANSCEIVER_TYPE_K 10 ///< K-line, without CAN
454#define canTRANSCEIVER_TYPE_1054_OPTO 11 ///< TJA1054 with optical isolation
455#define canTRANSCEIVER_TYPE_SWC_OPTO 12 ///< AU5790 with optical isolation
456#define canTRANSCEIVER_TYPE_TT 13 ///< B10011S Truck-And-Trailer
457#define canTRANSCEIVER_TYPE_1050 14 ///< TJA1050
458#define canTRANSCEIVER_TYPE_1050_OPTO 15 ///< TJA1050 with optical isolation
459#define canTRANSCEIVER_TYPE_1041 16 ///< TJA1041
460#define canTRANSCEIVER_TYPE_1041_OPTO 17 ///< TJA1041 with optical isolation
461#define canTRANSCEIVER_TYPE_RS485 18 ///< RS485 (i.e. J1708)
462#define canTRANSCEIVER_TYPE_LIN 19 ///< LIN
463#define canTRANSCEIVER_TYPE_KONE 20 ///< KONE
464#define canTRANSCEIVER_TYPE_CANFD 22 ///< CAN-FD
465#define canTRANSCEIVER_TYPE_LINX_LIN 64
466#define canTRANSCEIVER_TYPE_LINX_J1708 66
467#define canTRANSCEIVER_TYPE_LINX_K 68
468#define canTRANSCEIVER_TYPE_LINX_SWC 70
469#define canTRANSCEIVER_TYPE_LINX_LS 72
470/** @} */
471
472#endif
Note: See TracBrowser for help on using the repository browser.