From 32a04e48f3b7da5fa5abcea5367a55daf77581f6 Mon Sep 17 00:00:00 2001 From: biver Date: Thu, 10 Nov 2022 00:39:18 +0500 Subject: [PATCH] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D1=8F=D0=B5=D0=BC=20=D0=B1=D0=B0=D0=B3=20=D1=81=20=D0=B2=D1=8B?= =?UTF-8?q?=D0=B1=D0=BE=D1=80=D0=BE=D0=BC=20=D0=B6=D0=B5=D0=BB=D0=B5=D0=B7?= =?UTF-8?q?=D0=BD=D0=BE=D0=B3=D0=BE=20UART=20=D0=B4=D0=BB=D1=8F=20ESP32?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/sensors/UART/Uart.cpp | 9 ++++----- src/modules/sensors/UART/modinfo.json | 2 ++ 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/modules/sensors/UART/Uart.cpp b/src/modules/sensors/UART/Uart.cpp index d25c542d..884c7938 100644 --- a/src/modules/sensors/UART/Uart.cpp +++ b/src/modules/sensors/UART/Uart.cpp @@ -13,9 +13,6 @@ class UART : public IoTItem { private: - int _tx; - int _rx; - int _speed; int _eventFormat = 0; // 0 - нет приема, 1 - json IoTM, 2 - Nextion #ifdef ESP8266 @@ -26,17 +23,19 @@ class UART : public IoTItem { public: UART(String parameters) : IoTItem(parameters) { + int _tx, _rx, _speed, _line; jsonRead(parameters, "tx", _tx); jsonRead(parameters, "rx", _rx); jsonRead(parameters, "speed", _speed); + jsonRead(parameters, "line", _line); jsonRead(parameters, "eventFormat", _eventFormat); #ifdef ESP8266 - myUART = _myUART = new SoftwareSerial(_tx, _rx); + myUART = _myUART = new SoftwareSerial(_rx, _tx); _myUART->begin(_speed); #endif #ifdef ESP32 - myUART = _myUART = new HardwareSerial(2); + myUART = _myUART = new HardwareSerial(_line); _myUART->begin(_speed, SERIAL_8N1, _rx, _tx); #endif } diff --git a/src/modules/sensors/UART/modinfo.json b/src/modules/sensors/UART/modinfo.json index f9e68cda..cc6a0999 100644 --- a/src/modules/sensors/UART/modinfo.json +++ b/src/modules/sensors/UART/modinfo.json @@ -11,6 +11,7 @@ "id": "u", "tx": 12, "rx": 13, + "line": 2, "speed": 9600, "eventFormat": 0 } @@ -35,6 +36,7 @@ "tx": "TX пин", "rx": "RX пин", "speed": "Скорость UART", + "line": "Актуально только для ESP32: номер линии hardUART. =2 rx=16 tx=17", "eventFormat": "Выбор формата обмена сообщениями с другими контроллерами. =0 - не указан формат, значит не следим за событиями, =1 - формат событий IoTM с использованием json, =2 - формат событий для Nextion отправка событий: ID.val=Value0xFF0xFF0xFF прием ордеров: ID=Value. Отправляться будут события тех элементов, которые имеют суффикс в ИД _val или _txt, которые влияют на передаваемый формат." }, "retInfo": "Содержит полученное последнее по UART сообщение.",