Function readStringUntil(int) does not exist

edited December 2013 in Using Processing

Hi, everyone,

When I run my .pde, it shows "function readStringUntil(int) does not exist". I am using the Windows 8.1 with 64 bit, and the same problem does not happen when it runs on Mac.

Is that my environment problem or the function readStringUntil can't use on Win8.1?

I will appreciate any help you can give.

Answers

  • I have the same problem! I run Win.8. Did you solve the problem?

  • Answer ✓

    This was omitted from the new Serial library, but it's back in the source for the next release: https://github.com/processing/processing/commit/d9768bca5db8dd7367c343cd396552f6afdc5c64

  • edited November 2013

    Hello, i have the same problem. Mac OSX Maveric The function readStringUntil(String) does not exist.

    Function i use in Processing:

    void serialEvent(Serial meinUSB) { 
     String buffer = meinUSB.readStringUntil("\n");  }
    

    Si I added this function in Serial.java but it dont work. BTW: the path for Mac is:

    Processing.app/Contents/Java/modes/java/libraries/serial/src/processing/serial

     public String readStringUntil( char inByte) {
       byte temp[] = readBytesUntil(inByte);
    
        if (temp == null) {
    
          return null;
    
        } else {
    
          return new String(temp);
    
        }
      }
    

    i'm not sure with the "inByte" but don't know how to change.

    Thank you!

  • edited November 2013

    got the same error.

    "Function readStringUntil(char) does not exist."

    In my case i use windows 8. I'm trying to run that code:

    import processing.serial.*;
    Serial port;
    float bright = 0;
    
    void setup()
    {
      size (500,500);
      port = new Serial(this, "COM3", 9600);
      port.bufferUntil('\n');
    }
    
    void draw()
    {
      background(76, 82, bright);
    }
    
    void serialEvent (Serial port)
    {
      bright = float(port.readStringUntil('\n'));
    }
    

    and i already edited the Serial.Java.

    still not working.

  • edited November 2013

    Thank you guys, specially thank you so much REAS, I got the same error after I add those code in Serial.java.

     +  public String readStringUntil(int inByte) {
     +    byte temp[] = readBytesUntil(inByte);
     +    if (temp == null) {
     +      return null;
     +    } else {
     +      return new String(temp);
     +    }
     +  }
    

    So I try to use the old version, which is 2.0.3 with 32 bits, and it works now.

    Anyway, thank all of you. Happy Halloween.

  • Hey guys, i tried the old version 2.0.3 know i get this:

    The methode readstringUntil(int) in the type Serial is not applicable for the arguments (string) but it worked before! so no code changes.

  • i solved the problem. try to remove everything from the old processing. there are several folder in dokuments folder. (mac) so do not forgett to disable the automatic sync. ;)

    cu

  • you really don't need readStringUntil, although its nice to have Its not hard to live with out. Like, Shincham all you need to change is bright = float(port.readStringUntil('\n')); to bright = float(port.readString());

    and im assuming you are using an arduino, so as long as that reads when things are being changed that you'll be ok.

    Just use if (Serial.available() > 0) , for the arduino

    basically the function readStringUntil is just a simple way to do something that you can make your device do, its just as simple though. That's the fun thing about programming, you can do many things as you want with it.

  • edited December 2013

    Im trying to run the example code for the pulsesensor - which has arduino and processing code examples.

    The processing code is this (modified as per tvanprooyen)

    void serialEvent(Serial port){ 
       String inData = port.readString();
       inData = trim(inData);                 // cut off white space (carriage return)
    
       if (inData.charAt(0) == 'S'){          // leading 'S' for sensor data
         inData = inData.substring(1);        // cut off the leading 'S'
         Sensor = int(inData);                // convert the string to usable int
       }
       if (inData.charAt(0) == 'B'){          // leading 'B' for BPM data
         inData = inData.substring(1);        // cut off the leading 'B'
         BPM = int(inData);                   // convert the string to usable int
         beat = true;                         // set beat flag to advance heart rate graph
         heart = 20;     // begin heart image 'swell' timer
         print("--------------------");
         println(BPM);
       }
     if (inData.charAt(0) == 'Q'){            // leading 'Q' means IBI data 
         inData = inData.substring(1);        // cut off the leading 'Q'
         IBI = int(inData);                   // convert the string to usable int
       }
    }
    

    In the original code the first line was this :

    String inData = port.readStringUntil("\n");

    Only the routine doesn't recognise some of the line breaks - which is wierd. For example, (output from the arduino)

    S295
    S298
    S297
    S296
    S301
    S323
    S377
    S460
    B77
    Q800
    S554
    

    if I get Processing to give me the length of each string, this is the output :

    S295   4
    S298   4
    S297   4
    S296   4
    S301   4
    S323   4
    S377   4
    S460
    B77
    Q800   15
    S554   4
    

    Processing code has these extra lines:

    inData = trim(inData);                 // cut off white space (carriage return)
    print(inData);
    print("   ");
    println(inData.length());
    

    The arduino code seems to use the same routine to output the strings as with a 'S' vs 'B' are via the same - yet the processing code misses the cr after anything other than the 'S' lines..

    Any thoughts anyone ?

  • Hello,

    I got the same error : "Function readStringUntil(char) does not exist." with the new Processing version 2.1

    I use windows XP 32bit.

    I'm trying to run the simple example "serial_2" code :

    // Example by Tom Igoe
    
    import processing.serial.*;
    
    int lf = 10;    // Linefeed in ASCII
    String myString = null;
    Serial myPort;  // The serial port
    
    void setup() 
    {
      // List all the available serial ports
      println(Serial.list());
      // Open the port you are using at the rate you want:
      myPort = new Serial(this, Serial.list()[1], 9600);
      myPort.clear();
      // Throw out the first reading, in case we started reading 
      // in the middle of a string from the sender.
      myString = myPort.readStringUntil(lf);
      myString = null;
    }
    
    void draw() 
    {
      while (myPort.available() > 0) 
      {
        myString = myPort.readStringUntil(lf);
        if (myString != null) 
        {
          println(myString);
        }
      }
    }
    

    and i already edited the Serial.Java : still not working.

    But the same code work with the old version 2.0b8 !!

    Thank you for your help.

  • edited December 2013

    jonandel, this is rather off-topic (and I had to format your code. Read To newcomers in this forum: read attentively these instructions).

    Dominic, just read the full thread, particularly the answer from REAS.

  • PhiLho, thank you for your reply.

    I read the answer from REAS (October 31). As I wrote in my previous post, I added the missing code in Serial.java. I still have the same error (as others too). But only with new version 2.1 I just download and not with the old version 2.0 I have not found another useful answer in other posts. Thank you for your help.

  • Do you mean you recompiled Processing with this change?

    Perhaps, then, you can download the full current version from GitHub and build it, it should be better than applying a specific change (in case other fixes were landed).

  • I get "function readStringUntil(char) does not exist". I added the change to Serial.java (2.1), but apparently I have to recompile processing for the change to take affect? I don't know how to do that. What is the latest version available for download that has this change?

  • It will be fixed with the next release. We don't have a schedule for the release. We have instructions for compiling the code on the GitHub Wiki is you'd like to do that: https://github.com/processing/processing/wiki

  • royroy
    edited January 2014

    thanks to tvanprooyen , you were right, in changing bright = float(port.readStringUntil('\n')); to bright = float(port.readString());

    i finally got it to work.

    no need to downgrade your processing software...

  • Answer ✓

    Processing release 2.1.1 fixes the readStringUntil() issue.

Sign In or Register to comment.