CANopen紧急报文EEC ER MEF定义

CANopenNode紧急报文EEC ER MEF定义

放个图

Emergency Error Codes(ECC,紧急报文错误代码):

/**
 * @defgroup CO_EM_errorCode_t CANopen Error code
 * @{
 *
 * Standard error codes according to CiA DS-301 and DS-401.
 */
#define CO_EMC_NO_ERROR                 0x0000U /**< 0x00xx error Reset or No Error */
#define CO_EMC_GENERIC                  0x1000U /**< 0x10xx Generic Error */
#define CO_EMC_CURRENT                  0x2000U /**< 0x20xx Current */
#define CO_EMC_CURRENT_INPUT            0x2100U /**< 0x21xx Current device input side */
#define CO_EMC_CURRENT_INSIDE           0x2200U /**< 0x22xx Current inside the device */
#define CO_EMC_CURRENT_OUTPUT           0x2300U /**< 0x23xx Current device output side */
#define CO_EMC_VOLTAGE                  0x3000U /**< 0x30xx Voltage */
#define CO_EMC_VOLTAGE_MAINS            0x3100U /**< 0x31xx Mains Voltage */
#define CO_EMC_VOLTAGE_INSIDE           0x3200U /**< 0x32xx Voltage inside the device */
#define CO_EMC_VOLTAGE_OUTPUT           0x3300U /**< 0x33xx Output Voltage */
#define CO_EMC_TEMPERATURE              0x4000U /**< 0x40xx Temperature */
#define CO_EMC_TEMP_AMBIENT             0x4100U /**< 0x41xx Ambient Temperature */
#define CO_EMC_TEMP_DEVICE              0x4200U /**< 0x42xx Device Temperature */
#define CO_EMC_HARDWARE                 0x5000U /**< 0x50xx Device Hardware */
#define CO_EMC_SOFTWARE_DEVICE          0x6000U /**< 0x60xx Device Software */
#define CO_EMC_SOFTWARE_INTERNAL        0x6100U /**< 0x61xx Internal Software */
#define CO_EMC_SOFTWARE_USER            0x6200U /**< 0x62xx User Software */
#define CO_EMC_DATA_SET                 0x6300U /**< 0x63xx Data Set */
#define CO_EMC_ADDITIONAL_MODUL         0x7000U /**< 0x70xx Additional Modules */
#define CO_EMC_MONITORING               0x8000U /**< 0x80xx Monitoring */
#define CO_EMC_COMMUNICATION            0x8100U /**< 0x81xx Communication */
#define CO_EMC_CAN_OVERRUN              0x8110U /**< 0x8110 CAN Overrun (Objects lost) */
#define CO_EMC_CAN_PASSIVE              0x8120U /**< 0x8120 CAN in Error Passive Mode */
#define CO_EMC_HEARTBEAT                0x8130U /**< 0x8130 Life Guard Error or Heartbeat Error */
#define CO_EMC_BUS_OFF_RECOVERED        0x8140U /**< 0x8140 recovered from bus off */
#define CO_EMC_CAN_ID_COLLISION         0x8150U /**< 0x8150 CAN-ID collision */
#define CO_EMC_PROTOCOL_ERROR           0x8200U /**< 0x82xx Protocol Error */
#define CO_EMC_PDO_LENGTH               0x8210U /**< 0x8210 PDO not processed due to length error */
#define CO_EMC_PDO_LENGTH_EXC           0x8220U /**< 0x8220 PDO length exceeded */
#define CO_EMC_DAM_MPDO                 0x8230U /**< 0x8230 DAM MPDO not processed destination object not available */
#define CO_EMC_SYNC_DATA_LENGTH         0x8240U /**< 0x8240 Unexpected SYNC data length */
#define CO_EMC_RPDO_TIMEOUT             0x8250U /**< 0x8250 RPDO timeout */
#define CO_EMC_EXTERNAL_ERROR           0x9000U /**< 0x90xx External Error */
#define CO_EMC_ADDITIONAL_FUNC          0xF000U /**< 0xF0xx Additional Functions */
#define CO_EMC_DEVICE_SPECIFIC          0xFF00U /**< 0xFFxx Device specific */

