/** * @file include/di/can/net.h * @brief DI-Net CAN network maintenance * @date Jul 12, 2016 * @author jjacobs * @copyright 2016 Dual Inventive Technology Centre B.V. * * raw */ #ifndef LIBDI_INCLUDE_DI_CAN_NET_H_ #define LIBDI_INCLUDE_DI_CAN_NET_H_ #include #include #include #include #include #include #include #include #include #include #include struct di_can_ctx; #ifdef __cplusplus extern "C" { #endif /** * Initialize the NET subsystem * @note May only be called once */ void di_can_net_init(struct di_can_ctx *ctx); /** * Periodic execution of the network subsystem (maintenance, follower-leader FSMs) */ void di_can_net_execute(struct di_can_ctx *ctx); /** * @name Locking (NET subsystem only) * @{ */ /** Lock the NET subsystem context */ void di_can_net_lock(struct di_can_net *ctx); /** Unlock the NET subsystem context */ void di_can_net_unlock(struct di_can_net *ctx); /** * @} */ /** * @name Reply messaging * @{ */ /** * Send the device:uid as reply or publish CAN message * @param ctx CAN context * @param uid The device:uid string * @param req Request to create the reply for (MAY NOT be NULL, else DNE_PARAM is returned) * @retval DNOK When device:uid is send, !DNOK otherwise. */ di_errno_t di_can_net_send_node_uid(struct di_can_ctx *ctx, const char uid[DI_DEVICE_UID_LEN], const struct di_can_msg *req); /** * @} */ /** * @name Publish messaging * { */ di_errno_t di_can_net_publish_node_error(struct di_can_ctx *ctx, const di_errno_t err); /** * @} */ /** * @name Serialize values into pre-allocated msg structures * @{ */ /** * Serialize node type and role struct */ void di_can_net_serialize_node_struct_type_role(struct di_can_msg *msg, const struct di_can_net_node *node); /** * Serialize node error */ void di_can_net_serialize_node_error(struct di_can_msg *msg, const di_errno_t err); /** @} */ /** * @name Deserialize values from received can messages * @{ */ /** * Deserialize node type and role struct */ di_errno_t di_can_net_deserialize_node_struct_type_role(struct di_can_net_node *node, const struct di_can_msg *msg); /** * Deserialize node error */ di_errno_t di_can_net_deserialize_node_error(di_errno_t *err, const struct di_can_msg *msg); /** @} */ #ifdef __cplusplus } #endif #endif /* LIBDI_INCLUDE_DI_CAN_NET_H_ */