Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strange behaviour Software Serial (57600 and packets > 63/64 bytes) #17120

Closed
11 of 13 tasks
ortegafernando opened this issue Nov 17, 2022 · 13 comments
Closed
11 of 13 tasks

Comments

@ortegafernando
Copy link
Contributor

ortegafernando commented Nov 17, 2022

PROBLEM DESCRIPTION

A clear and concise description of what the problem is.
Hi, I found that software serial is quite bad. I don't know exactly why. I know about software serial problems with Arduino Uno, Pro Mini,.... but I always think that with a 40/80Mhz processor it will not have problems

REQUESTED INFORMATION

Make sure your have performed every step and checked the applicable boxes before submitting your issue. Thank you!

  • Read the Contributing Guide and Policy and the Code of Conduct
  • Searched the problem in issues
  • Searched the problem in discussions
  • Searched the problem in the docs
  • [] Searched the problem in the chat
  • Device used (e.g., Sonoff Basic): Wemos and NodeMCU
  • Tasmota binary firmware version number used: Developement 12.2.0.5 and also Master 12.2.0
    • Pre-compiled
    • Self-compiled
  • Flashing tools used: tasmotizer and web firmware update
  • Provide the output of command: Backlog Template; Module; GPIO 255:
  Configuration output here:

Software Bridge
18:25:58.204 MQT: bi/domo/victrontest/stat/RESULT = {"NAME":"Generic","GPIO":[1,1,1,1,1,1,1,1,1,1,1,1,1,1],"FLAG":0,"BASE":18}
18:25:58.412 MQT: bi/domo/victrontest/stat/RESULT = {"Module":{"0":"Generic"}}
18:25:58.667 MQT: bi/domo/victrontest/stat/RESULT = {"GPIO0":{"0":"None"},"GPIO1":{"0":"None"},"GPIO2":{"0":"None"},"GPIO3":{"0":"None"},"GPIO4":{"0":"None"},"GPIO5":{"0":"None"},"GPIO9":{"0":"None"},"GPIO10":{"0":"None"},"GPIO12":{"1824":"SerBr Rx"},"GPIO13":{"1792":"SerBr Tx"},"GPIO14":{"0":"None"},"GPIO15":{"0":"None"},"GPIO16":{"0":"None"},"GPIO17":{"0":"None"}}

Hardware Bridge
18:24:34.642 MQT: bi/domo/victrontest/stat/RESULT = {"NAME":"Generic","GPIO":[1,1,1,1,1,1,1,1,1,1,1,1,1,1],"FLAG":0,"BASE":18}
18:24:34.850 MQT: bi/domo/victrontest/stat/RESULT = {"Module":{"0":"Generic"}}
18:24:35.057 MQT: bi/domo/victrontest/stat/RESULT = {"GPIO0":{"0":"None"},"GPIO1":{"1792":"SerBr Tx"},"GPIO2":{"0":"None"},"GPIO3":{"1824":"SerBr Rx"},"GPIO4":{"0":"None"},"GPIO5":{"0":"None"},"GPIO9":{"0":"None"},"GPIO10":{"0":"None"},"GPIO12":{"0":"None"},"GPIO13":{"0":"None"},"GPIO14":{"0":"None"},"GPIO15":{"0":"None"},"GPIO16":{"0":"None"},"GPIO17":{"0":"None"}}
  • If using rules, provide the output of this command: Backlog Rule1; Rule2; Rule3:
  Rules output here:
NO RULES
  • Provide the output of this command: Status 0:
  STATUS 0 output here:
18:26:55.444 MQT: bi/domo/victrontest/stat/STATUS = {"Status":{"Module":0,"DeviceName":"Tasmota","FriendlyName":["Tasmota"],"Topic":"victrontest","ButtonTopic":"0","Power":0,"PowerOnState":3,"LedState":1,"LedMask":"FFFF","SaveData":1,"SaveState":1,"SwitchTopic":"0","SwitchMode":[0,0,0,0,0,0,0,0],"ButtonRetain":0,"SwitchRetain":0,"SensorRetain":0,"PowerRetain":0,"InfoRetain":0,"StateRetain":0,"StatusRetain":0}}
18:26:55.449 MQT: bi/domo/victrontest/stat/STATUS1 = {"StatusPRM":{"Baudrate":57600,"SerialConfig":"8N1","GroupTopic":"tasmotas","OtaUrl":"http://ota.tasmota.com/tasmota/tasmota.bin.gz","RestartReason":"Software/System restart","Uptime":"0T00:01:07","StartupUTC":"2022-11-17T17:25:48","Sleep":50,"CfgHolder":4617,"BootCount":108,"BCResetTime":"2022-10-28T21:52:13","SaveCount":268,"SaveAddress":"F4000"}}
18:26:55.453 MQT: bi/domo/victrontest/stat/STATUS2 = {"StatusFWR":{"Version":"12.2.0.5(tasmota)","BuildDateTime":"2022-11-17T14:27:29","Boot":31,"Core":"2_7_4_9","SDK":"2.2.2-dev(38a443e)","CpuFrequency":80,"Hardware":"ESP8266EX","CR":"390/699"}}
18:26:55.458 MQT: bi/domo/victrontest/stat/STATUS3 = {"StatusLOG":{"SerialLog":0,"WebLog":2,"MqttLog":0,"SysLog":0,"LogHost":"","LogPort":514,"SSId":["xxxxxxxxx","xxxxxxxxxxx"],"TelePeriod":300,"Resolution":"558180C0","SetOption":["00C08009","2805C80001000600003C5A0A192800000000","00000080","00006000","00004000","00000000"]}}
18:26:55.472 MQT: bi/domo/victrontest/stat/STATUS4 = {"StatusMEM":{"ProgramSize":633,"Free":368,"Heap":22,"ProgramFlashSize":1024,"FlashSize":4096,"FlashChipId":"164020","FlashFrequency":40,"FlashMode":"DOUT","Features":["00000809","8F9AC787","04368001","000000CF","010013C0","C000F981","00004004","00001000","54000020","00000080"],"Drivers":"1,2,3,4,5,6,7,8,9,10,12,16,18,19,20,21,22,24,26,27,29,30,35,37,45,62","Sensors":"1,2,3,4,5,6"}}
18:26:55.479 MQT: bi/domo/victrontest/stat/STATUS5 = {"StatusNET":{"Hostname":"victrontest-4763","IPAddress":"192.168.1.138","Gateway":"192.168.1.1","Subnetmask":"255.255.255.0","DNSServer1":"192.168.1.1","DNSServer2":"0.0.0.0","Mac":"C8:2B:96:1E:12:9B","Webserver":2,"HTTP_API":1,"WifiConfig":4,"WifiPower":17.0}}
18:26:55.484 MQT: bi/domo/victrontest/stat/STATUS6 = {"StatusMQT":{"MqttHost":"xxxxxxxxxxxxxx","MqttPort":xxxxx,"MqttClientMask":"DVES_%06X","MqttClient":"DVES_1E129B","MqttUser":"xxxxx","MqttCount":1,"MAX_PACKET_SIZE":1200,"KEEPALIVE":30,"SOCKET_TIMEOUT":4}}
18:26:55.491 MQT: bi/domo/victrontest/stat/STATUS7 = {"StatusTIM":{"UTC":"2022-11-17T17:26:55","Local":"2022-11-17T18:26:55","StartDST":"2022-03-27T02:00:00","EndDST":"2022-10-30T03:00:00","Timezone":"+01:00","Sunrise":"08:02","Sunset":"17:07"}}
18:26:55.495 MQT: bi/domo/victrontest/stat/STATUS10 = {"StatusSNS":{"Time":"2022-11-17T18:26:55"}}
18:26:55.657 MQT: bi/domo/victrontest/stat/STATUS11 = {"StatusSTS":{"Time":"2022-11-17T18:26:55","Uptime":"0T00:01:07","UptimeSec":67,"Heap":21,"SleepMode":"Dynamic","Sleep":50,"LoadAvg":22,"MqttCount":1,"Wifi":{"AP":1,"SSId":"xxxxxxxxxx","BSSId":"xxxxxxxxxxxx","Channel":9,"Mode":"11n","RSSI":84,"Signal":-58,"LinkCount":1,"Downtime":"0T00:00:03"}}}
  • Set weblog to 4 and then, when you experience your issue, provide the output of the Console log:
  Console output here:

D6 SerBrRX
D7 SerBrTX

00:00:00.001 HDW: ESP8266EX
00:00:00.046 CFG: Loaded from flash at FB, Count 260
00:00:00.214 QPC: Reset
00:00:00.224 Project tasmota - Tasmota Version 12.2.0.5(tasmota)-2_7_4_9(2022-11-17T14:27:29)
00:00:00.814 WIF: Connecting to AP1 xxxxxxxxxxxx Channel 9 BSSId xxxxxxxxxxxxxxxx in mode 11n as victrontest-4763...
00:00:01.753 WIF: Connected
00:00:02.004 HTP: Web server active on victrontest-4763 with IP address 192.168.1.138
18:17:35.068 MQT: Attempting connection...
18:17:35.520 MQT: Connected
18:17:35.523 MQT: bi/domo/victrontest/tele/LWT = Online (retained)
18:17:35.525 MQT: bi/domo/victrontest/cmnd/POWER = 
18:17:35.530 MQT: bi/domo/victrontest/tele/INFO1 = {"Info1":{"Module":"Generic","Version":"12.2.0.5(tasmota)","FallbackTopic":"cmnd/DVES_1E129B_fb/","GroupTopic":"bi/domo/tasmotas/cmnd/"}}
18:17:35.532 MQT: bi/domo/victrontest/tele/INFO2 = {"Info2":{"WebServerMode":"Admin","Hostname":"victrontest-4763","IPAddress":"192.168.1.138"}}
18:17:35.534 MQT: bi/domo/victrontest/tele/INFO3 = {"Info3":{"RestartReason":"Software/System restart","BootCount":105}}
18:17:39.430 MQT: bi/domo/victrontest/tele/STATE = {"Time":"2022-11-17T18:17:39","Uptime":"0T00:00:08","UptimeSec":8,"Heap":26,"SleepMode":"Dynamic","Sleep":50,"LoadAvg":21,"MqttCount":1,"Wifi":{"AP":1,"SSId":"xxxxxxxxxx","BSSId":"xxxxxxxxxxxxxxxx","Channel":9,"Mode":"11n","RSSI":94,"Signal":-53,"LinkCount":1,"Downtime":"0T00:00:03"}}
18:18:06.771 CMD: sserialsend5 55 05 00 05 A1
18:18:06.778 MQT: bi/domo/victrontest/stat/RESULT = {"SSerialSend":"Done"}
18:18:07.515 MQT: bi/domo/victrontest/tele/RESULT = {"SSerialReceived":"55050005A10D0A"}
18:18:13.280 MQT: bi/domo/victrontest/tele/RESULT = {"SSerialReceived":"55670001010032000009E2FFFFFF070A0000000800002F003B002E000D000C0000000029E20000002A000000002B02002C000000002D0200352F0033307841"}
18:18:18.290 MQT: bi/domo/victrontest/tele/RESULT = {"SSerialReceived":"55670001010032000009E2FFFFFF070A0000000800002F003B002E000D000C0000000029E20000002A000000002B02002C000000002D0200352F0033307841"}
18:18:23.298 MQT: bi/domo/victrontest/tele/RESULT = {"SSerialReceived":"55670001010032000009E2FFFFFF070A0000000800002F003B002E000D000C0000000029E20000002A000000002B02002C000000002D0200352F0033307841"}
18:18:28.311 MQT: bi/domo/victrontest/tele/RESULT = {"SSerialReceived":"55670001010032000009E2FFFFFF070A0000000800002F003B002E000D000C0000000029E20000002A000000002B02002C000000002D0200352F0033307841"}
18:18:33.318 MQT: bi/domo/victrontest/tele/RESULT = {"SSerialReceived":"55670001010032000009E2FFFFFF070A0000000800002F003B002E000D000C0000000029E20000002A000000002B02002C000000002D0200352F0033307841"}
18:18:38.326 MQT: bi/domo/victrontest/tele/RESULT = {"SSerialReceived":"55670001010032000009E2FFFFFF070A0000000800002F003B002E000D000C0000000029E20000002A000000002B02002C000000002D0200352F0033307841"}
18:18:43.333 MQT: bi/domo/victrontest/tele/RESULT = {"SSerialReceived":"55670001010032000009E2FFFFFF070A0000000800002F003B002E000D000C0000000029E20000002A000000002B02002C000000002D0200352F0033307841"}
18:18:44.259 CMD: sserialsend5 55 05 00 00 A6
18:18:44.267 MQT: bi/domo/victrontest/stat/RESULT = {"SSerialSend":"Done"}
18:18:44.581 MQT: bi/domo/victrontest/tele/RESULT = {"SSerialReceived":"55050000A60D0A"}
18:18:48.122 CMD: sbaudrate
18:18:48.128 MQT: bi/domo/victrontest/stat/RESULT = {"SBaudrate":57600}
18:18:51.521 CMD: sserialconfig
18:18:51.527 MQT: bi/domo/victrontest/stat/RESULT = {"SSerialConfig":"8N1"}
18:18:54.065 CMD: serialconfig
18:18:54.071 MQT: bi/domo/victrontest/stat/RESULT = {"SerialConfig":"8N1"}
18:18:55.831 CMD: baudrate
18:18:55.837 MQT: bi/domo/victrontest/stat/RESULT = {"Baudrate":115200}
18:18:59.982 CMD: serialbuffer
18:18:59.987 MQT: bi/domo/victrontest/stat/RESULT = {"SerialBuffer":256}

RX SerBrRX
TX SerBrTX

00:00:00.001 HDW: ESP8266EX
00:00:00.050 CFG: Loaded from flash at F7, Count 265
00:00:00.056 QPC: Count 1
00:00:00.064 SNS: Hardware Serial
00:00:00.067 Project tasmota - Tasmota Version 12.2.0.5(tasmota)-2_7_4_9(2022-11-17T14:27:29)
00:00:00.171 RSL: RESULT = {"SSerialReceived":"F8"}
00:00:00.556 WIF: Connecting to AP1 xxxxxxxxxx Channel 9 BSSId xxxxxxxxxxxxxx in mode 11n as victrontest-4763...
00:00:01.801 WIF: Connected
00:00:02.006 HTP: Web server active on victrontest-4763 with IP address 192.168.1.138
18:20:40.013 MQT: Attempting connection...
18:20:40.450 MQT: Connected
18:20:40.453 MQT: bi/domo/victrontest/tele/LWT = Online (retained)
18:20:40.455 MQT: bi/domo/victrontest/cmnd/POWER = 
18:20:40.460 MQT: bi/domo/victrontest/tele/INFO1 = {"Info1":{"Module":"Generic","Version":"12.2.0.5(tasmota)","FallbackTopic":"cmnd/DVES_1E129B_fb/","GroupTopic":"bi/domo/tasmotas/cmnd/"}}
18:20:40.462 MQT: bi/domo/victrontest/tele/INFO2 = {"Info2":{"WebServerMode":"Admin","Hostname":"victrontest-4763","IPAddress":"192.168.1.138"}}
18:20:40.464 MQT: bi/domo/victrontest/tele/INFO3 = {"Info3":{"RestartReason":"Software/System restart","BootCount":107}}
18:20:43.463 QPC: Reset
18:20:44.425 MQT: bi/domo/victrontest/tele/STATE = {"Time":"2022-11-17T18:20:44","Uptime":"0T00:00:09","UptimeSec":9,"Heap":27,"SleepMode":"Dynamic","Sleep":50,"LoadAvg":19,"MqttCount":1,"Wifi":{"AP":1,"SSId":"xxxxxxxxxxxxx","BSSId":"xxxxxxxxxxxxxxx","Channel":9,"Mode":"11n","RSSI":92,"Signal":-54,"LinkCount":1,"Downtime":"0T00:00:03"}}
18:20:50.160 CMD: serialsend5 55 05 00 05 A1
18:20:50.165 MQT: bi/domo/victrontest/stat/RESULT = {"SerialSend":"Done"}
18:20:50.576 MQT: bi/domo/victrontest/tele/RESULT = {"SSerialReceived":"55050005A10D0A"}
18:20:56.369 MQT: bi/domo/victrontest/tele/RESULT = {"SSerialReceived":"55670001010032000009E2FFFFFF070A0000000800002F003B002E000D000C0000000029E20000002A000000002B02002C000000002D0200352F0033307841303630090909090931313539090909344851323132354A514B325A163078303030303030303109220D0A"}
18:21:01.408 MQT: bi/domo/victrontest/tele/RESULT = {"SSerialReceived":"55670001010032000009E2FFFFFF070A0000000800002F003B002E000D000C0000000029E20000002A000000002B02002C000000002D0200352F0033307841303630090909090931313539090909344851323132354A514B325A163078303030303030303109220D0A"}
18:21:06.360 MQT: bi/domo/victrontest/tele/RESULT = {"SSerialReceived":"55670001010032000009E2FFFFFF070A0000000800002F003B002E000D000C0000000029E20000002A000000002B02002C000000002D0200352F0033307841303630090909090931313539090909344851323132354A514B325A163078303030303030303109220D0A"}
18:21:11.366 MQT: bi/domo/victrontest/tele/RESULT = {"SSerialReceived":"55670001010032000009E2FFFFFF070A0000000800002F003B002E000D000C0000000029E20000002A000000002B02002C000000002D0200352F0033307841303630090909090931313539090909344851323132354A514B325A163078303030303030303109220D0A"}
18:21:16.374 MQT: bi/domo/victrontest/tele/RESULT = {"SSerialReceived":"55670001010032000009E2FFFFFF070A0000000800002F003B002E000D000C0000000029E20000002A000000002B02002C000000002D0200352F0033307841303630090909090931313539090909344851323132354A514B325A163078303030303030303109220D0A"}
18:21:21.439 MQT: bi/domo/victrontest/tele/RESULT = {"SSerialReceived":"55670001010032000009E2FFFFFF070A0000000800002F003B002E000D000C0000000029E20000002A000000002B02002C000000002D0200352F0033307841303630090909090931313539090909344851323132354A514B325A163078303030303030303109220D0A"}
18:21:24.337 CMD: serialsend5 55 05 00 00 A6
18:21:24.342 MQT: bi/domo/victrontest/stat/RESULT = {"SerialSend":"Done"}
18:21:24.641 MQT: bi/domo/victrontest/tele/RESULT = {"SSerialReceived":"55050000A60D0A"}
18:21:33.975 CMD: sbaudrate
18:21:33.981 MQT: bi/domo/victrontest/stat/RESULT = {"SBaudrate":57600}
18:21:37.831 CMD: sserialconfig
18:21:37.838 MQT: bi/domo/victrontest/stat/RESULT = {"SSerialConfig":"8N1"}
18:21:42.287 CMD: serialconfig
18:21:42.293 MQT: bi/domo/victrontest/stat/RESULT = {"SerialConfig":"8N1"}
18:21:46.563 CMD: baudrate
18:21:46.569 MQT: bi/domo/victrontest/stat/RESULT = {"Baudrate":57600}
18:21:51.142 CMD: serialbuffer
18:21:51.148 MQT: bi/domo/victrontest/stat/RESULT = {"SerialBuffer":256}

TO REPRODUCE

Steps to reproduce the behavior:

I am working in a system to monitoring Ve.direct from victron using an arduino as bridge. I will publish all my work when I finish.
But.... i am talking now about serial bridge.
You can see both console outputs, both serialconfigs are the same, baudrate, etc...
But I can only get a buffer in Software Serial of 126 hex chars so it is 63 bytes
In hardware serial bridge, I get all packet: 210 hex chars, so 105 bytes

As you can see, software serial bridge packet is just the first part of the whole packet.

It sounds terrible near of 64 bytes. But buffer in source code is 256 bytes.

My question is: is software serial so bad also in ESP8266?

I have checked with 115200 bps and 57600 bps

NOTE: serialsend5 and sserialsend5 commands are for control the "arduino bridge"

EXPECTED BEHAVIOUR

A clear and concise description of what you expected to happen.
A buffer of 256 bytes must be able to "get" the 105 byte packet

SCREENSHOTS

If applicable, add screenshots to help explain your problem.

ADDITIONAL CONTEXT

Add any other context about the problem here.

(Please, remember to close the issue when the problem has been addressed)

@barbudor
Copy link
Contributor

At 115200, software serial is likely to fail whatever is the buffer size
Use hardware serial

@ortegafernando
Copy link
Contributor Author

At 115200, software serial is likely to fail whatever is the buffer size Use hardware serial

Hi Barbudor, that is why I have used 57600 but see my next post. I am just writting it.

@ortegafernando
Copy link
Contributor Author

ortegafernando commented Nov 17, 2022

One more test, same nodemcu esp8266 board, without any modification in dupon wires, power, ...., with a simply sketch (see below). And a YAT (terminal) software connected:

I send "my command" (55 05 00 05 A1) as with serialsend5 and I have stopped it after 3 packets (image below):

First I get in YAT my response (red in screenshoot): 55 05 00 05 A1
And then 3 packets (in blue) of a total of 105 bytes. (every 5 seconds)

For me, this is very strange. May be the 50ms loop time for Software Serial Bridge is "a lot" ????

We know that hardware serial works, but we must think also in people that need two ports in esp866, and of course, why software serial is cutting the packet, or why it doesnt work well. I am not enough expert to know what reasons or whatever we could find to check or to test.

image

Sketch:

#include <SoftwareSerial.h>
const int pin_rx = 12; //ESP8266 D5 GPIO14, D6 GPIO12, D7 GPIO13
const int pin_tx = 13; 

SoftwareSerial gprs(pin_rx,pin_tx);

void setup(){
  Serial.begin(57600);
  gprs.begin(57600);
}

void loop(){
  if(gprs.available()){
    char c = gprs.read();
    Serial.write(c);
  }
  if(Serial.available()){     
    gprs.write(Serial.read()); 
  }
}

@ortegafernando ortegafernando changed the title Strange behaviour Software Serial Strange behaviour Software Serial (57600 and packets > 63/64 bytes) Nov 17, 2022
@ortegafernando
Copy link
Contributor Author

ortegafernando commented Nov 17, 2022

¿64 byte input buffer?

#define TM_SERIAL_BUFFER_SIZE 64 // Receive buffer size

But ... why then we have this other line:

const uint16_t SERIAL_BRIDGE_BUFFER_SIZE = MIN_INPUT_BUFFER_SIZE;

const uint16_t MIN_INPUT_BUFFER_SIZE = 256; // Max number of characters in Tasmota serial command buffer

@sfromis
Copy link
Contributor

sfromis commented Nov 17, 2022

57600 is still a high speed for software serial. Hardware serial strongly recommended.

@ortegafernando
Copy link
Contributor Author

57600 is still a high speed for software serial. Hardware serial strongly recommended.

Tomorrow I will check again with 9600bps.
But I am still confused about software serial in tasmota firmware (not ok), and the "simple" sketch (ok). I supossed because Tasmota firmware has more things to do, hasn't it?

Tomorrow I will publish more test with 9600bps. Thanks.

@arendst
Copy link
Owner

arendst commented Nov 18, 2022

As a test replace SoftwareSerial with TasmotaSerial.

