G'Day Bill,
Below are the answers to your Questions.
Thanks very much for chasing this up so quickly. :-)
Cheers,
Bernie
On 20/03/2007, at 10:43 AM, Bbirthisel@aol.com via RT wrote:
Show quoted text> 1. Have you run the test suite (which is easier if you get the CPAN
> distribution rather than using a PPM install)? If so, what were the
> results (aside from
> a couple of deprecated steps in the test suite)?
I originally installed from PPM but have downloaded the module from
CPAN and run the tests.
A number fail but I looked further into what they are doing yet.
C:\Perl\cpan\build\SerialPort-0.19>test.pl
t/test1....defined(@array) is deprecated at t/test1.t line 445,
<DATA> line 164.
(Maybe you should just omit the defined()?)
t/test1....ok
t/test2....ok
t/test3....defined(@array) is deprecated at t/test3.t line 444,
<DATA> line 164.
(Maybe you should just omit the defined()?)
t/test3....ok
t/test4....FAILED tests 100, 252
Failed 2/516 tests, 99.61% okay
t/test5....ok
t/test6....NOK 116SetCommState failed at t/test6.t line 403
t/test6....FAILED tests 74, 114, 116, 201, 233, 237
Failed 6/315 tests, 98.10% okay
t/test7....ok
Failed Test Stat Wstat Total Fail Failed List of Failed
------------------------------------------------------------------------
-------
t/test4.t 516 2 0.39% 100 252
t/test6.t 315 6 1.90% 74 114 116 201 233 237
Failed 2/7 test scripts, 71.43% okay. 8/1749 subtests failed, 99.54%
okay.
Show quoted text> 2. In the "complete" distribution from CPAN, there is a program called
> options.plx that does much like your log output - except I know
> exactly what it does
> in what sequence.
Here's the output from options.plx
C:\Perl\cpan\build\SerialPort-0.19>perl eg\options.plx
Available Options for port COM1
Data Bit Options: 8 6 7 5
Stop Bit Options: 1 1.5 2
Handshake Options: none xoff dtr rts
Parity Options: mark none even odd space
Baudrate Options: 115200 1200 38400 4800 56000 2400 600 57600
19200 9600 14400 110 300
Binary Capabilities:
can_baud
can_databits
can_stopbits
can_dtrdsr
can_handshake
can_parity_check
can_parity_config
can_parity_enable
can_rlsd
can_rtscts
can_xonxoff
can_interval_timeout
can_total_timeout
can_xon_char
is_rs232
binary
Current Settings:
baud = 9600
parity = none
data = 8
stop = 1
hshake = none
Byte Capabilities:
xon_char = 0x11
xoff_char = 0x13
eof_char = 0x0
event_char = 0x0
error_char = 0x0
Other Capabilities:
input buffer max = 0xffffffff
output buffer max = 0xffffffff
input buffer = 4096
output buffer = 0
alias = COM1
xon_limit = 0x800
xoff_limit = 0x200
Timeouts:
read_interval = 0x0
read_const_time = 1000
read_char_time = 0
write_const_time = 2000
write_char_time = 0
C:\Perl\cpan\build\SerialPort-0.19>
Show quoted text> 3. Please digest the actual code you are using to open the port into
> something I can examine. Over one page is too much - I'm just
> looking for clues in the
> operation sequence.
Here are the relevant code fragments that use the Win32::SerialPort
module.
This is an extract from the module Device::TNC::KISS that I've been
working on and is available on CPAN.
Please feel free to have a look at that module and flame me for
anything I'm doing wrong. :-)
use strict;
use Config;
if ($Config{'osname'} eq "MSWin32")
{
require Win32::SerialPort;
Win32::SerialPort->import( qw( :STAT 0.19 ) );
}
else
{
require Device::SerialPort;
}
my $m_port;
my $m_port_name;
sub new
{
my $class = shift;
my %port_data = @_;
my $baudrate;
my %data;
foreach my $key (keys %port_data)
{
if (lc($key) eq "port")
{
$m_port_name = $port_data{$key};
}
if (lc($key) eq "baudrate")
{
$baudrate = $port_data{$key};
}
}
if ($Config{'osname'} eq "MSWin32")
{
$m_port = new Win32::SerialPort($m_port_name) or
warn "Error: Cannot open serial port \"$m_port_name\": $^E\n";
}
else
{
$m_port = new Device::SerialPort($m_port_name) or
warn "Error: Cannot open serial port \"$m_port_name\": $!\n";
}
$m_port->baudrate($baudrate);
$m_port->parity("none");
$m_port->databits(8);
$m_port->stopbits(1);
$m_port->handshake("none");
$m_port->read_interval(100) if $Config{'osname'} eq "MSWin32";
$m_port->read_char_time(0);
$m_port->read_const_time(1000);
$data{'PORT'} = $m_port;
my $self = bless \%data, $class;
return $self;
}
# When we close try and close the port too.
DESTROY
{
# Close the serial port
$m_port->close() or
warn "Error: Failed to the serial port \"$m_port_name\": $!\n";
}
sub read_data
{
my $self = shift;
my ($count,$saw) = $self->{'PORT'}->read(1);
if ($count > 0)
{
# process the byte
}
# more processing and return
}