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