|
@@ -27,7 +27,7 @@
|
27
|
27
|
#define SML_BAUD 9600
|
28
|
28
|
#define SML_PARAM SWSERIAL_8N1
|
29
|
29
|
|
30
|
|
-static EspSoftwareSerial::UART port1, port2;
|
|
30
|
+static EspSoftwareSerial::UART port;
|
31
|
31
|
RTC_DATA_ATTR static unsigned long counter = 0;
|
32
|
32
|
|
33
|
33
|
static double SumWh = NAN, T1Wh = NAN, T2Wh = NAN;
|
|
@@ -93,16 +93,18 @@ static OBISHandler handlers[] = {
|
93
|
93
|
void sml_init(void) {
|
94
|
94
|
init_vars();
|
95
|
95
|
|
96
|
|
- port1.begin(SML_BAUD, SML_PARAM, SML_RX, -1, false);
|
97
|
|
- port2.begin(SML_BAUD, SML_PARAM, SML_TX, -1, false);
|
|
96
|
+ pinMode(SML_RX, INPUT);
|
|
97
|
+ pinMode(SML_TX, OUTPUT);
|
|
98
|
+
|
|
99
|
+ port.begin(SML_BAUD, SML_PARAM, SML_RX, SML_TX, false);
|
98
|
100
|
}
|
99
|
101
|
|
100
|
102
|
void sml_run(void) {
|
101
|
|
- if ((!port1.available()) && (!port2.available())) {
|
|
103
|
+ if (!port.available()) {
|
102
|
104
|
return;
|
103
|
105
|
}
|
104
|
106
|
|
105
|
|
- unsigned char c = port1.available() ? port1.read() : port2.read();
|
|
107
|
+ unsigned char c = port.read();
|
106
|
108
|
sml_states_t s = smlState(c);
|
107
|
109
|
|
108
|
110
|
if (s == SML_START) {
|