34 lines
872 B
C
34 lines
872 B
C
#ifndef __waterlevel_h
|
|
#define __waterlevel_h
|
|
|
|
#include <zephyr/modbus/modbus.h>
|
|
|
|
#define MODBUS_THREAD_STACK_SIZE (512)
|
|
#define MODBUS_THREAD_PRIORITY (6)
|
|
#define MODBUS_MSGQ_SIZE (5)
|
|
|
|
const static struct modbus_iface_param client_param = {
|
|
.mode = MODBUS_MODE_RTU,
|
|
.rx_timeout = 50000,
|
|
.serial = {
|
|
.baud = 9600,
|
|
.parity = UART_CFG_PARITY_NONE,
|
|
},
|
|
};
|
|
|
|
typedef struct {
|
|
uint8_t reg;
|
|
uint8_t command; // 0 for set, 1 for get
|
|
int16_t value;
|
|
} modbus_register_t;
|
|
|
|
int mb_init_client(void);
|
|
int mb_read_holding_registers(int node, uint16_t reg_addr, uint16_t *data, size_t len);
|
|
int mb_read_water_level(double *mb_read_water_level);
|
|
int mb_read_water_level_mm(int *mb_read_water_level_mm);
|
|
int mb_read_minimum_mm(int *mb_read_minimum);
|
|
int mb_read_maximum_mm(int *mb_read_maximum);
|
|
int mb_write_minimum_mm(int minimum);
|
|
int mb_write_maximum_mm(int maximum);
|
|
|
|
#endif |