You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Processing 2.1 is extremely slow on receiving serial communications.
Serial data is being generated by an Arduino and sent to my PC over USB, per typical Arduino setup. Baud rate is supposedly 115200, but some text being streamed at the startup of the Arduino is coming in at a snail's pace. It took 25 seconds to read the 2860 characters that are issued at the startup of my Arduino (~900 bps). It is the correct text (so the baud rates are appropriately matched) but it is soooo slow.
When I switch my Arduino to stream its sensor data (~80 kbps of continuous binary data), the Processing program claims that it's only getting the data at ~1.9 kbps. When tested in a basic terminal program (RealTerm) the bytes are received at the correct rate without issue. So, the problem is not with the Arduino nor with Windows in general.
This slow behavior is seen using my own Processing program as well as with Processing's Serial example "SimpleRead" as modified to print the received byte to Processing's console via "print(char(val))". So, the problem is not with my own program, since it is in the example program as well.
My own program to receive the data stream from the Arduino worked fine in Processing 2.0.x when run in the 32-bit version of Processing. So, I believe that the problem has been introduced with the change to Processing 2.1.
I'm running Windows 7SP1, 64-bit. I tested in both 32-bit and 64-bit versions of Processing 2.1 and they both have this slowness problem. I'm using the latest drivers for video card, as downloaded today. I'm running Java 7u45, also downloaded today.
Thanks for the detailed report - I am looking into this right now.
Do you perhaps have a way to test your sketch w/ Processing 2.1 on a different OS?
Which Arduino model are you using?
Would you mind testing a version of the Serial library with some extra debugging code put in?
To answer your question regarding alternate platforms...I do have a friend who had similar problems with super-slow Serial when using my sketch in Processing 2.1 on the Mac. On Processing 2.0.3 on the Mac, the serial works as expected.
For the Arduino, I was using an Uno R3.
I would be happy to test an alternate Serial library, though I might need a pointer on where to put it to ensure that the new library is used instead of the old one.
Thanks for the detailed report - I am looking into this right now.
Do you perhaps have a way to test your sketch w/ Processing 2.1 on a different OS?
Which Arduino model are you using?
Would you mind testing a version of the Serial library with some extra debugging code put in?
—
Reply to this email directly or view it on GitHub.
I would also be more than happy to test a debug version to help remediate the speed issue on 2.1 on the mac. I have a drum sequencer that I use as a primary musical instrument when I perform live, and 2.1 serial is unusable with mavericks. It has the appearance of working, but after 3 minutes of the compiled app running in the background, the communication with the arduino becomes unstable, eventually becoming completely out of sync and unusable.
My toolchain looks like this:
my hardware -> arduino mega -> serial -> processing -> Open Sound Control -> max msp -> midi.
My hardware hasn't changed. The arduino firmware hasn't changed. The Max MSP app continues to run the sequence perfectly, despite having lost meaningful communication with the hardware... I have a hardware emulator that I wrote in Objective C that I can use to test the OSC messaging, and it looks like that's still running just fine. So it's looking like the serial communication is an area to investigate next.
I also have a slower connection (about 400 ms) . I use an arduino uno board on mac mini (snow leopard). Didn’t change arduino firmware, osx or anything else.
using an incoming pulse (GPIO) to arduino > serial > processing 2.1 ( before 2.0.3)
I would also be more than happy to test a debug version to help remediate the speed issue on 2.1 on the mac. I have a drum sequencer that I use as a primary musical instrument when I perform live, and 2.1 serial is unusable with mavericks. It has the appearance of working, but after 3 minutes of the compiled app running in the background, the communication with the arduino becomes unstable, eventually becoming completely out of sync and unusable.
My toolchain looks like this:
my hardware -> arduino mega -> serial -> processing -> Open Sound Control -> max msp -> midi.
My hardware hasn't changed. The arduino firmware hasn't changed. The Max MSP app continues to run the sequence perfectly, despite having lost meaningful communication with the hardware... I have a hardware emulator that I wrote in Objective C that I can use to test the OSC messaging, and it looks like that's still running just fine. So it's looking like the serial communication is an area to investigate next.
On OS X, this works by opening up the application (right click, "Show Package Contents") and then navigating to Contents > Java > modes > java > libraries > serial > library.
If you see the "Serial: test #1" line upon object instantiation, then the replacement was successful. Could you send me the output, perhaps with an added println() for whenever you're receiving a byte or so? (I'll test this myself as well when I get a chance.)
On OS X, this works by opening up the application (right click, "Show Package Contents") and then navigating to Contents > Java > modes > java > libraries > serial > library.
If you see the "Serial: test #1" line upon object instantiation, then the replacement was successful. Could you send me the output, perhaps with an added println() for whenever you're receiving a byte or so? (I'll test this myself as well when I get a chance.)
—
Reply to this email directly or view it on GitHub.
Sorry, should have been more specific: the file above is for anyone who is seeing this issue - won't fix anything but might provide some clues as to what is going on. Thanks.
@stevecooley Thanks. What baudrate is this? Are you using available() & friends inside draw or serialEvent? Could you try again with a println() that either outputs the return value of available() or something whenever serialEvent is called?
57600 bps. Yes, I'm using available() inside of draw(). I'm not using serialEvent. While serial_port.available(), println of what available() was... interesting. Screenshot of output next to activity monitor attached.
@stevecooley Could you paste a log as above, with the println()s from available() interleaved with the Serial debugging information? This could provide some insight wrt the timing.. Thanks.
I'm having a hard time doing this because when I run the program, with the output of available() println()'ing, the process runs away (see above graphic at 650% CPU usage) and because the log automatically truncates, and I can not see where to locate a disk-based log verison of the run log... no. I'm unable to do that at this time. Um.... I want to help more.
Thanks @thebishopgame, much appreciate you taking the time to look into this! Making serialEvent more reactive should certainly be doable, but I am still a bit unsure what change to the serial library triggered the overflow and the seconds long delay for you.. it's /supposed/ to be just a drop-in replacement for the serial library we used in 2.0.3.
@REAS Not yet, I still feel there is a bug lurking somewhere.. I'll look through the code again and perhaps cook up a version that can spit out some internal statistics on demand.
To install: overwrite the specific jar files inside Processing 2.1 with the ones available here: http://sukzessiv.net/processing-serial/test4/
On OS X, this works by opening up the application (right click, "Show Package Contents") and then navigating to Contents > Java > modes > java > libraries > serial > library.
@thebishopgame You might want to try your original code that made use of serialEvent.
I make a little test for checking serial communication speed in processing. I have not found any problems nor in 2.1 nor in 2.0.3 in Win32. I have a little note for modifying a Serial processing class, because there are some non-optimal jSSC event listener using, but it's not so critical.
I make an app for my Arduino Duemilanove for sending a simple string at 115200 baud:
Processing 2.1 (Serial based on jSSC-2.6.0):
cur rate: 115000
avg rate: 113850
Kbytes: 3398 (bytes: 3479936)
Time spent: 00:05:00
Processing 2.0.3 (Serial based on RXTX-2.1-7)
cur rate: 115000
avg rate: 113850
Kbytes: 3398 (bytes: 3479951)
Time spent: 00:05:00
As you can see results are the same, and pretty-pretty close to 115200 baud. Please run this on your OS-s (Linux, MacOS etc.) and post results here. Processing sketch you can find here: https://github.com/scream3r/tmp/blob/master/SerialTest.pde
@scream3r Hi Alexey!
I believe the the issue was this: RXTX would call the event handler once for each byte that became available, whereas on jSSC, with a USB attached Arduino and OS X, you would get chunks of e.g. 908 bytes at once followed by a 300ms delay. Same throughput, but this broke code that assumed the serialEvent callback in Processing would be called at evenly spaced, regular intervals.
At first I thought the 300ms delay was specifically an issue with jSSC (FIONREAD ioctl not refreshing), but it turns out that RXTX also has times when no byte is coming in - so this might just be a limitation of the OS. (Let me know if you have some ideas - oddly, writing to the port seems to update the value returned by FIONREAD).
So the change we'll be doing for the next Processing release is to read in byte for byte and call serialEvent - in case the sketch is using this callback. One change that I'd like to make to jSSC is to use select() on the file handle instead of the 100ns wait - if mask is only set to RXCHAR. Have you had a chance to look at my other patches to jSSC?
@gohai First, sorry it took so long to get back to this, I got slammed. Second, THIS IS SO MUCH BETTER. Thank you! Just did some quick testing in my app, both methods seem improved but serialEvent appears to be a little snappier when actually using the instrument. I'm psyched that I don't have to scrap four weeks of work and re-do it in C++!
Would you like me to run any more of the timing tests or anything and post results or are you confident in the fix?
@gohai I just tried the latest to jar files. I used my Processing sketch and it received data piped over USB from my Arduino. It seems to run great. I'm pumping about 80kbps, which is what my Arduino data collection unit is trying to do. I'm satisfied. Nice work!
Since I'm the one who opened this issue, is there anything that I need to do to close it?
@thebishopgame@chipaudette
I just committed a slightly different fix for this issue (that reverts a busy-loop deep down in the library back into a 100ns delay - which is easier on the CPU). If you have some time to check whether http://sukzessiv.net/processing-serial/test5/ still works for you - hope to have Serial working solidly for the next proper release. Thanks!
Activity
chipaudette commentedon Nov 10, 2013
Just re-confirmed...works fine in Processing 2.0.3 on my computer.
gohai commentedon Nov 11, 2013
Thanks for the detailed report - I am looking into this right now.
Do you perhaps have a way to test your sketch w/ Processing 2.1 on a different OS?
Which Arduino model are you using?
Would you mind testing a version of the Serial library with some extra debugging code put in?
chipaudette commentedon Nov 11, 2013
Hi!
Thanks for looking into the serial problem!
To answer your question regarding alternate platforms...I do have a friend who had similar problems with super-slow Serial when using my sketch in Processing 2.1 on the Mac. On Processing 2.0.3 on the Mac, the serial works as expected.
For the Arduino, I was using an Uno R3.
I would be happy to test an alternate Serial library, though I might need a pointer on where to put it to ensure that the new library is used instead of the old one.
Chip
On Monday, November 11, 2013 3:34 PM, gohai notifications@github.com wrote:
Thanks for the detailed report - I am looking into this right now.
Do you perhaps have a way to test your sketch w/ Processing 2.1 on a different OS?
Which Arduino model are you using?
Would you mind testing a version of the Serial library with some extra debugging code put in?
—
Reply to this email directly or view it on GitHub.
stevecooley commentedon Nov 11, 2013
I would also be more than happy to test a debug version to help remediate the speed issue on 2.1 on the mac. I have a drum sequencer that I use as a primary musical instrument when I perform live, and 2.1 serial is unusable with mavericks. It has the appearance of working, but after 3 minutes of the compiled app running in the background, the communication with the arduino becomes unstable, eventually becoming completely out of sync and unusable.
My toolchain looks like this:
my hardware -> arduino mega -> serial -> processing -> Open Sound Control -> max msp -> midi.
My hardware hasn't changed. The arduino firmware hasn't changed. The Max MSP app continues to run the sequence perfectly, despite having lost meaningful communication with the hardware... I have a hardware emulator that I wrote in Objective C that I can use to test the OSC messaging, and it looks like that's still running just fine. So it's looking like the serial communication is an area to investigate next.
h2oop commentedon Nov 11, 2013
Hey,
I also have a slower connection (about 400 ms) . I use an arduino uno board on mac mini (snow leopard). Didn’t change arduino firmware, osx or anything else.
using an incoming pulse (GPIO) to arduino > serial > processing 2.1 ( before 2.0.3)
On 11 Nov 2013, at 22:33, stevecooley notifications@github.com wrote:
gohai commentedon Nov 11, 2013
Could you take the serial.jar from http://sukzessiv.net/processing-serial/test1/ and replace the one that comes with Processing 2.1 with this file.
On OS X, this works by opening up the application (right click, "Show Package Contents") and then navigating to Contents > Java > modes > java > libraries > serial > library.
If you see the "Serial: test #1" line upon object instantiation, then the replacement was successful. Could you send me the output, perhaps with an added println() for whenever you're receiving a byte or so? (I'll test this myself as well when I get a chance.)
h2oop commentedon Nov 11, 2013
problem is that i am using this setup for broadcasting tv in brussels… i should buy a second arduino to test around… i ll see what i can do.
On 11 Nov 2013, at 23:18, gohai notifications@github.com wrote:
gohai commentedon Nov 11, 2013
Sorry, should have been more specific: the file above is for anyone who is seeing this issue - won't fix anything but might provide some clues as to what is going on. Thanks.
stevecooley commentedon Nov 11, 2013
Ok!
gohai commentedon Nov 11, 2013
@stevecooley Thanks. What baudrate is this? Are you using available() & friends inside draw or serialEvent? Could you try again with a println() that either outputs the return value of available() or something whenever serialEvent is called?
stevecooley commentedon Nov 11, 2013
57600 bps. Yes, I'm using available() inside of draw(). I'm not using serialEvent. While serial_port.available(), println of what available() was... interesting. Screenshot of output next to activity monitor attached.
gohai commentedon Nov 11, 2013
@stevecooley Could you paste a log as above, with the println()s from available() interleaved with the Serial debugging information? This could provide some insight wrt the timing.. Thanks.
stevecooley commentedon Nov 11, 2013
I'm having a hard time doing this because when I run the program, with the output of available() println()'ing, the process runs away (see above graphic at 650% CPU usage) and because the log automatically truncates, and I can not see where to locate a disk-based log verison of the run log... no. I'm unable to do that at this time. Um.... I want to help more.
gohai commentedon Nov 12, 2013
@stevecooley That looks odd, could you send me your sketch?
stevecooley commentedon Nov 12, 2013
yes, it's already on github.
https://github.com/stevecooley/beatseqr-software/blob/master/processing_code/roxor_2/roxor_2.pde
22 remaining items
gohai commentedon Nov 24, 2013
Thanks @thebishopgame, much appreciate you taking the time to look into this! Making serialEvent more reactive should certainly be doable, but I am still a bit unsure what change to the serial library triggered the overflow and the seconds long delay for you.. it's /supposed/ to be just a drop-in replacement for the serial library we used in 2.0.3.
REAS commentedon Nov 24, 2013
@gohai Do you think you have parity in response to 2.0.3 and the rxtx serial now through these recent changes/additions?
gohai commentedon Nov 24, 2013
@REAS Not yet, I still feel there is a bug lurking somewhere.. I'll look through the code again and perhaps cook up a version that can spit out some internal statistics on demand.
gohai commentedon Nov 25, 2013
@chipaudette @stevecooley @h2oop @thebishopgame
We have a new version for you to test - serialEvent should now work as it did in 2.0.3. Please let us know how it goes.
To install: overwrite the specific jar files inside Processing 2.1 with the ones available here: http://sukzessiv.net/processing-serial/test4/
On OS X, this works by opening up the application (right click, "Show Package Contents") and then navigating to Contents > Java > modes > java > libraries > serial > library.
@thebishopgame You might want to try your original code that made use of serialEvent.
scream3r commentedon Nov 26, 2013
Hi all.
I make a little test for checking serial communication speed in processing. I have not found any problems nor in
2.1nor in2.0.3inWin32. I have a little note for modifying aSerialprocessing class, because there are some non-optimal jSSC event listener using, but it's not so critical.I make an app for my
Arduino Duemilanovefor sending a simple string at115200 baud:My results after 5 minutes on WinXP 32-bit:
As you can see results are the same, and pretty-pretty close to
115200 baud. Please run this on your OS-s (Linux, MacOS etc.) and post results here. Processing sketch you can find here: https://github.com/scream3r/tmp/blob/master/SerialTest.pdegohai commentedon Nov 26, 2013
@scream3r Hi Alexey!
I believe the the issue was this: RXTX would call the event handler once for each byte that became available, whereas on jSSC, with a USB attached Arduino and OS X, you would get chunks of e.g. 908 bytes at once followed by a 300ms delay. Same throughput, but this broke code that assumed the serialEvent callback in Processing would be called at evenly spaced, regular intervals.
At first I thought the 300ms delay was specifically an issue with jSSC (FIONREAD ioctl not refreshing), but it turns out that RXTX also has times when no byte is coming in - so this might just be a limitation of the OS. (Let me know if you have some ideas - oddly, writing to the port seems to update the value returned by FIONREAD).
So the change we'll be doing for the next Processing release is to read in byte for byte and call serialEvent - in case the sketch is using this callback. One change that I'd like to make to jSSC is to use select() on the file handle instead of the 100ns wait - if mask is only set to RXCHAR. Have you had a chance to look at my other patches to jSSC?
Thanks for your time!
thebishopgame commentedon Nov 26, 2013
@gohai First, sorry it took so long to get back to this, I got slammed. Second, THIS IS SO MUCH BETTER. Thank you! Just did some quick testing in my app, both methods seem improved but serialEvent appears to be a little snappier when actually using the instrument. I'm psyched that I don't have to scrap four weeks of work and re-do it in C++!
Would you like me to run any more of the timing tests or anything and post results or are you confident in the fix?
gohai commentedon Nov 26, 2013
@thebishopgame I am glad it works again - thanks for your help over the weekend!
chipaudette commentedon Nov 27, 2013
@gohai I just tried the latest to jar files. I used my Processing sketch and it received data piped over USB from my Arduino. It seems to run great. I'm pumping about 80kbps, which is what my Arduino data collection unit is trying to do. I'm satisfied. Nice work!
Since I'm the one who opened this issue, is there anything that I need to do to close it?
REAS commentedon Nov 27, 2013
Great! I'll close it.
gohai commentedon Dec 16, 2013
@thebishopgame @chipaudette
I just committed a slightly different fix for this issue (that reverts a busy-loop deep down in the library back into a 100ns delay - which is easier on the CPU). If you have some time to check whether http://sukzessiv.net/processing-serial/test5/ still works for you - hope to have Serial working solidly for the next proper release. Thanks!
thebishopgame commentedon Dec 25, 2013
@gohai Finally got the chance to give it a whack, works great for me!
github-actions commentedon Jun 15, 2021
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.