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.
IndexProgramming Questions & HelpPrograms › can't read from the serial port
Page Index Toggle Pages: 1
can't read from the serial port (Read 782 times)
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
Re: can't read from the serial port
Reply #1 - Sep 21st, 2005, 1:31am
 
have you tried using one of the serial examples included with processing?
solved
Reply #2 - Sep 22nd, 2005, 2:48am
 
Hi

Sorry. Problem solved.
It was a hardware issue.

I say sorry because it was a hardware issue.
I didn't imagine it could be a hardware issue because other software could read from the port and I didn't know nor suspect that protocol handling at such a low level could be different from software to software.
I just disconnected one of the lines of the serial port and now it works.

In case someone is curious, I am using a Basic Stamp microcontroller and I had to disconnect the line that connected to the ATN pin of the BS (don't remember now how it is called at the PC side). I guess that line is not normally used in serial communication, Basic Stamp uses it for special purposes, and the BS debugging application accepts it to be connected during normal serial communication. I know that also other programs like EyesWeb are capable of communicating throw serial port with that connection, but others such as Processing and the HowIsItCalled Terminal don't.
However this is my own unsupported interpretation of the matter.

Thanks,
bye bye

Teo
Page Index Toggle Pages: 1