Browse Source

dont keep tx pin for sml floating

Thomas Buck 2 months ago
parent
commit
d1cbd69d21
1 changed files with 7 additions and 5 deletions
  1. 7
    5
      src/smart_meter.cpp

+ 7
- 5
src/smart_meter.cpp View File

27
 #define SML_BAUD 9600
27
 #define SML_BAUD 9600
28
 #define SML_PARAM SWSERIAL_8N1
28
 #define SML_PARAM SWSERIAL_8N1
29
 
29
 
30
-static EspSoftwareSerial::UART port1, port2;
30
+static EspSoftwareSerial::UART port;
31
 RTC_DATA_ATTR static unsigned long counter = 0;
31
 RTC_DATA_ATTR static unsigned long counter = 0;
32
 
32
 
33
 static double SumWh = NAN, T1Wh = NAN, T2Wh = NAN;
33
 static double SumWh = NAN, T1Wh = NAN, T2Wh = NAN;
93
 void sml_init(void) {
93
 void sml_init(void) {
94
     init_vars();
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
 void sml_run(void) {
102
 void sml_run(void) {
101
-    if ((!port1.available()) && (!port2.available())) {
103
+    if (!port.available()) {
102
         return;
104
         return;
103
     }
105
     }
104
 
106
 
105
-    unsigned char c = port1.available() ? port1.read() : port2.read();
107
+    unsigned char c = port.read();
106
     sml_states_t s = smlState(c);
108
     sml_states_t s = smlState(c);
107
 
109
 
108
     if (s == SML_START) {
110
     if (s == SML_START) {

Loading…
Cancel
Save