#ifndef LIBDI_INCLUDE_DI_CAN_DEFINES_H_ #define LIBDI_INCLUDE_DI_CAN_DEFINES_H_ #include /** Message timeouts for use with garbage collection */ enum di_can_timeout { DI_CAN_TIMEOUT_GC_SKIP = 0U, /**< Skip frame/message in garbage collection */ DI_CAN_TIMEOUT_GC_IMMEDIATE = UINT64_MAX /**< Garbage collect frame/message on next run */ }; /** Garbage collection */ enum di_can_gc { DI_CAN_GC_ALL = 0, /** Garbage collect all messages */ DI_CAN_GC_SINGLE = 1 /** Garbage collect only single message */ }; /** CAN message types */ enum di_can_msgtype { DI_CAN_MSGTYPE_RAW = 0U, /**< Raw message type (e.g struct or buffer) */ DI_CAN_MSGTYPE_RPC = 1U, /**< DI-Net RPC */ DI_CAN_MSGTYPE_NET = 2U, /**< Network monitoring and maintenance */ DI_CAN_MSGTYPE_LOG = 3U, /**< Logging facility */ DI_CAN_MSGTYPE_ANY = UINT_MAX /**< Any CAN message */ }; /** Reserved CAN node id */ enum di_can_nodeids { DI_CAN_NODEID_UNSET = 0x00000000, DI_CAN_NODEID_BROADCAST = 0xffffffff }; /** CAN transfer types */ enum di_can_transfertype { DI_CAN_TRANSFERTYPE_REPLY_ERR = 0, /**< Reply error */ DI_CAN_TRANSFERTYPE_REPLY = 1, /**< Reply */ DI_CAN_TRANSFERTYPE_REQUEST = 2, /**< Request */ DI_CAN_TRANSFERTYPE_PUBLISH = 3 /**< Publish */ }; /** CAN frame index */ enum di_can_frame_id { DI_CAN_FRAME_ID_FIRST = 0, DI_CAN_FRAME_ID_SRC_DST_NODEID = DI_CAN_FRAME_ID_FIRST, DI_CAN_FRAME_ID_MFT_METADATA = 1, DI_CAN_FRAME_ID_PAYLOAD_FIRST = 2, DI_CAN_FRAME_ID_MAX = 511, /* Frame index 2^9 - 1 */ DI_CAN_FRAME_ID_MAX_COUNT = 512 /* Frame index 2^9 */ }; /** CAN transaction id */ enum di_can_transaction_id { DI_CAN_TRANSACTION_FIRST = 0, /**< First valid transaction id */ DI_CAN_TRANSACTION_LAST = 15 /**< Last valid transaction id (2^4 - 1)*/ }; /** CAN last frame flag */ enum di_can_last_frame { DI_CAN_LAST_FRAME_FALSE = 0, /**< Last frame false marker */ DI_CAN_LAST_FRAME_TRUE = 1 /**< Last frame true marker */ }; #define DI_CAN_FRAME_SIZE 8U /**< CAN max frame size */ #define DI_CAN_FRAME_SIZE_MASK (DI_CAN_FRAME_SIZE - 1) /**< CAN frame max size mask */ enum di_can_msg_size { DI_CAN_MSG_SIZE_SFT = DI_CAN_FRAME_SIZE, DI_CAN_MSG_SIZE_MFT = (DI_CAN_FRAME_SIZE * 2) }; #define DI_CAN_MSG_DATA_PAYLOAD_OFFSET (DI_CAN_FRAME_SIZE * 2) /** Maximum frame/payload message size in bytes * * Maximum can frame data size: 512 frames * 8 bytes per frame * * Minus two frames when sending MFT (16 bytes) * * SFT, Source and Destination Node ID * * MFT-metadata **/ #define DI_CAN_FRAMING_SIZE_MAX ((DI_CAN_FRAME_SIZE * DI_CAN_FRAME_ID_MAX_COUNT) - (DI_CAN_FRAME_SIZE * 2)) #endif /* LIBDI_INCLUDE_DI_CAN_DEFINES_H_ */