source: pacpussensors/trunk/CanGateway/driver/kvaser/linux/canstat.h@ 102

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

add include files for kvaser

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