From 71b7b1632d96d047e44550110ea37a6281921c51 Mon Sep 17 00:00:00 2001 From: Charles Date: Mon, 15 Jun 2020 11:52:51 +0200 Subject: [PATCH] cleaned Serial init (not perfect but better) --- tasmota/xnrg_15_teleinfo.ino | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/tasmota/xnrg_15_teleinfo.ino b/tasmota/xnrg_15_teleinfo.ino index 83a20648f..97dfca314 100644 --- a/tasmota/xnrg_15_teleinfo.ino +++ b/tasmota/xnrg_15_teleinfo.ino @@ -262,14 +262,16 @@ void TInfoInit(void) // pinMode(GPIO_TELEINFO_RX, INPUT_PULLUP); - if (TInfoSerial->begin(TINFO_SPEED, SERIAL_7E1)) + // Trick here even using SERIAL_7E1 or TS_SERIAL_7E1 + // this is not working, need to call SetSerialConfig after + if (TInfoSerial->begin(TINFO_SPEED, TS_SERIAL_7E1)) { + // This is a dirty hack, looks like begin does not take into account + // the TS_SERIAL_7E1 configuration so on ESP8266 this is + // working only on Serial RX pin (Hardware Serial) for now + SetSerialConfig(TS_SERIAL_7E1); + if (TInfoSerial->hardwareSerial()) { - // This is a dirty hack to bypass HW serial init when for Teleinfo - // This protocol needs 7E1 configuration so on ESP8266 this is - // working only on Serial RX pin (Hardware Serial) for now - Serial.end(); - Serial.begin(TINFO_SPEED, SERIAL_7E1); ClaimSerial(); } TInfoSerial->setTimeout(TINFO_READ_TIMEOUT);