Modbus RTU - Multi Devices
This commit is contained in:
53
main/config_store.h
Normal file
53
main/config_store.h
Normal file
@@ -0,0 +1,53 @@
|
||||
#ifndef CONFIG_STORE_H
|
||||
#define CONFIG_STORE_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#define DEVICE_NAME_MAX_LEN 32
|
||||
#define DEVICE_CSV_MAX_LEN 64
|
||||
#define MAX_VIRTUAL_DEVICES 3
|
||||
|
||||
typedef enum
|
||||
{
|
||||
MB_RTU_PARITY_NONE = 0,
|
||||
MB_RTU_PARITY_EVEN,
|
||||
MB_RTU_PARITY_ODD
|
||||
} modbus_rtu_parity_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32_t baud_rate;
|
||||
modbus_rtu_parity_t parity;
|
||||
uint8_t stop_bits; /* 1 or 2 */
|
||||
uint8_t uart_num; /* UART_NUM_0/1/2 as integer */
|
||||
int tx_pin;
|
||||
int rx_pin;
|
||||
int de_pin; /* -1 if unused / auto-direction shield */
|
||||
} modbus_rtu_settings_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t device_count;
|
||||
} modbus_settings_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
bool enabled;
|
||||
uint8_t unit_id;
|
||||
char name[DEVICE_NAME_MAX_LEN];
|
||||
char csv[DEVICE_CSV_MAX_LEN];
|
||||
} virtual_device_settings_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
modbus_rtu_settings_t rtu;
|
||||
modbus_settings_t modbus;
|
||||
virtual_device_settings_t devices[MAX_VIRTUAL_DEVICES];
|
||||
} device_config_t;
|
||||
|
||||
void config_store_set_defaults(device_config_t *cfg);
|
||||
bool config_store_load(const char *filename, device_config_t *cfg);
|
||||
|
||||
#endif /* CONFIG_STORE_H */
|
||||
Reference in New Issue
Block a user