#define CO_EMC401_OUT_CUR_HI            0x2310U /**< 0x2310 DS401 Current at outputs too high (overload) */
#define CO_EMC401_OUT_SHORTED           0x2320U /**< 0x2320 DS401 Short circuit at outputs */
#define CO_EMC401_OUT_LOAD_DUMP         0x2330U /**< 0x2330 DS401 Load dump at outputs */
#define CO_EMC401_IN_VOLT_HI            0x3110U /**< 0x3110 DS401 Input voltage too high */
#define CO_EMC401_IN_VOLT_LOW           0x3120U /**< 0x3120 DS401 Input voltage too low */
#define CO_EMC401_INTERN_VOLT_HI        0x3210U /**< 0x3210 DS401 Internal voltage too high */
#define CO_EMC401_INTERN_VOLT_LO        0x3220U /**< 0x3220 DS401 Internal voltage too low */
#define CO_EMC401_OUT_VOLT_HIGH         0x3310U /**< 0x3310 DS401 Output voltage too high */
#define CO_EMC401_OUT_VOLT_LOW          0x3320U /**< 0x3320 DS401 Outp

旧版为结构体:

/**
 * CANopen Error code
 *
 * Standard error codes according to CiA DS-301 and DS-401.
 */
typedef enum {
    /** 0x00xx, error Reset or No Error */
    CO_EMC_NO_ERROR = 0x0000U,
    /** 0x10xx, Generic Error */
    CO_EMC_GENERIC = 0x1000U,
    /** 0x20xx, Current */
    CO_EMC_CURRENT = 0x2000U,
    /** 0x21xx, Current, device input side */
    CO_EMC_CURRENT_INPUT = 0x2100U,
    /** 0x22xx, Current inside the device */
    CO_EMC_CURRENT_INSIDE = 0x2200U,
    /** 0x23xx, Current, device output side */
    CO_EMC_CURRENT_OUTPUT = 0x2300U,
    /** 0x30xx, Voltage */
    CO_EMC_VOLTAGE = 0x3000U,
    /** 0x31xx, Mains Voltage */
    CO_EMC_VOLTAGE_MAINS = 0x3100U,
    /** 0x32xx, Voltage inside the device */
    CO_EMC_VOLTAGE_INSIDE = 0x3200U,
    /** 0x33xx, Output Voltage */
    CO_EMC_VOLTAGE_OUTPUT = 0x3300U,
    /** 0x40xx, Temperature */
    CO_EMC_TEMPERATURE = 0x4000U,
    /** 0x41xx, Ambient Temperature */
    CO_EMC_TEMP_AMBIENT = 0x4100U,
    /** 0x42xx, Device Temperature */
    CO_EMC_TEMP_DEVICE = 0x4200U,
    /** 0x50xx, Device Hardware */
    CO_EMC_HARDWARE = 0x5000U,
    /** 0x60xx, Device Software */
    CO_EMC_SOFTWARE_DEVICE = 0x6000U,
    /** 0x61xx, Internal Software */
    CO_EMC_SOFTWARE_INTERNAL = 0x6100U,
    /** 0x62xx, User Software */
    CO_EMC_SOFTWARE_USER = 0x6200U,
    /** 0x63xx, Data Set */
    CO_EMC_DATA_SET = 0x6300U,
    /** 0x70xx, Additional Modules */
    CO_EMC_ADDITIONAL_MODUL = 0x7000U,
    /** 0x80xx, Monitoring */
    CO_EMC_MONITORING = 0x8000U,
    /** 0x81xx, Communication */
    CO_EMC_COMMUNICATION = 0x8100U,
    /** 0x8110, CAN Overrun (Objects lost) */
    CO_EMC_CAN_OVERRUN = 0x8110U,
    /** 0x8120, CAN in Error Passive Mode */
    CO_EMC_CAN_PASSIVE = 0x8120U,
    /** 0x8130, Life Guard Error or Heartbeat Error */
    CO_EMC_HEARTBEAT = 0x8130U,
    /** 0x8140, recovered from bus off */
    CO_EMC_BUS_OFF_RECOVERED = 0x8140U,
    /** 0x8150, CAN-ID collision */
    CO_EMC_CAN_ID_COLLISION = 0x8150U,
    /** 0x82xx, Protocol Error */
    CO_EMC_PROTOCOL_ERROR = 0x8200U,
    /** 0x8210, PDO not processed due to length error */
    CO_EMC_PDO_LENGTH = 0x8210U,
    /** 0x8220, PDO length exceeded */
    CO_EMC_PDO_LENGTH_EXC = 0x8220U,
    /** 0x8230, DAM MPDO not processed, destination object not available */
    CO_EMC_DAM_MPDO = 0x8230U,
    /** 0x8240, Unexpected SYNC data length */
    CO_EMC_SYNC_DATA_LENGTH = 0x8240U,
    /** 0x8250, RPDO timeout */
    CO_EMC_RPDO_TIMEOUT = 0x8250U,
    /** 0x90xx, External Error */
    CO_EMC_EXTERNAL_ERROR = 0x9000U,
    /** 0xF0xx, Additional Functions */
    CO_EMC_ADDITIONAL_FUNC = 0xF000U,
    /** 0xFFxx, Device specific */
    CO_EMC_DEVICE_SPECIFIC = 0xFF00U,
    /** 0x2310, DS401, Current at outputs too high (overload) */
    CO_EMC401_OUT_CUR_HI = 0x2310U,
    /** 0x2320, DS401, Short circuit at outputs */
    CO_EMC401_OUT_SHORTED = 0x2320U,
    /** 0x2330, DS401, Load dump at outputs */
    CO_EMC401_OUT_LOAD_DUMP = 0x2330U,
    /** 0x3110, DS401, Input voltage too high */
    CO_EMC401_IN_VOLT_HI = 0x3110U,
    /** 0x3120, DS401, Input voltage too low */
    CO_EMC401_IN_VOLT_LOW = 0x3120U,
    /** 0x3210, DS401, Internal voltage too high */
    CO_EMC401_INTERN_VOLT_HI = 0x3210U,
    /** 0x3220, DS401, Internal voltage too low */
    CO_EMC401_INTERN_VOLT_LO = 0x3220U,
    /** 0x3310, DS401, Output voltage too high */
    CO_EMC401_OUT_VOLT_HIGH = 0x3310U,
    /** 0x3320, DS401, Output voltage too low */
    CO_EMC401_OUT_VOLT_LOW = 0x3320U,
} CO_EM_errorCode_t;

Error Register(ER,错误寄存器1001h):

/**
 * @defgroup CO_errorRegister_t CANopen Error register
 * @{
 *
 * Mandatory for CANopen, resides in object dictionary, index 0x1001.
 *
 * Error register is calculated from internal bitfield variable, critical bits. See @ref CO_EM_errorStatusBits_t and
 * @ref CO_STACK_CONFIG_EMERGENCY for error condition macros.
 *
 * Internal errors may prevent device to stay in NMT Operational state and changes may switch between the states. See
 * @ref CO_NMT_control_t for details.
 */
#define CO_ERR_REG_GENERIC_ERR          0x01U /**< bit 0, generic error */
#define CO_ERR_REG_CURRENT              0x02U /**< bit 1, current */
#define CO_ERR_REG_VOLTAGE              0x04U /**< bit 2, voltage */
#define CO_ERR_REG_TEMPERATURE          0x08U /**< bit 3, temperature */
#define CO_ERR_REG_COMMUNICATION        0x10U /**< bit 4, communication error */
#define CO_ERR_REG_DEV_PROFILE          0x20U /**< bit 5, device profile specific */
#define CO_ERR_REG_RESERVED             0x40U /**< bit 6, reserved (always 0) */
#define CO_ERR_REG_MANUFACTURER         0x80U /**< bit 7, manufa

旧版为结构体:

/**
 * CANopen Error register.
 *
 * Mandatory for CANopen, resides in object dictionary, index 0x1001.
 *
 * Error register is calculated from internal bitfield variable, critical bits.
 * See @ref CO_EM_errorStatusBits_t and @ref CO_STACK_CONFIG_EMERGENCY for error
 * condition macros.
 *
 * Internal errors may prevent device to stay in NMT Operational state and
 * changes may switch between the states. See @ref CO_NMT_control_t for details.
 */
typedef enum {
    CO_ERR_REG_GENERIC_ERR   = 0x01U, /**< bit 0, generic error */
    CO_ERR_REG_CURRENT       = 0x02U, /**< bit 1, current */
    CO_ERR_REG_VOLTAGE       = 0x04U, /**< bit 2, voltage */
    CO_ERR_REG_TEMPERATURE   = 0x08U, /**< bit 3, temperature */
    CO_ERR_REG_COMMUNICATION = 0x10U, /**< bit 4, communication error */
    CO_ERR_REG_DEV_PROFILE   = 0x20U, /**< bit 5, device profile specific */
    CO_ERR_REG_RESERVED      = 0x40U, /**< bit 6, reserved (always 0) */
    CO_ERR_REG_MANUFACTURER  = 0x80U  /**< bit 7, manufacturer specific */
} CO_errorRegister_t;

Manufacturer-specific Error Field(MEF,厂商自定义错误代码):

在CANopenNode中MEF对应名称为Error status bits

/**
 * @defgroup CO_EM_errorStatusBits_t Error status bits
 * @{
 *
 * Bits for internal indication of the error condition. Each error condition is specified by unique index from 0x00 up
 * to 0xFF.
 *
 * If specific error occurs in the stack or in the application, CO_errorReport() sets specific bit in the
 * _errorStatusBit_ variable from @ref CO_EM_t. If bit was already set, function returns without any action. Otherwise
 * it prepares emergency message.
 *
 * Maximum size (in bits) of the _errorStatusBit_ variable is specified by @ref CO_CONFIG_EM_ERR_STATUS_BITS_COUNT (set
 * to 10*8 bits by default). Stack uses first 6 bytes. Additional 4 bytes are pre-defined for manufacturer or device
 * specific error indications, by default.
 */
#define CO_EM_NO_ERROR                  0x00U /**< 0x00 Error Reset or No Error */
#define CO_EM_CAN_BUS_WARNING           0x01U /**< 0x01 communication info CAN bus warning limit reached */
#define CO_EM_RXMSG_WRONG_LENGTH        0x02U /**< 0x02 communication info Wrong data length of the received CAN message */
#define CO_EM_RXMSG_OVERFLOW            0x03U /**< 0x03 communication info Previous received CAN message wasn't processed */
#define CO_EM_RPDO_WRONG_LENGTH         0x04U /**< 0x04 communication info Wrong data length of received PDO */
#define CO_EM_RPDO_OVERFLOW             0x05U /**< 0x05 communication info Previous received PDO wasn't processed yet */
#define CO_EM_CAN_RX_BUS_PASSIVE        0x06U /**< 0x06 communication info CAN receive bus is passive */
#define CO_EM_CAN_TX_BUS_PASSIVE        0x07U /**< 0x07 communication info CAN transmit bus is passive */
#define CO_EM_NMT_WRONG_COMMAND         0x08U /**< 0x08 communication info Wrong NMT command received */
#define CO_EM_TIME_TIMEOUT              0x09U /**< 0x09 communication info TIME message timeout */
#define CO_EM_0A_unused                 0x0AU /**< 0x0A communication info (unused) */
#define CO_EM_0B_unused                 0x0BU /**< 0x0B communication info (unused) */
#define CO_EM_0C_unused                 0x0CU /**< 0x0C communication info (unused) */
#define CO_EM_0D_unused                 0x0DU /**< 0x0D communication info (unused) */
#define CO_EM_0E_unused                 0x0EU /**< 0x0E communication info (unused) */
#define CO_EM_0F_unused                 0x0FU /**< 0x0F communication info (unused) */

#define CO_EM_10_unused                 0x10U /**< 0x10 communication critical (unused) */
#define CO_EM_11_unused                 0x11U /**< 0x11 communication critical (unused) */
#define CO_EM_CAN_TX_BUS_OFF            0x12U /**< 0x12 communication critical CAN transmit bus is off */
#define CO_EM_CAN_RXB_OVERFLOW          0x13U /**< 0x13 communication critical CAN module receive buffer overflowed */
#define CO_EM_CAN_TX_OVERFLOW           0x14U /**< 0x14 communication critical CAN transmit buffer overflowed */
#define CO_EM_TPDO_OUTSIDE_WINDOW       0x15U /**< 0x15 communication critical TPDO is outside SYNC window */
#define CO_EM_16_unused                 0x16U /**< 0x16 communication critical (unused) */
#define CO_EM_RPDO_TIME_OUT             0x17U /**< 0x17 communication critical RPDO message timeout */
#define CO_EM_SYNC_TIME_OUT             0x18U /**< 0x18 communication critical SYNC message timeout */
#define CO_EM_SYNC_LENGTH               0x19U /**< 0x19 communication critical Unexpected SYNC data length */
#define CO_EM_PDO_WRONG_MAPPING         0x1AU /**< 0x1A communication critical Error with PDO mapping */
#define CO_EM_HEARTBEAT_CONSUMER        0x1BU /**< 0x1B communication critical Heartbeat consumer timeout */
#define CO_EM_HB_CONSUMER_REMOTE_RESET  0x1CU /**< 0x1C comm. critical Heartbeat consumer detected remote node reset */
#define CO_EM_SRDO_CONFIGURATION        0x1DU /**< 0x1D communication critical Error in SRDO configuration parameters */
#define CO_EM_1E_unused                 0x1EU /**< 0x1E communication critical (unused) */
#define CO_EM_1F_unused                 0x1FU /**< 0x1F communication critical (unused) */

#define CO_EM_EMERGENCY_BUFFER_FULL     0x20U /**< 0x20 generic info Emergency buffer is full or message wasn't sent */
#define CO_EM_21_unused                 0x21U /**< 0x21 generic info (unused) */
#define CO_EM_MICROCONTROLLER_RESET     0x22U /**< 0x22 generic info Microcontroller has just started */
#define CO_EM_23_unused                 0x23U /**< 0x23 generic info (unused) */
#define CO_EM_24_unused                 0x24U /**< 0x24 generic info (unused) */
#define CO_EM_25_unused                 0x25U /**< 0x25 generic info (unused) */
#define CO_EM_26_unused                 0x26U /**< 0x26 generic info (unused) */
#define CO_EM_NON_VOLATILE_AUTO_SAVE    0x27U /**< 0x27 generic info Automatic store to non-volatile memory failed */

#define CO_EM_WRONG_ERROR_REPORT        0x28U /**< 0x28 generic critical Wrong parameters to CO_errorReport() */
#define CO_EM_ISR_TIMER_OVERFLOW        0x29U /**< 0x29 generic critical Timer task has overflowed */
#define CO_EM_MEMORY_ALLOCATION_ERROR   0x2AU /**< 0x2A generic critical Unable to allocate memory for objects */
#define CO_EM_GENERIC_ERROR             0x2BU /**< 0x2B generic critical Generic error test usage */
#define CO_EM_GENERIC_SOFTWARE_ERROR    0x2CU /**< 0x2C generic critical Software error */
#define CO_EM_INCONSISTENT_OBJECT_DICT  0x2DU /**< 0x2D generic critical Object dict. does not match the software */
#define CO_EM_CALCULATION_OF_PARAMETERS 0x2EU /**< 0x2E generic critical Error in calculation of device parameters */
#define CO_EM_NON_VOLATILE_MEMORY       0x2FU /**< 0x2F generic critical Error with access to non volatile memory */

/**
 * 0x30+ manufacturer info or critical Error status buts free to use by manufacturer. By default bits 0x30..0x3F are set
 * as informational and bits 0x40..0x4F are set as critical. Manufacturer critical bits sets the error register as
 * specified by @ref CO_CONFIG_ERR_CONDITION_MANUFACTURER
 */
#define CO_EM_MANUFACTURER_START        0x30U
/** (@ref CO_CONFIG_EM_ERR_STATUS_BITS_COUNT - 1) largest value of the Error status bit. */
#define CO_EM_MANUFACTURER_END          (CO_CONFIG_EM_ERR_STATUS_BITS_COUNT - 1U)

旧版为结构体:

/**
 * Error status bits
 *
 * Bits for internal indication of the error condition. Each error condition is
 * specified by unique index from 0x00 up to 0xFF.
 *
 * If specific error occurs in the stack or in the application, CO_errorReport()
 * sets specific bit in the _errorStatusBit_ variable from @ref CO_EM_t. If bit
 * was already set, function returns without any action. Otherwise it prepares
 * emergency message.
 *
 * Maximum size (in bits) of the _errorStatusBit_ variable is specified by
 * @ref CO_CONFIG_EM_ERR_STATUS_BITS_COUNT (set to 10*8 bits by default). Stack
 * uses first 6 bytes. Additional 4 bytes are pre-defined for manufacturer
 * or device specific error indications, by default.
 */
typedef enum {
    /** 0x00, Error Reset or No Error */
    CO_EM_NO_ERROR                  = 0x00U,
    /** 0x01, communication, info, CAN bus warning limit reached */
    CO_EM_CAN_BUS_WARNING           = 0x01U,
    /** 0x02, communication, info, Wrong data length of the received CAN
     * message */
    CO_EM_RXMSG_WRONG_LENGTH        = 0x02U,
    /** 0x03, communication, info, Previous received CAN message wasn't
     * processed yet */
    CO_EM_RXMSG_OVERFLOW            = 0x03U,
    /** 0x04, communication, info, Wrong data length of received PDO */
    CO_EM_RPDO_WRONG_LENGTH         = 0x04U,
    /** 0x05, communication, info, Previous received PDO wasn't processed yet */
    CO_EM_RPDO_OVERFLOW             = 0x05U,
    /** 0x06, communication, info, CAN receive bus is passive */
    CO_EM_CAN_RX_BUS_PASSIVE        = 0x06U,
    /** 0x07, communication, info, CAN transmit bus is passive */
    CO_EM_CAN_TX_BUS_PASSIVE        = 0x07U,
    /** 0x08, communication, info, Wrong NMT command received */
    CO_EM_NMT_WRONG_COMMAND         = 0x08U,
    /** 0x09, communication, info, TIME message timeout */
    CO_EM_TIME_TIMEOUT              = 0x09U,
    /** 0x0A, communication, info, (unused) */
    CO_EM_0A_unused                 = 0x0AU,
    /** 0x0B, communication, info, (unused) */
    CO_EM_0B_unused                 = 0x0BU,
    /** 0x0C, communication, info, (unused) */
    CO_EM_0C_unused                 = 0x0CU,
    /** 0x0D, communication, info, (unused) */
    CO_EM_0D_unused                 = 0x0DU,
    /** 0x0E, communication, info, (unused) */
    CO_EM_0E_unused                 = 0x0EU,
    /** 0x0F, communication, info, (unused) */
    CO_EM_0F_unused                 = 0x0FU,

    /** 0x10, communication, critical, (unused) */
    CO_EM_10_unused                 = 0x10U,
    /** 0x11, communication, critical, (unused) */
    CO_EM_11_unused                 = 0x11U,
    /** 0x12, communication, critical, CAN transmit bus is off */
    CO_EM_CAN_TX_BUS_OFF            = 0x12U,
    /** 0x13, communication, critical, CAN module receive buffer has
     * overflowed */
    CO_EM_CAN_RXB_OVERFLOW          = 0x13U,
    /** 0x14, communication, critical, CAN transmit buffer has overflowed */
    CO_EM_CAN_TX_OVERFLOW           = 0x14U,
    /** 0x15, communication, critical, TPDO is outside SYNC window */
    CO_EM_TPDO_OUTSIDE_WINDOW       = 0x15U,
    /** 0x16, communication, critical, (unused) */
    CO_EM_16_unused                 = 0x16U,
    /** 0x17, communication, critical, RPDO message timeout */
    CO_EM_RPDO_TIME_OUT             = 0x17U,
    /** 0x18, communication, critical, SYNC message timeout */
    CO_EM_SYNC_TIME_OUT             = 0x18U,
    /** 0x19, communication, critical, Unexpected SYNC data length */
    CO_EM_SYNC_LENGTH               = 0x19U,
    /** 0x1A, communication, critical, Error with PDO mapping */
    CO_EM_PDO_WRONG_MAPPING         = 0x1AU,
    /** 0x1B, communication, critical, Heartbeat consumer timeout */
    CO_EM_HEARTBEAT_CONSUMER        = 0x1BU,
    /** 0x1C, communication, critical, Heartbeat consumer detected remote node
     * reset */
    CO_EM_HB_CONSUMER_REMOTE_RESET  = 0x1CU,
    /** 0x1D, communication, critical, (unused) */
    CO_EM_1D_unused                 = 0x1DU,
    /** 0x1E, communication, critical, (unused) */
    CO_EM_1E_unused                 = 0x1EU,
    /** 0x1F, communication, critical, (unused) */
    CO_EM_1F_unused                 = 0x1FU,

    /** 0x20, generic, info, Emergency buffer is full, Emergency message wasn't
     * sent */
    CO_EM_EMERGENCY_BUFFER_FULL     = 0x20U,
    /** 0x21, generic, info, (unused) */
    CO_EM_21_unused                 = 0x21U,
    /** 0x22, generic, info, Microcontroller has just started */
    CO_EM_MICROCONTROLLER_RESET     = 0x22U,
    /** 0x23, generic, info, (unused) */
    CO_EM_23_unused                 = 0x23U,
    /** 0x24, generic, info, (unused) */
    CO_EM_24_unused                 = 0x24U,
    /** 0x25, generic, info, (unused) */
    CO_EM_25_unused                 = 0x25U,
    /** 0x26, generic, info, (unused) */
    CO_EM_26_unused                 = 0x26U,
    /** 0x27, generic, info, Automatic store to non-volatile memory failed */
    CO_EM_NON_VOLATILE_AUTO_SAVE    = 0x27U,

    /** 0x28, generic, critical, Wrong parameters to CO_errorReport() function*/
    CO_EM_WRONG_ERROR_REPORT        = 0x28U,
    /** 0x29, generic, critical, Timer task has overflowed */
    CO_EM_ISR_TIMER_OVERFLOW        = 0x29U,
    /** 0x2A, generic, critical, Unable to allocate memory for objects */
    CO_EM_MEMORY_ALLOCATION_ERROR   = 0x2AU,
    /** 0x2B, generic, critical, Generic error, test usage */
    CO_EM_GENERIC_ERROR             = 0x2BU,
    /** 0x2C, generic, critical, Software error */
    CO_EM_GENERIC_SOFTWARE_ERROR    = 0x2CU,
    /** 0x2D, generic, critical, Object dictionary does not match the software*/
    CO_EM_INCONSISTENT_OBJECT_DICT  = 0x2DU,
    /** 0x2E, generic, critical, Error in calculation of device parameters */
    CO_EM_CALCULATION_OF_PARAMETERS = 0x2EU,
    /** 0x2F, generic, critical, Error with access to non volatile device memory
     */
    CO_EM_NON_VOLATILE_MEMORY       = 0x2FU,

    /** 0x30+, manufacturer, info or critical, Error status buts, free to use by
     * manufacturer. By default bits 0x30..0x3F are set as informational and
     * bits 0x40..0x4F are set as critical. Manufacturer critical bits sets the
     * error register, as specified by @ref CO_CONFIG_ERR_CONDITION_MANUFACTURER
     */
    CO_EM_MANUFACTURER_START        = 0x30U,
    /** (@ref CO_CONFIG_EM_ERR_STATUS_BITS_COUNT - 1), largest value of the
     * Error status bit. */
    CO_EM_MANUFACTURER_END          = CO_CONFIG_EM_ERR_STATUS_BITS_COUNT - 1
} CO_EM_errorStatusBits_t;
### CANopen 紧急报文概述 紧急报文Emergency Message),作为CANopen协议的一部分,在CiA 301标准中有详细的定义[^1]。这类报文用于报告节点内部发生的错误条件或其他异常情况,具有最高的优先级。 #### 协议特性 紧急报文采用特定的消息ID结构来确保在网络中的快速传递。该消息ID由固定部分和可变的Node-ID组成,其中固定的高位部分标识这是一个紧急报文,而低位则是发送者的唯一地址。这种设计使得即使在一个繁忙的网络环境中也能迅速识别并处理这些重要的通知信息。 ```cpp // 定义紧急报文的COB-ID计算方式 uint32_t calculate_emergency_cob_id(uint8_t node_id){ return (0x80 << 7) | node_id; // 0x80表示这是紧急报文 } ``` #### 使用方法 当检测到任何可能导致操作失败的情况时,比如硬件故障、软件运行时错误等,节点应该立即发出紧急报文给整个网络内的所有监听者。为了做到这一点,开发者通常会在应用程序逻辑中加入监控机制,并在必要时候调用API函数触发紧急报文传输过程。 ```cpp void send_emergency_message(uint8_t error_code, uint8_t additional_info[]){ can_frame frame; frame.id = calculate_emergency_cob_id(local_node_id); frame.dlc = 8; // 紧急报文中包含额外的信息字段 // 设置具体的错误码和其他诊断数据 memcpy(frame.data, &error_code, sizeof(error_code)); memcpy(&frame.data[sizeof(error_code)], additional_info, sizeof(additional_info)); transmit_can_frame(&frame); } ``` #### 故障排查指南 对于接收到的每一个紧急报文,接收端应当记录下时间戳以及完整的payload内容以便后续分析。如果频繁收到来自同一节点的相同类型的报警,则可能意味着存在潜在的设计缺陷或者是外部干扰源影响到了系统的稳定性。此时建议采取如下措施: - 检查电源供应是否稳定; - 查看连接线路是否有破损或接触不良现象; - 更新固件版本至最新状态以修复已知漏洞; - 调整环境因素减少电磁兼容性问题带来的负面影响。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值