cleaned Serial init (not perfect but better)

This commit is contained in:
Charles 2020-06-15 11:52:51 +02:00
parent 32d82b3568
commit 71b7b1632d
1 changed files with 8 additions and 6 deletions

View File

@ -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);