matteo.sistisette
YaBB Newbies
Offline
Posts: 14
can't read from the serial port
Sep 19th , 2005, 9:08pm
Hi I've already browsed the FAQs about the serial library and can't find what's wrong. I'm using windows (2000) I get no error messages but the serial ports appears not to be receiving anything (the buffer is always empty) while it just isn't the case. Check out this: ================= import processing.serial.*; Serial serialport; void setup(){ println(Serial.list()); //(*) serialport=new Serial(this, Serial.list()[0]); } void draw(){ println(serialport.available()); //(**) }; ================ line (*) outputs: COM1 COM2 So the port I'm using is COM1. Line (**) is continuously giving "0", as if the buffer were always empty, that is, as if no data was entering the COM1 port. I can assure that data IS entering the COM1 port (several bytes per second). I have checked it out with another program - but I have closed it in order to leave the port available to Processing. If the port weren't available, it wouldn't appear in the list. Don't like the example above? Check out this one: ================ import processing.serial.*; Serial serialport; void setup(){ println(Serial.list()); serialport=new Serial(this, Serial.list()[0]); serialport.buffer(1); } void serialEvent(Serial p) { char a=serialport.readChar(); print(a); } void draw(){}; ====================== It just does nothing, while it should be outputting a lot of characters. By the way, if I do: serialport = new Serial(this, "whatthecrappity smack"); both programs still work without error messages. The first one still outputs all zeros. i.e. a serial port that doesn't exist behaves just like one that is not receiving data, which doesn't help me in debugging. The protocol settings of the external device which is sending data to the COM1 port coincide with Processing default settings: 9600, no parity, 8 data bits, 1 stop bit. The program I've used to monitor serial input is setted this way and it does receive the data. Once again, I close that program before starting Processing. ¿¿What am I doing wrong?? Hope someone can help Thanks in advance bye Matteo