added hw option, moved serial port mode to build configuration
This commit is contained in:
parent
9116052ecb
commit
f1dfe3708e
19
Kconfig
19
Kconfig
|
|
@ -15,7 +15,11 @@ menu "WebGUIApp"
|
||||||
config BOARD_HARDWARE_REVISION
|
config BOARD_HARDWARE_REVISION
|
||||||
int "Board hardware revision"
|
int "Board hardware revision"
|
||||||
range 1 5
|
range 1 5
|
||||||
default 1
|
default 1
|
||||||
|
|
||||||
|
config BOARD_HARDWARE_OPTION
|
||||||
|
string "Board hardware option"
|
||||||
|
default "Base version"
|
||||||
|
|
||||||
config APP_PROJECT_VER
|
config APP_PROJECT_VER
|
||||||
string "Device firmware version"
|
string "Device firmware version"
|
||||||
|
|
@ -814,6 +818,19 @@ menu "WebGUIApp"
|
||||||
help
|
help
|
||||||
Switch on bridge uart to mqtt, else uart operate same way as rest and mqtt data exchange
|
Switch on bridge uart to mqtt, else uart operate same way as rest and mqtt data exchange
|
||||||
|
|
||||||
|
choice WEBGUIAPP_UART_MODE
|
||||||
|
prompt "Serial port mode"
|
||||||
|
default WEBGUIAPP_UART_MODE_UART
|
||||||
|
help
|
||||||
|
Select serial port mode.
|
||||||
|
|
||||||
|
config WEBGUIAPP_UART_MODE_UART
|
||||||
|
bool "UART"
|
||||||
|
|
||||||
|
config WEBGUIAPP_UART_MODE_RS485
|
||||||
|
bool "RS485"
|
||||||
|
endchoice
|
||||||
|
|
||||||
config WEBGUIAPP_UART_BAUD_RATE
|
config WEBGUIAPP_UART_BAUD_RATE
|
||||||
int "UART communication speed"
|
int "UART communication speed"
|
||||||
range 1200 115200
|
range 1200 115200
|
||||||
|
|
|
||||||
|
|
@ -326,6 +326,17 @@ static void funct_cronrecs(char *argres, int rw)
|
||||||
|
|
||||||
//CRON implementation END
|
//CRON implementation END
|
||||||
|
|
||||||
|
static void funct_serial_mode(char *argres, int rw)
|
||||||
|
{
|
||||||
|
|
||||||
|
#ifdef CONFIG_WEBGUIAPP_UART_MODE_UART
|
||||||
|
snprintf(argres, VAR_MAX_VALUE_LENGTH, "\"UART\"");
|
||||||
|
#elif CONFIG_WEBGUIAPP_UART_MODE_RS485
|
||||||
|
snprintf(argres, VAR_MAX_VALUE_LENGTH, "\"RS485\"");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void funct_objsinfo(char *argres, int rw)
|
static void funct_objsinfo(char *argres, int rw)
|
||||||
{
|
{
|
||||||
|
|
@ -360,6 +371,7 @@ const rest_var_t SystemVariables[] =
|
||||||
|
|
||||||
{ 0, "model_name", CONFIG_DEVICE_MODEL_NAME, VAR_STRING, R, 1, 64 },
|
{ 0, "model_name", CONFIG_DEVICE_MODEL_NAME, VAR_STRING, R, 1, 64 },
|
||||||
{ 0, "hw_rev", ((int*) &hw_rev), VAR_INT, R, 1, 1024 },
|
{ 0, "hw_rev", ((int*) &hw_rev), VAR_INT, R, 1, 1024 },
|
||||||
|
{ 0, "hw_opt", CONFIG_BOARD_HARDWARE_OPTION, VAR_STRING, R, 1, 256 },
|
||||||
{ 0, "build_date", CONFIG_DEVICE_MODEL_NAME, VAR_STRING, R, 1, 64 },
|
{ 0, "build_date", CONFIG_DEVICE_MODEL_NAME, VAR_STRING, R, 1, 64 },
|
||||||
{ 0, "model_name", CONFIG_DEVICE_MODEL_NAME, VAR_STRING, R, 1, 64 },
|
{ 0, "model_name", CONFIG_DEVICE_MODEL_NAME, VAR_STRING, R, 1, 64 },
|
||||||
|
|
||||||
|
|
@ -481,7 +493,7 @@ const rest_var_t SystemVariables[] =
|
||||||
#ifdef CONFIG_WEBGUIAPP_UART_TRANSPORT_ENABLE
|
#ifdef CONFIG_WEBGUIAPP_UART_TRANSPORT_ENABLE
|
||||||
{ 0, "serial_enab", &SysConfig.serialSettings.Flags.IsSerialEnabled, VAR_BOOL, RW, 0, 1 },
|
{ 0, "serial_enab", &SysConfig.serialSettings.Flags.IsSerialEnabled, VAR_BOOL, RW, 0, 1 },
|
||||||
{ 0, "serial_bridge", &SysConfig.serialSettings.Flags.IsBridgeEnabled, VAR_BOOL, RW, 0, 1 },
|
{ 0, "serial_bridge", &SysConfig.serialSettings.Flags.IsBridgeEnabled, VAR_BOOL, RW, 0, 1 },
|
||||||
{ 0, "serial_mode", &SysConfig.serialSettings.Serialmode, VAR_INT, RW, 1, 2 },
|
{ 0, "serial_mode", &funct_serial_mode, VAR_FUNCT, R, 1, 2 },
|
||||||
{ 0, "serial_baud", &SysConfig.serialSettings.BaudRate, VAR_INT, RW, 1200, 4096000 },
|
{ 0, "serial_baud", &SysConfig.serialSettings.BaudRate, VAR_INT, RW, 1200, 4096000 },
|
||||||
{ 0, "serial_break", &SysConfig.serialSettings.InputBrake, VAR_INT, RW, 1, 50 },
|
{ 0, "serial_break", &SysConfig.serialSettings.InputBrake, VAR_INT, RW, 1, 50 },
|
||||||
{ 0, "serial_visible", (bool*) (&VAR_TRUE), VAR_BOOL, R, 0, 1 },
|
{ 0, "serial_visible", (bool*) (&VAR_TRUE), VAR_BOOL, R, 0, 1 },
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,7 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "webguiapp.h"
|
#include "webguiapp.h"
|
||||||
|
#include "driver/gpio.h"
|
||||||
|
|
||||||
#define TAG "serial_port"
|
#define TAG "serial_port"
|
||||||
#define UART_READ_TOUT (100) // 3.5T * 8 = 28 ticks, TOUT=3 -> ~24..33 ticks
|
#define UART_READ_TOUT (100) // 3.5T * 8 = 28 ticks, TOUT=3 -> ~24..33 ticks
|
||||||
|
|
@ -243,10 +244,11 @@ void InitSerialPort(void)
|
||||||
ESP_ERROR_CHECK(uart_set_pin(CONFIG_WEBGUIAPP_UART_PORT_NUM,
|
ESP_ERROR_CHECK(uart_set_pin(CONFIG_WEBGUIAPP_UART_PORT_NUM,
|
||||||
CONFIG_WEBGUIAPP_UART_TXD, CONFIG_WEBGUIAPP_UART_RXD, CONFIG_WEBGUIAPP_UART_RTS, -1));
|
CONFIG_WEBGUIAPP_UART_TXD, CONFIG_WEBGUIAPP_UART_RXD, CONFIG_WEBGUIAPP_UART_RTS, -1));
|
||||||
|
|
||||||
if (GetSysConf()->serialSettings.Serialmode == 2)
|
#ifdef CONFIG_WEBGUIAPP_UART_MODE_UART
|
||||||
ESP_ERROR_CHECK(uart_set_mode(CONFIG_WEBGUIAPP_UART_PORT_NUM, UART_MODE_RS485_HALF_DUPLEX));
|
ESP_ERROR_CHECK(uart_set_mode(CONFIG_WEBGUIAPP_UART_PORT_NUM, UART_MODE_UART));
|
||||||
else
|
#elif CONFIG_WEBGUIAPP_UART_MODE_RS485
|
||||||
ESP_ERROR_CHECK(uart_set_mode(CONFIG_WEBGUIAPP_UART_PORT_NUM, UART_MODE_UART));
|
ESP_ERROR_CHECK(uart_set_mode(CONFIG_WEBGUIAPP_UART_PORT_NUM, UART_MODE_RS485_HALF_DUPLEX));
|
||||||
|
#endif
|
||||||
|
|
||||||
ESP_ERROR_CHECK(uart_enable_rx_intr(CONFIG_WEBGUIAPP_UART_PORT_NUM));
|
ESP_ERROR_CHECK(uart_enable_rx_intr(CONFIG_WEBGUIAPP_UART_PORT_NUM));
|
||||||
ESP_ERROR_CHECK(uart_set_rx_timeout(CONFIG_WEBGUIAPP_UART_PORT_NUM, UART_READ_TOUT));
|
ESP_ERROR_CHECK(uart_set_rx_timeout(CONFIG_WEBGUIAPP_UART_PORT_NUM, UART_READ_TOUT));
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user