-
Notifications
You must be signed in to change notification settings - Fork 7.6k
WiFiUDP not reading last byte #145
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
Comments
I agree that cbuf might need to be looked at, though that same cbuf is running on esp8266 also and is used by many libs, so it's strange to me to not be working. |
I've patched the "bug" in cbuf::room() by using:
room() will then return the correct free size (e.g. 17 bytes), but then available() returns 0, because _begin is the same value as _end (wrap_if_bufend). Proposed fix for this problem is to actually patch WiFiUDP::parsePacket():
should be
The usage of cbuf should be checked (is cbuf actually working correctly and only used "wrong" in WiFiUDP?).
For me it's actually strange that the one-off bug was not catched by anyone else here.
I can kinda agreee that overloading the method maybe confusing to other users (e.g. using parsePacket(buf, sizeof(buf)) and then trying to use WiFiUDP::read() or so). I will provide a pull request with my approach. |
done :) |
…rary throw warnings if action_install.sh is used and repo does not have 'arduino-library' tag in its topic
* Update CMakeLists.txt Removes RainMaker and replaces "all" to get it working with WSL Ubuntu * Tool fix Moving SR files copy from tools/copy-libs.sh to /build.sh :: WSL fix Commenting out all cloned components that are now part of the Managed Components. * Update idf_component.yml Lib builder Managed Components for the top level (not in Arduino as IDF Component level). Includes only Tensor Flow and Deep Learning. All other managed component will be added to ESP32-Arduino repository. * Adds Camera Component * DL component only for S3 * get Camera component from GH * Camera component for any Version + Public * Test for SR Models building in CI * add SR component to the CI * fix idf_component.yml format * Reverting not necessary change about ESP-SR component
The WiFiUDP implementation is not reading the last byte in WiFiUDP::read().
Example (code is working fine on ESP8266 and ESP32 with one byte extra padding when sending packets to it):
Size is for example 17 but read() reads only 16 bytes. The bug is in the cbuf class: cbuf::write() copies 16 bytes because cbuf::room() returns only 16 bytes (and not the correct length of 17 bytes).
The bug in the cbuf class should be fixed, but also a new method should be added to WiFiUDP:
int WiFiUDP::parsePacket(char* buffer, size_t size) (or some other signature).
parsePacket copies the packet content in the user provided buffer and returning the size of the packet. With this approach there is no need to create an internal cbuf instance and saving some memory overall.
The text was updated successfully, but these errors were encountered: