106 lines
4.4 KiB
C
Executable File
106 lines
4.4 KiB
C
Executable File
/**
|
|
* @file can/rpc.h
|
|
* @brief CAN RPC
|
|
* @date Aug 25, 2015
|
|
* @author rheijden
|
|
* @copyright 2015 Dual Inventive Technology Centre B.V.
|
|
*
|
|
* Descr
|
|
*/
|
|
#ifndef INCLUDE_DI_CAN_RPC_H_
|
|
#define INCLUDE_DI_CAN_RPC_H_
|
|
|
|
#include <stddef.h>
|
|
#include <stdint.h>
|
|
|
|
#include <di/types.h>
|
|
#include <di/can/defines.h>
|
|
#include <di/rpc/types.h>
|
|
#include <di/rpc/structures.h>
|
|
|
|
struct di_can_ctx;
|
|
struct di_can_msg;
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
di_errno_t di_can_rpc_send_device_info(struct di_can_ctx *ctx, enum di_can_transfertype ttype,
|
|
enum di_rpc_types type, const struct di_rpc_device_info *info, size_t len);
|
|
di_errno_t di_can_rpc_send_device_data(struct di_can_ctx *ctx, enum di_can_transfertype ttype,
|
|
enum di_rpc_types type, const struct di_rpc_device_data *data, size_t len);
|
|
di_errno_t di_can_rpc_send_info(struct di_can_ctx *ctx, enum di_can_transfertype ttype, enum di_rpc_types type,
|
|
const struct di_rpc_info *info, size_t len);
|
|
di_errno_t di_can_rpc_send_config_info(struct di_can_ctx *ctx, enum di_can_transfertype ttype,
|
|
enum di_rpc_types type, const struct di_rpc_config_info *info, size_t len);
|
|
di_errno_t di_can_rpc_send_data(struct di_can_ctx *ctx, enum di_can_transfertype ttype, enum di_rpc_types type,
|
|
const struct di_rpc_data *data, size_t len);
|
|
di_errno_t di_can_rpc_send_log(struct di_can_ctx *ctx, enum di_can_transfertype ttype, enum di_rpc_types type,
|
|
const struct di_rpc_log *log, size_t len);
|
|
di_errno_t di_can_rpc_send_device_ping(struct di_can_ctx *ctx, enum di_can_transfertype ttype);
|
|
|
|
/**
|
|
* Send di_errno_t map object as RPC message
|
|
* {
|
|
* "code" : DNE_OPNOTSUPP,
|
|
* "descr" : "Operation not supported"
|
|
* }
|
|
*/
|
|
di_errno_t di_can_rpc_send_errno(struct di_can_ctx *ctx, enum di_can_transfertype ttype,
|
|
enum di_rpc_types type, di_errno_t error);
|
|
|
|
di_errno_t di_can_rpc_send_device_errors(struct di_can_ctx *ctx, uint32_t dst_id, enum di_can_transfertype ttype);
|
|
|
|
di_errno_t di_can_rpc_pub_log_msg(struct di_can_ctx *ctx, enum di_rpc_types type, const char *msg);
|
|
|
|
di_errno_t di_can_rpc_deserialize_data(const struct di_can_msg *msg, struct di_rpc_data *data);
|
|
|
|
#ifndef __cplusplus
|
|
#define di_can_rpc_send(ctx, ttype, type, value, len) \
|
|
_Generic((value), \
|
|
const struct di_rpc_device_info * : di_can_rpc_send_device_info, \
|
|
struct di_rpc_device_info * : di_can_rpc_send_device_info, \
|
|
const struct di_rpc_device_data * : di_can_rpc_send_device_data, \
|
|
struct di_rpc_device_data * : di_can_rpc_send_device_data, \
|
|
const struct di_rpc_config_info * : di_can_rpc_send_config_info, \
|
|
struct di_rpc_config_info * : di_can_rpc_send_config_info, \
|
|
const struct di_rpc_info * : di_can_rpc_send_info, \
|
|
struct di_rpc_info * : di_can_rpc_send_info, \
|
|
const struct di_rpc_data * : di_can_rpc_send_data, \
|
|
struct di_rpc_data * : di_can_rpc_send_data, \
|
|
const struct di_rpc_log * : di_can_rpc_send_log, \
|
|
struct di_rpc_log * : di_can_rpc_send_log \
|
|
)(ctx, ttype, type, value, len)
|
|
#endif
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#ifdef __cplusplus
|
|
static inline di_errno_t di_can_rpc_send(struct di_can_ctx *ctx, enum di_can_transfertype ttype,
|
|
enum di_rpc_types type, const struct di_rpc_device_info *value,
|
|
size_t len) {
|
|
return di_can_rpc_send_device_info(ctx, ttype, type, value, len);
|
|
}
|
|
static inline di_errno_t di_can_rpc_send(struct di_can_ctx *ctx, enum di_can_transfertype ttype,
|
|
enum di_rpc_types type, const struct di_rpc_device_data *value,
|
|
size_t len) {
|
|
return di_can_rpc_send_device_data(ctx, ttype, type, value, len);
|
|
}
|
|
static inline di_errno_t di_can_rpc_send(struct di_can_ctx *ctx, enum di_can_transfertype ttype,
|
|
enum di_rpc_types type, const struct di_rpc_info *value, size_t len) {
|
|
return di_can_rpc_send_info(ctx, ttype, type, value, len);
|
|
}
|
|
static inline di_errno_t di_can_rpc_send(struct di_can_ctx *ctx, enum di_can_transfertype ttype,
|
|
enum di_rpc_types type, const struct di_rpc_data *value, size_t len) {
|
|
return di_can_rpc_send_data(ctx, ttype, type, value, len);
|
|
}
|
|
static inline di_errno_t di_can_rpc_send(struct di_can_ctx *ctx, enum di_can_transfertype ttype,
|
|
enum di_rpc_types type, const struct di_rpc_log *value, size_t len) {
|
|
return di_can_rpc_send_log(ctx, ttype, type, value, len);
|
|
}
|
|
#endif
|
|
|
|
#endif /* INCLUDE_DI_CAN_RPC_H_ */
|