Max-serial port-arduino-Computer Freezing(OSX.4.11) / Arduino crashing (OSX.5.7)
I have a patch sending out a 65 character message (header followed by 64 integers representing 8bit pixel values) over a serial object to an arduino board, onto an LED display. The display works fine for a while. Unfortunately, after a while I start losing frames. If I continue to run it in this manner my computer eventually becomes unresponsive. Not even a beach ball. My cursor (mac, os x 10.4.11) just hangs there, allowing me to use expose with some lag but never allowing me to escape the max environment.
On a few occasions, when I have stopped the program after experiencing this chunky playback, I have gone into the arduino ide and tried to re-upload the arduino sketch and the device is no longer visible. I then tried quitting all programs and then reopening the arduino-ide, and the device is not always visible. I then restart my computer and it hangs for a very long time. After a hard-restart I open up the ide and I am able to reselect my port.
One other thing I noticed, is that I am not receiving any messages back from my serial port's, even though the RX LED on my board indicates that I am. I only get a message out of the right outlet saying "write 65".
I made a scaled down version of this that runs from nothing other than a quicktime-8bit color conversion-65 char message- arduino, and it ran fine. So, I decided to scale things back a bit and they worked a little bit better. It seemed that the problem was either the rate that messages were hitting the serial board or the computation of my 2d visual-generating system. I decided to throw a jit.wake into the pipeline and immediately I had problems again. Of course, this still did not answer my question because if it's too much computation it could be slowing down the handling of the messages being processed at the point of reaching the serial port.
I decided to run things on a newer computer. I was running a macbook, core2duo second generation with 2 gigs of ram. I decided to try it on one of the latest builds of mac min with 4g ram. This time, the arduino stopped displaying new images but max seemed fine. Until, I removed the usb connection, verified that the device was available in the arduino ide and attempted to restart max. Max would not restart. Each time I tried to restart it it became unresponsive. So, I restarted my computer. Fortunately, max was able to open up afterwards.
What I would like to know is if there are common causes that might lead to the problems I am experiencing. Similarly, if there are solutions or known quidelines/limitations when sending large messages of serial data to an arduino. Since it is my intention to drive more LED displays than just one, It would be good to know if sending 65-260 char messages to serial ports at reasonable-reasonably-poor video rates is realistic.
It's possible that you are overloading the serial buffer with information and the bottleneck is choking the system. I've seen this happen many times with the exact setup you're describing. Make sure you are only sending bytes when the arduino is ready to deal with them. Try setting up a simple call and response protocol, that way the buffer isn't overrun with queued messages.
Thank you, Scott. I will look into this. Hopefully the problem is on the arduino end, as opposed to the max/serial object end, so that I at least have the option of running multiple units.