canstat.h
Go to the documentation of this file.
1 /*
2  * Copyright 2023 by Kvaser AB, Molndal, Sweden
3  * http://www.kvaser.com
4  *
5  * This software is dual licensed under the following two licenses:
6  * BSD-new and GPLv2. You may use either one. See the included
7  * COPYING file for details.
8  *
9  * License: BSD-new
10  * ==============================================================================
11  * Redistribution and use in source and binary forms, with or without
12  * modification, are permitted provided that the following conditions are met:
13  * * Redistributions of source code must retain the above copyright
14  * notice, this list of conditions and the following disclaimer.
15  * * Redistributions in binary form must reproduce the above copyright
16  * notice, this list of conditions and the following disclaimer in the
17  * documentation and/or other materials provided with the distribution.
18  * * Neither the name of the <organization> nor the
19  * names of its contributors may be used to endorse or promote products
20  * derived from this software without specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
29  * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
30  * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32  * POSSIBILITY OF SUCH DAMAGE.
33  *
34  *
35  * License: GPLv2
36  * ==============================================================================
37  * This program is free software; you can redistribute it and/or modify
38  * it under the terms of the GNU General Public License as published by
39  * the Free Software Foundation; either version 2 of the License, or
40  * (at your option) any later version.
41  *
42  * This program is distributed in the hope that it will be useful,
43  * but WITHOUT ANY WARRANTY; without even the implied warranty of
44  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
45  * GNU General Public License for more details.
46  *
47  * You should have received a copy of the GNU General Public License
48  * along with this program; if not, write to the Free Software
49  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
50  *
51  *
52  * IMPORTANT NOTICE:
53  * ==============================================================================
54  * This source code is made available for free, as an open license, by Kvaser AB,
55  * for use with its applications. Kvaser AB does not accept any liability
56  * whatsoever for any third party patent or other immaterial property rights
57  * violations that may result from any usage of this source code, regardless of
58  * the combination of source code and various applications that it can be used
59  * in, or with.
60  *
61  * -----------------------------------------------------------------------------
62  */
63 
64 #ifndef _CANSTAT_H_
65 #define _CANSTAT_H_
66 
80 //
81 // Don't forget to update canGetErrorText in canlib.c if this is changed!
82 //
83 typedef enum {
88  canOK = 0,
119 
121 
147 
158 
187 
201 
208 
240  canERR_DISK = -35,
244  canERR_CRC = -36,
264 
269 
274 
279 
284 
290 
296 
302 
309 
315 
316  // The last entry - a dummy so we know where NOT to place a comma.
318 } canStatus;
325 #define CANSTATUS_SUCCESS(X) ((X) == canOK)
326 #define CANSTATUS_FAILURE(X) ((X) != canOK)
327 
335 #define canEVENT_RX 32000
336 #define canEVENT_TX 32001
337 #define canEVENT_ERROR 32002
338 #define canEVENT_STATUS 32003
339 
345 #define canEVENT_ENVVAR 32004
346 #define canEVENT_BUSONOFF 32005
347 
360 #define canNOTIFY_NONE 0
361 #define canNOTIFY_RX 0x0001
362 #define canNOTIFY_TX 0x0002
363 #define canNOTIFY_ERROR 0x0004
364 #define canNOTIFY_STATUS 0x0008
365 #define canNOTIFY_ENVVAR 0x0010
366 
367 #define canNOTIFY_BUSONOFF 0x0020
368 
387 #define canSTAT_ERROR_PASSIVE 0x00000001
388 #define canSTAT_BUS_OFF 0x00000002
389 #define canSTAT_ERROR_WARNING 0x00000004
390 #define canSTAT_ERROR_ACTIVE 0x00000008
391 #define canSTAT_TX_PENDING 0x00000010
392 #define canSTAT_RX_PENDING 0x00000020
393 #define canSTAT_RESERVED_1 0x00000040
394 #define canSTAT_TXERR 0x00000080
395 #define canSTAT_RXERR 0x00000100
396 #define canSTAT_HW_OVERRUN 0x00000200
397 #define canSTAT_SW_OVERRUN 0x00000400
398 #define canSTAT_OVERRUN (canSTAT_HW_OVERRUN | canSTAT_SW_OVERRUN)
399 
418 #define canMSG_MASK 0x00ff
419 #define canMSG_RTR 0x0001
420 
421 
426 #define canMSG_STD 0x0002
427 #define canMSG_EXT 0x0004
428 #define canMSG_WAKEUP 0x0008
429 
430 
448 #define canMSG_NERR 0x0010
449 #define canMSG_ERROR_FRAME 0x0020
450 #define canMSG_TXACK 0x0040
451 #define canMSG_TXRQ 0x0080
452 #define canMSG_DELAY_MSG 0x0100
453 
454 #define canMSG_LOCAL_TXACK 0x10000000
455 
456 // single shot flags:
457 #define canMSG_SINGLE_SHOT 0x1000000
458 #define canMSG_TXNACK 0x2000000
459 #define canMSG_ABL 0x4000000
460 
461 
471 #define canFDMSG_MASK 0xff0000
472 #define canFDMSG_EDL 0x010000
473 #define canFDMSG_FDF 0x010000
474 #define canFDMSG_BRS 0x020000
475 #define canFDMSG_ESI 0x040000
476 
490 #define canMSGERR_MASK 0xff00
491 // 0x0100 reserved
492 #define canMSGERR_HW_OVERRUN 0x0200
493 #define canMSGERR_SW_OVERRUN 0x0400
494 #define canMSGERR_STUFF 0x0800
495 #define canMSGERR_FORM 0x1000
496 #define canMSGERR_CRC 0x2000
497 #define canMSGERR_BIT0 0x4000
498 #define canMSGERR_BIT1 0x8000
499 
500 // Convenience values for the message error flags.
501 #define canMSGERR_OVERRUN 0x0600
502 #define canMSGERR_BIT 0xC000
503 #define canMSGERR_BUSERR 0xF800
504 
505 
507 #define CAN_ERR_FLAG 0x20000000U /* error message frame, */
509 #define ERRORFRAME_TYPE_INDEX 2;
510 #define ERRORFRAME_LOCATION_INDEX 3;
511 
512 #define CAN_ERR_DLC 8 /* dlc for error message frames */
513 
514 /* error class (mask) in can_id */
515 #define CAN_ERR_TX_TIMEOUT 0x00000001U /* TX timeout (by netdevice driver) */
516 #define CAN_ERR_LOSTARB 0x00000002U /* lost arbitration / data[0] */
517 #define CAN_ERR_CRTL 0x00000004U /* controller problems / data[1] */
518 #define CAN_ERR_PROT 0x00000008U /* protocol violations / data[2..3] */
519 #define CAN_ERR_TRX 0x00000010U /* transceiver status / data[4] */
520 #define CAN_ERR_ACK 0x00000020U /* received no ACK on transmission */
521 #define CAN_ERR_BUSOFF 0x00000040U /* bus off */
522 #define CAN_ERR_BUSERROR 0x00000080U /* bus error (may flood!) */
523 #define CAN_ERR_RESTARTED 0x00000100U /* controller restarted */
524 #define CAN_ERR_CNT 0x00000200U /* TX error counter / data[6] */
525  /* RX error counter / data[7] */
526 
527 /* arbitration lost in bit ... / data[0] */
528 #define CAN_ERR_LOSTARB_UNSPEC 0x00 /* unspecified */
529  /* else bit number in bitstream */
530 
531 /* error status of CAN-controller / data[1] */
532 #define CAN_ERR_CRTL_UNSPEC 0x00 /* unspecified */
533 #define CAN_ERR_CRTL_RX_OVERFLOW 0x01 /* RX buffer overflow */
534 #define CAN_ERR_CRTL_TX_OVERFLOW 0x02 /* TX buffer overflow */
535 #define CAN_ERR_CRTL_RX_WARNING 0x04 /* reached warning level for RX errors */
536 #define CAN_ERR_CRTL_TX_WARNING 0x08 /* reached warning level for TX errors */
537 #define CAN_ERR_CRTL_RX_PASSIVE 0x10 /* reached error passive status RX */
538 #define CAN_ERR_CRTL_TX_PASSIVE 0x20 /* reached error passive status TX */
539  /* (at least one error counter exceeds */
540  /* the protocol-defined level of 127) */
541 #define CAN_ERR_CRTL_ACTIVE 0x40 /* recovered to error active state */
542 
543 /* error in CAN protocol (type) / data[2] */
544 #define CAN_ERR_PROT_UNSPEC 0x00 /* unspecified */
545 #define CAN_ERR_PROT_BIT 0x01 /* single bit error */
546 #define CAN_ERR_PROT_FORM 0x02 /* frame format error */
547 #define CAN_ERR_PROT_STUFF 0x04 /* bit stuffing error */
548 #define CAN_ERR_PROT_BIT0 0x08 /* unable to send dominant bit */
549 #define CAN_ERR_PROT_BIT1 0x10 /* unable to send recessive bit */
550 #define CAN_ERR_PROT_OVERLOAD 0x20 /* bus overload */
551 #define CAN_ERR_PROT_ACTIVE 0x40 /* active error announcement */
552 #define CAN_ERR_PROT_TX 0x80 /* error occurred on transmission */
553 
554 /* error in CAN protocol (location) / data[3] */
555 #define CAN_ERR_PROT_LOC_UNSPEC 0x00 /* unspecified */
556 #define CAN_ERR_PROT_LOC_SOF 0x03 /* start of frame */
557 #define CAN_ERR_PROT_LOC_ID28_21 0x02 /* ID bits 28 - 21 (SFF: 10 - 3) */
558 #define CAN_ERR_PROT_LOC_ID20_18 0x06 /* ID bits 20 - 18 (SFF: 2 - 0 )*/
559 #define CAN_ERR_PROT_LOC_SRTR 0x04 /* substitute RTR (SFF: RTR) */
560 #define CAN_ERR_PROT_LOC_IDE 0x05 /* identifier extension */
561 #define CAN_ERR_PROT_LOC_ID17_13 0x07 /* ID bits 17-13 */
562 #define CAN_ERR_PROT_LOC_ID12_05 0x0F /* ID bits 12-5 */
563 #define CAN_ERR_PROT_LOC_ID04_00 0x0E /* ID bits 4-0 */
564 #define CAN_ERR_PROT_LOC_RTR 0x0C /* RTR */
565 #define CAN_ERR_PROT_LOC_RES1 0x0D /* reserved bit 1 */
566 #define CAN_ERR_PROT_LOC_RES0 0x09 /* reserved bit 0 */
567 #define CAN_ERR_PROT_LOC_DLC 0x0B /* data length code */
568 #define CAN_ERR_PROT_LOC_DATA 0x0A /* data section */
569 #define CAN_ERR_PROT_LOC_CRC_SEQ 0x08 /* CRC sequence */
570 #define CAN_ERR_PROT_LOC_CRC_DEL 0x18 /* CRC delimiter */
571 #define CAN_ERR_PROT_LOC_ACK 0x19 /* ACK slot */
572 #define CAN_ERR_PROT_LOC_ACK_DEL 0x1B /* ACK delimiter */
573 #define CAN_ERR_PROT_LOC_EOF 0x1A /* end of frame */
574 #define CAN_ERR_PROT_LOC_INTERM 0x12 /* intermission */
575 
576 /* error status of CAN-transceiver / data[4] */
577 /* CANH CANL */
578 #define CAN_ERR_TRX_UNSPEC 0x00 /* 0000 0000 */
579 #define CAN_ERR_TRX_CANH_NO_WIRE 0x04 /* 0000 0100 */
580 #define CAN_ERR_TRX_CANH_SHORT_TO_BAT 0x05 /* 0000 0101 */
581 #define CAN_ERR_TRX_CANH_SHORT_TO_VCC 0x06 /* 0000 0110 */
582 #define CAN_ERR_TRX_CANH_SHORT_TO_GND 0x07 /* 0000 0111 */
583 #define CAN_ERR_TRX_CANL_NO_WIRE 0x40 /* 0100 0000 */
584 #define CAN_ERR_TRX_CANL_SHORT_TO_BAT 0x50 /* 0101 0000 */
585 #define CAN_ERR_TRX_CANL_SHORT_TO_VCC 0x60 /* 0110 0000 */
586 #define CAN_ERR_TRX_CANL_SHORT_TO_GND 0x70 /* 0111 0000 */
587 #define CAN_ERR_TRX_CANL_SHORT_TO_CANH 0x80 /* 1000 0000 */
588 
589 /* data[5] is reserved (do not use) */
590 
591 /* TX error counter / data[6] */
592 /* RX error counter / data[7] */
593 
594 #define canMSG_RESERVED_FOR_EXTENDING 0x80000000
595 
596 
607 #define canTRANSCEIVER_LINEMODE_NA 0
608 #define canTRANSCEIVER_LINEMODE_SWC_SLEEP 4
609 #define canTRANSCEIVER_LINEMODE_SWC_NORMAL 5
610 #define canTRANSCEIVER_LINEMODE_SWC_FAST 6
611 #define canTRANSCEIVER_LINEMODE_SWC_WAKEUP 7
612 #define canTRANSCEIVER_LINEMODE_SLEEP 8
613 #define canTRANSCEIVER_LINEMODE_NORMAL 9
614 #define canTRANSCEIVER_LINEMODE_STDBY 10
615 #define canTRANSCEIVER_LINEMODE_TT_CAN_H 11
616 #define canTRANSCEIVER_LINEMODE_TT_CAN_L 12
617 #define canTRANSCEIVER_LINEMODE_OEM1 13
618 #define canTRANSCEIVER_LINEMODE_OEM2 14
619 #define canTRANSCEIVER_LINEMODE_OEM3 15
620 #define canTRANSCEIVER_LINEMODE_OEM4 16
621 
622 
628 #define canTRANSCEIVER_RESNET_NA 0
629 #define canTRANSCEIVER_RESNET_MASTER 1
630 #define canTRANSCEIVER_RESNET_MASTER_STBY 2
631 #define canTRANSCEIVER_RESNET_SLAVE 3
632 
646 // Also see src\include\hwnames.h and registered document 048.
647 #define canTRANSCEIVER_TYPE_UNKNOWN 0
648 #define canTRANSCEIVER_TYPE_251 1
649 #define canTRANSCEIVER_TYPE_252 2
650 #define canTRANSCEIVER_TYPE_DNOPTO 3
651 #define canTRANSCEIVER_TYPE_W210 4
652 #define canTRANSCEIVER_TYPE_SWC_PROTO 5
653 #define canTRANSCEIVER_TYPE_SWC 6
654 #define canTRANSCEIVER_TYPE_EVA 7
655 #define canTRANSCEIVER_TYPE_FIBER 8
656 #define canTRANSCEIVER_TYPE_K251 9
657 #define canTRANSCEIVER_TYPE_K 10
658 #define canTRANSCEIVER_TYPE_1054_OPTO 11
659 #define canTRANSCEIVER_TYPE_SWC_OPTO 12
660 #define canTRANSCEIVER_TYPE_TT 13
661 #define canTRANSCEIVER_TYPE_1050 14
662 #define canTRANSCEIVER_TYPE_1050_OPTO 15
663 #define canTRANSCEIVER_TYPE_1041 16
664 #define canTRANSCEIVER_TYPE_1041_OPTO 17
665 #define canTRANSCEIVER_TYPE_RS485 18
666 #define canTRANSCEIVER_TYPE_LIN 19
667 #define canTRANSCEIVER_TYPE_KONE 20
668 #define canTRANSCEIVER_TYPE_CANFD 22
669 #define canTRANSCEIVER_TYPE_CANFD_LIN 24
670 #define canTRANSCEIVER_TYPE_CANFD_SIC 26
671 #define canTRANSCEIVER_TYPE_LINX_LIN 64
672 #define canTRANSCEIVER_TYPE_LINX_J1708 66
673 #define canTRANSCEIVER_TYPE_LINX_K 68
674 #define canTRANSCEIVER_TYPE_LINX_SWC 70
675 #define canTRANSCEIVER_TYPE_LINX_LS 72
676 
678 #endif
Definition: canstat.h:220
Definition: canstat.h:308
Definition: canstat.h:252
canStatus
Definition: canstat.h:83
Definition: canstat.h:164
Definition: canstat.h:88
Definition: canstat.h:130
Definition: canstat.h:108
Definition: canstat.h:283
Definition: canstat.h:176
Reserved.
Definition: canstat.h:157
Definition: canstat.h:273
Operation not supported by hardware or firmware.
Definition: canstat.h:183
Definition: canstat.h:192
Definition: canstat.h:139
Definition: canstat.h:197
Definition: canstat.h:213
Definition: canstat.h:244
Reserved.
Definition: canstat.h:317
Definition: canstat.h:248
Reserved.
Definition: canstat.h:185
Definition: canstat.h:278
Definition: canstat.h:156
Definition: canstat.h:94
Definition: canstat.h:182
Definition: canstat.h:263
Reserved.
Definition: canstat.h:200
Definition: canstat.h:268
The license is not valid.
Definition: canstat.h:207
Error in the ini-file (16-bit only)
Definition: canstat.h:146
Definition: canstat.h:118
Definition: canstat.h:112
Definition: canstat.h:301
Definition: canstat.h:230
Definition: canstat.h:225
Definition: canstat.h:295
Reserved.
Definition: canstat.h:186
Definition: canstat.h:240
Definition: canstat.h:145
Definition: canstat.h:235
Definition: canstat.h:125
Definition: canstat.h:206
Definition: canstat.h:99
Interrupted by signals.
Definition: canstat.h:120
Reserved.
Definition: canstat.h:184
Definition: canstat.h:170
Definition: canstat.h:151
The card was removed or not inserted.
Definition: canstat.h:199
Definition: canstat.h:289
Definition: canstat.h:314
Can&#39;t find req&#39;d config s/w (e.g. CS/SS)
Definition: canstat.h:198