-
-
Notifications
You must be signed in to change notification settings - Fork 7k
Properly decode UTF-8 characters comming in from serial one byte at a time. #5967
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
Conversation
… time. This fixes #2430.
I can see some performance penalty here with sketches writing a lot of stuff. |
My gut feeling is that the raw throughput of any such code (both mine and the previous) is much higher than any serial port or any UI work can ever be. If that helps any, I offer to provide performance tests to prove that point. |
I think testing is needed with Arduino Due and/or Teensy 3.6. Where's @ArduinoBot when we need him? |
int copyNow = buf.length - next < spaceInIn ? buf.length - next : spaceInIn; | ||
inFromSerial.put(buf, next, copyNow); | ||
next += copyNow; | ||
inFromSerial.flip(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why flip()
is called?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The buffer needs to be switched from being written to to being read from, which is what flip
does.
Both clear
and compact
switch the buffer from having being read to being ready to accept writes.
Ok, compiled and running it now. Seems to be ok CPU-wise. Tested only on Linux 64 bit running on a fast desktop machine. |
@ArduinoBot build this please. |
✅ Build completed. Please test this code using one of the following: ⬇️ http://downloads.arduino.cc/javaide/pull_requests/arduino-PR-5967-BUILD-652-linux32.tar.xz ℹ️ The |
What's the usual process with pull requests here in the Arduino repo? I thought, the obvious, "push a pull request and wait a few days". But there has been nothing here for more than a week now. For that week, I've been waiting for the maintainers to move. I hope they are not simultaneously waiting for me. Is anything missing I'm expected to provide? If so, I'm not aware of it. Please tell me. Or what's been hindering this to be merged, if I may ask? |
@aknrdureegaesr |
This fixes #2430.