If you compile your sketch from Arduino IDE it is likely using a different SDK version too.

@arendst
Copy link
Owner

arendst commented Nov 18, 2022

I also think you may be up to something regarding 64 byte input buffer....

You might want to change the serial bridge code and add the buffersize to the initial call to tasmotaserial. This enlarges the default serial buffer size. Change line 183.

    SerialBridgeSerial = new TasmotaSerial(Pin(GPIO_SBR_RX), Pin(GPIO_SBR_TX), HARDWARE_FALLBACK, 0, SERIAL_BRIDGE_BUFFER_SIZE);

My test shows it solves receiving larger messages over 64 bytes at 57600bps and higher

I'll do some more investigation how to decide to make the receive buffer larger without spending too much RAM.

arendst added a commit that referenced this issue Nov 18, 2022
Add command ``SSerialBuffer 64..256`` to change software serial bridge receive buffer size from default (64) to max local buffer size (256) (#17120)
@arendst
Copy link
Owner

arendst commented Nov 18, 2022

Using latest dev release you have the option to increase the TasmotaSerial Rx buffer from 64 up to 256 (equal to the ESP8266 serial bridge receive buffer).

If you execute command SSerialBuffer 110 you must be able to receive all data at 115200bps without error.

Give it a try.

NB. After a restart the Rx buffer is reset to 64 so at every restart you will need to execute command SSerialBuffer 110 before executing the SSerialSend5 ... command.

arendst added a commit that referenced this issue Nov 18, 2022
- Add optional define ``SERIAL_BRIDGE_BUFFER_SIZE`` to set Serial Bridge internal buffer size (Default ESP8266 = 256, ESP32 = 800)
- Add command ``SSerialBuffer 256..SERIAL_BRIDGE_BUFFER_SIZE`` to change serial bridge rx buffer size (#17120)
@arendst
Copy link
Owner

arendst commented Nov 18, 2022

The Serial Bridge uses an internal buffer to store received characters from either HardwareSerial or (Software)TasmotaSerial. Depending on processor type this buffer is size 256 (ESP8266) or 800 (ESP32). HardwareSerial has a rx buffer with default size 256. TasmotaSerial had a rx buffer with default size 64 (to save precious memory).

Latest update changes default TasmotaSerial rx buffer size from 64 to 256 when using Serial Bridge.
This solves your issue of missing data over 64 bytes at high speeds (low speeds, below 50000 bps worked fine). On the fly changes to these rx buffers is possible using command SSerialBuffer.

In addition it adds a new compile time define called SERIAL_BRIDGE_BUFFER_SIZE to change the Serial Bridge internal buffer size from 256/800.

So with these changes you must be able to safely receive at least up to 256 characters at 115200bps without any Tasmota config changes.

Give it a try.

@ortegafernando
Copy link
Contributor Author

Hi, I have been doing test today

First with developement firmware at different baud rates

21:48:49.631 CMD: sbaudrate 9600
21:48:49.637 MQT: bi/domo/victrontest/stat/RESULT = {"SBaudrate":9600}
21:49:43.034 CMD: sserialsend5 55 05 00 05 A1
21:49:43.046 MQT: bi/domo/victrontest/stat/RESULT = {"SSerialSend":"Done"}
21:49:43.410 MQT: bi/domo/victrontest/tele/RESULT = {"SSerialReceived":"55050005A10D0A"}
21:49:49.253 MQT: bi/domo/victrontest/tele/RESULT = {"SSerialReceived":"55670001010032000009F6FFFFFF070A0000000800002F003B002E000D000C0000000029E20000002A000000002B02002C000000002D0200352F0033307841303630090909090931313539090909344851323132354A514B325A1630783030303030303031090E0D0A"}
21:49:54.251 MQT: bi/domo/victrontest/tele/RESULT = {"SSerialReceived":"55670001010032000009F6FFFFFF070A0000000800002F003B002E000D000C0000000029E20000002A000000002B02002C000000002D0200352F0033307841303630090909090931313539090909344851323132354A514B325A1630783030303030303031090E0D0A"}
21:49:59.251 MQT: bi/domo/victrontest/tele/RESULT = {"SSerialReceived":"55670001010032000009F6FFFFFF070A0000000800002F003B002E000D000C0000000029E20000002A000000002B02002C000000002D0200352F0033307841303630090909090931313539090909344851323132354A514B325A1630783030303030303031090E0D0A"}
21:50:04.281 MQT: bi/domo/victrontest/tele/RESULT = {"SSerialReceived":"55670001010032000009F6FFFFFF070A0000000800002F003B002E000D000C0000000029E20000002A000000002B02002C000000002D0200352F0033307841303630090909090931313539090909344851323132354A514B325A1630783030303030303031090E0D0A"}
21:50:09.274 MQT: bi/domo/victrontest/tele/RESULT = {"SSerialReceived":"55670001010032000009F6FFFFFF070A0000000800002F003B002E000D000C0000000029E20000002A000000002B02002C000000002D0200352F0033307841303630090909090931313539090909344851323132354A514B325A1630783030303030303031090E0D0A"}
21:50:14.293 MQT: bi/domo/victrontest/tele/RESULT = {"SSerialReceived":"55670001010032000009F6FFFFFF070A0000000800002F003B002E000D000C0000000029E20000002A000000002B02002C000000002D0200352F0033307841303630090909090931313539090909344851323132354A514B325A1630783030303030303031090E0D0A"}
21:50:19.321 MQT: bi/domo/victrontest/tele/RESULT = {"SSerialReceived":"55670001010032000009F6FFFFFF070A0000000800002F003B002E000D000C0000000029E20000002A000000002B02002C000000002D0200352F0033307841303630090909090931313539090909344851323132354A514B325A1630783030303030303031090E0D0A"}
21:50:24.285 MQT: bi/domo/victrontest/tele/RESULT = {"SSerialReceived":"55670001010032000009E2FFFFFF070A0000000800002F003B002E000D000C0000000029E20000002A000000002B02002C000000002D0200352F0033307841303630090909090931313539090909344851323132354A514B325A163078303030303030303109220D0A"}
21:50:26.971 CMD: sserialsend5 55 05 00 00 A6
21:50:26.984 MQT: bi/domo/victrontest/stat/RESULT = {"SSerialSend":"Done"}
21:50:27.459 MQT: bi/domo/victrontest/tele/RESULT = {"SSerialReceived":"55050000A60D0A"}
**21:51:04.743 CMD: CHANGE ARDUINO TO 19200**
21:51:04.751 MQT: bi/domo/victrontest/stat/RESULT = {"Command":"Unknown"}
21:51:09.683 CMD: sbaudrate 19200
21:51:09.690 MQT: bi/domo/victrontest/stat/RESULT = {"SBaudrate":19200}
21:51:12.767 MQT: bi/domo/victrontest/tele/RESULT = {"SSerialReceived":"00"}
21:51:54.986 CMD: sserialsend5 55 05 00 05 A1
21:51:54.997 MQT: bi/domo/victrontest/stat/RESULT = {"SSerialSend":"Done"}
21:51:55.582 MQT: bi/domo/victrontest/tele/RESULT = {"SSerialReceived":"55050005A10D0A"}
21:52:01.382 MQT: bi/domo/victrontest/tele/RESULT = {"SSerialReceived":"55670001010032000009E2FFFFFF070A0000000800002F003B002E000D000C0000000029E20000002A000000002B02002C000000002D0200352F0033307841303630090909090931313539090909344851323132354A514B325A163078303030303030303109220D0A"}
21:52:06.387 MQT: bi/domo/victrontest/tele/RESULT = {"SSerialReceived":"55670001010032000009F6FFFFFF070A0000000800002F003B002E000D000C0000000029E20000002A000000002B02002C000000002D0200352F0033307841303630090909090931313539090909344851323132354A514B325A1630783030303030303031090E0D0A"}
21:52:11.391 MQT: bi/domo/victrontest/tele/RESULT = {"SSerialReceived":"55670001010032000009E2FFFFFF070A0000000800002F003B002E000D000C0000000029E20000002A000000002B02002C000000002D0200352F0033307841303630090909090931313539090909344851323132354A514B325A163078303030303030303109220D0A"}
21:52:16.369 MQT: bi/domo/victrontest/tele/RESULT = {"SSerialReceived":"55670001010032000009E2FFFFFF070A0000000800002F003B002E000D000C0000000029E20000002A000000002B02002C000000002D0200352F0033307841323132354A514B325A163078303030303030303109220D0A"}
21:52:21.383 MQT: bi/domo/victrontest/tele/RESULT = {"SSerialReceived":"55670001010032000009E2FFFFFF070A0000000800002F003B002E000D000C0000000029E20000002A000000002B02002C000000002D0200352F0033307841303109220D0A"}
21:52:26.397 MQT: bi/domo/victrontest/tele/RESULT = {"SSerialReceived":"55670001010032000009E2FFFFFF070A0000000800002F003B002E000D000C0000000029E20000002A000000002B02002C000000002D0200352F0033307841"}
21:52:31.421 MQT: bi/domo/victrontest/tele/RESULT = {"SSerialReceived":"55670001010032000009E2FFFFFF070A0000000800002F003B002E000D000C0000000029E20000002A000000002B02002C000000002D0200352F0033307841303630090909090931313539090909344851323132354A514B325A163078303030303030303109220D0A"}
21:52:36.391 MQT: bi/domo/victrontest/tele/RESULT = {"SSerialReceived":"55670001010032000009E2FFFFFF070A0000000800002F003B002E000D000C0000000029E20000002A000000002B02002C000000002D0200352F0033307841090909090931313539090909344851323132354A514B325A163078303030303030303109220D0A"}
21:52:41.442 MQT: bi/domo/victrontest/tele/RESULT = {"SSerialReceived":"55670001010032000009E2FFFFFF070A0000000800002F003B002E000D000C0000000029E20000002A000000002B02002C000000002D0200352F0033307841303630090909090931313539090909344851323132354A514B325A163078303030303030303109220D0A"}
21:52:46.452 MQT: bi/domo/victrontest/tele/RESULT = {"SSerialReceived":"55670001010032000009E2FFFFFF070A0000000800002F003B002E000D000C0000000029E20000002A000000002B02002C000000002D0200352F0033307841303630090909090931313539090909344851323132354A514B325A163078303030303030303109220D0A"}
21:52:51.428 MQT: bi/domo/victrontest/tele/RESULT = {"SSerialReceived":"55670001010032000009E2FFFFFF070A0000000800002F003B002E000D000C0000000029E20000002A000000002B02002C000000002D0200352F0033307841163078303030303030303109220D0A"}
21:52:56.416 MQT: bi/domo/victrontest/tele/RESULT = {"SSerialReceived":"55670001010032000009E2FFFFFF070A0000000800002F003B002E000D000C0000000029E20000002A000000002B02002C000000002D0200352F003330784109090931313539090909344851323132354A514B325A163078303030303030303109220D0A"}
21:53:01.444 MQT: bi/domo/victrontest/tele/RESULT = {"SSerialReceived":"55670001010032000009E2FFFFFF070A0000000800002F003B002E000D000C0000000029E20000002A000000002B02002C000000002D0200352F00333078413036300909090909313135390909"}
21:53:06.449 MQT: bi/domo/victrontest/tele/RESULT = {"SSerialReceived":"55670001010032000009E2FFFFFF070A0000000800002F003B002E000D000C0000000029E20000002A000000002B02002C000000002D0200352F00333078410D0A"}
21:53:11.448 MQT: bi/domo/victrontest/tele/RESULT = {"SSerialReceived":"55670001010032000009E2FFFFFF070A0000000800002F003B002E000D000C0000000029E20000002A000000002B02002C000000002D0200352F003330784132354A514B325A163078303030303030303109220D0A"}
21:53:16.464 MQT: bi/domo/victrontest/tele/RESULT = {"SSerialReceived":"55670001010A32000009E2FFFFFF070A0000000800002F003B002E000D000C0000000029E20000002A000000002B02002C000000002D0200352F00333078414B3078303030303030303109180D0A"}
21:53:21.459 MQT: bi/domo/victrontest/tele/RESULT = {"SSerialReceived":"55670001010032000009E2FFFFFF070A0000000800002F003B002E000D000C0000000029E20000002A000000002B02002C000000002D0200352F00333078410951323132354A514B325A163078303030303030303109220D0A"}
21:53:26.467 MQT: bi/domo/victrontest/tele/RESULT = {"SSerialReceived":"55670001010032000009E2FFFFFF070A0000000800002F003B002E000D000C0000000029E20000002A000000002B02002C000000002D0200352F003330784131313539090909344851323132354A514B325A163078303030303030303109220D0A"}
21:53:31.486 MQT: bi/domo/victrontest/tele/RESULT = {"SSerialReceived":"55670001010032000009E2FFFFFF070A0000000800002F003B002E000D000C0000000029E20000002A000000002B02002C000000002D0200352F0033307841"}
21:53:36.426 MQT: bi/domo/victrontest/tele/STATE = {"Time":"2022-11-18T21:53:36","Uptime":"0T00:05:09","UptimeSec":309,"Heap":26,"SleepMode":"Dynamic","Sleep":50,"LoadAvg":20,"MqttCount":1,"Wifi":{"AP":1,"SSId":"xxxxxxxxxxx","BSSId":"xxxxxxxxxxxxxxxx","Channel":9,"Mode":"11n","RSSI":100,"Signal":-48,"LinkCount":1,"Downtime":"0T00:00:03"}}
21:53:36.470 MQT: bi/domo/victrontest/tele/RESULT = {"SSerialReceived":"55670001010032000009E2FFFFFF070A0000000800002F003B002E000D000C0000000029E20000002A000000002B02002C000000002D0200352F0033307841300909090931313539090909344851323132354A514B325A163078303030303030303109220D0A"}
21:53:40.280 CMD: sserialsend5 55 05 00 00 A6
21:53:40.289 MQT: bi/domo/victrontest/stat/RESULT = {"SSerialSend":"Done"}
21:53:41.560 MQT: bi/domo/victrontest/tele/RESULT = {"SSerialReceived":"55670001010032000009E2FFFFFF070A0000000800002F003B002E000D000C0000000029E20000002A000000002B02002C000000002D0200352F0033307841303630090909090931313539090909344851323132354A514B325A163078303030303030303109220D0A55050000A60D0A"}
21:54:38.243 MQT: bi/domo/victrontest/tele/RESULT = {"SSerialReceived":"00"}
**21:55:00.572 CMD: CHANGE ARDUINO TO 9600**
21:55:00.579 MQT: bi/domo/victrontest/stat/RESULT = {"Command":"Unknown"}
21:55:04.905 CMD: sbaudrate 9600
21:55:04.912 MQT: bi/domo/victrontest/stat/RESULT = {"SBaudrate":9600}
21:55:11.259 CMD: sserialsend5 55 05 00 05 A1
21:55:11.272 MQT: bi/domo/victrontest/stat/RESULT = {"SSerialSend":"Done"}
21:55:11.891 MQT: bi/domo/victrontest/tele/RESULT = {"SSerialReceived":"55050005A10D0A"}
21:55:17.702 MQT: bi/domo/victrontest/tele/RESULT = {"SSerialReceived":"55670001010032000009E2FFFFFF070A0000000800002F003B002E000D000C0000000029E20000002A000000002B02002C000000002D0200352F0033307841303630090909090931313539090909344851323132354A514B325A163078303030303030303109220D0A"}
21:55:22.712 MQT: bi/domo/victrontest/tele/RESULT = {"SSerialReceived":"55670001010032000009E2FFFFFF070A0000000800002F003B002E000D000C0000000029E20000002A000000002B02002C000000002D0200352F0033307841303630090909090931313539090909344851323132354A514B325A163078303030303030303109220D0A"}
21:55:27.722 MQT: bi/domo/victrontest/tele/RESULT = {"SSerialReceived":"55670001010032000009E2FFFFFF070A0000000800002F003B002E000D000C0000000029E20000002A000000002B02002C000000002D0200352F0033307841303630090909090931313539090909344851323132354A514B325A163078303030303030303109220D0A"}
21:55:32.729 MQT: bi/domo/victrontest/tele/RESULT = {"SSerialReceived":"55670001010032000009E2FFFFFF070A0000000800002F003B002E000D000C0000000029E20000002A000000002B02002C000000002D0200352F0033307841303630090909090931313539090909344851323132354A514B325A163078303030303030303109220D0A"}
21:55:37.736 MQT: bi/domo/victrontest/tele/RESULT = {"SSerialReceived":"55670001010032000009E2FFFFFF070A0000000800002F003B002E000D000C0000000029E20000002A000000002B02002C000000002D0200352F0033307841303630090909090931313539090909344851323132354A514B325A163078303030303030303109220D0A"}
21:55:42.691 MQT: bi/domo/victrontest/tele/RESULT = {"SSerialReceived":"55670001010032000009E2FFFFFF070A0000000800002F003B002E000D000C0000000029E20000002A000000002B02002C000000002D0200352F0033307841303630090909090931313539090909344851323132354A514B325A163078303030303030303109220D0A"}
21:55:47.693 MQT: bi/domo/victrontest/tele/RESULT = {"SSerialReceived":"55670001010032000009E2FFFFFF070A0000000800002F003B002E000D000C0000000029E20000002A000000002B02002C000000002D0200352F0033307841303630090909090931313539090909344851323132354A514B325A163078303030303030303109220D0A"}
21:55:52.753 MQT: bi/domo/victrontest/tele/RESULT = {"SSerialReceived":"55670001010032000009E2FFFFFF070A0000000800002F003B002E000D000C0000000029E20000002A000000002B02002C000000002D0200352F0033307841303630090909090931313539090909344851323132354A514B325A16307830303030303030"}
21:55:57.765 MQT: bi/domo/victrontest/tele/RESULT = {"SSerialReceived":"55670001010032000009E2FFFFFF070A0000000800002F003B002E000D000C0000000029E20000002A000000002B02002C000000002D0200352F0033307841303630090909090931313539090909344851323132354A514B325A163078303030303030303109220D0A"}
21:56:02.766 MQT: bi/domo/victrontest/tele/RESULT = {"SSerialReceived":"55670001010032000009E2FFFFFF070A0000000800002F003B002E000D000C0000000029E20000002A000000002B02002C000000002D0200352F003330784130363009090909"}
21:56:07.740 MQT: bi/domo/victrontest/tele/RESULT = {"SSerialReceived":"55670001010A32000009E2FFFFFF070A0000000800002F003B002E000D000C0000000029E20000002A000000002B02002C000000002D0200352F00333078414851323132354A514B325A163078303030303030303109180D0A"}
21:56:12.781 MQT: bi/domo/victrontest/tele/RESULT = {"SSerialReceived":"55670001010032000009E2FFFFFF070A0000000800002F003B002E000D000C0000000029E20000002A000000002B02002C000000002D0200352F0033307841303630090909090931313539090909344851323132354A514B325A1630783030303030303031"}
21:56:17.788 MQT: bi/domo/victrontest/tele/RESULT = {"SSerialReceived":"55670001010032000009E2FFFFFF070A0000000800002F003B002E000D000C0000000029E20000002A000000002B02002C000000002D0200352F0033307841303630090909090931313539090909344851323132354A51"}
21:56:22.799 MQT: bi/domo/victrontest/tele/RESULT = {"SSerialReceived":"55670001010032000009E2FFFFFF070A0000000800002F003B002E000D000C0000000029E20000002A000000002B02002C000000002D0200352F003330784130363009090909093131353909"}
21:56:27.797 MQT: bi/domo/victrontest/tele/RESULT = {"SSerialReceived":"55670001010032000009E2FFFFFF070A0000000800002F003B002E000D000C0000000029E20000002A000000002B02002C000000002D0200352F00333078413036300909090909313135390909"}
21:56:32.764 MQT: bi/domo/victrontest/tele/RESULT = {"SSerialReceived":"55670001010A32000009E2FFFFFF070A0000000800002F003B002E000D000C0000000029E20000002A000000002B02002C000000002D0200352F0033307841"}
21:56:37.846 MQT: bi/domo/victrontest/tele/RESULT = {"SSerialReceived":"55670001010032000009E2FFFFFF070A0000000800002F003B002E000D000C0000000029E20000002A000000002B02002C000000002D0200352F0033307841303630090909090931313539090909344851323132354A514B325A163078303030303030303109220D0A"}
21:56:42.806 MQT: bi/domo/victrontest/tele/RESULT = {"SSerialReceived":"55670001010032000009E2FFFFFF070A0000000800002F003B002E000D000C0000000029E20000002A000000002B02002C000000002D0200352F0033307841303630090909090931313539090909344851323132354A514B325A163078303030303030303109220D0A"}
21:56:47.821 MQT: bi/domo/victrontest/tele/RESULT = {"SSerialReceived":"55670001010032000009E2FFFFFF070A0000000800002F003B002E000D000C0000000029E20000002A000000002B02002C000000002D0200352F0033307841303630090909090931313539090909344851323132354A514B325A163078303030303030303109220D0A"}
21:56:52.852 MQT: bi/domo/victrontest/tele/RESULT = {"SSerialReceived":"55670001010032000009E2FFFFFF070A0000000800002F003B002E000D000C0000000029E20000002A000000002B02002C000000002D0200352F0033307841303630090909090931313539090909344851323132354A514B325A163078303030303030303109220D0A"}
21:56:57.824 MQT: bi/domo/victrontest/tele/RESULT = {"SSerialReceived":"55670001010032000009E2FFFFFF070A0000000800002F003B002E000D000C0000000029E20000002A000000002B02002C000000002D0200352F003330784130363009090909093131353909303030303109220D0A"}
21:57:02.835 MQT: bi/domo/victrontest/tele/RESULT = {"SSerialReceived":"55670001010032000009E2FFFFFF070A0000000800002F003B002E000D000C0000000029E20000002A000000002B02002C000000002D0200352F0033307841303630090909090931313539090909344851323132354A514B325A163078303030303030303109220D0A"}
21:57:07.860 MQT: bi/domo/victrontest/tele/RESULT = {"SSerialReceived":"55670001010A32000009E2FFFFFF070A0000000800002F003B002E000D000C0000000029E20000002A000000002B02002C000000002D0200352F0033307841303630090909090931313539090909344851323132354A514B325A163078303030303030303109180D0A"}
21:57:12.889 MQT: bi/domo/victrontest/tele/RESULT = {"SSerialReceived":"55670001010032000009E2FFFFFF070A0000000800002F003B002E000D000C0000000029E20000002A000000002B02002C000000002D0200352F0033307841303630090909090931313539090909344851323132354A514B325A163078303030303030303109220D0A"}
21:57:17.884 MQT: bi/domo/victrontest/tele/RESULT = {"SSerialReceived":"55670001010032000009E2FFFFFF070A0000000800002F003B002E000D000C0000000029E20000002A000000002B02002C000000002D0200352F0033307841"}
21:57:22.842 MQT: bi/domo/victrontest/tele/RESULT = {"SSerialReceived":"55670001010032000009E2FFFFFF070A0000000800002F003B002E000D000C0000000029E20000002A000000002B02002C000000002D0200352F0033307841303630090909090931313539090909344851323132354A514B325A163078303030303030303109220D0A"}
21:57:27.884 MQT: bi/domo/victrontest/tele/RESULT = {"SSerialReceived":"55670001010032000009E2FFFFFF070A0000000800002F003B002E000D000C0000000029E20000002A000000002B02002C000000002D0200352F0033307841303630090909090931313539090909344851323132354A514B325A163078303030303030303109220D0A"}
21:57:32.851 MQT: bi/domo/victrontest/tele/RESULT = {"SSerialReceived":"55670001010032000009E2FFFFFF070A0000000800002F003B002E000D000C0000000029E20000002A000000002B02002C000000002D0200352F0033307841303630090909090931313539090909344851323132354A514B325A163078303030303030303109220D0A"}
21:57:37.902 MQT: bi/domo/victrontest/tele/RESULT = {"SSerialReceived":"55670001010032000009E2FFFFFF070A0000000800002F003B002E000D000C0000000029E20000002A000000002B02002C000000002D0200352F0033307841303630090909090931313539090909344851323132354A514B325A163078303030303030303109220D0A"}
21:57:42.886 MQT: bi/domo/victrontest/tele/RESULT = {"SSerialReceived":"55670001010032000009E2FFFFFF070A0000000800002F003B002E000D000C0000000029E20000002A000000002B02002C000000002D0200352F0033307841325A163078303030303030303109220D0A"}
21:57:47.945 MQT: bi/domo/victrontest/tele/RESULT = {"SSerialReceived":"55670001010032000009E2FFFFFF070A0000000800002F003B002E000D000C0000000029E20000002A000000002B02002C000000002D0200352F0033307841303630090909090931313539090909344851323132354A514B325A163078303030303030303109220D0A"}
21:57:52.918 MQT: bi/domo/victrontest/tele/RESULT = {"SSerialReceived":"55670001010032000009E2FFFFFF070A0000000800002F003B002E000D000C0000000029E20000002A000000002B02002C000000002D0200352F003330784130363009090909"}
21:57:57.893 MQT: bi/domo/victrontest/tele/RESULT = {"SSerialReceived":"55670001010032000009E2FFFFFF070A0000000800002F003B002E000D000C0000000029E20000002A000000002B02002C000000002D0200352F0033307841303630090909090931313539090909344851323132354A514B325A163078303030303030303109220D0A"}
21:58:02.896 MQT: bi/domo/victrontest/tele/RESULT = {"SSerialReceived":"55670001010032000009E2FFFFFF070A0000000800002F003B002E000D000C0000000029E20000002A000000002B02002C000000002D0200352F0033307841303030303109220D0A"}
21:58:07.591 CMD: sserialsend5 55 05 00 00 A6
21:58:07.603 MQT: bi/domo/victrontest/stat/RESULT = {"SSerialSend":"Done"}

Then, fork developement branch, change this line, and compile with gitpod.io:

#define TM_SERIAL_BUFFER_SIZE 64 // Receive buffer size

to

 #define TM_SERIAL_BUFFER_SIZE        256     // Receive buffer size 
WITH 256 BYTES:
---------------
21:59:41.232 CMD: sbaudrate 115200
21:59:41.239 MQT: bi/domo/victrontest/stat/RESULT = {"SBaudrate":115200}
21:59:53.925 CMD: sserialsend5 55 05 00 05 A1
21:59:53.932 MQT: bi/domo/victrontest/stat/RESULT = {"SSerialSend":"Done"}
21:59:54.662 MQT: bi/domo/victrontest/tele/RESULT = {"SSerialReceived":"55050005A10D0A"}
22:00:00.418 MQT: bi/domo/victrontest/tele/RESULT = {"SSerialReceived":"55670001010032000009E2FFFFFF070A0000000800002F003B002E000D000C0000000029E20000002A000000002B02002C000000002D0200352F0033307841303630090909090931313539090909344851323132354A514B325A163078303030303030303109220D0A"}
22:00:05.434 MQT: bi/domo/victrontest/tele/RESULT = {"SSerialReceived":"55670001010032000009E2FFFFFF070A0000000800002F003B002E000D000C0000000029E20000002A000000002B02002C000000002D0200352F0033307841303630090909090931313539090909344851323132354A514B325A163078303030303030303109220D0A"}
22:00:10.435 MQT: bi/domo/victrontest/tele/RESULT = {"SSerialReceived":"55670001010032000009E2FFFFFF070A0000000800002F003B002E000D000C0000000029E20000002A000000002B02002C000000002D0200352F0033307841303630090909090931313539090909344851323132354A514B325A163078303030303030303109220D0A"}
22:00:15.450 MQT: bi/domo/victrontest/tele/RESULT = {"SSerialReceived":"55670001010032000009E2FFFFFF070A0000000800002F003B002E000D000C0000000029E20000002A000000002B02002C000000002D0200352F0033307841303630090909090931313539090909344851323132354A514B325A163078303030303030303109220D0A"}
22:00:20.454 MQT: bi/domo/victrontest/tele/RESULT = {"SSerialReceived":"55670001010032000009E2FFFFFF070A0000000800002F003B002E000D000C0000000029E20000002A000000002B02002C000000002D0200352F0033307841303630090909090931313539090909344851323132354A514B325A163078303030303030303109220D0A"}
22:00:25.464 MQT: bi/domo/victrontest/tele/RESULT = {"SSerialReceived":"5567000101F631000009E2FFFFFF070A0000000800002F003B002E000D000C0000000029E20000002A000000002B02002C000000002D0200352F0033307841303630090909090931313539090909344851323132354A514B325A1630783030303030303031092D0D0A"}
22:00:30.472 MQT: bi/domo/victrontest/tele/RESULT = {"SSerialReceived":"5567000101F631000009E2FFFFFF070A0000000800002F003B002E000D000C0000000029E20000002A000000002B02002C000000002D0200352F0033307841303630090909090931313539090909344851323132354A514B325A1630783030303030303031092D0D0A"}
22:00:35.480 MQT: bi/domo/victrontest/tele/RESULT = {"SSerialReceived":"55670001010032000009E2FFFFFF070A0000000800002F003B002E000D000C0000000029E20000002A000000002B02002C000000002D0200352F0033307841303630090909090931313539090909344851323132354A514B325A163078303030303030303109220D0A"}
22:00:40.491 MQT: bi/domo/victrontest/tele/RESULT = {"SSerialReceived":"55670001010032000009E2FFFFFF070A0000000800002F003B002E000D000C0000000029E20000002A000000002B02002C000000002D0200352F0033307841303630090909090931313539090909344851323132354A514B325A163078303030303030303109220D0A"}
22:00:45.495 MQT: bi/domo/victrontest/tele/RESULT = {"SSerialReceived":"55670001010032000009E2FFFFFF070A0000000800002F003B002E000D000C0000000029E20000002A000000002B02002C000000002D0200352F0033307841303630090909090931313539090909344851323132354A514B325A163078303030303030303109220D0A"}
22:00:50.506 MQT: bi/domo/victrontest/tele/RESULT = {"SSerialReceived":"5567000101EC31000009E2FFFFFF070A0000000800002F003B002E000D000C0000000029E20000002A000000002B02002C000000002D0200352F0033307841303630090909090931313539090909344851323132354A514B325A163078303030303030303109370D0A"}
22:00:55.511 MQT: bi/domo/victrontest/tele/RESULT = {"SSerialReceived":"55670001010032000009E2FFFFFF070A0000000800002F003B002E000D000C0000000029E20000002A000000002B02002C000000002D0200352F0033307841303630090909090931313539090909344851323132354A514B325A163078303030303030303109220D0A"}
22:01:00.522 MQT: bi/domo/victrontest/tele/RESULT = {"SSerialReceived":"55670001010032000009E2FFFFFF070A0000000800002F003B002E000D000C0000000029E20000002A000000002B02002C000000002D0200352F0033307841303630090909090931313539090909344851323132354A514B325A163078303030303030303109220D0A"}
22:01:05.525 MQT: bi/domo/victrontest/tele/RESULT = {"SSerialReceived":"55670001010032000009E2FFFFFF070A0000000800002F003B002E000D000C0000000029E20000002A000000002B02002C000000002D0200352F0033307841303630090909090931313539090909344851323132354A514B325A163078303030303030303109220D0A"}
22:01:10.536 MQT: bi/domo/victrontest/tele/RESULT = {"SSerialReceived":"5567000101EC31000009E2FFFFFF070A0000000800002F003B002E000D000C0000000029E20000002A000000002B02002C000000002D0200352F0033307841303630090909090931313539090909344851323132354A514B325A163078303030303030303109370D0A"}
22:01:15.540 MQT: bi/domo/victrontest/tele/RESULT = {"SSerialReceived":"55670001010032000009E2FFFFFF070A0000000800002F003B002E000D000C0000000029E20000002A000000002B02002C000000002D0200352F0033307841303630090909090931313539090909344851323132354A514B325A163078303030303030303109220D0A"}
22:01:20.549 MQT: bi/domo/victrontest/tele/RESULT = {"SSerialReceived":"55670001010032000009E2FFFFFF070A0000000800002F003B002E000D000C0000000029E20000002A000000002B02002C000000002D0200352F0033307841303630090909090931313539090909344851323132354A514B325A163078303030303030303109220D0A"}
22:01:25.558 MQT: bi/domo/victrontest/tele/RESULT = {"SSerialReceived":"55670001010032000009E2FFFFFF070A0000000800002F003B002E000D000C0000000029E20000002A000000002B02002C000000002D0200352F0033307841303630090909090931313539090909344851323132354A514B325A163078303030303030303109220D0A"}
22:01:30.568 MQT: bi/domo/victrontest/tele/RESULT = {"SSerialReceived":"5567000101F631000009E2FFFFFF070A0000000800002F003B002E000D000C0000000029E20000002A000000002B02002C000000002D0200352F0033307841303630090909090931313539090909344851323132354A514B325A1630783030303030303031092D0D0A"}
22:01:35.574 MQT: bi/domo/victrontest/tele/RESULT = {"SSerialReceived":"5567000101EC31000009E2FFFFFF070A0000000800002F003B002E000D000C0000000029E20000002A000000002B02002C000000002D0200352F0033307841303630090909090931313539090909344851323132354A514B325A163078303030303030303109370D0A"}
22:01:40.586 MQT: bi/domo/victrontest/tele/RESULT = {"SSerialReceived":"5567000101F631000009E2FFFFFF070A0000000800002F003B002E000D000C0000000029E20000002A000000002B02002C000000002D0200352F0033307841303630090909090931313539090909344851323132354A514B325A1630783030303030303031092D0D0A"}
22:01:45.591 MQT: bi/domo/victrontest/tele/RESULT = {"SSerialReceived":"5567000101EC31000009E2FFFFFF070A0000000800002F003B002E000D000C0000000029E20000002A000000002B02002C000000002D0200352F0033307841303630090909090931313539090909344851323132354A514B325A163078303030303030303109370D0A"}
22:01:50.597 MQT: bi/domo/victrontest/tele/RESULT = {"SSerialReceived":"55670001010032000009E2FFFFFF070A0000000800002F003B002E000D000C0000000029E20000002A000000002B02002C000000002D0200352F0033307841303630090909090931313539090909344851323132354A514B325A163078303030303030303109220D0A"}
22:01:55.612 MQT: bi/domo/victrontest/tele/RESULT = {"SSerialReceived":"55670001010032000009E2FFFFFF070A0000000800002F003B002E000D000C0000000029E20000002A000000002B02002C000000002D0200352F0033307841303630090909090931313539090909344851323132354A514B325A163078303030303030303109220D0A"}
22:02:00.613 MQT: bi/domo/victrontest/tele/RESULT = {"SSerialReceived":"55670001010032000009E2FFFFFF070A0000000800002F003B002E000D000C0000000029E20000002A000000002B02002C000000002D0200352F0033307841303630090909090931313539090909344851323132354A514B325A163078303030303030303109220D0A"}
22:02:05.623 MQT: bi/domo/victrontest/tele/RESULT = {"SSerialReceived":"55670001010032000009E2FFFFFF070A0000000800002F003B002E000D000C0000000029E20000002A000000002B02002C000000002D0200352F0033307841303630090909090931313539090909344851323132354A514B325A163078303030303030303109220D0A"}
22:02:10.630 MQT: bi/domo/victrontest/tele/RESULT = {"SSerialReceived":"5567000101F631000009E2FFFFFF070A0000000800002F003B002E000D000C0000000029E20000002A000000002B02002C000000002D0200352F0033307841303630090909090931313539090909344851323132354A514B325A1630783030303030303031092D0D0A"}
22:02:15.644 MQT: bi/domo/victrontest/tele/RESULT = {"SSerialReceived":"55670001010032000009E2FFFFFF070A0000000800002F003B002E000D000C0000000029E20000002A000000002B02002C000000002D0200352F0033307841303630090909090931313539090909344851323132354A514B325A163078303030303030303109220D0A"}
22:02:16.473 CMD: sserialsend5 55 05 00 00 A6
22:02:16.480 MQT: bi/domo/victrontest/stat/RESULT = {"SSerialSend":"Done"}
22:02:16.890 MQT: bi/domo/victrontest/tele/RESULT = {"SSerialReceived":"55050000A60D0A"}

With a buffer of 64 bytes I get a first test at 9600bps good, 19200bps bad and a final third test again at 9600bps bad (some packets arrives with all bytes, some others not)

With a buffer of 256 bytes (exact the same as software serial bridge min input buffer size) not problem at all even at 115200 bps !!!!

Tasmota/tasmota/tasmota_xdrv_driver/xdrv_08_serial_bridge.ino
const uint16_t SERIAL_BRIDGE_BUFFER_SIZE = MIN_INPUT_BUFFER_SIZE; 
Tasmota/tasmota/include/tasmota.h
 const uint16_t MIN_INPUT_BUFFER_SIZE = 256;  // Max number of characters in Tasmota serial command buffer

Gitpod.io output:

RAM:   [=====     ]  50.9% (used 41676 bytes from 81920 bytes)
Flash: [======    ]  62.9% (used 644344 bytes from 1023984 bytes)

Conclusion, could I make a PR to change this buffer size to 256 bytes to be the same as tasmota minimal buffer size for software serial bridge? It makes me sense, and we have plenty of RAM to used another 192 bytes (256-64), haven't we?

Hope your answer, I think it will avoid future problems with software serial bridge, ESP8266 with have a very good serial ports (hardware and software), .... I think it will avoid lots of headaches ;)

@ortegafernando
Copy link
Contributor Author

The Serial Bridge uses an internal buffer to store received characters from either HardwareSerial or (Software)TasmotaSerial. Depending on processor type this buffer is size 256 (ESP8266) or 800 (ESP32). HardwareSerial has a rx buffer with default size 256. TasmotaSerial had a rx buffer with default size 64 (to save precious memory).

Latest update changes default TasmotaSerial rx buffer size from 64 to 256 when using Serial Bridge. This solves your issue of missing data over 64 bytes at high speeds (low speeds, below 50000 bps worked fine). On the fly changes to these rx buffers is possible using command SSerialBuffer.

In addition it adds a new compile time define called SERIAL_BRIDGE_BUFFER_SIZE to change the Serial Bridge internal buffer size from 256/800.

So with these changes you must be able to safely receive at least up to 256 characters at 115200bps without any Tasmota config changes.

Give it a try.

Sorry; I have just sent my tests without reading you. But conclusion is the same. (I am not an expert in github, I dont know how I didn't be able to see your changes even I have fork tasmota 1 hour before my message) But it dont mind, the best is that you have already update to 256 as a default value, haven't you?

@ortegafernando
Copy link
Contributor Author

Hi, after checking last developement release, software serial bridge is working perfectlly. Thanks a lot.

Thanks a lot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants