mirror of https://github.com/arendst/Tasmota.git
Changed management of serial baudrate
Changed management of serial baudrate (#9554)
This commit is contained in:
parent
9ab50db8ef
commit
7bc8956d86
|
@ -12,6 +12,7 @@ All notable changes to this project will be documented in this file.
|
|||
### Changed
|
||||
- Command ``Gpio17`` replaces command ``Adc``
|
||||
- Command ``Gpios`` replaces command ``Adcs``
|
||||
- Management of serial baudrate (#9554)
|
||||
|
||||
### Fixed
|
||||
- Convert AdcParam parameters from versions before v9.0.0.2
|
||||
|
|
|
@ -82,6 +82,7 @@ The attached binaries can also be downloaded from http://ota.tasmota.com/tasmota
|
|||
- ``Status`` command output for disabled status types
|
||||
- IRremoteESP8266 library from v2.7.10 to v2.7.11
|
||||
- NeoPixelBus library from v2.5.0.09 to v2.6.0
|
||||
- Management of serial baudrate (#9554)
|
||||
|
||||
### Fixed
|
||||
- Ledlink blink when no network connected regression from v8.3.1.4 (#9292)
|
||||
|
|
|
@ -885,8 +885,7 @@ int GetStateNumber(char *state_text)
|
|||
return state_number;
|
||||
}
|
||||
|
||||
String GetSerialConfig(void)
|
||||
{
|
||||
String GetSerialConfig(void) {
|
||||
// Settings.serial_config layout
|
||||
// b000000xx - 5, 6, 7 or 8 data bits
|
||||
// b00000x00 - 1 or 2 stop bits
|
||||
|
@ -902,16 +901,14 @@ String GetSerialConfig(void)
|
|||
return String(config);
|
||||
}
|
||||
|
||||
void SetSerialBegin()
|
||||
{
|
||||
uint32_t baudrate = Settings.baudrate * 300;
|
||||
void SetSerialBegin(void) {
|
||||
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)
|
||||
{
|
||||
void SetSerialConfig(uint32_t serial_config) {
|
||||
if (serial_config > TS_SERIAL_8O2) {
|
||||
serial_config = TS_SERIAL_8N1;
|
||||
}
|
||||
|
@ -921,29 +918,29 @@ void SetSerialConfig(uint32_t serial_config)
|
|||
}
|
||||
}
|
||||
|
||||
void SetSerialBaudrate(uint32_t baudrate)
|
||||
{
|
||||
void SetSerialBaudrate(uint32_t ubaudrate) {
|
||||
baudrate = ubaudrate;
|
||||
Settings.baudrate = baudrate / 300;
|
||||
if (Serial.baudRate() != baudrate) {
|
||||
SetSerialBegin();
|
||||
}
|
||||
}
|
||||
|
||||
void SetSerial(uint32_t baudrate, uint32_t serial_config)
|
||||
{
|
||||
void SetSerial(uint32_t ubaudrate, uint32_t serial_config) {
|
||||
Settings.flag.mqtt_serial = 0; // CMND_SERIALSEND and CMND_SERIALLOG
|
||||
Settings.serial_config = serial_config;
|
||||
baudrate = ubaudrate;
|
||||
Settings.baudrate = baudrate / 300;
|
||||
SetSeriallog(LOG_LEVEL_NONE);
|
||||
SetSerialBegin();
|
||||
}
|
||||
|
||||
void ClaimSerial(void)
|
||||
{
|
||||
void ClaimSerial(void) {
|
||||
serial_local = true;
|
||||
AddLog_P(LOG_LEVEL_INFO, PSTR("SNS: Hardware Serial"));
|
||||
SetSeriallog(LOG_LEVEL_NONE);
|
||||
Settings.baudrate = Serial.baudRate() / 300;
|
||||
baudrate = Serial.baudRate();
|
||||
Settings.baudrate = baudrate / 300;
|
||||
}
|
||||
|
||||
void SerialSendRaw(char *codes)
|
||||
|
|
|
@ -440,7 +440,7 @@ void CmndStatus(void)
|
|||
",\"" D_JSON_SAVEADDRESS "\":\"%X\""
|
||||
#endif
|
||||
"}}"),
|
||||
Settings.baudrate * 300, GetSerialConfig().c_str(), SettingsText(SET_MQTT_GRP_TOPIC), SettingsText(SET_OTAURL),
|
||||
baudrate, 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, GetDateAndTime(DT_BOOTCOUNT).c_str(), Settings.save_flag
|
||||
#ifdef ESP8266
|
||||
|
@ -1341,10 +1341,10 @@ void CmndBaudrate(void)
|
|||
{
|
||||
if (XdrvMailbox.payload >= 300) {
|
||||
XdrvMailbox.payload /= 300; // Make it a valid baudrate
|
||||
uint32_t baudrate = (XdrvMailbox.payload & 0xFFFF) * 300;
|
||||
baudrate = (XdrvMailbox.payload & 0xFFFF) * 300;
|
||||
SetSerialBaudrate(baudrate);
|
||||
}
|
||||
ResponseCmndNumber(Settings.baudrate * 300);
|
||||
ResponseCmndNumber(baudrate);
|
||||
}
|
||||
|
||||
void CmndSerialConfig(void)
|
||||
|
|
|
@ -1473,6 +1473,7 @@ void GpioInit(void)
|
|||
if (Settings.module != Settings.last_module) {
|
||||
Settings.baudrate = APP_BAUDRATE / 300;
|
||||
Settings.serial_config = TS_SERIAL_8N1;
|
||||
SetSerialBegin();
|
||||
}
|
||||
|
||||
// AddLog_P2(LOG_LEVEL_DEBUG, PSTR("DBG: Used GPIOs %d"), GPIO_SENSOR_END);
|
||||
|
|
|
@ -109,6 +109,7 @@ uint32_t uptime = 0; // Counting every second until 42949
|
|||
uint32_t loop_load_avg = 0; // Indicative loop load average
|
||||
uint32_t global_update = 0; // Timestamp of last global temperature and humidity update
|
||||
uint32_t web_log_index = 1; // Index in Web log buffer (should never be 0)
|
||||
uint32_t baudrate = APP_BAUDRATE; // Current Serial baudrate
|
||||
float global_temperature_celsius = NAN; // Provide a global temperature to be used by some sensors
|
||||
float global_humidity = 0.0f; // Provide a global humidity to be used by some sensors
|
||||
float global_pressure_hpa = 0.0f; // Provide a global pressure to be used by some sensors
|
||||
|
@ -207,7 +208,7 @@ void setup(void) {
|
|||
#endif
|
||||
RtcRebootSave();
|
||||
|
||||
Serial.begin(APP_BAUDRATE);
|
||||
Serial.begin(baudrate);
|
||||
// Serial.setRxBufferSize(INPUT_BUFFER_SIZE); // Default is 256 chars
|
||||
seriallog_level = LOG_LEVEL_INFO; // Allow specific serial messages until config loaded
|
||||
|
||||
|
|
Loading…
Reference in New Issue