-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Comments
At 115200, software serial is likely to fail whatever is the buffer size |
Hi Barbudor, that is why I have used 57600 but see my next post. I am just writting it. |
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 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. Sketch:
|
¿64 byte input buffer?
But ... why then we have this other line:
Tasmota/tasmota/include/tasmota.h Line 201 in 5f3d504
|
57600 is still a high speed for software serial. Hardware serial strongly recommended. |
Tomorrow I will check again with 9600bps. Tomorrow I will publish more test with 9600bps. Thanks. |
As a test replace SoftwareSerial with TasmotaSerial. If you compile your sketch from Arduino IDE it is likely using a different SDK version too. |
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.
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. |
Add command ``SSerialBuffer 64..256`` to change software serial bridge receive buffer size from default (64) to max local buffer size (256) (#17120)
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 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 |
- 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)
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. In addition it adds a new compile time define called 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. |
Hi, I have been doing test today First with developement firmware at different baud rates
Then, fork developement branch, change this line, and compile with gitpod.io:
to
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 !!!!
Gitpod.io output:
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 ;) |
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? |
Hi, after checking last developement release, software serial bridge is working perfectlly. Thanks a lot. Thanks a lot. |
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!
Backlog Template; Module; GPIO 255
:Backlog Rule1; Rule2; Rule3
:Status 0
:weblog
to 4 and then, when you experience your issue, provide the output of the Console log: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)
The text was updated successfully, but these errors were encountered: