mirror of
https://github.com/arendst/Tasmota.git
synced 2025-04-24 14:57:16 +00:00
Fix Serial initialization regression
Fix Serial initialization regression from previous fix
This commit is contained in:
parent
d627de5d76
commit
df944ed058
@ -57,6 +57,7 @@ The following binary downloads have been compiled with ESP8266/Arduino library c
|
||||
- Change Lights: simplified gamma correction and 10 bits internal computation
|
||||
- Fix Sonoff Bridge, Sc, L1, iFan03 and CSE7766 serial interface to forced speed, config and disable logging
|
||||
- Fix commands ``Display`` and ``Counter`` from overruling command processing (#7322)
|
||||
- Fix ``White`` added to light status (#7142)
|
||||
- Add command ``SetOption79 0/1`` to enable reset of counters at teleperiod time by Andre Thomas (#7355)
|
||||
- Add SerialConfig to ``Status 1``
|
||||
- Add WifiPower to ``Status 5``
|
||||
|
@ -4,13 +4,14 @@
|
||||
|
||||
- Change Lights: simplified gamma correction and 10 bits internal computation
|
||||
- Fix Sonoff Bridge, Sc, L1, iFan03 and CSE7766 serial interface to forced speed, config and disable logging
|
||||
- Fix Serial initialization regression from previous fix
|
||||
- Fix commands ``Display`` and ``Counter`` from overruling command processing (#7322)
|
||||
- Fix ``White`` added to light status (#7142)
|
||||
- Add command ``SetOption79 0/1`` to enable reset of counters at teleperiod time by Andre Thomas (#7355)
|
||||
- Add SerialConfig to ``Status 1``
|
||||
- Add WifiPower to ``Status 5``
|
||||
- Add support for DS1624, DS1621 Temperature sensor by Leonid Myravjev
|
||||
- Add Zigbee attribute decoder for Xiaomi Aqara Cube
|
||||
- Fix ``White`` added to light status (#7142)
|
||||
|
||||
## Released
|
||||
|
||||
|
@ -793,34 +793,40 @@ String GetSerialConfig(void)
|
||||
return String(config);
|
||||
}
|
||||
|
||||
void SetSerialBegin(uint32_t baudrate)
|
||||
void SetSerialBegin()
|
||||
{
|
||||
AddLog_P2(LOG_LEVEL_INFO, PSTR(D_LOG_APPLICATION "Set Serial to %s %d bit/s"), GetSerialConfig().c_str(), baudrate);
|
||||
uint32_t baudrate = Settings.baudrate * 300;
|
||||
AddLog_P2(LOG_LEVEL_INFO, PSTR(D_LOG_SERIAL "Set to %s %d bit/s"), GetSerialConfig().c_str(), baudrate);
|
||||
Serial.flush();
|
||||
Serial.begin(baudrate, (SerialConfig)pgm_read_byte(kTasmotaSerialConfig + Settings.serial_config));
|
||||
}
|
||||
|
||||
void SetSerialConfig(uint32_t serial_config)
|
||||
{
|
||||
if (serial_config == Settings.serial_config) { return; }
|
||||
if (serial_config > TS_SERIAL_8O2) { return; }
|
||||
|
||||
Settings.serial_config = serial_config;
|
||||
SetSerialBegin(Serial.baudRate());
|
||||
if (serial_config > TS_SERIAL_8O2) {
|
||||
serial_config = TS_SERIAL_8N1;
|
||||
}
|
||||
if (serial_config != Settings.serial_config) {
|
||||
Settings.serial_config = serial_config;
|
||||
SetSerialBegin();
|
||||
}
|
||||
}
|
||||
|
||||
void SetSerialBaudrate(int baudrate)
|
||||
void SetSerialBaudrate(uint32_t baudrate)
|
||||
{
|
||||
Settings.baudrate = baudrate / 300;
|
||||
SetSerialBegin(baudrate);
|
||||
if (Serial.baudRate() != baudrate) {
|
||||
SetSerialBegin();
|
||||
}
|
||||
}
|
||||
|
||||
void PrepSerial(int prep_baudrate, uint32_t serial_config)
|
||||
void SetSerial(uint32_t baudrate, uint32_t serial_config)
|
||||
{
|
||||
Settings.flag.mqtt_serial = 0; // CMND_SERIALSEND and CMND_SERIALLOG
|
||||
Settings.serial_config = serial_config;
|
||||
baudrate = prep_baudrate;
|
||||
Settings.baudrate = baudrate / 300;
|
||||
SetSeriallog(LOG_LEVEL_NONE);
|
||||
SetSerialBegin();
|
||||
}
|
||||
|
||||
void ClaimSerial(void)
|
||||
@ -828,8 +834,7 @@ void ClaimSerial(void)
|
||||
serial_local = true;
|
||||
AddLog_P(LOG_LEVEL_INFO, PSTR("SNS: Hardware Serial"));
|
||||
SetSeriallog(LOG_LEVEL_NONE);
|
||||
baudrate = Serial.baudRate();
|
||||
Settings.baudrate = baudrate / 300;
|
||||
Settings.baudrate = Serial.baudRate() / 300;
|
||||
}
|
||||
|
||||
void SerialSendRaw(char *codes)
|
||||
|
@ -369,7 +369,7 @@ void CmndStatus(void)
|
||||
Response_P(PSTR("{\"" D_CMND_STATUS D_STATUS1_PARAMETER "\":{\"" D_JSON_BAUDRATE "\":%d,\"" D_CMND_SERIALCONFIG "\":\"%s\",\"" D_CMND_GROUPTOPIC "\":\"%s\",\"" D_CMND_OTAURL "\":\"%s\",\""
|
||||
D_JSON_RESTARTREASON "\":\"%s\",\"" D_JSON_UPTIME "\":\"%s\",\"" D_JSON_STARTUPUTC "\":\"%s\",\"" D_CMND_SLEEP "\":%d,\""
|
||||
D_JSON_CONFIG_HOLDER "\":%d,\"" D_JSON_BOOTCOUNT "\":%d,\"" D_JSON_SAVECOUNT "\":%d,\"" D_JSON_SAVEADDRESS "\":\"%X\"}}"),
|
||||
baudrate, GetSerialConfig().c_str(), SettingsText(SET_MQTT_GRP_TOPIC), SettingsText(SET_OTAURL),
|
||||
Settings.baudrate * 300, GetSerialConfig().c_str(), SettingsText(SET_MQTT_GRP_TOPIC), SettingsText(SET_OTAURL),
|
||||
GetResetReason().c_str(), GetUptime().c_str(), GetDateAndTime(DT_RESTART).c_str(), Settings.sleep,
|
||||
Settings.cfg_holder, Settings.bootcount, Settings.save_flag, GetSettingsAddress());
|
||||
MqttPublishPrefixTopic_P(option, PSTR(D_CMND_STATUS "1"));
|
||||
@ -1091,7 +1091,7 @@ void CmndBaudrate(void)
|
||||
{
|
||||
if (XdrvMailbox.payload >= 300) {
|
||||
XdrvMailbox.payload /= 300; // Make it a valid baudrate
|
||||
baudrate = (XdrvMailbox.payload & 0xFFFF) * 300;
|
||||
uint32_t baudrate = (XdrvMailbox.payload & 0xFFFF) * 300;
|
||||
SetSerialBaudrate(baudrate);
|
||||
}
|
||||
ResponseCmndNumber(Settings.baudrate * 300);
|
||||
|
@ -1169,7 +1169,7 @@ void GpioInit(void)
|
||||
SetModuleType();
|
||||
|
||||
if (Settings.module != Settings.last_module) {
|
||||
baudrate = APP_BAUDRATE;
|
||||
Settings.baudrate = APP_BAUDRATE / 300;
|
||||
}
|
||||
|
||||
for (uint32_t i = 0; i < sizeof(Settings.user_template.gp); i++) {
|
||||
@ -1297,15 +1297,15 @@ void GpioInit(void)
|
||||
}
|
||||
else if (SONOFF_DUAL == my_module_type) {
|
||||
devices_present = 2;
|
||||
PrepSerial(19200, TS_SERIAL_8N1);
|
||||
SetSerial(19200, TS_SERIAL_8N1);
|
||||
}
|
||||
else if (CH4 == my_module_type) {
|
||||
devices_present = 4;
|
||||
PrepSerial(19200, TS_SERIAL_8N1);
|
||||
SetSerial(19200, TS_SERIAL_8N1);
|
||||
}
|
||||
#ifdef USE_SONOFF_SC
|
||||
else if (SONOFF_SC == my_module_type) {
|
||||
PrepSerial(19200, TS_SERIAL_8N1);
|
||||
SetSerial(19200, TS_SERIAL_8N1);
|
||||
}
|
||||
#endif // USE_SONOFF_SC
|
||||
|
||||
|
@ -96,7 +96,6 @@ power_t blink_mask = 0; // Blink relay active mask
|
||||
power_t blink_powersave; // Blink start power save state
|
||||
power_t latching_power = 0; // Power state at latching start
|
||||
power_t rel_inverted = 0; // Relay inverted flag (1 = (0 = On, 1 = Off))
|
||||
int baudrate = APP_BAUDRATE; // Serial interface baud rate
|
||||
int serial_in_byte_counter = 0; // Index in receive buffer
|
||||
int ota_state_flag = 0; // OTA state flag
|
||||
int ota_result = 0; // OTA result
|
||||
@ -193,7 +192,7 @@ void setup(void)
|
||||
RtcReboot.fast_reboot_count++;
|
||||
RtcRebootSave();
|
||||
|
||||
Serial.begin(baudrate);
|
||||
Serial.begin(APP_BAUDRATE);
|
||||
seriallog_level = LOG_LEVEL_INFO; // Allow specific serial messages until config loaded
|
||||
|
||||
snprintf_P(my_version, sizeof(my_version), PSTR("%d.%d.%d"), VERSION >> 24 & 0xff, VERSION >> 16 & 0xff, VERSION >> 8 & 0xff); // Release version 6.3.0
|
||||
@ -215,7 +214,6 @@ void setup(void)
|
||||
XdrvCall(FUNC_SETTINGS_OVERRIDE);
|
||||
}
|
||||
|
||||
baudrate = Settings.baudrate * 300;
|
||||
// mdns_delayed_start = Settings.param[P_MDNS_DELAYED_START];
|
||||
seriallog_level = Settings.seriallog_level;
|
||||
seriallog_timer = SERIALLOG_TIMER;
|
||||
@ -274,8 +272,6 @@ void setup(void)
|
||||
GetEspHardwareType();
|
||||
GpioInit();
|
||||
|
||||
SetSerialBaudrate(baudrate);
|
||||
|
||||
WifiConnect();
|
||||
|
||||
if (MOTOR == my_module_type) { Settings.poweronstate = POWER_ALL_ON; } // Needs always on else in limbo!
|
||||
|
@ -578,7 +578,7 @@ bool Xdrv06(uint8_t function)
|
||||
SonoffBridgeSendCommand(0xA7); // Stop reading RF signals enabling iTead default RF handling
|
||||
break;
|
||||
case FUNC_PRE_INIT:
|
||||
PrepSerial(19200, TS_SERIAL_8N1);
|
||||
SetSerial(19200, TS_SERIAL_8N1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -217,7 +217,7 @@ void CmndFanspeed(void)
|
||||
bool SonoffIfanInit(void)
|
||||
{
|
||||
if (SONOFF_IFAN03 == my_module_type) {
|
||||
PrepSerial(9600, TS_SERIAL_8N1);
|
||||
SetSerial(9600, TS_SERIAL_8N1);
|
||||
}
|
||||
return false; // Continue init chain
|
||||
}
|
||||
|
@ -222,7 +222,7 @@ void SnfL1ModuleSelected(void)
|
||||
{
|
||||
if (SONOFF_L1 == my_module_type) {
|
||||
if ((pin[GPIO_RXD] < 99) && (pin[GPIO_TXD] < 99)) {
|
||||
PrepSerial(19200, TS_SERIAL_8N1);
|
||||
SetSerial(19200, TS_SERIAL_8N1);
|
||||
|
||||
light_type = LT_RGB;
|
||||
light_flg = XLGT_05;
|
||||
|
@ -210,7 +210,7 @@ void CseEverySecond(void)
|
||||
void CseDrvInit(void)
|
||||
{
|
||||
if ((3 == pin[GPIO_CSE7766_RX]) && (1 == pin[GPIO_CSE7766_TX])) { // As it uses 8E1 currently only hardware serial is supported
|
||||
PrepSerial(4800, TS_SERIAL_8E1);
|
||||
SetSerial(4800, TS_SERIAL_8E1);
|
||||
if (0 == Settings.param[P_CSE7766_INVALID_POWER]) {
|
||||
Settings.param[P_CSE7766_INVALID_POWER] = CSE_MAX_INVALID_POWER; // SetOption39 1..255
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user