-
Notifications
You must be signed in to change notification settings - Fork 9
NullPointer exception on running sketch on processing #1
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 found that adding a small delay after the check to see if serial data was available stopped the NullPointer exception. I do not have any idea why it fixed it and I think it is a kludge. My thinking is that there is something messy with the Processing 3 Serial handler, my computer or something. I also ran this on an Wemos mini Lite so maybe that is a factor. Oh I also changed my null terminator in the arduino code to '\0' to try to fix this, that is why I have a readStringUntil(00). The initial code has 13 which is carriage return. See below: |
I have experienced the same problem with Processing 3. I added a little check to make sure that the string is not empty before doing anything else in the draw() function.
Seems to solve it, but I have no idea why the string would be empty after the |
FYI, looks like the issue is with the line There's actually something closer to 300 bytes available before the carriage return character is sent, but I think this varies as the data is sent as a string of floats, which I think can have different numbers of characters in the decimal value, so the length of bytes in the float string might change depending on what the data looks like. A better way for the code to be written might be to use something that reads each character as it comes in, adds it to a buffer, and checks if the character is the string terminator.
|
Thank you for raising this issue - and apologies for the VERY slow reply! I've merged @Suisse00 's PR #4 into v1.0.2. v1.0.2 will be released shortly. I know it has been years since this issue was opened, but please do give v1.0.2 a try and let me know if you see any other issues. Very best wishes, |
Im havin a lot of errors on Processing 3, some are nullpointer exceptions and map(NaN, 20, 40, 240, 360) called, which returns NaN (not a number)
The text was updated successfully, but these errors were encountered: