For Programmers: Free Programming Magazines  


Home > Archive > PERL POE > April 2008 > Problem with serial port access in Tk app?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Problem with serial port access in Tk app?
John R.

2008-03-31, 11:17 pm

From the Cookbook item under SerialPorts I have the following code
snippet that works in a small test program (pretty much the Cookbook item:

# Open a serial port, and tie it to a file handle for POE.

my $handle = gensym();
my $port = tie( *$handle, "Device::SerialPort", "/dev/ttyS0" );
die "can't open port: $!" unless $port;

$port->datatype('raw');
$port->baudrate(9600);
$port->databits(8);
$port->parity("none");
$port->stopbits(2);
$port->handshake("xof");
$port->write_settings();

# Start interacting with the scanner.

$heap->{port} = $port;

print"DEBUG: Before ReadWrite->new\n";

$heap->{port_wheel} = POE::Wheel::ReadWrite->new(
Handle => $handle,
Filter => POE::Filter::Line->new(
InputLiteral => "\x0D\x0A", # Received line endings.
OutputLiteral => "\x0D", # Sent line endings.
),
InputEvent => "got_port",
ErrorEvent => "got_error",
);

print"DEBUG: After ReadWrite->new\n";

However, when I incorporate this in a Tk based application I get the
following output/error:

DEBUG: Before ReadWrite->new
Handle not opened for input at
/usr/lib/perl5/vendor_perl/5.8.8/i686-linux/Tk/Event/IO.pm line 122.

In the that file, line 122 is the first code line in this snippet:

# set the handler
my $h = $obj->handler($imode,$cb);
undef $obj; # Prevent warnings about untie with ref to object
unless ($h)
{
untie *$file;
}


Any ideas?

Thanks,

John
Punkin

2008-04-27, 11:21 pm

http://www.diarydiscount.com//thumb/001.jpghttp://www.diarydiscount.com//thumb/002.jpghttp://www.diarydiscount.com//thumb/003.jpg

http://www.diarydiscount.com//thumb/004.jpghttp://www.diarydiscount.com//thumb/005.jpghttp://www.diarydiscount.com//thumb/006.jpg

http://www.diarydiscount.com//thumb/007.jpghttp://www.diarydiscount.com//thumb/008.jpghttp://www.diarydiscount.com//thumb/009.jpg

http://www.diarydiscount.com//thumb/010.jpghttp://www.diarydiscount.com//thumb/011.jpghttp://www.diarydiscount.com//thumb/012.jpg

http://www.diarydiscount.com//thumb/013.jpghttp://www.diarydiscount.com//thumb/014.jpghttp://www.diarydiscount.com//thumb/015.jpg
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com