correggi con:
print "$PortName\n";
e vedrai che quello lo scrive.
Si blocca subito dopo avere aperto la porta con
port = new Device::SerialPort ("/dev/ttyS1") || die "Can't open $PortName: $!\n";
ho provato questo script d'esempio e funziona, nel senso che hai 10 secondi per inserire un comando o più, e te lo esegue alla fine dei 10 secondi.
codice:
#!/usr/bin/perl -w
use Device::SerialPort;
my $port=Device::SerialPort->new("/dev/ttyS0");
my $STALL_DEFAULT=10; # how many seconds to wait for new input
my $timeout=$STALL_DEFAULT;
$port->read_char_time(0); # don't wait for each character
$port->read_const_time(1000); # 1 second per unfulfilled "read" call
my $chars=0;
my $buffer="";
while ($timeout>0) {
my ($count,$saw)=$port->read(255); # will read _up to_ 255 chars
if ($count > 0) {
$chars+=$count;
$buffer.=$saw;
# Check here to see if what we want is in the $buffer
# say "last" if we find it
}
else {
$timeout--;
}
}
if ($timeout==0) {
die "Waited $STALL_DEFAULT seconds and never saw what I wanted\n";
}
prova.