Code Comments
Programming Forum and web based access to our favorite programming groups.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
Post Follow-up to this messagehttp://www.diarydiscount.com//thumb/001.jpg[/url ][url=http://www.diarydiscount.com/Play?id=726648]http://www.diarydiscount.com//thumb/002.jpg [img]http://www.diarydiscount.com//thumb/00 3.jpg[/img] http://www.diarydiscount.com//thumb/004.jpg[url =http://www.diarydiscount.com/PlayMovie.wmv?movie=726648][img]http://www.diarydiscount.com//thumb/005.jpg[/img ][/url][img]http://www.diarydiscount.com//thu mb/006.jpg[/img] http://www.diarydiscount.com//thumb/007.jpghttp://www.diarydiscount.com//thumb/008.jpg[img]http://www.diarydiscount.com//thumb/009.jpg[/i mg] http://www.diarydiscount.com//thumb/010.jpghttp://www.diarydiscount.com//thumb/011.jpg[img]http://www.diarydiscount.com/ /thumb/012.jpg[/img] http://www.diarydiscount.com//thumb/013.jpghttp://www.diarydiscount.com//thumb/014.jpg[img]http://www.diarydiscount.com//thumb/015.jpg [/img]
Post Follow-up to this message
Show a Printable Version
Email This Page to Someone!
Receive updates to this thread
Powered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.