131 lines
4.1 KiB
C
Executable File
131 lines
4.1 KiB
C
Executable File
/**
|
|
* @file include/di/can/raw.h
|
|
* @brief raw
|
|
* @date Sep 2, 2015
|
|
* @author rheijden
|
|
* @copyright 2015 Dual Inventive Technology Centre B.V.
|
|
*
|
|
* raw
|
|
*/
|
|
#ifndef LIBDI_INCLUDE_DI_CAN_RAW_H_
|
|
#define LIBDI_INCLUDE_DI_CAN_RAW_H_
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
#include <stddef.h>
|
|
#include <stdint.h>
|
|
#include <stdbool.h>
|
|
|
|
#include <di/types.h>
|
|
#include <di/device.h>
|
|
#include <di/constants/device/battery.h>
|
|
#include <di/can.h>
|
|
#include <di/can/raw/dtypes.h>
|
|
#include <di/can/raw/structures.h>
|
|
|
|
/**
|
|
* Send raw message buffer
|
|
* @param ctx CAN driver context
|
|
* @param dst_id Destination NodeID
|
|
* @param ttype Transfer type
|
|
* @param dtype Message data type
|
|
* @param ptype Message payload type
|
|
* @param buf Buffer to write into
|
|
* @param size Size of buffer
|
|
* @return DNOK on success
|
|
*/
|
|
di_errno_t di_can_raw_send(struct di_can_ctx *ctx, uint32_t dst_id, enum di_can_transfertype ttype,
|
|
enum di_can_raw_dtypes dtype, enum di_can_ptypes ptype, const void *buf, size_t size);
|
|
|
|
/**
|
|
* Send NULL terminated device:uid
|
|
* @param ctx CAN context
|
|
* @param dst_id Destination NodeID
|
|
* @param ttype Transfer type
|
|
* @param uid device:uid (must be null terminated 32 character string)
|
|
*/
|
|
di_errno_t di_can_raw_send_device_uid(struct di_can_ctx *ctx, uint32_t dst_id, enum di_can_transfertype ttype,
|
|
const char uid[33]);
|
|
|
|
/**
|
|
* Send raw messge hardware version
|
|
* @param ctx CAN context
|
|
* @param dst_id Destination NodeID
|
|
* @param ttype Transfer type
|
|
* @param hw_version (string)
|
|
*/
|
|
di_errno_t di_can_raw_send_device_hw_version(struct di_can_ctx *ctx, uint32_t dst_id, enum di_can_transfertype ttype,
|
|
const char hw_version[DI_DEVICE_HW_VERSION_LEN]);
|
|
|
|
/**
|
|
* Send raw messge firmware version
|
|
* @param ctx CAN context
|
|
* @param dst_id Destination NodeID
|
|
* @param ttype Transfer type
|
|
* @param fw_version (string)
|
|
*/
|
|
di_errno_t di_can_raw_send_device_fw_version(struct di_can_ctx *ctx, uint32_t dst_id, enum di_can_transfertype ttype,
|
|
const char fw_version[DI_DEVICE_FW_VERSION_LEN]);
|
|
|
|
/**
|
|
* Send raw message
|
|
* @param msg CAN message
|
|
* @param type Message type
|
|
* @return DNOK on success
|
|
*/
|
|
di_errno_t di_can_raw_send_msg(struct di_can_msg **msg, enum di_can_raw_dtypes type);
|
|
|
|
/**
|
|
* Request the DNCM CAN-bus leader (broadcast) for communication status reporting
|
|
* @param ctx CAN context
|
|
* @param on_change Report status on change (false is disabled)
|
|
* @param interval_sec Report interval in seconds (0 is disabled)
|
|
* @param timeout_ms CAN request-reply timeout in milliseconds
|
|
*/
|
|
di_errno_t di_can_raw_req_dncm_communication_status(struct di_can_ctx *ctx,
|
|
const bool on_change,
|
|
const uint16_t interval_sec,
|
|
const uint32_t timeout_ms);
|
|
|
|
/** DNCM communication status request deserialize
|
|
* @param on_change Report status on change (false is disabled)
|
|
* @param interval_sec Report interval in seconds (0 is disabled)
|
|
* @retval DNOK when deserialize is ok
|
|
*/
|
|
di_errno_t di_can_raw_deserialize_dncm_communication_status_req(bool *on_change, uint16_t *interval_ms,
|
|
const struct di_can_msg *msg);
|
|
|
|
/**
|
|
* DNCM GPS sensor update and reporting interval configuration
|
|
* @param ctx CAN context
|
|
* @param interval_sec Update and reporting interval in seconds
|
|
* @param timeout_ms CAN request-reply timeout in milliseconds
|
|
*/
|
|
di_errno_t di_can_raw_req_dncm_gps_sensor_set_interval(struct di_can_ctx *ctx, const uint16_t interval_sec,
|
|
const uint32_t timeout_ms);
|
|
|
|
/**
|
|
* DNCM GPS sensor trigger update
|
|
* @param ctx CAN context
|
|
* @param timeout_ms CAN request-reply timeout in milliseconds
|
|
* @retval DNOK when GPS sensor is scheduled for update and DI-Net RPC send (as CAN device:uid)
|
|
*/
|
|
di_errno_t di_can_raw_req_dncm_gps_sensor_trigger(struct di_can_ctx *ctx, const uint32_t timeout_ms);
|
|
|
|
/**
|
|
* publish Battery status over CAN bus
|
|
* @param ctx CAN context
|
|
* @param state Battery state (always battery #1)
|
|
*
|
|
* @return di_errno_t DNOK if no errors, other if otherwise
|
|
*/
|
|
di_errno_t di_can_raw_serialize_publish_battery_state(struct di_can_ctx *ctx, enum di_device_battery_state state);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif /* LIBDI_INCLUDE_DI_CAN_RAW_H_ */
|