mirror of https://github.com/arendst/Tasmota.git
fix serial buffer issues
This commit is contained in:
parent
e4e9a39c79
commit
f1a2fb2b8d
|
@ -174,6 +174,7 @@ bool TasmotaSerial::begin(long speed, int stop_bits) {
|
||||||
m_uart = tasmota_serial_index;
|
m_uart = tasmota_serial_index;
|
||||||
tasmota_serial_index--;
|
tasmota_serial_index--;
|
||||||
TSerial = new HardwareSerial(m_uart);
|
TSerial = new HardwareSerial(m_uart);
|
||||||
|
if (TM_SERIAL_BUFFER_SIZE != serial_buffer_size) TSerial->setRxBufferSize(serial_buffer_size);
|
||||||
if (2 == m_stop_bits) {
|
if (2 == m_stop_bits) {
|
||||||
TSerial->begin(speed, SERIAL_8N2, m_rx_pin, m_tx_pin);
|
TSerial->begin(speed, SERIAL_8N2, m_rx_pin, m_tx_pin);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -25,6 +25,8 @@
|
||||||
|
|
||||||
#include <TasmotaSerial.h>
|
#include <TasmotaSerial.h>
|
||||||
|
|
||||||
|
#define TMSBSIZ 256
|
||||||
|
|
||||||
#define HM17_BAUDRATE 9600
|
#define HM17_BAUDRATE 9600
|
||||||
|
|
||||||
#define IBEACON_DEBUG
|
#define IBEACON_DEBUG
|
||||||
|
@ -96,7 +98,7 @@ void IBEACON_Init() {
|
||||||
|
|
||||||
// actually doesnt work reliably with software serial
|
// actually doesnt work reliably with software serial
|
||||||
if (PinUsed(GPIO_IBEACON_RX) && PinUsed(GPIO_IBEACON_TX)) {
|
if (PinUsed(GPIO_IBEACON_RX) && PinUsed(GPIO_IBEACON_TX)) {
|
||||||
IBEACON_Serial = new TasmotaSerial(Pin(GPIO_IBEACON_RX), Pin(GPIO_IBEACON_TX),1);
|
IBEACON_Serial = new TasmotaSerial(Pin(GPIO_IBEACON_RX), Pin(GPIO_IBEACON_TX),1,0,TMSBSIZ);
|
||||||
if (IBEACON_Serial->begin(HM17_BAUDRATE)) {
|
if (IBEACON_Serial->begin(HM17_BAUDRATE)) {
|
||||||
if (IBEACON_Serial->hardwareSerial()) {
|
if (IBEACON_Serial->hardwareSerial()) {
|
||||||
ClaimSerial();
|
ClaimSerial();
|
||||||
|
@ -144,7 +146,7 @@ void hm17_every_second(void) {
|
||||||
void hm17_sbclr(void) {
|
void hm17_sbclr(void) {
|
||||||
memset(hm17_sbuffer,0,HM17_BSIZ);
|
memset(hm17_sbuffer,0,HM17_BSIZ);
|
||||||
hm17_sindex=0;
|
hm17_sindex=0;
|
||||||
IBEACON_Serial->flush();
|
//IBEACON_Serial->flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
void hm17_sendcmd(uint8_t cmd) {
|
void hm17_sendcmd(uint8_t cmd) {
|
||||||
|
@ -405,7 +407,7 @@ hm17_v110:
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
#ifdef IBEACON_DEBUG
|
#ifdef IBEACON_DEBUG
|
||||||
if (hm17_debug) AddLog_P2(LOG_LEVEL_INFO, PSTR(">>%s"),&hm17_sbuffer[8]);
|
if (hm17_debug) AddLog_P2(LOG_LEVEL_INFO, PSTR(">->%s"),&hm17_sbuffer[8]);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -517,7 +519,7 @@ bool xsns52_cmd(void) {
|
||||||
#ifdef IBEACON_DEBUG
|
#ifdef IBEACON_DEBUG
|
||||||
else if (*cp=='d') {
|
else if (*cp=='d') {
|
||||||
cp++;
|
cp++;
|
||||||
if (*cp) hm17_debug=atoi(cp);
|
hm17_debug=atoi(cp);
|
||||||
Response_P(S_JSON_IBEACON, XSNS_52,"debug",hm17_debug);
|
Response_P(S_JSON_IBEACON, XSNS_52,"debug",hm17_debug);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -49,6 +49,8 @@
|
||||||
#define SPECIAL_SS
|
#define SPECIAL_SS
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define TMSBSIZ 256
|
||||||
|
|
||||||
// addresses a bug in meter DWS74
|
// addresses a bug in meter DWS74
|
||||||
//#define DWS74_BUG
|
//#define DWS74_BUG
|
||||||
|
|
||||||
|
@ -2144,9 +2146,9 @@ init10:
|
||||||
// serial input, init
|
// serial input, init
|
||||||
#ifdef SPECIAL_SS
|
#ifdef SPECIAL_SS
|
||||||
if (meter_desc_p[meters].type=='m' || meter_desc_p[meters].type=='M' || meter_desc_p[meters].type=='p') {
|
if (meter_desc_p[meters].type=='m' || meter_desc_p[meters].type=='M' || meter_desc_p[meters].type=='p') {
|
||||||
meter_ss[meters] = new TasmotaSerial(meter_desc_p[meters].srcpin,meter_desc_p[meters].trxpin,1);
|
meter_ss[meters] = new TasmotaSerial(meter_desc_p[meters].srcpin,meter_desc_p[meters].trxpin,1,0,TMSBSIZ);
|
||||||
} else {
|
} else {
|
||||||
meter_ss[meters] = new TasmotaSerial(meter_desc_p[meters].srcpin,meter_desc_p[meters].trxpin,1,1);
|
meter_ss[meters] = new TasmotaSerial(meter_desc_p[meters].srcpin,meter_desc_p[meters].trxpin,1,1,TMSBSIZ);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
#ifdef ESP32
|
#ifdef ESP32
|
||||||
|
@ -2154,8 +2156,9 @@ init10:
|
||||||
if (uart_index==0) { ClaimSerial(); }
|
if (uart_index==0) { ClaimSerial(); }
|
||||||
uart_index--;
|
uart_index--;
|
||||||
if (uart_index<0) uart_index=0;
|
if (uart_index<0) uart_index=0;
|
||||||
|
meter_ss[meters]->setRxBufferSize(TMSBSIZ);
|
||||||
#else
|
#else
|
||||||
meter_ss[meters] = new TasmotaSerial(meter_desc_p[meters].srcpin,meter_desc_p[meters].trxpin,1);
|
meter_ss[meters] = new TasmotaSerial(meter_desc_p[meters].srcpin,meter_desc_p[meters].trxpin,1,0,TMSBSIZ);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -2188,6 +2191,15 @@ uint32_t SML_SetBaud(uint32_t meter, uint32_t br) {
|
||||||
if (meter<1 || meter>meters_used) return 0;
|
if (meter<1 || meter>meters_used) return 0;
|
||||||
meter--;
|
meter--;
|
||||||
if (!meter_ss[meter]) return 0;
|
if (!meter_ss[meter]) return 0;
|
||||||
|
|
||||||
|
#ifdef ESP32
|
||||||
|
meter_ss[meter]->flush();
|
||||||
|
if (meter_desc_p[meter].type=='M') {
|
||||||
|
meter_ss[meter]->begin(br,SERIAL_8E1,meter_desc_p[meter].srcpin,meter_desc_p[meter].trxpin);
|
||||||
|
} else {
|
||||||
|
meter_ss[meter]->begin(br,SERIAL_8N1,meter_desc_p[meter].srcpin,meter_desc_p[meter].trxpin);
|
||||||
|
}
|
||||||
|
#else
|
||||||
if (meter_ss[meter]->begin(br)) {
|
if (meter_ss[meter]->begin(br)) {
|
||||||
meter_ss[meter]->flush();
|
meter_ss[meter]->flush();
|
||||||
}
|
}
|
||||||
|
@ -2196,6 +2208,7 @@ uint32_t SML_SetBaud(uint32_t meter, uint32_t br) {
|
||||||
Serial.begin(br, SERIAL_8E1);
|
Serial.begin(br, SERIAL_8E1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue