src.dualinventive.com/dinet/libdi_fw/include/di_fw/can/gateways.h

42 lines
1.3 KiB
C

/**
* @file di_fw/can/gateways.h
* @brief CAN-bus gateways discovery and caching
* @copyright 2016 Dual Inventive Technology Centre B.V.
*/
#ifndef INCLUDE_DI_FW_CAN_GATEWAYS_H_
#define INCLUDE_DI_FW_CAN_GATEWAYS_H_
#include <di/can.h>
#ifndef DI_FW_CAN_GATEWAYS_LEN
#error DI_FW_CAN_GATEWAYS_LEN not defined in board.h
#endif
/**
* CAN-bus (DNCM) gateways cache for device:uid
*/
struct di_fw_can_gateways {
size_t pos;
struct di_can_msg *msg[DI_FW_CAN_GATEWAYS_LEN];
const char *device_uid[DI_FW_CAN_GATEWAYS_LEN];
};
/**
* Discover the CAN-bus gateways and cache the corresponding device:uid
* When a gateway is not present or timeouts on device:uid request it is
* set to DI_DEVICE_UID_DEFAULT_VALUE.
* @remark The device:uid reside as CAN message data, then need to be freed after use with
* di_fw_can_gateways_free.
* @param gw Gateways cache
* @return DNOK when all gateways device:uid are cached
* @return DNE_TIMEOUT when one or more gateways didn't respond
*/
di_errno_t di_fw_can_gateways_discover(struct di_can_ctx *ctx, struct di_fw_can_gateways *gw);
/**
* Free the device:uid which reside in the gateways CAN reply messages
*/
void di_fw_can_gateways_free(struct di_fw_can_gateways *gw);
#endif /* INCLUDE_DI_FW_CAN_GATEWAYS_H_ */