How to have data in a file without having the buffer full

I have this code, it works almost fine, it read the data at the serial and saves it in a .txt file, i run the program during 16 seconds and all i got is a 8 seconds of data, i'm quite sure there's a delay of 8 seconds (kind of) later i let the program run for 24 seconds and i get 16 seconds of data (quite sure i got a delay of 8) now i'm letting the 8 seconds, and i start to trying to obtain the data from second 8 til 15 for example and i didn't get data cuz it seemed to me that the buffer isn't full, i would like to have data without having to wait for the buffer to be completely full.

Any idea? Also, any idea if it's possible for me to no wait the fisrt 8 seconds.

Thanks

                import processing.serial.*;
                PrintWriter output;

                Serial myPort;  // The serial port

                void setup() {

                  output = createWriter("andyPiezoBuzzerADXL335.txt");
                  // Open whatever port is the one you're using.
                  myPort = new Serial(this, "COM4", 9600);
                }

                void draw()
                {
                  while (myPort.available () > 0) {
                    String inBuffer = myPort.readString();   
                    if (inBuffer != null) {  // != not equal
                      output.println(inBuffer);
                      delay(3000);
                    }
                  }


                  output.flush(); // Write the remaining data

                  output.close(); // Finish the file

                    exit(); // Stop the program
                } 
Sign In or Register to comment.