We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
Page Index Toggle Pages: 1
serial (Read 291 times)
serial
Dec 10th, 2008, 5:39am
 
I am new to working with the serial port library and serial ports in general so please excuse me if this is a simple question.

I am simply trying to write out a 64 to the serial port multiple times in a loop.

The problem is that after the first iteration the serial port never becomes available again.

can someone please explain to me what exactly is going on. Should I be doing something to reset the port on each iteration? Thank you for your help.


This is what my code looks like.



import processing.serial.*;

// The serial port:
Serial myPort;
void setup(){
// List all the available serial ports:
println(Serial.list());

myPort = new Serial(this, Serial.list()[1], 2400);
}
void draw(){
println(myPort.available());


if (myPort.available() == 0) {
delay(600);
myPort.write(65);

}
}
Re: serial
Reply #1 - Dec 10th, 2008, 7:07pm
 
available (see reference) is to check how many bytes are available to be _read_. it's not related to writing to the serial port. since you are not waiting for data to be read you do not need the available() check all together ..

F
Re: serial
Reply #2 - Dec 10th, 2008, 7:24pm
 
Thank you that is a big help.
Page Index Toggle Pages: 1