We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi everybody,
When I try to use the instruction "readStringUntil" it's seems to not working, even when I try some examples found on the Web.
Is it possible this instruction don't work on a Windows environment ?
Thank you for the information....
Answers
Well, if there is no bug opened about this, it is probably a problem on your system or your attempts.
Thank you PhiLho for your answer.
To be clearer here is the message I had received : > "The function readStringUntil(short) does not exist".
Here is the code I had tested and generated this error (as all other codes using the readStringUntil instruction) :
// Processing Sketch to read comma delimited serial
// expects format: H,1,2,3,
import processing.serial.*;
Serial myPort; // Create object from Serial class
char HEADER = 'H'; // character to identify the start of a message
short LF = 10; // ASCII linefeed
// WARNING!
// If necessary change the definition below to the correct port
short portIndex = 3; // select the com port, 0 is the first port
void setup() {
size(200, 200);
println(Serial.list());
println(" Connecting to -> " + Serial.list()[portIndex]);
myPort = new Serial(this,Serial.list()[portIndex], 9600);
}
void draw() {
}
void serialEvent(Serial p)
{
String message = myPort.readStringUntil(LF); // read serial data
if(message != null)
{
print(message);
String [] data = message.split(","); // Split the comma-separated message
if(data[0].charAt(0) == HEADER && data.length > 3) // check validity
{
for( int i = 1; i < data.length-1; i++) // skip the header & end if line
{
println("Value " + i + " = " + data[i]); // Print the field values
}
println();
}
}
}
This code comes from page 105 of the "Arduino Cookbook, Second Edition by Michael Margolis".
Did I am the only user of Processing to have received this message: "The function readStringUntil(short) does not exist" ?
I use Processing 2.1 on Windows 7.
New 2.1 serial library is buggy.
Not only they forgot to add readStringUntil() method, but also serialEvent() and receiving data are not working properly, so better roll back to 2.0.3.
readStringUntil() is now in the source on Github for the next release. @Razorblade, I don't think we have bug reports about serialEvent() in 2.1 on Github. Please let us know what is not working for you.
Thanks for your answer REAS.
I wish I knew how to describe the problem, so I could make a bug report. The thing is that serial code working in 2.0.3, doesn't work in 2.1. It seems to hang when it has to receive serial data, as if it were no input data.
I'm on Windows 8 x64, same behaviour with Processing 2.1 32 and 64. I'm sorry I have no time to test it on other platforms, or test in detail.