mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-23 10:46:31 +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
|
- 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 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 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 command ``SetOption79 0/1`` to enable reset of counters at teleperiod time by Andre Thomas (#7355)
|
||||||
- Add SerialConfig to ``Status 1``
|
- Add SerialConfig to ``Status 1``
|
||||||
- Add WifiPower to ``Status 5``
|
- Add WifiPower to ``Status 5``
|
||||||
|
@ -4,13 +4,14 @@
|
|||||||
|
|
||||||
- Change Lights: simplified gamma correction and 10 bits internal computation
|
- 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 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 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 command ``SetOption79 0/1`` to enable reset of counters at teleperiod time by Andre Thomas (#7355)
|
||||||
- Add SerialConfig to ``Status 1``
|
- Add SerialConfig to ``Status 1``
|
||||||
- Add WifiPower to ``Status 5``
|
- Add WifiPower to ``Status 5``
|
||||||
- Add support for DS1624, DS1621 Temperature sensor by Leonid Myravjev
|
- Add support for DS1624, DS1621 Temperature sensor by Leonid Myravjev
|
||||||
- Add Zigbee attribute decoder for Xiaomi Aqara Cube
|
- Add Zigbee attribute decoder for Xiaomi Aqara Cube
|
||||||
- Fix ``White`` added to light status (#7142)
|
|
||||||
|
|
||||||
## Released
|
## Released
|
||||||
|
|
||||||
|
@ -793,34 +793,40 @@ String GetSerialConfig(void)
|
|||||||
return String(config);
|
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.flush();
|
||||||
Serial.begin(baudrate, (SerialConfig)pgm_read_byte(kTasmotaSerialConfig + Settings.serial_config));
|
Serial.begin(baudrate, (SerialConfig)pgm_read_byte(kTasmotaSerialConfig + Settings.serial_config));
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetSerialConfig(uint32_t serial_config)
|
void SetSerialConfig(uint32_t serial_config)
|
||||||
{
|
{
|
||||||
if (serial_config == Settings.serial_config) { return; }
|
if (serial_config > TS_SERIAL_8O2) {
|
||||||
if (serial_config > TS_SERIAL_8O2) { return; }
|
serial_config = TS_SERIAL_8N1;
|
||||||
|
}
|
||||||
|
if (serial_config != Settings.serial_config) {
|
||||||
Settings.serial_config = serial_config;
|
Settings.serial_config = serial_config;
|
||||||
SetSerialBegin(Serial.baudRate());
|
SetSerialBegin();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetSerialBaudrate(int baudrate)
|
void SetSerialBaudrate(uint32_t baudrate)
|
||||||
{
|
{
|
||||||
Settings.baudrate = baudrate / 300;
|
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.flag.mqtt_serial = 0; // CMND_SERIALSEND and CMND_SERIALLOG
|
||||||
Settings.serial_config = serial_config;
|
Settings.serial_config = serial_config;
|
||||||
baudrate = prep_baudrate;
|
Settings.baudrate = baudrate / 300;
|
||||||
SetSeriallog(LOG_LEVEL_NONE);
|
SetSeriallog(LOG_LEVEL_NONE);
|
||||||
|
SetSerialBegin();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClaimSerial(void)
|
void ClaimSerial(void)
|
||||||
@ -828,8 +834,7 @@ void ClaimSerial(void)
|
|||||||
serial_local = true;
|
serial_local = true;
|
||||||
AddLog_P(LOG_LEVEL_INFO, PSTR("SNS: Hardware Serial"));
|
AddLog_P(LOG_LEVEL_INFO, PSTR("SNS: Hardware Serial"));
|
||||||
SetSeriallog(LOG_LEVEL_NONE);
|
SetSeriallog(LOG_LEVEL_NONE);
|
||||||
baudrate = Serial.baudRate();
|
Settings.baudrate = Serial.baudRate() / 300;
|
||||||
Settings.baudrate = baudrate / 300;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SerialSendRaw(char *codes)
|
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\",\""
|
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_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\"}}"),
|
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,
|
GetResetReason().c_str(), GetUptime().c_str(), GetDateAndTime(DT_RESTART).c_str(), Settings.sleep,
|
||||||
Settings.cfg_holder, Settings.bootcount, Settings.save_flag, GetSettingsAddress());
|
Settings.cfg_holder, Settings.bootcount, Settings.save_flag, GetSettingsAddress());
|
||||||
MqttPublishPrefixTopic_P(option, PSTR(D_CMND_STATUS "1"));
|
MqttPublishPrefixTopic_P(option, PSTR(D_CMND_STATUS "1"));
|
||||||
@ -1091,7 +1091,7 @@ void CmndBaudrate(void)
|
|||||||
{
|
{
|
||||||
if (XdrvMailbox.payload >= 300) {
|
if (XdrvMailbox.payload >= 300) {
|
||||||
XdrvMailbox.payload /= 300; // Make it a valid baudrate
|
XdrvMailbox.payload /= 300; // Make it a valid baudrate
|
||||||
baudrate = (XdrvMailbox.payload & 0xFFFF) * 300;
|
uint32_t baudrate = (XdrvMailbox.payload & 0xFFFF) * 300;
|
||||||
SetSerialBaudrate(baudrate);
|
SetSerialBaudrate(baudrate);
|
||||||
}
|
}
|
||||||
ResponseCmndNumber(Settings.baudrate * 300);
|
ResponseCmndNumber(Settings.baudrate * 300);
|
||||||
|
@ -1169,7 +1169,7 @@ void GpioInit(void)
|
|||||||
SetModuleType();
|
SetModuleType();
|
||||||
|
|
||||||
if (Settings.module != Settings.last_module) {
|
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++) {
|
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) {
|
else if (SONOFF_DUAL == my_module_type) {
|
||||||
devices_present = 2;
|
devices_present = 2;
|
||||||
PrepSerial(19200, TS_SERIAL_8N1);
|
SetSerial(19200, TS_SERIAL_8N1);
|
||||||
}
|
}
|
||||||
else if (CH4 == my_module_type) {
|
else if (CH4 == my_module_type) {
|
||||||
devices_present = 4;
|
devices_present = 4;
|
||||||
PrepSerial(19200, TS_SERIAL_8N1);
|
SetSerial(19200, TS_SERIAL_8N1);
|
||||||
}
|
}
|
||||||
#ifdef USE_SONOFF_SC
|
#ifdef USE_SONOFF_SC
|
||||||
else if (SONOFF_SC == my_module_type) {
|
else if (SONOFF_SC == my_module_type) {
|
||||||
PrepSerial(19200, TS_SERIAL_8N1);
|
SetSerial(19200, TS_SERIAL_8N1);
|
||||||
}
|
}
|
||||||
#endif // USE_SONOFF_SC
|
#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 blink_powersave; // Blink start power save state
|
||||||
power_t latching_power = 0; // Power state at latching start
|
power_t latching_power = 0; // Power state at latching start
|
||||||
power_t rel_inverted = 0; // Relay inverted flag (1 = (0 = On, 1 = Off))
|
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 serial_in_byte_counter = 0; // Index in receive buffer
|
||||||
int ota_state_flag = 0; // OTA state flag
|
int ota_state_flag = 0; // OTA state flag
|
||||||
int ota_result = 0; // OTA result
|
int ota_result = 0; // OTA result
|
||||||
@ -193,7 +192,7 @@ void setup(void)
|
|||||||
RtcReboot.fast_reboot_count++;
|
RtcReboot.fast_reboot_count++;
|
||||||
RtcRebootSave();
|
RtcRebootSave();
|
||||||
|
|
||||||
Serial.begin(baudrate);
|
Serial.begin(APP_BAUDRATE);
|
||||||
seriallog_level = LOG_LEVEL_INFO; // Allow specific serial messages until config loaded
|
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
|
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);
|
XdrvCall(FUNC_SETTINGS_OVERRIDE);
|
||||||
}
|
}
|
||||||
|
|
||||||
baudrate = Settings.baudrate * 300;
|
|
||||||
// mdns_delayed_start = Settings.param[P_MDNS_DELAYED_START];
|
// mdns_delayed_start = Settings.param[P_MDNS_DELAYED_START];
|
||||||
seriallog_level = Settings.seriallog_level;
|
seriallog_level = Settings.seriallog_level;
|
||||||
seriallog_timer = SERIALLOG_TIMER;
|
seriallog_timer = SERIALLOG_TIMER;
|
||||||
@ -274,8 +272,6 @@ void setup(void)
|
|||||||
GetEspHardwareType();
|
GetEspHardwareType();
|
||||||
GpioInit();
|
GpioInit();
|
||||||
|
|
||||||
SetSerialBaudrate(baudrate);
|
|
||||||
|
|
||||||
WifiConnect();
|
WifiConnect();
|
||||||
|
|
||||||
if (MOTOR == my_module_type) { Settings.poweronstate = POWER_ALL_ON; } // Needs always on else in limbo!
|
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
|
SonoffBridgeSendCommand(0xA7); // Stop reading RF signals enabling iTead default RF handling
|
||||||
break;
|
break;
|
||||||
case FUNC_PRE_INIT:
|
case FUNC_PRE_INIT:
|
||||||
PrepSerial(19200, TS_SERIAL_8N1);
|
SetSerial(19200, TS_SERIAL_8N1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -217,7 +217,7 @@ void CmndFanspeed(void)
|
|||||||
bool SonoffIfanInit(void)
|
bool SonoffIfanInit(void)
|
||||||
{
|
{
|
||||||
if (SONOFF_IFAN03 == my_module_type) {
|
if (SONOFF_IFAN03 == my_module_type) {
|
||||||
PrepSerial(9600, TS_SERIAL_8N1);
|
SetSerial(9600, TS_SERIAL_8N1);
|
||||||
}
|
}
|
||||||
return false; // Continue init chain
|
return false; // Continue init chain
|
||||||
}
|
}
|
||||||
|
@ -222,7 +222,7 @@ void SnfL1ModuleSelected(void)
|
|||||||
{
|
{
|
||||||
if (SONOFF_L1 == my_module_type) {
|
if (SONOFF_L1 == my_module_type) {
|
||||||
if ((pin[GPIO_RXD] < 99) && (pin[GPIO_TXD] < 99)) {
|
if ((pin[GPIO_RXD] < 99) && (pin[GPIO_TXD] < 99)) {
|
||||||
PrepSerial(19200, TS_SERIAL_8N1);
|
SetSerial(19200, TS_SERIAL_8N1);
|
||||||
|
|
||||||
light_type = LT_RGB;
|
light_type = LT_RGB;
|
||||||
light_flg = XLGT_05;
|
light_flg = XLGT_05;
|
||||||
|
@ -210,7 +210,7 @@ void CseEverySecond(void)
|
|||||||
void CseDrvInit(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
|
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]) {
|
if (0 == Settings.param[P_CSE7766_INVALID_POWER]) {
|
||||||
Settings.param[P_CSE7766_INVALID_POWER] = CSE_MAX_INVALID_POWER; // SetOption39 1..255
|
Settings.param[P_CSE7766_INVALID_POWER] = CSE_MAX_INVALID_POWER; // SetOption39 1..255
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user