nargetdev / arduinoscope

Automatically exported from code.google.com/p/arduinoscope
0 stars 0 forks source link

Array out of bounds exception on slow machines. #10

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Run the SimpleSerialArduinoscope example on a slow PC (I am using an
Intel Atom N270 on Windows XP).
2. The CPU usage of java.exe will remain constant at 95%.
3. Soon after it will crash:

Exception in thread "Animation Thread"
java.lang.ArrayIndexOutOfBoundsException: 4
    at SimpleSerialArduinoscope.draw(SimpleSerialArduinoscope.java:124)
    at processing.core.PApplet.handleDraw(PApplet.java:1425)
    at processing.core.PApplet.run(PApplet.java:1327)
    at java.lang.Thread.run(Thread.java:619)

What is the expected output? What do you see instead?
No Crash.

What version of the product are you using? On what operating system?
Aug 26 release zip, built from source. Windows XP.

Please provide any additional information below.
I guess some serial data is being dropped due to the high CPU load. I have
done a little investigation and the crash happens here:

  for (int i=0;i<scopes.length;i++){
    // update and draw scopes

    scopes[i].addData(vals[i]);  <--- vals[i] is out of bounds.

I have worked around the problem by modifying:

void serialEvent(Serial p)

so that it dropps short packets. i.e.

void serialEvent(Serial p) { 

  String data = p.readStringUntil(LINE_FEED);
  if (data != null) {
    int[] tempVals = int(split(data, ' '));
    if(tempVals.length>=scopes.length) {
      vals = tempVals;
      }
    else {
      println("Warning: Dropped a short packet.");
      }
  }
}

But I wouldn't expect an application like this to be quite so CPU intensive!

Original issue reported on code.google.com by george_n...@hotmail.com on 24 Nov 2009 at 8:11

GoogleCodeExporter commented 8 years ago
I also had this problem. Plus Im not getting any readings. The monitor opens 
but no 
readings. I do get readings however in the example TestOscope but no readings 
in 
simplearduinoscope. 

Original comment by wslewis...@gmail.com on 13 Feb 2010 at 11:45

GoogleCodeExporter commented 8 years ago
try bringing your scope count down, it may just be too much to handle.

The no-readings thing might be coming from the wrong serial port being used. My 
code 
just grabs the first port. If you have more then 1, this might not be what you 
want. 
to fix, try changing "port = new Serial(this, Serial.list()[0], 115200);" 
around line 
87 in SimpleSerialArduinoscope.pde, to "... Serial.list()[1] ..." or "... 
Serial.list()[2] ..." or "... Serial.list()[3] ..." for example.

Original comment by david.ko...@gmail.com on 18 Feb 2010 at 1:20

GoogleCodeExporter commented 8 years ago
Hi David,
Is there a chance you will send me source for win-32 Application please?
I search some days now how to work with incoming serial data. I am using 
VS2008. I 
read incoming data within my software but i have no idea how to bind incoming 
values 
with sliders ect. 
Thank you 

Original comment by xlme...@t-online.de on 28 Feb 2010 at 7:28

GoogleCodeExporter commented 8 years ago
You can find the source for all the versions in the "source" tab above.

Original comment by david.ko...@gmail.com on 9 Nov 2011 at 4:04

GoogleCodeExporter commented 8 years ago

Original comment by david.ko...@gmail.com on 25 Sep 2012 at 6:44