ark::canbus

Enums

Typedefs

Defined in “ark/canbus/canopen/sdo.hh”:

Variables

Defined in “ark/canbus/canopen.hh”:

  • constexpr uint32_t COB_FLAG_STANDARD= (0 « 29)

  • constexpr uint32_t COB_FLAG_EXTENDED= (1 « 29)

  • constexpr uint32_t COB_FLAG_RTR= (0 « 30)

  • constexpr uint32_t COB_FLAG_NO_RTR= (1 « 30)

  • constexpr uint32_t COB_FLAG_ENABLED= (0 « 31)

  • constexpr uint32_t COB_FLAG_DISABLED= (1 « 31)

  • constexpr size_t kEmcyHeaderSize= 3
    The mandatory leading EMCY bytes: two of error code, one of error register.

  • constexpr size_t kEmcyPayloadSize= 8
    The full size of an EMCY payload, header plus manufacturer specific bytes.

Defined in “ark/canbus/canopen/error_descriptions.hh”:

  • constexpr uint16_t kEmcyErrorResetCode= 0x0000
    The CiA 301 “error reset / no error” emergency code. A node sends this to report that it has cleared an error it previously reported.

Defined in “ark/canbus/canopen/node.hh”:

  • constexpr auto kHeartbeatPeriod= std::chrono::seconds(1)

  • constexpr size_t kEmcyEventCapacity= 16
    The number of emergency (EMCY) records a node will hold pending a call to CanOpenNode::pop_emcy_events(). Bounded so that a node stuck emitting EMCYs cannot grow memory without limit; sized to match the depth of object 0x1003, the “predefined error field” that CiA 301 has nodes keep for the same reason.

Defined in “ark/canbus/cia315_frames.hh”:

  • constexpr uint8_t CIA315_PREAMBLE_MAGIC= 0x55
    The ‘preamble’ magic bytes that begin each packet.

  • constexpr size_t CIA315_GENERIC_PAYLOAD_SIZE_MAX= 255
    The maximum payload size for a CIA315 generic frame.

Defined in “ark/canbus/testing/has_vcan.hh”:

  • constexpr const auto *const TEST_CANBUS_NAME= “ark_test_vcan0”
    Name for the magic CANbus name we use for testing.

Classes

Functions

Declared in “ark/canbus/can_csv_io.hh”:

  • std::string can_csv_header()
    Outputs the header for the CAN CSV format.

  • std::string to_csv_row(const std::string & channel_name, const CanPacket & packet)
    Converts the given CAN packet into a CSV row, suitable for parsing in other languages. This is a bit different then the generic CSV tool, in that it formats things in a way that is more usable.

Declared in “ark/canbus/canopen.hh”:

  • core::ByteBuffer encode_nmt_heartbeat(NmtStateCode state)
    Encodes the given state code into a CANopen packet, returning the contents in the given byte buffer.

  • NmtStateCode decode_nmt_heartbeat(const core::ByteBuffer & buffer)
    Decodes the given CANopen packet, as if it was an NMT heartbeat message.

  • uint8_t encode_nmt_heartbeat(void * destination, NmtStateCode state)
    Encodes the given NMT command into a CANopen packet. The data is written to the destination, and the size is returned.

  • uint8_t encode_nmt_command(void * destination, NmtCommandCode command, uint8_t node_id)
    Encodes the given NMT command into a CANopen packet. The data is written to the destination, and the size is returned.

  • NmtStateCode decode_nmt_heartbeat(const void * source, size_t source_length)
    Decodes the given CANopen packet, as if it was an NMT heartbeat message.

  • core::ByteBuffer encode_emcy(const EmergencyDataObject & object)
    Encodes the given EMCY data into specified packet.

  • uint8_t encode_emcy(void * destination, const EmergencyDataObject & object)
    Encodes the given EMCY data into the given destination, returning the number of bytes written. Destination must always be at least kEmcyPayloadSize bytes large.

  • EmergencyDataObject decode_emcy(const core::ByteBuffer & buffer)
    Decodes the given buffer into an EMCY. Throws if the buffer is shorter than kEmcyHeaderSize. Manufacturer specific bytes the producer did not send are left default constructed.

  • EmergencyDataObject decode_emcy(const void * source, size_t source_length)
    Decodes the given buffer into an SDO.

  • uint32_t encode_cob_id(FunctionCode function_code, uint32_t node_id)

  • uint32_t encode_cob_id(const CanOpenPacket & packet)

  • std::string to_str(const CanOpenPacket & packet)
    Emits a CanOpenPacket as a string suitable for printing on a single line.

  • CanOpenPacket decode_canopen_packet(uint32_t can_id, const void * source, size_t source_length, std::chrono::steady_clock::time_point receive_time)
    Decode the canopen packet.

  • CanOpenPacket decode_canopen_packet(const CanPacket & packet)

  • CanPacket encode_canopen_packet(const CanOpenPacket & canopen_packet)

Declared in “ark/canbus/canopen/bytes.hh”:

  • T as_type(const ark::core::ByteBuffer & buffer)

  • T as_type(const PdoResult & buffer)

  • T as_type(const SdoResult & buffer)

  • ark::core::ByteBuffer as_buffer(const T & value)

  • size_t unpack_buffer(const ark::core::ByteBuffer & buffer, Args &… args)

  • void unpack_buffer(const PdoResult & result, Args &… args)

  • void unpack_buffer(const SdoResult & result, Args &… args)

  • ark::core::ByteBuffer pack_buffer(const Args &… args)

Declared in “ark/canbus/canopen/encoder.hh”:

  • void decode(FunctionCode & code, uint32_t raw)

  • void encode(uint32_t & raw, const FunctionCode & code)

  • uint32_t encode(const FunctionCode & code)

  • void decode(NmtCommandCode & code, uint8_t raw)

  • void encode(uint8_t & raw, const NmtCommandCode & code)

  • uint8_t encode(const NmtCommandCode & code)

  • void decode(NmtStateCode & state, uint8_t raw)

  • void encode(uint8_t & raw, const NmtStateCode & state)

  • uint8_t encode(const NmtStateCode & state)

  • void decode(CommandSpecifier & cmd, uint8_t raw)

  • void encode(uint8_t & raw, const CommandSpecifier & cmd)

  • uint8_t encode(const CommandSpecifier & cmd)

  • void decode(ConsumerHeartbeat & heartbeat, uint32_t raw)

  • void encode(uint32_t & raw, const ConsumerHeartbeat & heartbeat)

  • uint32_t encode(const ConsumerHeartbeat & heartbeat)

Declared in “ark/canbus/canopen/error_descriptions.hh”:

  • const char * canopen_error_to_string(uint32_t code)
    Returns a human readable string for the given error description.

  • const char * canopen_emcy_error_to_string(uint16_t error_code)
    Returns a human readable string for the given emergency (EMCY) error code.

    CiA 301 assigns meaning to the high byte, which names the error class, and leaves the low byte to the device profile or the manufacturer. Codes with a well known exact meaning are described precisely; everything else falls back to its class.

  • std::string canopen_emcy_error_register_to_string(uint8_t error_register)
    Returns a human readable rendering of an emergency (EMCY) error register, which is the bitfield a node keeps in object 0x1001. Returns “None” when no bits are set.

Declared in “ark/canbus/cia315_frames.hh”:

Declared in “ark/canbus/sae_j1939.hh”:

  • void decode(SaeJ1939CanId & id, uint32_t canid)

  • void encode(uint32_t & canid, const SaeJ1939CanId & id)

Declared in “ark/canbus/testing/has_vcan.hh”:

  • bool has_vcan()
    Returns true if we have a vcan device, or false otherwise. If false, prints a warning message.