CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Beginner:
Another reading serial port problem


New User

Mar 21, 2011, 10:53 AM

Post #1 of 1 (925 views)
Another reading serial port problem Can't Post

I'm running Ubuntu and have a simple perl app that reads in the serial port.


use Device::SerialPort;

my $port = Device::SerialPort->new("/dev/ttyUSB0");


while (1) {

# Poll to see if any data is coming in
my $char = $port->lookfor();

if ($char) {

print "Recieved character: " . $char . " \n";

When I run the program the data is not read from the serial port.

If I run
tail -f < /dev/ttyUSB0
I can see the data being read correctly so I know its not a port/hardware problem.

The serial port is 9600/8/n/1 which I've setup in perl.

Any idea where I"m going wrong?

The data read is in the format #1,2,3,4#

I've been reading up and it looks like the lookfor() might be expecting a "\n" which is why its not working?

(This post was edited by gregmcc on Mar 21, 2011, 11:12 AM)


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives