sidthakur has asked for the wisdom of the Perl Monks concerning the following question:
sub configPort($,$){
my $port = ($_[0]);
my $refConfigHash = ($_1);
$$port->baudrate($refConfigHash->{portBaudRate}) || die "Cannot Set Baud Rate \n";
$$port->databits($refConfigHash->{portData}) || die "Cannot Set Data Bits \n";
$$port->stopbits($refConfigHash->{portStopBits}) || die "Cannot Set Stop Bits \n";
$$port->parity($refConfigHash->{portParity}) || die "Cannot Set Parity \n";
$$port->handshake("none");
$$port->read_char_time(0); # don't wait for each character
$$port->read_const_time(1000); # 1 second per unfulfilled "read" call
$$port->get_tick_count;
$$port->write_settings;
}
sub subSerialPortWrite($,$){
my $port = ($_[0]);
my $buffer = $_1;
my $i;
$$port->write("\r");
for($i=0;$i<=length($buffer);$i++){
$$port->write(substr($buffer,$i,1));
Time::HiRes::usleep(50000);
}
}
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Writing to serial port with a delay between each character
by mr_mischief (Monsignor) on Apr 21, 2009 at 18:04 UTC | |
by sidthakur (Initiate) on Apr 21, 2009 at 18:55 UTC | |
by mr_mischief (Monsignor) on Apr 21, 2009 at 19:13 UTC | |
|
Re: Writing to serial port with a delay between each character
by roboticus (Chancellor) on Apr 21, 2009 at 20:30 UTC | |
by sidthakur (Initiate) on Apr 22, 2009 at 21:07 UTC | |
|
Re: Writing to serial port with a delay between each character
by afoken (Chancellor) on Apr 21, 2009 at 19:49 UTC | |
by sidthakur (Initiate) on Apr 21, 2009 at 20:56 UTC |