B
bell
Sorry if this has been already resolved; but I have a problem getting
both sysreads to work.
I do transmit but only one sysread is active.
Why do I never see the print ( "rec 001 $in $rx \n"); execute ?
ENVIRONMENT: CYGWIN with Perl 5.8.6
EXPERIENCE in Perl: much less than intermediate..
Any help is greatly appreciated.
use strict;
use warnings;
use Fcntl;
sysopen (TTYIN, "/dev/ttyS0", O_RDWR )
or die "can't open /dev/ttyS0: $!";
open(PORT_TX, "+>&TTYIN")
or die "can't dup PORT_TX: $!";
my $ofh = select(PORT_TX); $| = 1; select($ofh);
print PORT_TX "aaaa";
my $in;
my $rx;
my $timeout = 100;
eval {
local $SIG{ALRM} = sub { die "timeout" };
alarm($timeout);
$in= sysread (TTYIN, $rx, 1);
};
alarm(0);
print "sysREAD-001\n";
print ( "rec 001 $in $rx \n");
eval {
local $SIG{ALRM} = sub { die "timeout" };
alarm($timeout);
$in= sysread (TTYIN, $rx, 1);
};
alarm(0);
print "sysREAD-002\n";
print ( "rec 002 $in $rx \n");
print PORT_TX "dddd";
close ( PORT_TX) or die "child can't closing COM1: $!";
Most of this code is webish
both sysreads to work.
I do transmit but only one sysread is active.
Why do I never see the print ( "rec 001 $in $rx \n"); execute ?
ENVIRONMENT: CYGWIN with Perl 5.8.6
EXPERIENCE in Perl: much less than intermediate..
Any help is greatly appreciated.
use strict;
use warnings;
use Fcntl;
sysopen (TTYIN, "/dev/ttyS0", O_RDWR )
or die "can't open /dev/ttyS0: $!";
open(PORT_TX, "+>&TTYIN")
or die "can't dup PORT_TX: $!";
my $ofh = select(PORT_TX); $| = 1; select($ofh);
print PORT_TX "aaaa";
my $in;
my $rx;
my $timeout = 100;
eval {
local $SIG{ALRM} = sub { die "timeout" };
alarm($timeout);
$in= sysread (TTYIN, $rx, 1);
};
alarm(0);
print "sysREAD-001\n";
print ( "rec 001 $in $rx \n");
eval {
local $SIG{ALRM} = sub { die "timeout" };
alarm($timeout);
$in= sysread (TTYIN, $rx, 1);
};
alarm(0);
print "sysREAD-002\n";
print ( "rec 002 $in $rx \n");
print PORT_TX "dddd";
close ( PORT_TX) or die "child can't closing COM1: $!";
Most of this code is webish