For Programmers: Free Programming Magazines  


Home > Archive > PERL POE > March 2008 > SOLVED (sort of) [Fwd: 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 SOLVED (sort of) [Fwd: Problem with serial port access in Tk app?]
John R.

2008-03-31, 11:17 pm

I used Google Code search to find other examples of assigning the handle
to POE::Wheel::ReadWrite. Code snipped:

$heap->{fh} = new IO::File;
if (!$heap->{fh}->open("+</dev/ttyS0")) {
confess("Unable to open /dev/ttyS0 RW: $!\n");
}

set_speed($_[HEAP]->{fh}, '9600');

Then I could do a "Handle => $heap->{fh}"

set_speed I used verbatim and it and the rest seems to work fine:

sub set_speed ($$) {
my $fh = shift || die;
my $speed = shift;

my $termios = POSIX::Termios->new() || die;
$termios->getattr(fileno($fh)) || die "$!";

# The handshake is done at 9600
eval("\$termios->setispeed(&POSIX::B$speed)") || die "$!";
eval("\$termios->setospeed(&POSIX::B$speed)") || die "$!";

$termios->setattr(fileno($fh), &POSIX::TCSANOW);
}
Sponsored Links







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

Copyright 2008 codecomments.com