Device-SerialPort-1.04/0000755000076500007650000000000010707557125013402 5ustar keeskeesDevice-SerialPort-1.04/modemtest0000755000076500007650000001607410520606534015331 0ustar keeskees#!/usr/bin/perl # # This tool is used to check how Device::SerialPort is behaving on # your machine. It will list all the possible values for each function # as it runs. Edit this tool to test various settings. # # $Id: modemtest 281 2004-02-24 05:27:24Z nemies $ # # Copyright (C) 2000-2003 Kees Cook # kees@outflux.net, http://outflux.net/ # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # http://www.gnu.org/copyleft/gpl.html use Device::SerialPort qw (:STAT); use strict; use warnings; =head1 NAME modemtest - Tool to examining your modem through Perl's Device::SerialPort =head1 SYNOPSIS modemtest [OPTS] [DEVICE [BAUD [DATA [PARITY [STOP [FLOW]]]]]] DEVICE Device to use as a serial port (default: "/dev/modem") BAUD Serial speed to use (default: 9600) DATA Number of databits to use (default: 8) PARITY Type of parity to use (default: "none") STOP Number of stop bits to use (default: 1) FLOW Kind of flow control to use (default: "none") -h, --help Help report --skip-status Skip modem status bit tests --hide-possible Don't show all possible settings =head1 DESCRIPTION Some systems, serial ports, and modem behave in strange ways. To test the capabilities of Perl's Device::SerialPort, this tool queries the system settings for the given DEVICE, and attempts to set up the port and send the initialization string "ATE1" to the modem, reporting the results seen. =head1 SEE ALSO L L =head1 AUTHOR Kees Cook . =head1 COPYRIGHT AND LICENSE Copyright 2000-2004 by Kees Cook . This program is free software; you may redistribute it and/or modify it under the same terms ans Perl itself. =cut printf "Device::SerialPort v%d.%d.%d loaded.\n", int(${Device::SerialPort::VERSION}), (int(${Device::SerialPort::VERSION}*1000)=~/(\d{3})$/), (int(${Device::SerialPort::VERSION}*1000000)=~/(\d{3})$/); my $opt_skip_status=0; my $opt_hide_possible=0; # quick params if ($ARGV[0] eq "-h" || $ARGV[0] eq "--help") { die "Usage: $0 [DEVICE [BAUD [DATABITS [PARITY [STOPBITS [FLOW]]]]]] -h, --help Help report --skip-status Skip modem status bit tests --hide-possible Don't show all possible settings "; } while ($ARGV[0]=~/^--(.*)/) { if ($1 eq "skip-status") { $opt_skip_status=1; } elsif ($1 eq "hide-possible") { $opt_hide_possible=1; } else { die "Unknown option '--$1'. Try '--help'.\n"; } shift @ARGV; } # your serial port. my ($device,$baudrate,$databits,$parity,$stopbits,$handshake)=@ARGV; $device ||= "/dev/modem"; $baudrate ||= "9600"; $databits ||= "8"; $parity ||= "none"; $stopbits ||= "1"; $handshake ||= "none"; my $port=new Device::SerialPort($device) || die "new($device): $!\n"; print "Port '$device' open\n"; # Are the ioctls loaded? my $bool=$port->can_ioctl(); print "can ioctl: ",($bool ? "Yes" : "No"),"\n"; if (!$bool) { die "The rest of this test is useless without ioctl methods.\n"; } # Handshaking if (!$opt_hide_possible) { my @handshakes=$port->handshake; print "Handshakes:\n"; grep(print("\t$_\n"),sort(@handshakes)); } $handshake=$port->handshake($handshake); print "Got handshake: $handshake\n"; # Baud rate if (!$opt_hide_possible) { my @bauds=$port->baudrate; print "Bauds:\n"; grep(print("\t$_\n"),sort { $b <=> $a } @bauds); } $baudrate=$port->baudrate($baudrate); print "Got baud: $baudrate\n"; # Databits if (!$opt_hide_possible) { my @databits=$port->databits; print "Databits:\n"; grep(print("\t$_\n"),sort { $b <=> $a } @databits); } $databits=$port->databits($databits); print "Got databits: $databits\n"; # Parity if (!$opt_hide_possible) { my @parity=$port->parity; print "Parity:\n"; grep(print("\t$_\n"),sort @parity); } $parity=$port->parity($parity); print "Got parity: $parity\n"; # Stopbits if (!$opt_hide_possible) { my @stopbits=$port->stopbits; print "Stopbits:\n"; grep(print("\t$_\n"),sort { $b <=> $a } @stopbits); } $stopbits=$port->stopbits($stopbits); print "Got stopbits: $stopbits\n"; if (!$opt_skip_status) { linestatus(); print "\n"; my $delay=3; # Flip on DTR and RTS my $dtr=$port->dtr_active(1) ? "okay" : "failed"; my $rts=$port->rts_active(1) ? "okay" : "failed"; print "Activated DTR($dtr) and RTS($rts) ... pausing for $delay seconds\n"; linestatus(); print "\n"; sleep $delay; $dtr=$port->dtr_active(0) ? "okay" : "failed"; $rts=$port->rts_active(0) ? "okay" : "failed"; print "Deactivated DTR($dtr) and RTS($rts) ... pausing for $delay seconds\n"; linestatus(); print "\n"; sleep $delay; $dtr=$port->dtr_active(1) ? "okay" : "failed"; print "Activated DTR($dtr) ... pausing for $delay seconds\n"; linestatus(); print "\n"; sleep $delay; $rts=$port->rts_active(1) ? "okay" : "failed"; print "Activated RTS($rts) ... pausing for $delay seconds\n"; linestatus(); print "\n"; sleep $delay; } # Just in case: reset our timing and buffers $port->lookclear(); $port->read_const_time(100); $port->read_char_time(5); # Turn on parity checking: #$port->stty_inpck(1); #$port->stty_istrip(1); # Read a chunk my ($count,$str,$got,$cnt); readchunk(); # Write some AT commands to the modem writechunk("ATE1\r"); # Read a few chunks readchunk(); readchunk(); print "\n"; linestatus(); # close the port undef $port; print "Port closed\n"; sub writechunk { my $str=shift; my $count = $port->write($str); print "wrote: $count\n"; $str=~s/([^\040-\176])/sprintf("{0x%02X}",ord($1))/ge; print "written ->$str<-\n"; } sub readchunk { # read a chunk of data sleep 1; my ($count,$str)=$port->read(1); my $got; $cnt=$count; while ($count>0) { ($count,$got)=$port->read(1); $str.=$got; $cnt+=$count; } print "read: $cnt\n"; $str=~s/([^\040-\176])/sprintf("{0x%02X}",ord($1))/ge; print "saw ->$str<-\n"; } sub linestatus { my $status = $port->modemlines; printf("Modem status = 0x%04X (DTR=%s CTS=%s RTS=%s DSR=%s RNG=%s CD=%s)\n", $status, ($status & MS_DTR_ON) ? "ON " : "off", ($status & MS_CTS_ON) ? "ON " : "off", ($status & MS_RTS_ON) ? "ON " : "off", ($status & MS_DSR_ON) ? "ON " : "off", ($status & MS_RING_ON) ? "ON " : "off", ($status & MS_RLSD_ON) ? "ON " : "off", ); } # /* vi:set ai ts=4 sw=4 expandtab: */ Device-SerialPort-1.04/t/0000755000076500007650000000000010707557125013645 5ustar keeskeesDevice-SerialPort-1.04/t/10basic.t0000755000076500007650000003751110650175032015254 0ustar keeskees#!/usr/bin/perl -w use lib '.','./t','./blib/lib','../blib/lib'; # can run from here or distribution base # Before installation is performed this script should be runnable with # `perl test1.t time' which pauses `time' seconds (1..5) between pages use Test::More; eval "use DefaultPort;"; if ($@) { plan skip_all => 'No serial port selected for use with testing'; } else { plan tests => 188; } use_ok("Device::SerialPort"); use POSIX qw(uname); # can not drain ports without modems on them under POSIX in Solaris 2.6 my ($sysname, $nodename, $release, $version, $machine) = POSIX::uname(); my $SKIPDRAIN=0; if ($sysname eq "SunOS" && $machine =~ /^sun/) { $SKIPDRAIN=1; } use Device::SerialPort qw( :STAT 0.10 ); use strict; ## verifies the (0, 1) list returned by binary functions sub test_bin_list { return undef unless (@_ == 2); return undef unless (0 == shift); return undef unless (1 == shift); return 1; } sub is_ok { local $Test::Builder::Level = $Test::Builder::Level + 1; return ok(shift); } sub is_zero { local $Test::Builder::Level = $Test::Builder::Level + 1; return ok(shift == 0); } sub is_bad { local $Test::Builder::Level = $Test::Builder::Level + 1; return ok(!shift); } # assume a "vanilla" port on "/dev/ttyS0" my $file = "/dev/ttyS0"; if ($SerialJunk::Makefile_Test_Port) { $file = $SerialJunk::Makefile_Test_Port; } if (exists $ENV{Makefile_Test_Port}) { $file = $ENV{Makefile_Test_Port}; } if (@ARGV) { $file = shift @ARGV; } #diag("Using '$file' as test port."); my $cfgfile = "$file"."_test.cfg"; my $tstlock = "$file"."_lock.cfg"; $cfgfile =~ s/.*\///; $tstlock =~ s/.*\///; my $fault = 0; my $ob; my $pass; my $fail; my $in; my $in2; my @opts; my $out; my $err; my $blk; my $e; my $tick; my $tock; my %required_param; my @necessary_param = Device::SerialPort->set_test_mode_active(1); unlink $cfgfile; foreach $e (@necessary_param) { $required_param{$e} = 0; } ## 2 - 5 SerialPort Global variable ($Babble); is_bad(scalar Device::SerialPort->debug); # 2: start out false is_ok(scalar Device::SerialPort->debug(1)); # 3: set it is_bad(scalar Device::SerialPort->debug(2)); # 4: invalid binary=false # 5: yes_true subroutine, no need to SHOUT if it works ok( Device::SerialPort->debug("T") ); ok( !Device::SerialPort->debug("F")); { no strict 'subs'; ok( Device::SerialPort->debug(T)); ok(!Device::SerialPort->debug(F)); ok( Device::SerialPort->debug(Y)); ok(!Device::SerialPort->debug(N)); ok( Device::SerialPort->debug(ON)); ok(!Device::SerialPort->debug(OFF)); ok( Device::SerialPort->debug(TRUE)); ok(!Device::SerialPort->debug(FALSE)); ok( Device::SerialPort->debug(Yes)); ok(!Device::SerialPort->debug(No)); ok( Device::SerialPort->debug("yes")); ok(!Device::SerialPort->debug("f")); } ok(!$fault); @opts = Device::SerialPort->debug; # 6: binary_opt array is_ok(test_bin_list(@opts)); # 7: Constructor unless (is_ok ($ob = Device::SerialPort->new ($file))) { die "\n7: could not open port '$file'. Are permissions correct?\n"; # next test would die at runtime without $ob } #### 8 - 64: Check Port Capabilities ## 8 - 21: Binary Capabilities is_ok($ob->can_baud); # 8 is_ok($ob->can_databits); # 9 is_ok($ob->can_stopbits); # 10 is_ok($ob->can_dtrdsr); # 11 is_ok($ob->can_handshake); # 12 is_ok($ob->can_parity_check); # 13 is_ok($ob->can_parity_config); # 14 is_ok($ob->can_parity_enable); # 15 is_zero($ob->can_rlsd); # 16 is_ok($ob->can_rtscts); # 17 is_ok($ob->can_xonxoff); # 18 is_zero($ob->can_interval_timeout); # 19 is_ok($ob->can_total_timeout); # 20 is_ok($ob->can_xon_char); # 21 is_zero($ob->can_spec_char); # 22 is_zero($ob->can_16bitmode); # 23 is_ok($ob->is_rs232); # 24 is_zero($ob->is_modem); # 25 #### 26 - xx: Set Basic Port Parameters ## 26 - 31: Baud (Valid/Invalid/Current) @opts=$ob->baudrate; # list of allowed values is_ok(1 == grep(/^9600$/, @opts)); # 26 is_zero(scalar grep(/^9601/, @opts)); # 27 is_ok($in = $ob->baudrate); # 28 is_ok(1 == grep(/^$in$/, @opts)); # 29 is_bad(scalar $ob->baudrate(9601)); # 30 is_ok($in == $ob->baudrate(9600)); # 31 # leaves 9600 pending ## 32 - xx: Parity (Valid/Invalid/Current) @opts=$ob->parity; # list of allowed values is_ok(1 == grep(/none/, @opts)); # 32 is_zero(scalar grep(/any/, @opts)); # 33 is_ok($in = $ob->parity); # 34 is_ok(1 == grep(/^$in$/, @opts)); # 35 is_bad(scalar $ob->parity("any")); # 36 is_ok($in eq $ob->parity("none")); # 37 # leaves "none" pending ## 38 - 43: Databits (Valid/Invalid/Current) @opts=$ob->databits; # list of allowed values is_ok(1 == grep(/8/, @opts)); # 38 is_zero(scalar grep(/4/, @opts)); # 39 is_ok($in = $ob->databits); # 40 is_ok(1 == grep(/^$in$/, @opts)); # 41 is_bad(scalar $ob->databits(3)); # 42 is_ok($in == $ob->databits(8)); # 43 # leaves 8 pending ## 44 - 49: Stopbits (Valid/Invalid/Current) @opts=$ob->stopbits; # list of allowed values is_ok(1 == grep(/2/, @opts)); # 44 is_zero(scalar grep(/1.5/, @opts)); # 45 is_ok($in = $ob->stopbits); # 46 is_ok(1 == grep(/^$in$/, @opts)); # 47 is_bad(scalar $ob->stopbits(3)); # 48 is_ok($in == $ob->stopbits(1)); # 49 # leaves 1 pending ## 50 - 55: Handshake (Valid/Invalid/Current) @opts=$ob->handshake; # list of allowed values is_ok(1 == grep(/none/, @opts)); # 50 is_zero(scalar grep(/moo/, @opts)); # 51 is_ok($in = $ob->handshake); # 52 is_ok(1 == grep(/^$in$/, @opts)); # 53 is_bad(scalar $ob->handshake("moo")); # 54 is_ok($in = $ob->handshake("rts")); # 55 ## 56 - 61: Buffer Size ($in, $out) = $ob->buffer_max(512); is_bad(defined $in); # 56 ($in, $out) = $ob->buffer_max; is_ok(defined $in); # 57 if (($in > 0) and ($in < 4096)) { $in2 = $in; } else { $in2 = 4096; } if (($out > 0) and ($out < 4096)) { $err = $out; } else { $err = 4096; } is_ok(scalar $ob->buffers($in2, $err)); # 58 @opts = $ob->buffers(4096, 4096, 4096); is_bad(defined $opts[0]); # 59 ($in, $out)= $ob->buffers; is_ok($in2 == $in); # 60 is_ok($out == $err); # 61 ## 62 - 64: Other Parameters (Defaults) is_ok("TestPort" eq $ob->alias("TestPort")); # 62 is_zero(scalar $ob->parity_enable(0)); # 63 is_ok($ob->write_settings); # 64 is_ok($ob->binary); # 65 ## 66 - 67: Read Timeout Initialization is_zero($ob->read_const_time); # 66 is_zero($ob->read_char_time); # 67 ## 68 - 74: No Handshake, Polled Write is_ok("none" eq $ob->handshake("none")); # 68 $e="testing is a wonderful thing - this is a 60 byte long string"; # 123456789012345678901234567890123456789012345678901234567890 my $line = "\r\n$e\r\n$e\r\n$e\r\n"; # about 195 MS at 9600 baud $tick=$ob->get_tick_count; $pass=$ob->write($line); if ($SKIPDRAIN) { is_zero(0); # 69 select(undef,undef,undef,0.195); } else { is_ok(1 == $ob->write_drain); # 69 } $tock=$ob->get_tick_count; is_ok($pass == 188); # 70 $err=$tock - $tick; is_bad (($err < 100) or ($err > 300)); # 71 print "<195> elapsed time=$err\n"; is_ok(scalar $ob->purge_tx); # 72 is_ok(scalar $ob->purge_rx); # 73 is_ok(scalar $ob->purge_all); # 74 ## 75 - 80: Optional Messages @opts = $ob->user_msg; is_ok(test_bin_list(@opts)); # 75 is_zero(scalar $ob->user_msg); # 76 is_ok(1 == $ob->user_msg(1)); # 77 @opts = $ob->error_msg; is_ok(test_bin_list(@opts)); # 78 is_zero(scalar $ob->error_msg); # 79 is_ok(1 == $ob->error_msg(1)); # 80 ## 81 - 164: Save and Check Configuration is_ok(scalar $ob->save($cfgfile)); # 81 is_ok(9600 == $ob->baudrate); # 82 is_ok("none" eq $ob->parity); # 83 is_ok(8 == $ob->databits); # 84 is_ok(1 == $ob->stopbits); # 85 is_ok(1 == $ob->close); # 86 undef $ob; ## 87 - 89: Check File Headers is_ok(open CF, "$cfgfile"); # 87 my ($signature, $name, $lockfile, @values) = ; close CF; is_ok(1 == grep(/SerialPort_Configuration_File/, $signature)); # 88 chomp $name; is_ok($name eq $file); # 89 chomp $lockfile; is_ok($lockfile eq ""); # 90 ## 91 - 92: Check that Values listed exactly once $fault = 0; foreach $e (@values) { chomp $e; ($in, $out) = split(',',$e); $fault++ if ($out eq ""); $required_param{$in}++; } is_zero($fault); # 91 $fault = 0; foreach $e (@necessary_param) { $fault++ unless ($required_param{$e} ==1); } is_zero($fault); # 92 ## 93 - 110: Reopen as (mostly 5.003 Compatible) Tie # constructor = TIEHANDLE method # 93 unless (is_ok ($ob = tie(*PORT,'Device::SerialPort', $cfgfile))) { die "\n93: could not reopen port from $cfgfile\n"; # next test would die at runtime without $ob } # tie to PRINT method $tick=$ob->get_tick_count; $pass=print PORT $line; is_ok(1 == $ob->write_drain); # 94 $tock=$ob->get_tick_count; is_ok($pass == 1); # 95 $err=$tock - $tick; is_bad (($err < 160) or ($err > 245)); # 96 print "<195> elapsed time=$err\n"; # tie to PRINTF method $tick=$ob->get_tick_count; if ( $] < 5.004 ) { $out=sprintf "123456789_%s_987654321", $line; $pass=print PORT $out; } else { $pass=printf PORT "123456789_%s_987654321", $line; } is_ok(1 == $ob->write_drain); # 97 $tock=$ob->get_tick_count; is_ok($pass == 1); # 98 $err=$tock - $tick; is_bad (($err < 180) or ($err > 265)); # 99 print "<215> elapsed time=$err\n"; is_ok (300 == $ob->read_const_time(300)); # 100 is_ok (20 == $ob->read_char_time(20)); # 101 $tick=$ob->get_tick_count; ($in, $in2) = $ob->read(10); $tock=$ob->get_tick_count; unless (is_zero ($in)) { # 102 die "\n102: Looks like you have a modem on the serial port!\n". "Please turn it off, or remove it and restart the tests.\n"; # many tests following here will fail if there is modem attached } is_ok ($in2 eq ""); # 103 $err=$tock - $tick; is_bad (($err < 475) or ($err > 585)); # 104 print "<500> elapsed time=$err\n"; is_ok (0 == $ob->read_char_time(0)); # 105 $tick=$ob->get_tick_count; $in2= getc PORT; $tock=$ob->get_tick_count; is_bad (defined $in2); # 106 $err=$tock - $tick; is_bad (($err < 275) or ($err > 365)); # 107 print "<300> elapsed time=$err\n"; is_ok (0 == $ob->read_const_time(0)); # 108 $tick=$ob->get_tick_count; $in2= getc PORT; $tock=$ob->get_tick_count; is_bad (defined $in2); # 109 $err=$tock - $tick; is_bad ($err > 50); # 110 print "<0> elapsed time=$err\n"; ## 111 - 115: Bad Port (new + quiet) my $file2 = "/dev/badport"; my $ob2; is_bad ($ob2 = Device::SerialPort->new ($file2)); # 111 is_bad (defined $ob2); # 112 is_bad ($ob2 = Device::SerialPort->new ($file2, 1)); # 113 is_bad ($ob2 = Device::SerialPort->new ($file2, 0)); # 114 is_bad (defined $ob2); # 115 ## 116 - 131: Output bits and pulses SKIP: { skip "Can't IOCTL", 32 unless $ob->can_ioctl; is_ok ($ob->dtr_active(0)); # 116 $tick=$ob->get_tick_count; is_ok ($ob->pulse_dtr_on(100)); # 117 $tock=$ob->get_tick_count; $err=$tock - $tick; if (!is_bad (($err < 180) or ($err > 265))) {# 118 if ($err > 265) { warn "\n118: DTR toggle took too long. Is this a Solaris serial port?\n\tPlease read the 'SOLARIS TROUBLE' section in the README\n\tto correct this problem.\n"; } } print "<200> elapsed time=$err\n"; is_ok ($ob->dtr_active(1)); # 119 $tick=$ob->get_tick_count; is_ok ($ob->pulse_dtr_off(200)); # 120 $tock=$ob->get_tick_count; $err=$tock - $tick; if (!is_bad (($err < 370) or ($err > 485))) {# 121 if ($err > 485) { warn "\n121: DTR toggle took too long. Is this a Solaris serial port?\n\tPlease read the 'SOLARIS TROUBLE' section in the README\n\tto correct this problem.\n"; } } print "<400> elapsed time=$err\n"; SKIP: { skip "Can't RTS", 7 unless $ob->can_rts(); is_ok ($ob->rts_active(0)); # 122 $tick=$ob->get_tick_count; is_ok ($ob->pulse_rts_on(150)); # 123 $tock=$ob->get_tick_count; $err=$tock - $tick; is_bad (($err < 275) or ($err > 365)); # 124 print "<300> elapsed time=$err\n"; is_ok ($ob->rts_active(1)); # 125 $tick=$ob->get_tick_count; is_ok ($ob->pulse_rts_off(50)); # 126 $tock=$ob->get_tick_count; $err=$tock - $tick; is_bad (($err < 80) or ($err > 145)); # 127 print "<100> elapsed time=$err\n"; is_ok ($ob->rts_active(0)); # 128 } is_ok ($ob->dtr_active(0)); # 129 is_ok("rts" eq $ob->handshake("rts")); # 130 # for an unconnected port, should be $in=0, $out=0, $blk=0, $err=0 if ($ob->can_status()) { ($blk, $in, $out, $err) = $ob->status; } else { $out=0; } is_zero($out); # 131 is_ok(188 == $ob->write($line)); # 132 # XXX What is this group trying to do? --Eric print "<0 or 1> can_status=".$ob->can_status()."\n"; if ($ob->can_status()) { ($blk, $in, $out, $err) = $ob->status; } else { $out=188; $in=0; $err=0; $blk=0; } is_zero($blk); # 133 is_zero($in); # 134 is($out, 188, 'output bytes is 188 (cannot have anything attached to port)'); is_zero($err); # 136 if ($ob->can_write_done()) { ($out, $err) = $ob->write_done(0); } else { $out=0; } is_zero($out); # 137 $tick=$ob->get_tick_count; is_ok("none" eq $ob->handshake("none")); # 138 if ($ob->can_write_done()) { ($out, $err) = $ob->write_done(0); } else { $out=0; } is_zero($out); # 139 if ($ob->can_write_done()) { ($out, $err) = $ob->write_done(1); } else { $out=1; select(undef,undef,undef,0.200); } $tock=$ob->get_tick_count; is_ok(1 == $out); # 140 $err=$tock - $tick; is_bad (($err < 170) or ($err > 255)); # 141 print "<200> elapsed time=$err\n"; if ($ob->can_status()) { ($blk, $in, $out, $err) = $ob->status; } else { $out=0; } is_zero($out); # 142 is_ok(MS_CTS_ON); # 143 is_ok(MS_DSR_ON); # 144 is_ok(MS_RING_ON); # 145 ok(MS_RLSD_ON, "MS_RLSD_ON defined"); # 146 $blk = MS_CTS_ON | MS_DSR_ON | MS_RING_ON | MS_RLSD_ON; is_ok(defined($ob->modemlines)); # 147 is($blk & $ob->modemlines, 0, "Modem lines clear (cannot have anything attached to port)"); # 148 } is_zero(ST_BLOCK); # 149 is_ok(1 == ST_INPUT); # 150 is_ok(2 == ST_OUTPUT); # 151 is_ok(3 == ST_ERROR); # 152 $tick=$ob->get_tick_count; # on Sun, break waits to be flushed, but we're on an empty serial port... if ($SKIPDRAIN) { is_zero(0); # 153 select(undef,undef,undef,0.250); } else { is_ok ($ob->pulse_break_on(250)); # 153 } $tock=$ob->get_tick_count; $err=$tock - $tick; is_bad (($err < 235) or ($err > 900)); # 154 print "<500> elapsed time=$err\n"; # destructor = CLOSE method if ($SKIPDRAIN) { is_zero(0); # 155 } else { if ( $] < 5.005 ) { is_ok($ob->close); # 155 } else { is_ok(close PORT); # 155 } } # destructor = DESTROY method undef $ob; # Don't forget this one!! untie *PORT; #### 156 - 163: Lock File Tests unlink $tstlock; is_bad (-e $tstlock); # 156 is_ok ($ob = Device::SerialPort->new ($file, 1, $tstlock)); # 157 is_ok (-e $tstlock); # 158 is_ok (-s $tstlock); # 159 is_ok ($ob->restart($cfgfile)); # 160 sleep 1; my $cfg2 = "tmp.$cfgfile"; is_ok(scalar $ob->save($cfg2)); # 161 is_ok($ob->close); # 162 sleep 1; is_bad (-e $tstlock); # 163 #### 164 - 167: Lock from Configuration File with DESTROY is_ok ($ob = Device::SerialPort->start ($cfg2)); # 164 is_ok (-e $tstlock); # 165 is_ok (-s $tstlock); # 166 undef $ob; sleep 1; is_bad (-e $tstlock); # 167 ## 168 - 170: Repeat with Lock SET is_ok(open LF, ">$tstlock"); # 168 print LF "$$\n"; close LF; is_zero ($ob = Device::SerialPort->start ($cfg2)); # 169 is_bad ($ob = Device::SerialPort->new ($file, 1, $tstlock)); # 170 unlink $tstlock; ## 171 - 174: Check File Headers with Lock is_ok(open CF, "$cfg2"); # 171 ($signature, $name, $lockfile, @values) = ; close CF; is_ok(1 == grep(/SerialPort_Configuration_File/, $signature)); # 172 chomp $name; is_ok($name eq $file); # 173 chomp $lockfile; is_ok($lockfile eq $tstlock); # 174 unlink $cfg2; # vim:ts=8:sw=4:sts=4:et:sta Device-SerialPort-1.04/t/AltPort.pm0000755000076500007650000000063110520606533015562 0ustar keeskeespackage AltPort; # Inheritance test for test3.t and test4.t only use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); $VERSION = '0.10'; require Exporter; use Device::SerialPort qw( :PARAM 0.07 ); @ISA = qw( Exporter Device::SerialPort ); @EXPORT= qw(); @EXPORT_OK= @Device::SerialPort::EXPORT_OK; %EXPORT_TAGS = %Device::SerialPort::EXPORT_TAGS; my $in = SHORTsize; print "AltPort import=$in\n"; 1; Device-SerialPort-1.04/t/21inherited-state.t0000755000076500007650000004566410650175302017276 0ustar keeskees#!/usr/bin/perl -w use lib '.','./t','./blib/lib','../blib/lib'; # can run from here or distribution base # Before installation is performed this script should be runnable with # `perl test4.t time' which pauses `time' seconds (1..5) between pages ######################### We start with some black magic to print on failure. use Test::More; eval "use DefaultPort;"; if ($@) { plan skip_all => 'No serial port selected for use with testing'; } else { plan tests => 340; } use AltPort 0.10; # check inheritance & export ######################### End of black magic. # Insert your test code below (better if it prints "ok 13" # (correspondingly "not ok 13") depending on the success of chunk 13 # of the test code): # tests start using file created by test1.t use strict; my $file = "/dev/ttyS0"; if ($SerialJunk::Makefile_Test_Port) { $file = $SerialJunk::Makefile_Test_Port; } if (exists $ENV{Makefile_Test_Port}) { $file = $ENV{Makefile_Test_Port}; } my $naptime = 0; # pause between output pages if (@ARGV) { $naptime = shift @ARGV; unless ($naptime =~ /^[0-5]$/) { die "Usage: perl test?.t [ page_delay (0..5) ] [ /dev/ttyxx ]"; } } if (@ARGV) { $file = shift @ARGV; } my $cfgfile = $file."_test.cfg"; $cfgfile =~ s/.*\///; my $fault = 0; my $ob; my $pass; my $fail; my $in; my $in2; my @opts; my $out; my $blk; my $err; my $e; my $patt; my $instead; my $tick; my $tock; my @necessary_param = AltPort->set_test_mode_active(1); sub is_ok { local $Test::Builder::Level = $Test::Builder::Level + 1; return ok(shift); } sub is_zero { local $Test::Builder::Level = $Test::Builder::Level + 1; return ok(shift == 0); } sub is_bad { local $Test::Builder::Level = $Test::Builder::Level + 1; return ok(!shift); } # 2: Constructor unless (is_ok ($ob = AltPort->start ($cfgfile))) { printf "could not open port from $cfgfile\n"; exit 1; # next test would die at runtime without $ob } #### 3 - 11: Check Port Capabilities Match Save is_ok ($ob->baudrate == 9600); # 3 is_ok ($ob->parity eq "none"); # 4 is_ok ($ob->databits == 8); # 5 is_ok ($ob->stopbits == 1); # 6 is_ok ($ob->handshake eq "none"); # 7 is_ok ($ob->read_const_time == 0); # 8 is_ok ($ob->read_char_time == 0); # 9 is_ok ($ob->alias eq "AltPort"); # 10 is_ok ($ob->parity_enable == 0); # 11 #### 12 - 18: Application Parameter Defaults is_ok ($ob->devicetype eq 'none'); # 12 is_ok ($ob->hostname eq 'localhost'); # 13 is_zero ($ob->hostaddr); # 14 is_ok ($ob->datatype eq 'raw'); # 15 is_ok ($ob->cfg_param_1 eq 'none'); # 16 is_ok ($ob->cfg_param_2 eq 'none'); # 17 is_ok ($ob->cfg_param_3 eq 'none'); # 18 # 19 - 21: "Instant" return for read_xx_time=0 $tick=$ob->get_tick_count; ($in, $in2) = $ob->read(10); $tock=$ob->get_tick_count; is_zero ($in); # 19 is_bad ($in2); # 20 $out=$tock - $tick; is_ok ($out < 150); # 21 print "<0> elapsed time=$out\n"; if ($naptime) { print "++++ page break\n"; sleep $naptime; } print "Beginning Timed Tests at 2-5 Seconds per Set\n"; # 22 - 25: 2 Second Constant Timeout is_ok (2000 == $ob->read_const_time(2000)); # 22 $tick=$ob->get_tick_count; ($in, $in2) = $ob->read(10); $tock=$ob->get_tick_count; is_zero ($in); # 23 is_bad ($in2); # 24 $out=$tock - $tick; is_bad (($out < 1800) or ($out > 2400)); # 25 print "<2000> elapsed time=$out\n"; # 26 - 29: 4 Second Timeout Constant+Character is_ok (100 == $ob->read_char_time(100)); # 26 $tick=$ob->get_tick_count; ($in, $in2) = $ob->read(20); $tock=$ob->get_tick_count; is_zero ($in); # 27 is_bad ($in2); # 28 $out=$tock - $tick; is_bad (($out < 3800) or ($out > 4400)); # 29 print "<4000> elapsed time=$out\n"; # 30 - 33: 3 Second Character Timeout is_zero ($ob->read_const_time(0)); # 30 $tick=$ob->get_tick_count; ($in, $in2) = $ob->read(30); $tock=$ob->get_tick_count; is_zero ($in); # 31 is_bad ($in2); # 32 $out=$tock - $tick; is_bad (($out < 2800) or ($out > 3400)); # 33 print "<3000> elapsed time=$out\n"; #### 34 - 64: Verify Parameter Settings is_zero ($ob->read_char_time(0)); # 34 is_ok ("rts" eq $ob->handshake("rts")); # 35 is_ok ($ob->purge_rx); # 36 is_ok ($ob->purge_all); # 37 is_ok ($ob->purge_tx); # 38 if ($naptime) { print "++++ page break\n"; sleep $naptime; } is_ok(1 == $ob->user_msg); # 39 is_zero(scalar $ob->user_msg(0)); # 40 is_ok(1 == $ob->user_msg(1)); # 41 is_ok(1 == $ob->error_msg); # 42 is_zero(scalar $ob->error_msg(0)); # 43 is_ok(1 == $ob->error_msg(1)); # 44 print "Stty Shortcut Parameters\n"; my $vstart_1 = $ob->is_xon_char; is_ok(defined $vstart_1); # 45 my $vstop_1 = $ob->is_xoff_char; is_ok(defined $vstop_1); # 46 my $vintr_1 = $ob->is_stty_intr; is_ok(defined $vintr_1); # 47 my $vquit_1 = $ob->is_stty_quit; is_ok(defined $vquit_1); # 48 my $veof_1 = $ob->is_stty_eof; is_ok(defined $veof_1); # 49 my $veol_1 = $ob->is_stty_eol; is_ok(defined $veol_1); # 50 my $verase_1 = $ob->is_stty_erase; is_ok(defined $verase_1); # 51 my $vkill_1 = $ob->is_stty_kill; is_ok(defined $vkill_1); # 52 my $vsusp_1 = $ob->is_stty_susp; is_ok(defined $vsusp_1); # 53 is_zero $ob->stty_echo; # 54 my $echoe_1 = $ob->stty_echoe; is_ok(defined $echoe_1); # 55 my $echok_1 = $ob->stty_echok; is_ok(defined $echok_1); # 56 is_zero $ob->stty_echonl; # 57 is_zero $ob->stty_istrip; # 58 is_zero $ob->stty_icrnl; # 59 is_zero $ob->stty_igncr; # 60 if ($naptime) { print "++++ page break\n"; sleep $naptime; } is_zero $ob->stty_inlcr; # 61 is_zero $ob->stty_opost; # 62 is_zero $ob->stty_isig; # 63 is_zero $ob->stty_icanon; # 64 print "Change all the parameters\n"; #### 65 - 102: Modify All Port Capabilities is_ok ($ob->baudrate(1200) == 1200); # 65 is_ok ($ob->parity("odd") eq "odd"); # 66 is_ok ($ob->databits(7) == 7); # 67 is_ok ($ob->stopbits(2) == 2); # 68 is_ok ($ob->handshake("xoff") eq "xoff"); # 69 is_ok ($ob->read_const_time(1000) == 1000); # 70 is_ok ($ob->read_char_time(50) == 50); # 71 is_ok ($ob->alias("oddPort") eq "oddPort"); # 72 is_ok (scalar $ob->parity_enable(1)); # 73 is_zero ($ob->user_msg(0)); # 74 is_zero ($ob->error_msg(0)); # 75 is_ok(64 == $ob->is_xon_char(64)); # 76 is_ok(65 == $ob->is_xoff_char(65)); # 77 is_ok(66 == $ob->is_stty_intr(66)); # 78 is_ok(67 == $ob->is_stty_quit(67)); # 79 is_ok(68 == $ob->is_stty_eof(68)); # 80 is_ok(69 == $ob->is_stty_eol(69)); # 81 is_ok(70 == $ob->is_stty_erase(70)); # 82 if ($naptime) { print "++++ page break\n"; sleep $naptime; } is_ok(71 == $ob->is_stty_kill(71)); # 83 is_ok(72 == $ob->is_stty_susp(72)); # 84 is_ok($echoe_1 != $ob->stty_echoe(! $echoe_1)); # 85 is_ok($echok_1 != $ob->stty_echok(! $echok_1)); # 86 is_ok(1 == $ob->stty_echonl(1)); # 87 is_ok(1 == $ob->stty_istrip(1)); # 88 is_ok(1 == $ob->stty_icrnl(1)); # 89 is_ok(1 == $ob->stty_igncr(1)); # 90 is_ok(1 == $ob->stty_inlcr(1)); # 91 is_ok(1 == $ob->stty_opost(1)); # 92 is_ok(1 == $ob->stty_isig(1)); # 93 is_ok(1 == $ob->stty_icanon(1)); # 94 is_ok(1 == $ob->stty_echo(1)); # 95 is_ok ($ob->devicetype('type') eq 'type'); # 96 is_ok ($ob->hostname('any') eq 'any'); # 97 is_ok ($ob->hostaddr(9000) == 9000); # 98 is_ok ($ob->datatype('fixed') eq 'fixed'); # 99 is_ok ($ob->cfg_param_1('p1') eq 'p1'); # 100 is_ok ($ob->cfg_param_2('p2') eq 'p2'); # 101 is_ok ($ob->cfg_param_3('p3') eq 'p3'); # 102 #### 103 - 140: Check Port Capabilities Match Changes is_ok ($ob->baudrate == 1200); # 103 is_ok ($ob->parity eq "odd"); # 104 if ($naptime) { print "++++ page break\n"; sleep $naptime; } is_ok ($ob->databits == 7); # 105 is_ok ($ob->stopbits == 2); # 106 is_ok ($ob->handshake eq "xoff"); # 107 is_ok ($ob->read_const_time == 1000); # 108 is_ok ($ob->read_char_time == 50); # 109 is_ok ($ob->alias eq "oddPort"); # 110 is_ok (scalar $ob->parity_enable); # 111 is_zero ($ob->user_msg); # 112 is_zero ($ob->error_msg); # 113 is_ok(64 == $ob->is_xon_char); # 114 is_ok(65 == $ob->is_xoff_char); # 115 is_ok(66 == $ob->is_stty_intr); # 116 is_ok(67 == $ob->is_stty_quit); # 117 is_ok(68 == $ob->is_stty_eof); # 118 is_ok(69 == $ob->is_stty_eol); # 119 is_ok(70 == $ob->is_stty_erase); # 126 is_ok(71 == $ob->is_stty_kill); # 121 is_ok(72 == $ob->is_stty_susp); # 122 is_ok($echoe_1 != $ob->stty_echoe); # 123 is_ok($echok_1 != $ob->stty_echok); # 124 is_ok(1 == $ob->stty_echonl); # 125 if ($naptime) { print "++++ page break\n"; sleep $naptime; } is_ok(1 == $ob->stty_istrip); # 126 is_ok(1 == $ob->stty_icrnl); # 127 is_ok(1 == $ob->stty_igncr); # 128 is_ok(1 == $ob->stty_inlcr); # 129 is_ok(1 == $ob->stty_opost); # 130 is_ok(1 == $ob->stty_isig); # 131 is_ok(1 == $ob->stty_icanon); # 132 is_ok(1 == $ob->stty_echo); # 133 is_ok ($ob->devicetype eq 'type'); # 134 is_ok ($ob->hostname eq 'any'); # 135 is_ok ($ob->hostaddr == 9000); # 136 is_ok ($ob->datatype eq 'fixed'); # 137 is_ok ($ob->cfg_param_1 eq 'p1'); # 138 is_ok ($ob->cfg_param_2 eq 'p2'); # 139 is_ok ($ob->cfg_param_3 eq 'p3'); # 140 print "Restore all the parameters\n"; is_ok ($ob->restart($cfgfile)); # 141 #### 142 - 179: Check Port Capabilities Match Original is_ok ($ob->baudrate == 9600); # 142 is_ok ($ob->parity eq "none"); # 143 is_ok ($ob->databits == 8); # 144 is_ok ($ob->stopbits == 1); # 145 is_ok ($ob->handshake eq "none"); # 146 if ($naptime) { print "++++ page break\n"; sleep $naptime; } is_ok ($ob->read_const_time == 0); # 147 is_ok ($ob->read_char_time == 0); # 148 is_ok ($ob->alias eq "AltPort"); # 149 is_zero (scalar $ob->parity_enable); # 150 is_ok ($ob->user_msg == 1); # 151 is_ok ($ob->error_msg == 1); # 152 is_ok($vstart_1 == $ob->is_xon_char); # 153 is_ok($vstop_1 == $ob->is_xoff_char); # 154 is_ok($vintr_1 == $ob->is_stty_intr); # 155 is_ok($vquit_1 == $ob->is_stty_quit); # 156 is_ok($veof_1 == $ob->is_stty_eof); # 157 is_ok($veol_1 == $ob->is_stty_eol); # 158 is_ok($verase_1 == $ob->is_stty_erase); # 159 is_ok($vkill_1 == $ob->is_stty_kill); # 160 is_ok($vsusp_1 == $ob->is_stty_susp); # 161 is_ok(0 == $ob->stty_echo); # 162 is_ok($echoe_1 == $ob->stty_echoe); # 163 is_ok($echok_1 == $ob->stty_echok); # 164 is_ok(0 == $ob->stty_echonl); # 165 is_ok(0 == $ob->stty_istrip); # 166 if ($naptime) { print "++++ page break\n"; sleep $naptime; } is_ok(0 == $ob->stty_icrnl); # 167 is_ok(0 == $ob->stty_igncr); # 168 is_ok(0 == $ob->stty_inlcr); # 169 is_ok(0 == $ob->stty_opost); # 170 is_ok(0 == $ob->stty_isig); # 171 is_ok(0 == $ob->stty_icanon); # 172 is_ok ($ob->devicetype eq 'none'); # 173 is_ok ($ob->hostname eq 'localhost'); # 174 is_zero ($ob->hostaddr); # 175 is_ok ($ob->datatype eq 'raw'); # 176 is_ok ($ob->cfg_param_1 eq 'none'); # 177 is_ok ($ob->cfg_param_2 eq 'none'); # 178 is_ok ($ob->cfg_param_3 eq 'none'); # 179 #### 180 - 182: "Instant" return for read(0) is_ok (2000 == $ob->read_const_time(2000)); # 180 $tick=$ob->get_tick_count; ($in, $in2) = $ob->read(0); $tock=$ob->get_tick_count; # behavior changed in 1.0.2 to return "0" on a "0"-requested read is_ok ($in == 0); # 181 $out=$tock - $tick; is_ok ($out < 100); # 182 print "<0> elapsed time=$out\n"; ### 183 - 198: Defaults for lookfor @opts = $ob->are_match; is_ok ($#opts == 0); # 183 is_ok ($opts[0] eq "\n"); # 184 is_ok ($ob->lookclear == 1); # 185 is_ok ($ob->lookfor eq ""); # 186 is_ok ($ob->streamline eq ""); # 187 if ($naptime) { print "++++ page break\n"; sleep $naptime; } ($in, $out, $patt, $instead) = $ob->lastlook; is_ok ($in eq ""); # 188 is_ok ($out eq ""); # 189 is_ok ($patt eq ""); # 190 is_ok ($instead eq ""); # 191 is_ok ($ob->matchclear eq ""); # 192 is_ok ("" eq $ob->output_record_separator); # 193 is_ok ("" eq $ob->output_record_separator("ab")); # 194 is_ok ("ab" eq $ob->output_record_separator); # 195 is_ok ("ab" eq $ob->output_record_separator("")); # 196 is_ok ("" eq $ob->output_record_separator); # 197 is_ok ("" eq $ob->output_field_separator); # 198 @opts = $ob->are_match ("END","Bye"); is_ok ($#opts == 1); # 199 is_ok ($opts[0] eq "END"); # 200 is_ok ($opts[1] eq "Bye"); # 201 is_ok ($ob->lookclear("Good Bye, Hello") == 1); # 202 is_ok (1); # 203 is_ok ($ob->lookfor eq "Good "); # 204 ($in, $out, $patt, $instead) = $ob->lastlook; is_ok ($in eq "Bye"); # 205 is_ok ($out eq ", Hello"); # 206 is_ok ($patt eq "Bye"); # 207 is_ok ($instead eq ""); # 208 is_ok ($ob->matchclear eq "Bye"); # 209 if ($naptime) { print "++++ page break\n"; sleep $naptime; } is_ok ($ob->matchclear eq ""); # 210 is_ok ($ob->lookclear("Bye, Bye, Love. The END has come") == 1); # 211 is_ok ($ob->lookfor eq ""); # 212 ($in, $out, $patt, $instead) = $ob->lastlook; is_ok ($in eq "Bye"); # 213 is_ok ($out eq ", Bye, Love. The END has come");# 214 is_ok ($patt eq "Bye"); # 215 is_ok ($instead eq ""); # 216 is_ok ($ob->matchclear eq "Bye"); # 217 ($in, $out, $patt, $instead) = $ob->lastlook; is_ok ($in eq ""); # 218 is_ok ($out eq ", Bye, Love. The END has come");# 219 is_ok ($patt eq "Bye"); # 220 is_ok ($instead eq ""); # 221 is_ok ($ob->lookfor eq ", "); # 222 ($in, $out, $patt, $instead) = $ob->lastlook; is_ok ($in eq "Bye"); # 223 is_ok ($out eq ", Love. The END has come"); # 224 is_ok ($patt eq "Bye"); # 225 is_ok ($instead eq ""); # 226 is_ok ($ob->matchclear eq "Bye"); # 227 is_ok ($ob->lookfor eq ", Love. The "); # 228 ($in, $out, $patt, $instead) = $ob->lastlook; is_ok ($in eq "END"); # 229 is_ok ($out eq " has come"); # 230 is_ok ($patt eq "END"); # 231 if ($naptime) { print "++++ page break\n"; sleep $naptime; } is_ok ($instead eq ""); # 232 is_ok ($ob->matchclear eq "END"); # 233 is_ok ($ob->lookfor eq ""); # 234 is_ok ($ob->matchclear eq ""); # 235 ($in, $out, $patt, $instead) = $ob->lastlook; is_ok ($in eq ""); # 236 is_ok ($patt eq ""); # 237 is_ok ($instead eq " has come"); # 238 is_ok ($ob->lookclear("First\nSecond\nThe END") == 1); # 239 is_ok ($ob->lookfor eq "First\nSecond\nThe "); # 240 ($in, $out, $patt, $instead) = $ob->lastlook; is_ok ($in eq "END"); # 241 is_ok ($out eq ""); # 242 is_ok ($patt eq "END"); # 243 is_ok ($instead eq ""); # 244 is_ok ($ob->lookclear("Good Bye, Hello") == 1); # 245 is_ok ($ob->streamline eq "Good "); # 246 ($in, $out, $patt, $instead) = $ob->lastlook; is_ok ($in eq "Bye"); # 247 is_ok ($out eq ", Hello"); # 248 is_ok ($patt eq "Bye"); # 249 is_ok ($instead eq ""); # 250 is_ok ($ob->lookclear("Bye, Bye, Love. The END has come") == 1); # 251 is_ok ($ob->streamline eq ""); # 252 ($in, $out, $patt, $instead) = $ob->lastlook; is_ok ($in eq "Bye"); # 253 if ($naptime) { print "++++ page break\n"; sleep $naptime; } is_ok ($out eq ", Bye, Love. The END has come");# 254 is_ok ($patt eq "Bye"); # 255 is_ok ($instead eq ""); # 256 is_ok ($ob->matchclear eq "Bye"); # 257 ($in, $out, $patt, $instead) = $ob->lastlook; is_ok ($in eq ""); # 258 is_ok ($out eq ", Bye, Love. The END has come");# 259 is_ok ($patt eq "Bye"); # 260 is_ok ($instead eq ""); # 261 is_ok ($ob->streamline eq ", "); # 262 ($in, $out, $patt, $instead) = $ob->lastlook; is_ok ($in eq "Bye"); # 263 is_ok ($out eq ", Love. The END has come"); # 264 is_ok ($patt eq "Bye"); # 265 is_ok ($instead eq ""); # 266 is_ok ($ob->matchclear eq "Bye"); # 267 is_ok ($ob->streamline eq ", Love. The "); # 268 ($in, $out, $patt, $instead) = $ob->lastlook; is_ok ($in eq "END"); # 269 is_ok ($out eq " has come"); # 270 is_ok ($patt eq "END"); # 271 is_ok ($instead eq ""); # 272 is_ok ($ob->matchclear eq "END"); # 273 is_ok ($ob->streamline eq ""); # 274 is_ok ($ob->matchclear eq ""); # 275 if ($naptime) { print "++++ page break\n"; sleep $naptime; } ($in, $out, $patt, $instead) = $ob->lastlook; is_ok ($in eq ""); # 276 is_ok ($patt eq ""); # 277 is_ok ($instead eq " has come"); # 278 is_ok ($ob->lookclear("First\nSecond\nThe END") == 1); # 279 is_ok ($ob->streamline eq "First\nSecond\nThe "); # 280 ($in, $out, $patt, $instead) = $ob->lastlook; is_ok ($in eq "END"); # 281 is_ok ($out eq ""); # 282 is_ok ($patt eq "END"); # 283 is_ok ($instead eq ""); # 284 # 257 - 303 Test and Normal "lookclear" @opts = $ob->are_match("\n"); is_ok ($opts[0] eq "\n"); # 285 is_ok ($ob->lookclear("Before\nAfter") == 1); # 286 is_ok ($ob->lookfor eq "Before"); # 287 ($in, $out, $patt, $instead) = $ob->lastlook; is_ok ($in eq "\n"); # 288 is_ok ($out eq "After"); # 289 is_ok ($patt eq "\n"); # 290 is_ok ($instead eq ""); # 291 is_ok ($ob->lookfor eq ""); # 292 ($in, $out, $patt, $instead) = $ob->lastlook; is_ok ($in eq ""); # 293 is_ok ($patt eq ""); # 294 is_ok ($instead eq "After"); # 295 @opts = $ob->are_match ("B*e","ab..ef","-re","12..56","END"); is_ok ($#opts == 4); # 296 is_ok ($opts[2] eq "-re"); # 297 if ($naptime) { print "++++ page break\n"; sleep $naptime; } is_ok ($ob->lookclear("Good Bye, the END, Hello") == 1); # 298 is_ok ($ob->lookfor eq "Good Bye, the "); # 299 ($in, $out, $patt, $instead) = $ob->lastlook; is_ok ($in eq "END"); # 300 is_ok ($out eq ", Hello"); # 301 is_ok ($patt eq "END"); # 302 is_ok ($instead eq ""); # 303 is_ok ($ob->lookclear("Good Bye, the END, Hello") == 1); # 304 is_ok ($ob->streamline eq "Good Bye, the "); # 305 ($in, $out, $patt, $instead) = $ob->lastlook; is_ok ($in eq "END"); # 306 is_ok ($out eq ", Hello"); # 307 is_ok ($patt eq "END"); # 308 is_ok ($instead eq ""); # 309 is_ok ($ob->lookclear("Good B*e, abcdef, 123456") == 1); # 310 is_ok ($ob->lookfor eq "Good "); # 311 ($in, $out, $patt, $instead) = $ob->lastlook; is_ok ($in eq "B*e"); # 312 is_ok ($out eq ", abcdef, 123456"); # 313 is_ok ($patt eq "B*e"); # 314 is_ok ($instead eq ""); # 315 is_ok ($ob->lookfor eq ", abcdef, "); # 316 ($in, $out, $patt, $instead) = $ob->lastlook; is_ok ($in eq "123456"); # 317 is_ok ($out eq ""); # 318 if ($naptime) { print "++++ page break\n"; sleep $naptime; } is_ok ($patt eq "12..56"); # 319 is_ok ($instead eq ""); # 320 is_ok ($ob->lookclear("Good B*e, abcdef, 123456") == 1); # 321 is_ok ($ob->streamline eq "Good "); # 322 ($in, $out, $patt, $instead) = $ob->lastlook; is_ok ($in eq "B*e"); # 323 is_ok ($out eq ", abcdef, 123456"); # 324 is_ok ($patt eq "B*e"); # 325 is_ok ($instead eq ""); # 326 is_ok ($ob->streamline eq ", abcdef, "); # 327 ($in, $out, $patt, $instead) = $ob->lastlook; is_ok ($in eq "123456"); # 328 is_ok ($out eq ""); # 329 is_ok ($patt eq "12..56"); # 330 is_ok ($instead eq ""); # 331 @necessary_param = AltPort->set_test_mode_active(0); is_bad ($ob->lookclear("Good\nBye")); # 332 is_ok ($ob->lookfor eq ""); # 333 ($in, $out, $patt, $instead) = $ob->lastlook; is_ok ($in eq ""); # 334 is_ok ($out eq ""); # 335 is_ok ($patt eq ""); # 336 is_ok ("" eq $ob->output_field_separator(":")); # 337 is_ok (":" eq $ob->output_field_separator); # 338 is_ok (":" eq $ob->output_field_separator("")); # 339 is_ok ("" eq $ob->output_field_separator); # 340 is_ok ($ob->close); # 341 undef $ob; Device-SerialPort-1.04/t/01timing.t0000644000076500007650000000204610520606533015453 0ustar keeskees# Before `make install' is performed this script should be runnable with # `make test'. After `make install' it should work as `perl 1.t' use strict; ######################### use Test::More tests => 7; use_ok('Device::SerialPort'); # test ######################### # We need to test that the "get_tick_count" function actually works # as expected, since we use it during other tests to verify toggle # speeds, hang ups, etc. can_ok('Device::SerialPort',qw(get_tick_count)); # test my $then; ok(defined($then = Device::SerialPort->get_tick_count), "get_tick_count returns a number"); # test ok(sleep(2) <= 2, "sleep sleeps"); # test my $now; ok(defined($now = Device::SerialPort->get_tick_count), "get_tick_count still returns a number"); # test ok( ($now-$then) >= 1000, "measured sleep as more than 1 second") or diag("then: $then now: $now diff: ".($now-$then)); # test # Allow 100ms fudge-time for slow calls, etc ok( ($now-$then) <= 2100, "measured sleep as less than 2 seconds") or diag("then: $then now: $now diff: ".($now-$then)); # test Device-SerialPort-1.04/t/11saved-state.t0000755000076500007650000001134010650175156016413 0ustar keeskees#!/usr/bin/perl -w use lib '.','./t','./blib/lib','../blib/lib'; # can run from here or distribution base # Before installation is performed this script should be runnable with # `perl test2.t time' which pauses `time' seconds (1..5) between pages ######################### We start with some black magic to print on failure. use Test::More; eval "use DefaultPort;"; if ($@) { plan skip_all => 'No serial port selected for use with testing'; } else { plan tests => 46; } use_ok("Device::SerialPort"); use Device::SerialPort 0.10; ######################### End of black magic. # Insert your test code below (better if it prints "ok 13" # (correspondingly "not ok 13") depending on the success of chunk 13 # of the test code): # tests start using file created by test1.t use strict; my $file = "/dev/ttyS0"; if ($SerialJunk::Makefile_Test_Port) { $file = $SerialJunk::Makefile_Test_Port; } if (exists $ENV{Makefile_Test_Port}) { $file = $ENV{Makefile_Test_Port}; } my $naptime = 0; # pause between output pages if (@ARGV) { $naptime = shift @ARGV; unless ($naptime =~ /^[0-5]$/) { die "Usage: perl test?.t [ page_delay (0..5) ] [ /dev/ttyxx ]"; } } if (@ARGV) { $file = shift @ARGV; } my $cfgfile = $file."_test.cfg"; $cfgfile =~ s/.*\///; my $fault = 0; my $ob; my $pass; my $fail; my $in; my $in2; my @opts; my $out; my $blk; my $err; my $e; my $tick; my $tock; my @necessary_param = Device::SerialPort->set_test_mode_active(1); sub is_ok { local $Test::Builder::Level = $Test::Builder::Level + 1; return ok(shift); } sub is_zero { local $Test::Builder::Level = $Test::Builder::Level + 1; return ok(shift == 0); } sub is_bad { local $Test::Builder::Level = $Test::Builder::Level + 1; return ok(!shift); } # 2: Constructor unless (is_ok ($ob = Device::SerialPort->start ($cfgfile))) { printf "could not open port from $cfgfile\n"; exit 1; # next test would die at runtime without $ob } #### 3 - 11: Check Port Capabilities Match Save is_ok ($ob->baudrate == 9600); # 3 is_ok ($ob->parity eq "none"); # 4 is_ok ($ob->databits == 8); # 5 is_ok ($ob->stopbits == 1); # 6 is_ok ($ob->handshake eq "none"); # 7 is_ok ($ob->read_const_time == 0); # 8 is_ok ($ob->read_char_time == 0); # 9 is_ok ($ob->alias eq "TestPort"); # 10 is_ok ($ob->parity_enable == 0); # 11 #### 12 - 18: Application Parameter Defaults is_ok ($ob->devicetype eq 'none'); # 12 is_ok ($ob->hostname eq 'localhost'); # 13 is_zero ($ob->hostaddr); # 14 is_ok ($ob->datatype eq 'raw'); # 15 is_ok ($ob->cfg_param_1 eq 'none'); # 16 is_ok ($ob->cfg_param_2 eq 'none'); # 17 is_ok ($ob->cfg_param_3 eq 'none'); # 18 # 19 - 21: "Instant" return for read_xx_time=0 $tick=$ob->get_tick_count; ($in, $in2) = $ob->read(10); $tock=$ob->get_tick_count; is_zero ($in); # 19 is_bad ($in2); # 20 $out=$tock - $tick; is_ok ($out < 150); # 21 print "<0> elapsed time=$out\n"; if ($naptime) { print "++++ page break\n"; sleep $naptime; } print "Beginning Timed Tests at 2-5 Seconds per Set\n"; # 22 - 25: 2 Second Constant Timeout is_ok (2000 == $ob->read_const_time(2000)); # 22 $tick=$ob->get_tick_count; ($in, $in2) = $ob->read(10); $tock=$ob->get_tick_count; is_zero ($in); # 23 is_bad ($in2); # 24 $out=$tock - $tick; is_bad (($out < 1800) or ($out > 2400)); # 25 print "<2000> elapsed time=$out\n"; # 26 - 29: 4 Second Timeout Constant+Character is_ok (100 == $ob->read_char_time(100)); # 26 $tick=$ob->get_tick_count; ($in, $in2) = $ob->read(20); $tock=$ob->get_tick_count; is_zero ($in); # 27 is_bad ($in2); # 28 $out=$tock - $tick; is_bad (($out < 3800) or ($out > 4400)); # 29 print "<4000> elapsed time=$out\n"; # 30 - 34: 3 Second Character Timeout is_zero ($ob->read_const_time(0)); # 30 $tick=$ob->get_tick_count; ($in, $in2) = $ob->read(30); $tock=$ob->get_tick_count; is_zero ($in); # 31 is_bad ($in2); # 32 $out=$tock - $tick; is_bad (($out < 2800) or ($out > 3400)); # 33 print "<3000> elapsed time=$out\n"; is_zero ($ob->read_char_time(0)); # 34 is_ok ("rts" eq $ob->handshake("rts")); # 35 is_ok ($ob->purge_rx); # 36 is_ok ($ob->purge_all); # 37 is_ok ($ob->purge_tx); # 38 if ($naptime) { print "++++ page break\n"; sleep $naptime; } is_ok(1 == $ob->user_msg); # 39 is_zero(scalar $ob->user_msg(0)); # 40 is_ok(1 == $ob->user_msg(1)); # 41 is_ok(1 == $ob->error_msg); # 42 is_zero(scalar $ob->error_msg(0)); # 43 is_ok(1 == $ob->error_msg(1)); # 44 undef $ob; # 45 - 46: Reopen tests (unconfirmed) $ob->close via undef sleep 1; unless (is_ok ($ob = Device::SerialPort->start ($cfgfile))) { printf "could not reopen port from $cfgfile\n"; exit 1; # next test would die at runtime without $ob } is_ok(1 == $ob->close); # 46 undef $ob; Device-SerialPort-1.04/t/20inherited.t0000755000076500007650000004152610650175235016155 0ustar keeskees#!/usr/bin/perl -w use lib '.','./t','./blib/lib','../blib/lib'; # can run from here or distribution base # Before installation is performed this script should be runnable with # `perl test1.t time' which pauses `time' seconds (1..5) between pages ######################### We start with some black magic to print on failure. use Test::More; eval "use DefaultPort;"; if ($@) { plan skip_all => 'No serial port selected for use with testing'; } else { plan tests => 171; } use POSIX qw(uname); # can't drain ports without modems on them under POSIX in Solaris 2.6 my ($sysname, $nodename, $release, $version, $machine) = POSIX::uname(); my $SKIPDRAIN=0; if ($sysname eq "SunOS" && $machine =~ /^sun/) { $SKIPDRAIN=1; } use AltPort qw( :PARAM 0.10 ); # check inheritance & export ######################### End of black magic. # Insert your test code below (better if it prints "ok 13" # (correspondingly "not ok 13") depending on the success of chunk 13 # of the test code): use strict; ## verifies the (0, 1) list returned by binary functions sub test_bin_list { return undef unless (@_ == 2); return undef unless (0 == shift); return undef unless (1 == shift); return 1; } sub is_ok { local $Test::Builder::Level = $Test::Builder::Level + 1; return ok(shift); } sub is_zero { local $Test::Builder::Level = $Test::Builder::Level + 1; return ok(shift == 0); } sub is_bad { local $Test::Builder::Level = $Test::Builder::Level + 1; return ok(!shift); } # assume a "vanilla" port on "/dev/ttyS0" my $file = "/dev/ttyS0"; if ($SerialJunk::Makefile_Test_Port) { $file = $SerialJunk::Makefile_Test_Port; } if (exists $ENV{Makefile_Test_Port}) { $file = $ENV{Makefile_Test_Port}; } my $naptime = 0; # pause between output pages if (@ARGV) { $naptime = shift @ARGV; unless ($naptime =~ /^[0-5]$/) { die "Usage: perl test?.t [ page_delay (0..5) ] [ /dev/ttySx ]"; } } if (@ARGV) { $file = shift @ARGV; } my $cfgfile = "$file"."_test.cfg"; $cfgfile =~ s/.*\///; my $fault = 0; my $ob; my $pass; my $fail; my $in; my $in2; my @opts; my $out; my $err; my $blk; my $e; my $tick; my $tock; my %required_param; my $s="testing is a wonderful thing - this is a 60 byte long string"; # 123456789012345678901234567890123456789012345678901234567890 my $line = $s.$s.$s; # about 185 MS at 9600 baud is_ok(0x0 == nocarp); # 2 my @necessary_param = AltPort->set_test_mode_active(1); unlink $cfgfile; foreach $e (@necessary_param) { $required_param{$e} = 0; } ## 2 - 5 SerialPort Global variable ($Babble); ok(scalar(AltPort->debug) == 0); # 3: start out false ok(scalar(AltPort->debug(1))); # 4: set it # 5: yes_true subroutine, no need to SHOUT if it works ok ( AltPort->debug("T")); ok (!AltPort->debug("F")); { no strict 'subs'; ok ( AltPort->debug(T)); ok (!AltPort->debug(F)); ok ( AltPort->debug(Y)); ok (!AltPort->debug(N)); ok ( AltPort->debug(ON)); ok (!AltPort->debug(OFF)); ok ( AltPort->debug(TRUE)); ok (!AltPort->debug(FALSE)); ok ( AltPort->debug(Yes)); ok (!AltPort->debug(No)); ok ( AltPort->debug("yes")); ok (!AltPort->debug("f")); } @opts = AltPort->debug; # 6: binary_opt array is_ok(test_bin_list(@opts)); # 7: Constructor unless (is_ok ($ob = AltPort->new ($file))) { printf "could not open port $file\n"; exit 1; # next test would die at runtime without $ob } #### 8 - 64: Check Port Capabilities ## 8 - 21: Binary Capabilities is_ok($ob->can_baud); # 8 is_ok($ob->can_databits); # 9 is_ok($ob->can_stopbits); # 10 is_ok($ob->can_dtrdsr); # 11 is_ok($ob->can_handshake); # 12 is_ok($ob->can_parity_check); # 13 is_ok($ob->can_parity_config); # 14 is_ok($ob->can_parity_enable); # 15 is_zero($ob->can_rlsd); # 16 is_ok($ob->can_rtscts); # 17 is_ok($ob->can_xonxoff); # 18 is_zero($ob->can_interval_timeout); # 19 is_ok($ob->can_total_timeout); # 20 is_ok($ob->can_xon_char); # 21 if ($naptime) { print "++++ page break\n"; sleep $naptime; } is_zero($ob->can_spec_char); # 22 is_zero($ob->can_16bitmode); # 23 is_ok($ob->is_rs232); # 24 is_zero($ob->is_modem); # 25 #### 26 - xx: Set Basic Port Parameters ## 26 - 31: Baud (Valid/Invalid/Current) @opts=$ob->baudrate; # list of allowed values is_ok(1 == grep(/^9600$/, @opts)); # 26 is_zero(scalar grep(/^9601/, @opts)); # 27 is_ok($in = $ob->baudrate); # 28 is_ok(1 == grep(/^$in$/, @opts)); # 29 is_bad(scalar $ob->baudrate(9601)); # 30 is_ok($in == $ob->baudrate(9600)); # 31 # leaves 9600 pending ## 32 - xx: Parity (Valid/Invalid/Current) @opts=$ob->parity; # list of allowed values is_ok(1 == grep(/none/, @opts)); # 32 is_zero(scalar grep(/any/, @opts)); # 33 is_ok($in = $ob->parity); # 34 is_ok(1 == grep(/^$in$/, @opts)); # 35 is_bad(scalar $ob->parity("any")); # 36 is_ok($in eq $ob->parity("none")); # 37 # leaves "none" pending ## 38 - 43: Databits (Valid/Invalid/Current) @opts=$ob->databits; # list of allowed values is_ok(1 == grep(/8/, @opts)); # 38 is_zero(scalar grep(/4/, @opts)); # 39 is_ok($in = $ob->databits); # 40 is_ok(1 == grep(/^$in$/, @opts)); # 41 is_bad(scalar $ob->databits(3)); # 42 is_ok($in == $ob->databits(8)); # 43 # leaves 8 pending if ($naptime) { print "++++ page break\n"; sleep $naptime; } ## 44 - 49: Stopbits (Valid/Invalid/Current) @opts=$ob->stopbits; # list of allowed values is_ok(1 == grep(/2/, @opts)); # 44 is_zero(scalar grep(/1.5/, @opts)); # 45 is_ok($in = $ob->stopbits); # 46 is_ok(1 == grep(/^$in$/, @opts)); # 47 is_bad(scalar $ob->stopbits(3)); # 48 is_ok($in == $ob->stopbits(1)); # 49 # leaves 1 pending ## 50 - 55: Handshake (Valid/Invalid/Current) @opts=$ob->handshake; # list of allowed values is_ok(1 == grep(/none/, @opts)); # 50 is_zero(scalar grep(/moo/, @opts)); # 51 is_ok($in = $ob->handshake); # 52 is_ok(1 == grep(/^$in$/, @opts)); # 53 is_bad(scalar $ob->handshake("moo")); # 54 is_ok($in = $ob->handshake("rts")); # 55 # leaves "rts" pending for status ## 56 - 61: Buffer Size ($in, $out) = $ob->buffer_max(512); is_bad(defined $in); # 56 ($in, $out) = $ob->buffer_max; is_ok(defined $in); # 57 if (($in > 0) and ($in < 4096)) { $in2 = $in; } else { $in2 = 4096; } if (($out > 0) and ($out < 4096)) { $err = $out; } else { $err = 4096; } is_ok(scalar $ob->buffers($in2, $err)); # 58 @opts = $ob->buffers(4096, 4096, 4096); is_bad(defined $opts[0]); # 59 ($in, $out)= $ob->buffers; is_ok($in2 == $in); # 60 is_ok($out == $err); # 61 ## 62 - 64: Other Parameters (Defaults) is_ok("AltPort" eq $ob->alias("AltPort")); # 62 is_zero(scalar $ob->parity_enable(0)); # 63 is_ok($ob->write_settings); # 64 is_ok($ob->binary); # 65 if ($naptime) { print "++++ page break\n"; sleep $naptime; } ## 66 - 67: Read Timeout Initialization is_zero($ob->read_const_time); # 66 is_zero($ob->read_char_time); # 67 ## 68 - 74: No Handshake, Polled Write is_ok("none" eq $ob->handshake("none")); # 68 $tick=$ob->get_tick_count; $pass=$ob->write($line); if ($SKIPDRAIN) { is_zero(0); # 69 select(undef,undef,undef,0.185); } else { is_ok(1 == $ob->write_drain); # 69 } $tock=$ob->get_tick_count; is_ok($pass == 180); # 70 $err=$tock - $tick; is_bad (($err < 160) or ($err > 220)); # 71 print "<185> elapsed time=$err\n"; is_ok(scalar $ob->purge_tx); # 72 is_ok(scalar $ob->purge_rx); # 73 is_ok(scalar $ob->purge_all); # 74 ## 75 - 80: Optional Messages @opts = $ob->user_msg; is_ok(test_bin_list(@opts)); # 75 is_zero(scalar $ob->user_msg); # 76 is_ok(1 == $ob->user_msg(1)); # 77 @opts = $ob->error_msg; is_ok(test_bin_list(@opts)); # 78 is_zero(scalar $ob->error_msg); # 79 is_ok(1 == $ob->error_msg(1)); # 80 ## 81: Save Configuration is_ok(scalar $ob->save($cfgfile)); # 81 undef $ob; sleep 1; ## 82 - 116: Reopen as (mostly 5.003 Compatible) Tie # constructor = TIEHANDLE method # 82 unless (is_ok ($ob = tie(*PORT,'AltPort', $cfgfile))) { printf "could not reopen port from $cfgfile\n"; exit 1; # next test would die at runtime without $ob } # tie to PRINT method $tick=$ob->get_tick_count; $pass=print PORT $line; if ($SKIPDRAIN) { is_zero(0); # 83 select(undef,undef,undef,0.185); } else { is_ok(1 == $ob->write_drain); # 83 } $tock=$ob->get_tick_count; is_ok($pass == 1); # 84 $err=$tock - $tick; is_bad (($err < 160) or ($err > 235)); # 85 print "<185> elapsed time=$err\n"; if ($naptime) { print "++++ page break\n"; sleep $naptime; } # tie to PRINTF method $tick=$ob->get_tick_count; if ( $] < 5.004 ) { $out=sprintf "123456789_%s_987654321", $line; $pass=print PORT $out; } else { $pass=printf PORT "123456789_%s_987654321", $line; } if ($SKIPDRAIN) { is_zero(0); # 86 select(undef,undef,undef,0.205); } else { is_ok(1 == $ob->write_drain); # 86 } $tock=$ob->get_tick_count; is_ok($pass == 1); # 87 $err=$tock - $tick; is_bad (($err < 170) or ($err > 255)); # 88 print "<205> elapsed time=$err\n"; is_ok (300 == $ob->read_const_time(300)); # 89 is_ok (20 == $ob->read_char_time(20)); # 90 $tick=$ob->get_tick_count; $in2 = $ob->input; $tock=$ob->get_tick_count; is_ok (20 == $ob->read_char_time); # 91 unless (is_ok ($in2 eq "")) { # 92 die "\n92: Looks like you have a modem on the serial port!\n". "Please turn it off, or remove it and restart the tests.\n"; # many tests following here will fail if there is modem attached } $err=$tock - $tick; is_bad ($err > 50); # 93 print "<0> elapsed time=$err\n"; is_ok (0 == $ob->read_char_time(0)); # 94 $tick=$ob->get_tick_count; $in2= getc PORT; $tock=$ob->get_tick_count; is_bad (defined $in2); # 95 $err=$tock - $tick; is_bad (($err < 275) or ($err > 365)); # 96 print "<300> elapsed time=$err\n"; is_ok (0 == $ob->read_const_time(0)); # 97 $tick=$ob->get_tick_count; $in2= getc PORT; $tock=$ob->get_tick_count; is_bad (defined $in2); # 98 $err=$tock - $tick; is_bad ($err > 50); # 99 print "<0> elapsed time=$err\n"; ## 99 - 103: Bad Port (new + quiet) $file = "/dev/badport"; my $ob2; is_bad ($ob2 = AltPort->new ($file)); # 100 is_bad (defined $ob2); # 101 is_bad ($ob2 = AltPort->new ($file, 1)); # 102 is_bad ($ob2 = AltPort->new ($file, 0)); # 103 if ($naptime) { print "++++ page break\n"; sleep $naptime; } is_bad (defined $ob2); # 104 ## 104 - 119: Output bits and pulses SKIP: { skip "Can't IOCTL", 14 unless $ob->can_ioctl; is_ok ($ob->dtr_active(0)); # 105 $tick=$ob->get_tick_count; is_ok ($ob->pulse_dtr_on(100)); # 106 $tock=$ob->get_tick_count; $err=$tock - $tick; if (!is_bad (($err < 180) or ($err > 265))) {# 107 if ($err > 265) { warn "\n107: DTR toggle took too long. Is this a Solaris serial port?\n\tPlease read the 'SOLARIS TROUBLE' section in the README\n\tto correct this problem.\n"; } } print "<200> elapsed time=$err\n"; is_ok ($ob->dtr_active(1)); # 108 $tick=$ob->get_tick_count; is_ok ($ob->pulse_dtr_off(200)); # 109 $tock=$ob->get_tick_count; $err=$tock - $tick; if (!is_bad (($err < 370) or ($err > 485))) {# 110 if ($err > 485) { warn "\n110: DTR toggle took too long. Is this a Solaris serial port?\n\tPlease read the 'SOLARIS TROUBLE' section in the README\n\tto correct this problem.\n"; } } print "<400> elapsed time=$err\n"; SKIP: { skip "Can't RTS", 7 unless $ob->can_rts(); is_ok ($ob->rts_active(0)); # 111 $tick=$ob->get_tick_count; is_ok ($ob->pulse_rts_on(150)); # 112 $tock=$ob->get_tick_count; $err=$tock - $tick; is_bad (($err < 275) or ($err > 365)); # 113 print "<300> elapsed time=$err\n"; is_ok ($ob->rts_active(1)); # 114 $tick=$ob->get_tick_count; is_ok ($ob->pulse_rts_on(50)); # 115 $tock=$ob->get_tick_count; $err=$tock - $tick; is_bad (($err < 80) or ($err > 145)); # 116 print "<100> elapsed time=$err\n"; is_ok ($ob->rts_active(0)); # 117 } is_ok ($ob->dtr_active(0)); # 118 } $tick=$ob->get_tick_count; is_ok ($ob->pulse_break_on(250)); # 119 $tock=$ob->get_tick_count; $err=$tock - $tick; is_bad (($err < 235) or ($err > 900)); # 120 print "<500> elapsed time=$err\n"; if ($naptime) { print "++++ page break\n"; sleep $naptime; } ## 121 - 135: Record and Field Separators my $r = "I am the very model of an output record separator"; ## =49 # 1234567890123456789012345678901234567890123456789 my $f = "The fields are alive with the sound of music"; ## =44 my $ff = "$f, with fields they have sung for a thousand years"; ## =93 my $rr = "$r, not animal or vegetable or mineral or any other"; ## =98 is_ok($ob->output_record_separator eq ""); # 121 is_ok($ob->output_field_separator eq ""); # 122 $, = ""; $\ = ""; # tie to PRINT method $tick=$ob->get_tick_count; $pass=print PORT $s, $s, $s; if ($SKIPDRAIN) { is_zero(0); # 123 select(undef,undef,undef,0.185); } else { is_ok(1 == $ob->write_drain); # 123 } $tock=$ob->get_tick_count; is_ok($pass == 1); # 124 $err=$tock - $tick; is_bad (($err < 160) or ($err > 210)); # 125 print "<185> elapsed time=$err\n"; is_ok($ob->output_field_separator($f) eq ""); # 126 $tick=$ob->get_tick_count; $pass=print PORT $s, $s, $s; if ($SKIPDRAIN) { is_zero(0); # 127 select(undef,undef,undef,0.275); } else { is_ok(1 == $ob->write_drain); # 127 } $tock=$ob->get_tick_count; is_ok($pass == 1); # 128 $err=$tock - $tick; is_bad (($err < 260) or ($err > 310)); # 129 print "<275> elapsed time=$err\n"; is_ok($ob->output_record_separator($r) eq ""); # 130 $tick=$ob->get_tick_count; $pass=print PORT $s, $s, $s; if ($SKIPDRAIN) { is_zero(0); # 131 select(undef,undef,undef,0.325); } else { is_ok(1 == $ob->write_drain); # 131 } $tock=$ob->get_tick_count; is_ok($pass == 1); # 132 $err=$tock - $tick; is_bad (($err < 310) or ($err > 360)); # 133 print "<325> elapsed time=$err\n"; is_ok($ob->output_record_separator eq $r); # 134 is_ok($ob->output_field_separator eq $f); # 135 $, = $ff; $\ = $rr; $tick=$ob->get_tick_count; $pass=print PORT $s, $s, $s; if ($SKIPDRAIN) { is_zero(0); # 136 select(undef,undef,undef,0.325); } else { is_ok(1 == $ob->write_drain); # 136 } $tock=$ob->get_tick_count; $, = ""; $\ = ""; is_ok($pass == 1); # 137 $err=$tock - $tick; is_bad (($err < 310) or ($err > 360)); # 138 print "<325> elapsed time=$err\n"; if ($naptime) { print "++++ page break\n"; sleep $naptime; } $, = $ff; $\ = $rr; is_ok($ob->output_field_separator("") eq $f); # 139 $tick=$ob->get_tick_count; $pass=print PORT $s, $s, $s; if ($SKIPDRAIN) { is_zero(0); # 140 select(undef,undef,undef,0.425); } else { is_ok(1 == $ob->write_drain); # 140 } $tock=$ob->get_tick_count; $, = ""; $\ = ""; is_ok($pass == 1); # 141 $err=$tock - $tick; is_bad (($err < 410) or ($err > 460)); # 142 print "<425> elapsed time=$err\n"; $, = $ff; $\ = $rr; is_ok($ob->output_record_separator("") eq $r); # 143 $tick=$ob->get_tick_count; $pass=print PORT $s, $s, $s; if ($SKIPDRAIN) { is_zero(0); # 144 select(undef,undef,undef,0.475); } else { is_ok(1 == $ob->write_drain); # 144 } $tock=$ob->get_tick_count; $, = ""; $\ = ""; is_ok($pass == 1); # 145 $err=$tock - $tick; is_bad (($err < 460) or ($err > 510)); # 146 print "<475> elapsed time=$err\n"; is_ok($ob->output_field_separator($f) eq ""); # 147 is_ok($ob->output_record_separator($r) eq ""); # 148 # tie to PRINTF method $tick=$ob->get_tick_count; if ( $] < 5.004 ) { $out=sprintf "123456789_%s_987654321", $line; $pass=print PORT $out; } else { $pass=printf PORT "123456789_%s_987654321", $line; } if ($SKIPDRAIN) { is_zero(0); # 149 select(undef,undef,undef,0.260); } else { is_ok(1 == $ob->write_drain); # 149 } $tock=$ob->get_tick_count; is_ok($pass == 1); # 150 $err=$tock - $tick; is_bad (($err < 240) or ($err > 295)); # 151 print "<260> elapsed time=$err\n"; is_ok($ob->output_field_separator("") eq $f); # 152 is_ok($ob->output_record_separator("") eq $r); # 153 # destructor = CLOSE method if ( $] < 5.005 ) { is_ok($ob->close); # 154 } else { is_ok(close PORT); # 154 } # destructor = DESTROY method undef $ob; # Don't forget this one!! untie *PORT; no strict 'subs'; is_ok(0xffffffff == LONGsize); # 155 is_ok(0xffff == SHORTsize); # 156 is_ok(0x1 == nocarp); # 157 is_ok(0x0 == yes_true("F")); # 158 is_ok(0x1 == yes_true("T")); # 159 Device-SerialPort-1.04/Device-SerialPort.spec0000644000076500007650000000611610520606534017533 0ustar keeskees# # This spec file was originally generated by cpan2rpm v2.014, but # now it has been rather modified. :) # %define pkgname Device-SerialPort %define summary Linux/POSIX emulation of Win32::SerialPort functions %define filelist %{pkgname}-%{version}-filelist # If you want to run the tests, make sure there is no modem on the port, # and change the following "0" to a "1". %define maketest 0 %define testport /dev/ttyS0 # Be sure to change both %define pkgversion 1.002 %define rpmversion 1.2.0 %define namever %{pkgname}-%{pkgversion} %define docs eg TODO Changes README name: perl-%{pkgname} summary: %{pkgname} - %{summary} epoch: 1 version: %{rpmversion} release: 1 vendor: Kees Cook packager: Arix International license: Artistic group: Applications/CPAN url: http://www.cpan.org buildroot: %{_tmppath}/%{name}-%{version}-%(id -u -n) buildarch: i386 source: %{namever}.tar.gz %description POSIX-based version of the Win32::Serialport module for serial port control. %prep %setup -q -n %{namever} chmod -R u+w %{_builddir}/%{namever} %build CFLAGS="$RPM_OPT_FLAGS" %{__perl} Makefile.PL `%{__perl} -MExtUtils::MakeMaker -e ' print qq|PREFIX=%{buildroot}%{_prefix}| if \$ExtUtils::MakeMaker::VERSION =~ /5\.9[1-6]|6\.0[0-5]/ '` TESTPORT=%{testport} %{__make} %if %maketest %{__make} test %endif %install [ "%{buildroot}" != "/" ] && rm -rf %{buildroot} %{makeinstall} `%{__perl} -MExtUtils::MakeMaker -e ' print \$ExtUtils::MakeMaker::VERSION <= 6.05 ? qq|PREFIX=%{buildroot}%{_prefix}| : qq|DESTDIR=%{buildroot}| '` [ -x /usr/lib/rpm/brp-compress ] && /usr/lib/rpm/brp-compress # SuSE Linux if [ -e /etc/SuSE-release ]; then %{__mkdir_p} %{buildroot}/var/adm/perl-modules %{__cat} `find %{buildroot} -name "perllocal.pod"` \ | %{__sed} -e s+%{buildroot}++g \ > %{buildroot}/var/adm/perl-modules/%{name} fi # remove special files find %{buildroot} -name "perllocal.pod" \ -o -name ".packlist" \ -o -name "*.bs" \ |xargs -i rm -f {} # no empty directories find %{buildroot}%{_prefix} \ -type d -depth \ -exec rmdir {} \; 2>/dev/null %{__perl} -MFile::Find -le ' find({ wanted => \&wanted, no_chdir => 1}, "%{buildroot}"); print "%defattr(-,root,root)"; print "%doc %{docs}"; for my $x (sort @dirs, @files) { push @ret, $x unless indirs($x); } print join "\n", sort @ret; sub wanted { return if /auto$/; local $_ = $File::Find::name; my $f = $_; s|^%{buildroot}||; return unless length; return $files[@files] = $_ if -f $f; $d = $_; /\Q$d\E/ && return for reverse sort @INC; $d =~ /\Q$_\E/ && return for qw|/etc %_prefix/man %_prefix/bin %_prefix/share|; $dirs[@dirs] = $_; } sub indirs { my $x = shift; $x =~ /^\Q$_\E\// && $x ne $_ && return 1 for @dirs; } ' > %filelist [ -z %filelist ] && { echo "ERROR: empty %files listing" exit -1 } grep -rsl '^#!.*perl' %{docs} | grep -v '.bak$' |xargs --no-run-if-empty \ %__perl -MExtUtils::MakeMaker -e 'MY->fixin(@ARGV)' %clean [ "%{buildroot}" != "/" ] && rm -rf %{buildroot} %files -f %filelist %changelog * Mon Feb 23 2004 kees@outflux.net - Initial build. Device-SerialPort-1.04/MANIFEST0000644000076500007650000000111510707557016014530 0ustar keeskeesChanges modemtest MANIFEST configure config.h.in Makefile.PL README TODO SerialPort.pm SerialPort.xs eg/any_os.plx eg/demo1.plx eg/demo2.plx eg/demo3.plx eg/demo4.plx eg/demo5.plx eg/demo6.plx eg/demo7.plx eg/demo8.plx eg/example1.txt eg/example2.txt eg/example3.txt eg/example4.txt eg/example5.txt eg/example6.txt eg/example7.txt eg/example8.txt eg/options.plx t/AltPort.pm t/01timing.t t/10basic.t t/11saved-state.t t/20inherited.t t/21inherited-state.t configure.ac show-tiocm.c.test Device-SerialPort.spec META.yml Module meta-data (added by MakeMaker) Device-SerialPort-1.04/configure.ac0000644000076500007650000001051210707556466015676 0ustar keeskeesdnl Process this file with autoconf to produce a configure script. AC_PREREQ(2.61) AC_INIT([Device::SerialPort],[1.04],[devser-bugs@outflux.net]) AC_REVISION($Revision: 313 $) AC_CONFIG_SRCDIR([SerialPort.xs]) AC_CONFIG_HEADERS([config.h]) AC_PROG_CC AC_PROG_CC_STDC AC_HEADER_STDC AC_ISC_POSIX dnl Find all the possible headers our little friends are hiding in AC_CHECK_HEADERS(sys/ioctl.h) dnl Linux AC_CHECK_HEADERS(termios.h) dnl Linux AC_CHECK_HEADERS(sys/termiox.h) dnl AIX AC_CHECK_HEADERS(sys/termios.h) dnl OpenBSD AC_CHECK_HEADERS(sys/ttycom.h) dnl OpenBSD AC_CHECK_HEADERS(sys/modem.h) dnl HPUX AC_CHECK_HEADERS(IOKit/serial/ioss.h) dnl OSX dnl Actually find all the defines in the suspected headers dnl *** IF YOU MODIFY THESE, YOU MUST MODIFY SerialPort.xs *** AC_LANG(C) for check_define in \ _SC_CLK_TCK \ TIOCMBIS TIOCMBIC TIOCMGET \ CRTSCTS OCRNL ONLCR ECHOKE ECHOCTL \ TIOCM_CAR TIOCM_CD TIOCM_RNG TIOCM_RI TIOCM_CTS TIOCM_DSR \ TIOCMIWAIT TIOCGICOUNT \ TIOCINQ FIONREAD \ TIOCOUTQ \ TIOCSER_TEMT TIOCM_LE \ TIOCSERGETLSR \ TIOCSDTR TIOCCDTR \ TIOCM_RTS TIOCM_DTR \ CTSXON RTSXOFF TCGETX TCSETX \ IOSSIOSPEED \ B0 B50 B75 B110 B134 B150 B200 B300 B600 \ B1200 B1800 B2400 B4800 B9600 B19200 B38400 B57600 \ B115200 B230400 B460800 B500000 B576000 B921600 B1000000 \ B1152000 B1500000 B2000000 B2500000 B3000000 B3500000 B4000000 \ ; do AC_MSG_CHECKING([definition of $check_define]) AC_LINK_IFELSE( [AC_LANG_PROGRAM( [[ #ifdef HAVE_UNISTD_H # include #endif #ifdef HAVE_SYS_IOCTL_H # include #endif #ifdef HAVE_TERMIOS_H # include #endif #ifdef HAVE_SYS_TERMIOX_H # include #endif #ifdef HAVE_SYS_TERMIOS_H # include #endif #ifdef HAVE_SYS_TTYCOM_H # include #endif #ifdef HAVE_SYS_MODEM_H # include #endif #ifdef HAVE_IOKIT_SERIAL_IOSS_H # include #endif ]], [int a=$check_define]) ], [ eval "check_got_$check_define=yes" AC_MSG_RESULT([found]) ], [ eval "check_got_$check_define=no" AC_MSG_RESULT([missing]) ] ) done dnl ************************************** dnl Verify per-usage sanity of the defines dnl ************************************** dnl Can ioctl at all AC_MSG_CHECKING([[serial control via ioctl]]) if test "$check_got_TIOCMBIS" = "yes" && test "$check_got_TIOCMBIC" = "yes"; then AC_MSG_RESULT([yes]) else AC_MSG_RESULT([no]) AC_MSG_WARN([[Without ioctl support, most serial control functions are missing]]) fi dnl Get/Set RTS AC_MSG_CHECKING([[read/write of RTS signal]]) if test "$check_got_TIOCMBIS" = "yes" && test "$check_got_TIOCMBIC" = "yes" && test "$check_got_TIOCM_RTS" = "yes"; then AC_MSG_RESULT([yes]) else AC_MSG_RESULT([no]) AC_MSG_WARN([[You will not be able to check or change the RTS line (direct flow control)]]) fi dnl Get/Set DTR AC_MSG_CHECKING([[read/write of DTR signal]]) if test "$check_got_TIOCMBIS" = "yes" && test "$check_got_TIOCMBIC" = "yes" && test "$check_got_TIOCM_DTR" = "yes"; then AC_MSG_RESULT([yes]) else AC_MSG_RESULT([no]) AC_MSG_WARN([[You will not be able to check or change the DTR line (modem hang up)]]) fi dnl Get modem lines AC_MSG_CHECKING([[read access to modem lines]]) if test "$check_got_TIOCMGET" = "yes"; then AC_MSG_RESULT([yes]) else AC_MSG_RESULT([no]) AC_MSG_WARN([[You will not be able to check modem status lines (carrier, ring, etc)]]) fi dnl Get Buffer Status AC_MSG_CHECKING([[read access to buffer status]]) if test "$check_got_TIOCINQ" = "yes" && test "$check_got_TIOCOUTQ" = "yes"; then AC_MSG_RESULT([yes]) else AC_MSG_RESULT([no]) AC_MSG_WARN([[You will not be able to check the serial buffer state (to test for flushes)]]) fi dnl Get Line Status AC_MSG_CHECKING([[read access to serial line status]]) if test "$check_got_TIOCSERGETLSR" = "yes"; then AC_MSG_RESULT([yes]) else AC_MSG_RESULT([no]) AC_MSG_WARN([[You will not be able to check serial line status (to do full write flush)]]) fi dnl Weird Flow Control Setting AC_MSG_CHECKING([[normal CTS/RTS flow control]]) if test "$check_got_CTSXON" = "yes" && test "$check_got_RTSXOFF" = "yes" && test "$check_got_TCGETX" = "yes" && test "$check_got_TCSETX" = "yes"; then AC_MSG_RESULT([no]) AC_MSG_WARN([[Your system does CTS/RTS flow control strangely. Hopefully, we can work around it]]) else AC_MSG_RESULT([yes]) fi AC_OUTPUT Device-SerialPort-1.04/Makefile.PL0000644000076500007650000001312710650170212015341 0ustar keeskeesuse 5.006; use strict; use warnings; use ExtUtils::MakeMaker; my @SERIALS; # Scan for argument we know about my @passargs; if (@ARGV) { foreach my $arg (@ARGV) { my ($key,$value)=split /=/, $arg, 2; if ($key eq "TESTPORT") { push(@SERIALS,$value); } else { push(@passargs,$arg); } } } @ARGV=@passargs; # First, we need to figure out a default serial port to use for # testing. if (scalar(@SERIALS)>0 && $SERIALS[0] eq "auto") { print "Trying to find a serial port for testing...\n"; @SERIALS=( "/dev/ttyS1", "/dev/cua01", "/dev/cua/b", "/dev/tty1", "/dev/tty.modem" ); print "(use 'perl Makefile.PL TESTPORT=' to override this search)\n"; } if (scalar(@SERIALS)<1) { print "To enable serial port tests, use:\n"; print "\tperl Makefile.PL TESTPORT=\n"; print "where is a specific port or 'auto' to autodetect.\n"; unlink("t/DefaultPort.pm"); } else { my $file=undef; my $test; foreach $test (@SERIALS) { print "\tchecking '$test' ... "; lstat($test); if (-e _) { if (-l _) { my $sunserial=readlink($test); $sunserial="/dev/$sunserial" unless ($sunserial =~ m#^/#); stat($sunserial); if (-c _) { print "link to character device\n"; if ($sunserial =~ m#/devices/#) { # this is a sun serial device, check the type my @paths=split('/',$sunserial); my $serialtype=""; foreach my $part (@paths) { if ($part =~ /^(zs|se)\@/) { $serialtype=$1; last; } } if ($serialtype =~ /^zs/) { &CheckEtcSystem("zs:default_dtrlow"); } elsif ($serialtype =~ /^se/) { warn "\nMake sure you have patch 105924-09 or better ". "to handle your 'se' serial port.\n"; &CheckEtcSystem("se:se_default_dtrlow"); } else { warn "\nFound what seems to be a Sun serial device.\n". "Its path is '$sunserial',\n". "but is not a 'zs' or 'se' style serial device.\n". "continuing anyway...\n"; } $file=$test; last; } } } # if we get here, it's either not a link, or not a link to a sun dev stat($test); if (-c _) { print "character device\n"; $file=$test; last; } } print "nope\n"; } if (!defined($file)) { die "Could not find a serial port to use for testing.\n". "Please specify one on the 'perl Makefile.PL' command line, like so:\n". "\tperl Makefile.PL /dev/ttyS0\n"; } my $dfile = "t/DefaultPort.pm"; open (DEFAULT, "> $dfile") or die "Can't create $dfile: $!\n"; print DEFAULT < 'Device::SerialPort', 'VERSION_FROM' => 'SerialPort.pm', # finds $VERSION 'PREREQ_PM' => { 'Test::More' => 0, }, # e.g., Module::Name => 1.1 'ABSTRACT_FROM' => 'SerialPort.pm', # retrieve abstract from module 'AUTHOR' => 'Kees Cook ', 'LIBS' => [''], # e.g., '-lm' 'EXE_FILES' => ['modemtest'], 'DEFINE' => '', # e.g., '-DHAVE_SOMETHING' 'INC' => '-I.', # e.g., '-I. -I/usr/include/other' 'clean' => { 'FILES' => "config.h t/DefaultPort.pm *.cfg t/*.cfg" }, 'realclean' => { 'FILES' => "config.h config.log config.status" }, ); # Prepare config.h print "Running ./configure ...\n"; system("./configure"); if ($? != 0) { die <; close(SYSTEM); my $found=0; foreach my $line (@lines) { chomp($line); next if ($line !~ /^set/); next if ($line !~ /$setting/); my @parts=split(/\s*=\s*/,$line,2); my $value=$parts[1]; $value=~s/\s*$//; if ($value != 0) { warn "\nYour '$setting' in '/etc/system' is not '0'. This will\n". "break several of the Device::SerialPort tests, and cause\n". "longer delays when working with the DTR functions.\n"; } else { $found=1; } } if ($found != 1) { warn "\n***** WARNING *****\n". "You don't have a '$setting' line in '/etc/system'.\n". "you might need to add:\n". "\tset $setting = 0\n". "to '/etc/system', or else Device::SerialPort's DTR functions\n". "will not work properly.\n". "\nHopefully, you'll be lucky (PCI? fully patched Solaris 8?)". "\nand you won't need to make this change. See what 'make test' says.\n". "\n*** Please read the 'SOLARIS TROUBLE' section of the README\n"; } else { print "\tOh good, your '/etc/system' contains '$setting = 0'!\n"; } } Device-SerialPort-1.04/eg/0000755000076500007650000000000010707557125013775 5ustar keeskeesDevice-SerialPort-1.04/eg/demo3.plx0000755000076500007650000001043110520606533015522 0ustar keeskees#!/usr/bin/perl -w use lib './blib/lib','../blib/lib'; # can run from here or distribution base use Device::SerialPort 0.05; use strict; sub get_tf { my $result = shift; if ($result) { return "T"; } return "F"; } my $file = "/dev/ttyS0"; my $ob; my $full_cfg = 0; # Constructor if (@ARGV) { $file = $ARGV[0]; $ob = Device::SerialPort->start ($file) or die "could not open port from configuration $file\n"; # next test would die at runtime without $ob $full_cfg++; } else { $ob = Device::SerialPort->new ($file) or die "could not open port from $file\n"; # next test would die at runtime without $ob } my @carp_off_please = Device::SerialPort->set_test_mode_active(1); #### Check Port Settings my $baud=$ob->baudrate; my $par=$ob->parity; my $data=$ob->databits; my $stop=$ob->stopbits; my $hshake=$ob->handshake; my $rint="Win32"; my $rconst=$ob->read_const_time; my $rchar=$ob->read_char_time; my $wconst="Win32"; my $wchar="Win32"; my ($rbuf, $wbuf)= $ob->buffers; my $alias=$ob->alias; my $xof_l="Win32"; my $xon_l="Win32"; my $user=get_tf(scalar $ob->user_msg); my $error=get_tf(scalar $ob->error_msg); my $debug=get_tf(scalar $ob->debug); my $bin=get_tf(scalar $ob->binary); my $par_e=get_tf(scalar $ob->parity_enable); my $xon_c="Win32"; my $xof_c="Win32"; my $eof_c="Win32"; my $evt_c="Win32"; my $err_c="Win32"; ## if ($rint == 0xffffffff) { $rint = "OFF "; } sub update_menu { $baud=$ob->baudrate; $par=$ob->parity; $data=$ob->databits; $stop=$ob->stopbits; $hshake=$ob->handshake; ## $rint=$ob->read_interval; $rconst=$ob->read_const_time; $rchar=$ob->read_char_time; ## $wconst=$ob->write_const_time; ## $wchar=$ob->write_char_time; ($rbuf, $wbuf)= $ob->buffers; $alias=$ob->alias; ## $xof_l=$ob->xoff_limit; ## $xon_l=$ob->xon_limit; $user=get_tf(scalar $ob->user_msg); $error=get_tf(scalar $ob->error_msg); $debug=get_tf(scalar $ob->debug); $bin=get_tf(scalar $ob->binary); $par_e=get_tf(scalar $ob->parity_enable); ## $xon_c=sprintf("0x%x", scalar $ob->xon_char); ## $xof_c=sprintf("0x%x", scalar $ob->xoff_char); ## $eof_c=sprintf("0x%x", scalar $ob->eof_char); ## $evt_c=sprintf("0x%x", scalar $ob->event_char); ## $err_c=sprintf("0x%x", scalar $ob->error_char); ## if ($rint == 0xffffffff) { $rint = "OFF "; } $-=0; write; } format STDOUT_TOP = ======================== Serial Port Setup =========================== . format STDOUT = A Alias: @<<<<<<<<<<<< M Read Interval Time @>>>>>>> MS $alias, $rint B Baud: @<<<<<< N Read Char. Time @>>>>>>> MS $baud, $rchar C Binary: @< O Read Constant Time @>>>>>>> MS $bin, $rconst D Databits: @< P Write Char. Time @>>>>>>> MS $data, $wchar E Parity_En: @< Q Write Const. Time @>>>>>>> MS $par_e, $wconst F Parity: @<<<< R Read Buffer Size @>>>>>>> $par, $rbuf G Error Msg: @<< S Write Buffer Size @>>>>>>> $error, $wbuf H Handshake: @<<<< T Buffer Send Xon (top) @>>>>> $hshake, $xon_l I User Msg: @<<<< U Buffer Send Xoff (bot) @>>>>> $user, $xof_l J Error Char: @<<<< V Xoff Character @>>>>> $err_c, $xof_c K Event Char: @<<<< W Xon Character @>>>>> $evt_c, $xon_c L Debug: @<<<< X Eof Character @>>>>> $debug, $eof_c . write; print "\nWaiting 5 seconds before continuing\n"; sleep 5; $ob->user_msg(1); $ob->parity("odd"); $ob->parity_enable(1); update_menu; ## unless ($full_cfg) { ## print "\nParity settings will not update until write_settings complete\n"; ## } undef $ob; Device-SerialPort-1.04/eg/example1.txt0000755000076500007650000000142010520606533016241 0ustar keeskees#!/usr/bin/perl -w # cross-platform example1 use strict; use vars qw( $OS_win $ob $port ); BEGIN { $OS_win = ($^O eq "MSWin32") ? 1 : 0; if ($OS_win) { eval "use Win32::SerialPort"; die "$@\n" if ($@); } else { eval "use Device::SerialPort"; die "$@\n" if ($@); } } # End BEGIN if ($OS_win) { $port = 'COM2'; $ob = Win32::SerialPort->new ($port); } else { $port = '/dev/modem'; $ob = Device::SerialPort->new ($port); } die "Can't open serial port $port: $^E\n" unless ($ob); my $baud = $ob->baudrate; my $parity = $ob->parity; my $data = $ob->databits; my $stop = $ob->stopbits; my $hshake = $ob->handshake; print "B = $baud, D = $data, S = $stop, P = $parity, H = $hshake\n"; undef $ob; Device-SerialPort-1.04/eg/demo4.plx0000755000076500007650000000275110520606533015531 0ustar keeskees#! perl -w use lib './blib/lib','../blib/lib'; # can run from here or distribution base ######################### We start with some black magic to print on failure. BEGIN { $| = 1; print "demo4.plx "; } END {print "not ok\n" unless $loaded;} use Device::SerialPort 0.05; $loaded = 1; print "ok\n"; ######################### End of black magic. use strict; my $ob; # Constructor unless ($ob = Device::SerialPort->new ('/dev/ttyS0')) { printf "could not open port /dev/ttyS0\n"; exit 1; # next test would die at runtime without $ob } $ob->baudrate(9600) || die "bad baudrate"; $ob->parity('even') || die "bad parity"; $ob->databits(7) || die "bad databits"; $ob->stopbits(2) || die "bad stopbits"; # you probably want this one, too # note "defined" since "0" ("false") is a legal return value # returns "undef" on failure defined $ob->parity_enable('T') || die "bad parity_enable"; $ob->write_settings || undef $ob; unless ($ob) { die "couldn't write_settings"; } print "write_settings done\n"; $ob->handshake("rts") || die "bad handshake"; print "handshake problem\n" unless ("rts" eq $ob->handshake); print "baudrate problem\n" unless (9600 == $ob->baudrate); print "parity problem\n" unless ("even" eq $ob->parity); print "databits problem\n" unless (7 == $ob->databits); print "stopbits problem\n" unless (2 == $ob->stopbits); # note result comes from bit-mask test (zero/non-zero) print "parity_enable problem\n" unless (0 != $ob->parity_enable); undef $ob; Device-SerialPort-1.04/eg/demo8.plx0000755000076500007650000000176510520606533015541 0ustar keeskees#!perl -w # # Simple command-line terminal emulator # by Andrej Mikus # with small modifications by Bill Birthisel # no local echo at either end # use lib './blib/lib','../blib/lib'; # can run from here or distribution base use Device::SerialPort 0.05; use Term::ReadKey; use strict; my $file = "/dev/ttyS0"; my $ob = Device::SerialPort->new ($file) or die "Can't start $file\n"; # next test will die at runtime unless $ob my $c; my $p1 = "Simple Terminal Emulator\n"; $p1 .= "Type CAPITAL Q to quit\n\n"; print $p1; $p1 =~ s/\n/\r\n/ogs; $ob->write ($p1); for ( ;; ) { if ( $c = $ob -> input ) { $c =~ s/\r/\n/ogs; print $c; last if $c =~ /Q/; $c =~ s/\n/\r\n/ogs; $ob -> write ( $c ); } if ( defined ( $c = ReadKey ( -1 ) ) ) { $c =~ s/\r/\n/ogs; $c =~ s/\n/\r\n/ogs; $ob -> write ( $c ); last if $c eq 'Q'; } select undef, undef, undef, 0.04; # 25/sec. } $ob -> close or die "Close failed: $!\n"; undef $ob; # closes port AND frees memory in perl Device-SerialPort-1.04/eg/any_os.plx0000644000076500007650000000253710520606533016010 0ustar keeskees#!/usr/bin/perl #--------------------------------------------------------------------------- # Author: # Bruce Winter brucewinter@home.net http://members.home.net/winters # # This free software is licensed under the terms of the GNU public license. # Copyright 1998,1999 Bruce Winter # #--------------------------------------------------------------------------- use strict; use vars qw($OS_win); BEGIN { $OS_win = ($^O eq "MSWin32") ? 1 : 0; print "Perl version: $]\n"; print "OS version: $^O\n"; # This must be in a BEGIN in order for the 'use' to be conditional if ($OS_win) { print "Loading Windows modules\n"; eval "use Win32::SerialPort"; die "$@\n" if ($@); } else { print "Loading Unix modules\n"; eval "use Device::SerialPort"; die "$@\n" if ($@); } } # End BEGIN die "\n\nno port specified\n" unless (@ARGV); my $port = shift @ARGV; my $serial_port; if ($OS_win) { $serial_port = new Win32::SerialPort ($port,1); } else { $serial_port = new Device::SerialPort ($port,1); } die "Can't open serial port $port: $^E\n" unless ($serial_port); my $name = $serial_port->alias; print "\nopened serial port $port as $name\n"; $serial_port->close || die "\nclose problem with $port\n"; Device-SerialPort-1.04/eg/example2.txt0000755000076500007650000000266610520606533016257 0ustar keeskees#!/usr/bin/perl -w # cross-platform example2 use strict; use vars qw( $OS_win $ob $port ); BEGIN { $OS_win = ($^O eq "MSWin32") ? 1 : 0; if ($OS_win) { eval "use Win32::SerialPort 0.11"; die "$@\n" if ($@); } else { eval "use Device::SerialPort"; die "$@\n" if ($@); } } # End BEGIN if ($OS_win) { $port = 'COM2'; $ob = Win32::SerialPort->new ($port); } else { $port = '/dev/modem'; $ob = Device::SerialPort->new ($port); } die "Can't open serial port $port: $^E\n" unless ($ob); my $baud = $ob->baudrate; my $parity = $ob->parity; my $data = $ob->databits; my $stop = $ob->stopbits; my $hshake = $ob->handshake; my @baud_opt = $ob->baudrate; my @parity_opt = $ob->parity; my @data_opt = $ob->databits; my @stop_opt = $ob->stopbits; my @hshake_opt = $ob->handshake; my $c = 8; print "\nData Bit Options: "; foreach $a (@data_opt) { print " $a"; } print "\n\nStop Bit Options: "; foreach $a (@stop_opt) { print " $a"; } print "\n\nHandshake Options: "; foreach $a (@hshake_opt) { print " $a"; } print "\n\nParity Options: "; foreach $a (@parity_opt) { print " $a"; } print "\n\nBaudrate Options: "; foreach $a (@baud_opt) { print " $a"; unless (--$c > 0) { $c = 8; print "\n "; } } print "\n\nCurrent Settings: "; print "B = $baud, D = $data, S = $stop, P = $parity, H = $hshake\n"; undef $ob; Device-SerialPort-1.04/eg/demo5.plx0000755000076500007650000001537110520606533015534 0ustar keeskees#!/usr/bin/perl -w use lib './t','../t','./blib/lib','../blib/lib'; # can run from here or distribution base use Device::SerialPort 0.06; require "DefaultPort.pm"; use Carp; use strict; # tests start using file created by test1.t unless overridden my $file = "/dev/ttyS0"; if ($SerialJunk::Makefile_Test_Port) { $file = $SerialJunk::Makefile_Test_Port; } if (exists $ENV{Makefile_Test_Port}) { $file = $ENV{Makefile_Test_Port}; } if (@ARGV) { $file = shift @ARGV; } my $cfgfile = $file."_test.cfg"; $cfgfile =~ s/.*\///; if (-e "../t/$cfgfile") { $cfgfile = "../t/$cfgfile"; } elsif (-e "../$cfgfile") { $cfgfile = "../$cfgfile"; } elsif (-e "t/$cfgfile") { $cfgfile = "t/$cfgfile"; } else { die "$cfgfile not found" unless (-e $cfgfile); } my $ob; my $pass; my @wanted; my $before; my $did_match; my $stty_onlcr; sub nextline { my $delay = 0; my $prompt; $delay = shift if (@_); if (@_) { $prompt = shift; } else { $prompt = ""; } my $timeout=$ob->get_tick_count + (1000 * $delay); my $gotit = ""; my $fmatch = ""; my @junk; # this count wraps every 49 days or so ## $ob->is_prompt($prompt); $prompt =~ s/\n/\r\n/ogs if ($ob->stty_opost && $stty_onlcr); $ob->write($prompt); for (;;) { return unless (defined ($gotit = $ob->lookfor)); if ($gotit ne "") { ($fmatch, @junk) = $ob->lastlook; return ($gotit, $fmatch); } $fmatch = $ob->matchclear; return ("", $fmatch) if ($fmatch); return if ($ob->reset_error); select undef, undef, undef, 0.05; # 20/sec. return if ($ob->get_tick_count > $timeout); } } sub waitfor { croak "parameter problem" unless (@_ == 1); $ob->lookclear; nextline ( shift ); } sub stty_char { my $pos = shift; return '%%%%' unless ($pos); ## return $pos if (2 >= length($pos)); my $n_char = chr $pos; if ($pos < 32) { $n_char = "^".chr($pos + 64); } if ($pos == 127) { $n_char = "DEL"; } return $n_char; } # starts configuration created by test1.pl # =============== execution begins here ======================= # 2: Constructor $ob = Device::SerialPort->start ($cfgfile) or die "Can't start $cfgfile\n"; # next test will die at runtime unless $ob ### setup for dumb terminal, your mileage may vary $ob->stty_echo(1); $ob->stty_icrnl(1); $stty_onlcr = 1; $ob->stty_opost(1); ### my $intr = stty_char($ob->is_stty_intr); my $quit = stty_char($ob->is_stty_quit); my $eof = stty_char($ob->is_stty_eof); my $eol = stty_char($ob->is_stty_eol); my $erase = stty_char($ob->is_stty_erase); my $kill = stty_char($ob->is_stty_kill); my $echo = ($ob->stty_echo ? "" : "-")."echo"; my $echoe = ($ob->stty_echoe ? "" : "-")."echoe"; my $echok = ($ob->stty_echok ? "" : "-")."echok"; my $echonl = ($ob->stty_echonl ? "" : "-")."echonl"; ## my $echoke = ($ob->stty_echoke ? "" : "-")."echoke"; ## my $echoctl = ($ob->stty_echoctl ? "" : "-")."echoctl"; my $istrip = ($ob->stty_istrip ? "" : "-")."istrip"; my $icrnl = ($ob->stty_icrnl ? "" : "-")."icrnl"; ## my $ocrnl = ($ob->stty_ocrnl ? "" : "-")."ocrnl"; my $igncr = ($ob->stty_igncr ? "" : "-")."igncr"; my $inlcr = ($ob->stty_inlcr ? "" : "-")."inlcr"; my $onlcr = ($stty_onlcr ? "" : "-")."onlcr"; my $opost = ($ob->stty_opost ? "" : "-")."opost"; my $isig = $ob->stty_isig ? "enabled" : "disabled"; my $icanon = $ob->stty_icanon ? "enabled" : "disabled"; # 3: Prints Prompts to Port and Main Screen my $head = "\r\n\r\n++++++++++++++++++++++++++++++++++++++++++\r\n"; my $e="\r\n....Bye\r\n"; my $tock = <stty_opost && $stty_onlcr); $pass=$ob->write($head); $pass=$ob->write($tock); $ob->error_msg(1); # use built-in error messages $ob->user_msg(1); my $match1 = "YES"; my $match2 = "NO"; my $prompt1 = "Type $match1 or $match2 or exactly to continue\r\n"; $pass=$ob->write($prompt1) if ($ob->stty_echo); $ob->are_match($match1, $match2, "\n"); ($before, $did_match) = waitfor (30); my ($found, $end, $patt, $instead) = $ob->lastlook; if (defined $before) { if ("\n" eq $did_match) { $did_match = "newline"; } print "\ngot: $before...followed by: $did_match...\n"; } else { print "\r\nAborted or Timed Out\r\n"; print "actually received: $instead...\n"; } print $head; $pass=$ob->write($head); $ob->lookclear; ($before, $did_match) = nextline (60, "\nPROMPT:"); if (defined $before) { if ("\n" eq $did_match) { $did_match = "newline"; } print "\ngot: $before...followed by: $did_match...\n"; } else { ($found, $end, $patt, $instead) = $ob->lastlook; print "\r\nAborted or Timed Out\r\n"; print "actually received: $instead...\n"; } sleep 2; ($before, $did_match) = nextline (60, "\nPROMPT2:"); if (defined $before) { if ("\n" eq $did_match) { $did_match = "newline"; } print "\ngot2: $before...followed by: $did_match...\n"; } else { ($found, $end, $patt, $instead) = $ob->lastlook; print "\r\nAborted or Timed Out\r\n"; print "actually received: $instead...\n"; } sleep 2; @wanted = ("BYE"); $ob->are_match(@wanted); ($before, $did_match) = nextline (60, "\ntype 'BYE' to quit:"); if (defined $before) { print "\ngot3: $before...followed by: $did_match...\n"; } else { ($found, $end, $patt, $instead) = $ob->lastlook; print "\r\nAborted or Timed Out\r\n"; print "actually received: $instead...\n"; } ### example from the docs $ob->are_match("text", "\n"); # possible end strings $ob->lookclear; # empty buffers $ob->write("\r\nFeed Me:"); # initial prompt ## $ob->is_prompt("More Food:"); # new prompt after "kill" char my $gotit = ""; $match1 = ""; until ("" ne $gotit) { $gotit = $ob->lookfor; # poll until data ready die "Aborted without match\n" unless (defined $gotit); last if ($gotit); $match1 = $ob->matchclear; # match is first thing received last if ($match1); sleep 1; # polling sample time } printf "gotit = %s...\n", $gotit; # input BEFORE the match ($found, $end, $patt, $instead) = $ob->lastlook; # input that MATCHED, input AFTER the match, PATTERN that matched # input received INSTEAD when timeout without match if ($match1) { $found = $match1; } print "lastlook-match = $found...\n" if ($found); print "lastlook-after = $end...\n" if ($end); print "lastlook-pattern = $patt...\n" if ($patt); print "lastlook-instead = $instead...\n" if ($instead); ### print $e; $pass=$ob->write($e); sleep 1; undef $ob; Device-SerialPort-1.04/eg/demo1.plx0000755000076500007650000000304710520606533015525 0ustar keeskees#!/usr/bin/perl -w use lib './blib/lib','../blib/lib'; # can run from here or distribution base ######################### We start with some black magic to print on failure. BEGIN { $| = 1; print "demo1.plx loaded "; } END {print "not ok 1\n" unless $loaded;} use Device::SerialPort 0.05; $loaded = 1; print "ok 1\n"; ######################### End of black magic. use strict; my $file = "/dev/ttyS0"; my $pass; my $fail; my $in; my $in2; my @opts; my $out; my $loc; my $e; my $tick; my $tock; # 2: Constructor and Basic Values my $ob = Device::SerialPort->new ($file) || die "Can't open $file: $!"; $ob->baudrate(9600) || die "fail setting baudrate"; $ob->parity("none") || die "fail setting parity"; $ob->databits(8) || die "fail setting databits"; $ob->stopbits(1) || die "fail setting stopbits"; $ob->handshake("none") || die "fail setting handshake"; $ob->write_settings || die "no settings"; # 3: Prints Prompts to Port and Main Screen $out= "\r\n\r\n++++++++++++++++++++++++++++++++++++++++++\r\n"; $tick= "Simple Serial Terminal with echo to STDOUT\r\n\r\n"; $tock= "type CONTROL-Z on serial terminal to quit\r\n"; $e="\r\n....Bye\r\n"; print $out, $tick, $tock; $pass=$ob->write($out); $pass=$ob->write($tick); $pass=$ob->write($tock); $ob->error_msg(1); # use built-in error messages $ob->user_msg(1); $in = 1; while ($in) { if (($loc = $ob->input) ne "") { $loc =~ s/\cM/\r\n/; $ob->write($loc); print $loc; } if ($loc =~ /\cZ/) { $in--; } if ($ob->reset_error) { $in--; } } print $e; $pass=$ob->write($e); sleep 1; undef $ob; Device-SerialPort-1.04/eg/demo2.plx0000755000076500007650000000420210520606533015520 0ustar keeskees#! perl -w use lib './blib/lib','../blib/lib'; # can run from here or distribution base ######################### We start with some black magic to print on failure. BEGIN { $| = 1; print "demo2.plx loaded "; } END {print "not ok 1\n" unless $loaded;} use Device::SerialPort 0.05; $loaded = 1; print "ok 1\n"; ######################### End of black magic. # starts configuration created by test1.pl use strict; my $file = "/dev/ttyS0"; my $tc = 2; # next test number my $pass; my $fail; my $in; my $in2; my @necessary_param = Device::SerialPort->set_test_mode_active; # 2: Constructor my $ob = Device::SerialPort->new ($file) || die "Can't open $file: $!"; $ob->baudrate(9600) || die "fail setting baudrate"; $ob->parity("none") || die "fail setting parity"; $ob->databits(8) || die "fail setting databits"; $ob->stopbits(1) || die "fail setting stopbits"; $ob->handshake("none") || die "fail setting handshake"; $ob->write_settings || die "no settings"; # 3: Prints Prompts to Port and Main Screen my $out= "\r\n\r\n++++++++++++++++++++++++++++++++++++++++++\r\n"; my $tick= "Very Simple Half-Duplex Chat Demo\r\n\r\n"; my $tock= "type CAPITAL-Q on either terminal to quit\r\n"; my $e="\r\n....Bye\r\n"; my $loc="\r\n"; print $out, $tick, $tock; $pass=$ob->write($out); $pass=$ob->write($tick); $pass=$ob->write($tock); $out= "Your turn first"; $tick= "\r\nterminal>"; $tock= "\r\n\r\nperl>"; $pass=$ob->write($out); ## $_ = ; # flush it out (shell dependent) $ob->error_msg(1); # use built-in error messages $ob->user_msg(1); $fail=0; while (not $fail) { $pass=$ob->write($tick); $in = 1; while ($in) { if (($_ = $ob->input) ne "") { $ob->write($_); print $_; if (/\cM/) { $ob->write($loc); $in--; } if (/Q/) { $ob->write($loc); $in--; $fail++; } if ($ob->reset_error) { $ob->write($loc); $in--; $fail++; } } } unless ($fail) { print $tock; $_ = ; last unless (defined $_); print "\n"; $fail++ if (/Q/); $ob->write($loc); $ob->write($_) unless ($_ eq ""); } } print $e; $pass=$ob->write($e); sleep 1; undef $ob; Device-SerialPort-1.04/eg/demo6.plx0000755000076500007650000001021610520606533015526 0ustar keeskees#!/usr/bin/perl -w use lib './t','../t','./blib/lib','../blib/lib'; # can run from here or distribution base use Device::SerialPort 0.06; require "DefaultPort.pm"; use strict; # tests start using file created by test1.t unless overridden my $file = "/dev/ttyS0"; if ($SerialJunk::Makefile_Test_Port) { $file = $SerialJunk::Makefile_Test_Port; } if (exists $ENV{Makefile_Test_Port}) { $file = $ENV{Makefile_Test_Port}; } if (@ARGV) { $file = shift @ARGV; } my $cfgfile = $file."_test.cfg"; $cfgfile =~ s/.*\///; if (-e "../t/$cfgfile") { $cfgfile = "../t/$cfgfile"; } elsif (-e "../$cfgfile") { $cfgfile = "../$cfgfile"; } elsif (-e "t/$cfgfile") { $cfgfile = "t/$cfgfile"; } else { die "$cfgfile not found" unless (-e $cfgfile); } # Constructor my $head = "\r\n\r\n+++++++++++ Tied FileHandle Demo ++++++++++\r\n"; my $e="\r\n....Bye\r\n"; # =============== execution begins here ======================= # constructor = TIEHANDLE method my $tie_ob = tie(*PORT,'Device::SerialPort', $cfgfile) || die "Can't start $cfgfile\n"; # timeouts $tie_ob->read_char_time(0); $tie_ob->read_const_time(10000); ### $tie_ob->read_interval(0); ### $tie_ob->write_char_time(0); ### $tie_ob->write_const_time(3000); ### ### # match parameters ### $tie_ob->are_match("\n"); $tie_ob->lookclear; ### $tie_ob->is_prompt("\r\nPrompt! "); # other parameters $tie_ob->error_msg(1); # use built-in error messages $tie_ob->user_msg(1); $tie_ob->handshake("xoff"); ### $tie_ob->handshake("rts"); # will cause output timeouts if no connect ### $tie_ob->stty_onlcr(1); # depends on terminal ### $tie_ob->stty_opost(1); # depends on terminal $tie_ob->stty_icrnl(1); # depends on terminal $tie_ob->stty_echo(0); # depends on terminal # Print Prompts to Port and Main Screen print $head; print PORT $head; # tie to PRINT method print PORT "\r\nEnter one character (10 seconds): " or print "PRINT timed out\n\n"; # tie to GETC method my $char = getc PORT; if (!defined $char) { print "GETC timed out\n"; print PORT "...GETC timed_out\r\n"; } else { print PORT "$char\r\n"; } # tie to WRITE method if ( $] < 5.005 ) { print "syswrite tie to WRITE not supported in this Perl\n\n"; } else { my $out = "\r\nThis is a 'syswrite' test\r\n\r\n"; syswrite PORT, $out, length($out), 0 or print "WRITE timed out\n\n"; } # tie to READLINE method $tie_ob->stty_echo(1); # depends on terminal print PORT "enter line: "; my $line = ; if (defined $line) { print "READLINE received: $line"; # no chomp print PORT "\r\nREADLINE received: $line\r"; } else { print "READLINE timed out\n\n"; print PORT "...READLINE timed out\r\n"; my ($patt, $after, $match, $instead) = $tie_ob->lastlook; ## NEW print "got_instead = $instead\n" if ($instead); ## NEW } # tie to READ method my $in = "FIRST:12345, SECOND:67890, END"; $tie_ob->stty_echo(0); # depends on terminal print PORT "\r\nenter 5 char (no echo): "; unless (defined sysread (PORT, $in, 5, 6)) { print "READ timed out:\n"; print PORT "...READ timed out\r\n"; } $tie_ob->stty_echo(1); # depends on terminal print PORT "\r\nenter 5 more char (with echo): "; unless (defined sysread (PORT, $in, 5, 20)) { print "READ timed out:\n"; print PORT "...READ timed out\r\n"; } # tie to PRINTF method printf PORT "\r\nreceived: %s\r\n", $in or print "PRINTF timed out\n\n"; # PORT-specific versions of the $, and $\ variables my $n1 = ".number1_"; my $n2 = ".number2_"; my $n3 = ".number3_"; print PORT $n1, $n2, $n3; print PORT "\r\n"; $tie_ob->output_field_separator("COMMA"); print PORT $n1, $n2, $n3; print PORT "\r\n"; $tie_ob->output_record_separator("RECORD"); print PORT $n1, $n2, $n3; $tie_ob->output_record_separator(""); print PORT "\r\n"; # the $, and $\ variables will also work print PORT $e; # destructor = CLOSE method if ( $] < 5.005 ) { print "close tie to CLOSE not supported in this Perl\n\n"; $tie_ob->close || print "port close failed\n\n"; } else { close PORT || print "CLOSE failed\n\n"; } # destructor = DESTROY method undef $tie_ob; # Don't forget this one!! untie *PORT; print $e; Device-SerialPort-1.04/eg/example6.txt0000755000076500007650000000174010520606533016253 0ustar keeskees#!/usr/bin/perl -w # cross-platform example6 use strict; use vars qw( $OS_win $ob $file ); BEGIN { $OS_win = ($^O eq "MSWin32") ? 1 : 0; if ($OS_win) { eval "use Win32::SerialPort 0.11"; die "$@\n" if ($@); } else { eval "use Device::SerialPort"; die "$@\n" if ($@); } } # End BEGIN $file = 'tpj4.cfg'; if ($OS_win) { $ob = Win32::SerialPort->start ($file); } else { $ob = Device::SerialPort->start ($file); } die "Can't open serial port from $file: $^E\n" unless ($ob); $ob->write("ATE0X4\r"); $ob->read_interval(100) if ($OS_win); $ob->read_const_time(1000); my ($count, $result) = $ob->read(20); print "count = $count, result = $result\n"; $ob->read_interval(0) if ($OS_win); $ob->read_const_time(5000); $ob->write("AT&V\r"); ($count, $result) = $ob->read(40); print "count = $count, result = $result\n"; ($count, $result) = $ob->read(4000); print "count = $count, result = $result\n"; undef $ob; Device-SerialPort-1.04/eg/example7.txt0000755000076500007650000000266710520606533016265 0ustar keeskees#!/usr/bin/perl -w # cross-platform example7 use strict; use vars qw( $OS_win $ob $file ); BEGIN { $OS_win = ($^O eq "MSWin32") ? 1 : 0; if ($OS_win) { eval "use Win32::SerialPort 0.13"; die "$@\n" if ($@); } else { eval "use Device::SerialPort"; die "$@\n" if ($@); } } # End BEGIN $file = 'tpj4.cfg'; if ($OS_win) { $ob = Win32::SerialPort->start ($file); } else { $ob = Device::SerialPort->start ($file); } die "Can't open serial port from $file: $^E\n" unless ($ob); sub waitfor { my $timeout=$ob->get_tick_count + (1000 * shift); $ob->lookclear; # clear buffers my $gotit = ""; for (;;) { return unless (defined ($gotit = $ob->lookfor)); if ($gotit ne "") { my ($found, $end) = $ob->lastlook; return $gotit.$found; } return if ($ob->reset_error); return if ($ob->get_tick_count > $timeout); } } # =============== execution begins here ======================= $ob->error_msg(1); # use built-in error messages $ob->user_msg(1); $ob->are_match("BUSY","CONNECT","OK","NO DIALTONE","ERROR","RING", "NO CARRIER","NO ANSWER"); $ob->write("ATE0X4\r"); printf "%s\n", waitfor(1); # 1 second print "\nStarting Dial\n"; $ob->write("ATDT5551234\r"); # Use a different number! printf "%s\n", waitfor(20); print "\n5 seconds to failure..\n"; waitfor(5) || print "Timed Out\n"; undef $ob; Device-SerialPort-1.04/eg/example5.txt0000755000076500007650000000144710520606533016256 0ustar keeskees#!/usr/bin/perl -w # cross-platform example5 use strict; use vars qw( $OS_win $ob $file ); BEGIN { $OS_win = ($^O eq "MSWin32") ? 1 : 0; if ($OS_win) { eval "use Win32::SerialPort 0.11"; die "$@\n" if ($@); } else { eval "use Device::SerialPort"; die "$@\n" if ($@); } } # End BEGIN $file = 'tpj4.cfg'; if ($OS_win) { $ob = Win32::SerialPort->start ($file); } else { $ob = Device::SerialPort->start ($file); } die "Can't open serial port from $file: $^E\n" unless ($ob); my $baud = $ob->baudrate; print "baud from configuration: $baud\n"; $ob->write("ATE0X4\r"); sleep 1; my $result = $ob->input; print "result = $result\n"; $ob->write("AT&V\r"); sleep 2; $result = $ob->input; print "result = $result\n"; undef $ob; Device-SerialPort-1.04/eg/example4.txt0000755000076500007650000000162310520606533016251 0ustar keeskees#!/usr/bin/perl -w # cross-platform example4 use strict; use vars qw( $OS_win $ob $port ); BEGIN { $OS_win = ($^O eq "MSWin32") ? 1 : 0; if ($OS_win) { eval "use Win32::SerialPort"; die "$@\n" if ($@); } else { eval "use Device::SerialPort"; die "$@\n" if ($@); } } # End BEGIN if ($OS_win) { $port = 'COM2'; $ob = Win32::SerialPort->new ($port); } else { $port = '/dev/modem'; $ob = Device::SerialPort->new ($port); } die "Can't open serial port $port: $^E\n" unless ($ob); $ob->user_msg(1); # misc. warnings $ob->error_msg(1); # hardware and data errors $ob->baudrate(38400); $ob->parity("none"); ## $ob->parity_enable(1); # for any parity except "none" $ob->databits(8); $ob->stopbits(1); $ob->handshake('rts'); $ob->write_settings; $ob->save("tpj4.cfg"); print "wrote configuration file tpj4.cfg\n"; undef $ob; Device-SerialPort-1.04/eg/options.plx0000755000076500007650000000540210520606533016210 0ustar keeskees#!/usr/bin/perl -w ## use lib './blib/lib','../blib/lib'; # can run from here or distribution base use strict; use Device::SerialPort 0.02; my $file = "/dev/ttyS0"; if (@ARGV) { $file = shift @ARGV; } my $ob = Device::SerialPort->new ($file) || die "Usage: perl options.plx port_name (/dev/ttySx) > results"; my @baud_opt = $ob->baudrate; my @parity_opt = $ob->parity; my @data_opt = $ob->databits; my @stop_opt = $ob->stopbits; my @hshake_opt = $ob->handshake; print "\nAvailable Options for port $file\n"; print "\nData Bit Options: "; foreach $a (@data_opt) { print " $a"; } print "\n\nStop Bit Options: "; foreach $a (@stop_opt) { print " $a"; } print "\n\nHandshake Options: "; foreach $a (@hshake_opt) { print " $a"; } print "\n\nParity Options: "; foreach $a (@parity_opt) { print " $a"; } my $c = 8; print "\n\nBaudrate Options: "; foreach $a (@baud_opt) { print " $a"; unless (--$c > 0) { $c = 8; print "\n "; } } print "\nBinary Capabilities:\n"; print " can_baud\n" if (scalar $ob->can_baud); print " can_databits\n" if (scalar $ob->can_databits); print " can_stopbits\n" if (scalar $ob->can_stopbits); print " can_dtrdsr\n" if (scalar $ob->can_dtrdsr); print " can_handshake\n" if (scalar $ob->can_handshake); print " can_parity_check\n" if (scalar $ob->can_parity_check); print " can_parity_config\n" if (scalar $ob->can_parity_config); print " can_parity_enable\n" if (scalar $ob->can_parity_enable); print " can_rlsd\n" if (scalar $ob->can_rlsd); print " can_rtscts\n" if (scalar $ob->can_rtscts); print " can_xonxoff\n" if (scalar $ob->can_xonxoff); print " can_interval_timeout\n" if (scalar $ob->can_interval_timeout); print " can_total_timeout\n" if (scalar $ob->can_total_timeout); print " can_xon_char\n" if (scalar $ob->can_xon_char); print " can_spec_char\n" if (scalar $ob->can_spec_char); print " can_16bitmode\n" if (scalar $ob->can_16bitmode); print " is_rs232\n" if (scalar $ob->is_rs232); print " is_modem\n" if (scalar $ob->is_modem); print " binary\n" if (scalar $ob->binary); print " parity_enable\n" if (scalar $ob->parity_enable); print "\nCurrent Settings:\n"; printf " baud = %d\n", scalar $ob->baudrate; printf " parity = %s\n", scalar $ob->parity; printf " data = %d\n", scalar $ob->databits; printf " stop = %d\n", scalar $ob->stopbits; printf " hshake = %s\n", scalar $ob->handshake; print "\nOther Capabilities:\n"; my ($in, $out) = $ob->buffer_max; printf " input buffer max = 0x%x\n", $in; printf " output buffer max = 0x%x\n", $out; ($in, $out)= $ob->buffers; print " input buffer = $in\n"; print " output buffer = $out\n"; printf " alias = %s\n", $ob->alias; undef $ob; Device-SerialPort-1.04/eg/demo7.plx0000755000076500007650000000752210520606533015535 0ustar keeskees#!/usr/bin/perl -w # # a perl/Tk based simple chat program # demonstrates use of non-blocking I/O with event loop # uses same setup as other demo?.plx programs in SerialPort distribution # # Send-Button does not add "\n", = does use lib './t','../t','./blib/lib','../blib/lib'; # can run from here or distribution base BEGIN { require 5.004; } use Tk; use Tk::ROText; use Tk::LabEntry; use Device::SerialPort 0.06; require "DefaultPort.pm"; ## use subs qw/newline sendline/; use strict; # tests start using file created by test1.t unless overridden my $file = "/dev/ttyS0"; if ($SerialJunk::Makefile_Test_Port) { $file = $SerialJunk::Makefile_Test_Port; } if (exists $ENV{Makefile_Test_Port}) { $file = $ENV{Makefile_Test_Port}; } if (@ARGV) { $file = shift @ARGV; } my $cfgfile = $file."_test.cfg"; $cfgfile =~ s/.*\///; if (-e "../t/$cfgfile") { $cfgfile = "../t/$cfgfile"; } elsif (-e "../$cfgfile") { $cfgfile = "../$cfgfile"; } elsif (-e "t/$cfgfile") { $cfgfile = "t/$cfgfile"; } else { die "$cfgfile not found" unless (-e $cfgfile); } # =============== execution begins here ======================= # constructor my $ob = Device::SerialPort->start ($cfgfile) or die "Can't start $cfgfile\n"; # next test will die at runtime unless $ob my $poll = 0; my $polltime = 200; # milliseconds my $maxpoll = 150; # 30 seconds my $msg = ""; my $send = ""; my $senttext = ""; my $mw= MainWindow->new('-title' => 'Device::SerialPort Chat Demo7'); my $f = $mw->Frame; my $s = $f->LabEntry(-label => 'Local: ', -width => 60, -labelPack => [qw/-side left -anchor w/], -textvariable => \$send)->pack(qw/-side left/); $s->Subwidget('entry')->focus; my $sendret = sub { $send .= "\n"; &sendline; }; my $sendcmd = \&sendline; my $b = $f->Button(-text => 'Send'); $b->pack(qw/-side left/); $b->configure(-command => $sendcmd); $s->bind('' => $sendret); $f->pack(qw/-side bottom -fill x/); my $t = $mw->Scrolled(qw/ROText -setgrid true -height 20 -scrollbars e/); $t->pack(qw/-expand yes -fill both/); $t->tagConfigure(qw/Win32 -foreground black -background white/); $t->tagConfigure(qw/Serial -foreground white -background red/); $t->insert('end'," Welcome to the Tk SerialPort Demo\n", 'Win32'); $t->insert('end'," REMOTE messages\n", 'Serial'); $t->insert('end'," LOCAL messages\n\n", 'Win32'); my $stty_onlcr = 1; # on my terminal, but not POSIX $ob->stty_opost(1); # on my terminal $ob->stty_icrnl(1); # but you might change $ob->stty_echo(1); $ob->stty_icanon(1); $ob->are_match("\n"); # possible end strings $ob->lookclear; # empty buffer $ob->write("\nSerialPort Demo\n"); # "write" first to init "write_done" $msg = "\nTalking to Tk\n"; # initial prompt ## $ob->is_prompt("Again?"); # new prompt after "kill" char &newline; MainLoop(); sub newline { my $gotit = ""; # poll until data ready ## if ($ob->write_done(0)) { $gotit = $ob->lookfor; # poll until data ready ## } die "Aborted without match\n" unless (defined $gotit); my $match = $ob->matchclear; if ( ($gotit ne "") || ($match ne "") ) { $t->insert('end',"$gotit\n",'Serial'); $poll = 0; $t->see('end'); $ob->write("\r") if ($stty_onlcr); } if ($maxpoll < $poll++) { $t->insert('end',"\nCOUNTER: long time with no input\n",'Win32'); $poll = 0; $msg = "\nAnybody there?\n"; } if ($senttext) { $t->insert('end',"\n$senttext",'Win32'); $senttext = ""; } ## if ($msg && $ob->write_done(0)) { if ($msg) { if ($stty_onlcr) { $msg =~ s/\n/\r\n/osg; } ## $ob->write_bg($msg); $ob->write($msg); $msg = ""; $t->see('end'); } $mw->after($polltime, \&newline); } sub sendline { $msg .= "\n$send"; $senttext = "$send"; $send = ""; } Device-SerialPort-1.04/eg/example8.txt0000755000076500007650000000303410520606533016253 0ustar keeskees#!/usr/bin/perl -w # cross-platform example8 use strict; use vars qw( $OS_win $ob $file ); BEGIN { $OS_win = ($^O eq "MSWin32") ? 1 : 0; if ($OS_win) { eval "use Win32::SerialPort 0.11"; die "$@\n" if ($@); } else { eval "use Device::SerialPort"; die "$@\n" if ($@); } } # End BEGIN $file = 'tpj4.cfg'; if ($OS_win) { $ob = Win32::SerialPort->start ($file); } else { $ob = Device::SerialPort->start ($file); } die "Can't open serial port from $file: $^E\n" unless ($ob); my $baud = $ob->baudrate(1200); print "baud for background demo: $baud\n"; $ob->read_interval(0) if ($OS_win); $ob->read_const_time(10000); $ob->write("ATE0X4\r"); sleep 1; my $result = $ob->input; print "result = $result\n"; $ob->write("AT&V\r"); print "Starting 500 character background read\n"; my $in; $in = $ob->read_bg(500) if ($OS_win); my $done = 0; my $blk; my $err; my $out; for (;;) { ($blk, $in, $out, $err)=$ob->status; print "got $in characters so far..\n"; sleep 1; ($done, $in, $result) = $ob->read_done(0) if ($OS_win); last if $done; last if ($in >= 500); } if ($OS_win) { print "got = $in\nresult = $result\n"; $baud = $ob->baudrate(38400); sleep 2; $result = $ob->input; } else { my $active = $ob->input; print "result = $active\n"; sleep 1; $active = $ob->input; $result = ""; while ($active) { $result .= $active; sleep 1; $active = $ob->input; } } print "\n\n....And now the rest = \n$result\n"; undef $ob; Device-SerialPort-1.04/eg/example3.txt0000755000076500007650000000246310520606533016253 0ustar keeskees#!/usr/bin/perl -w # cross-platform example3 use strict; use vars qw( $OS_win $ob $port ); BEGIN { $OS_win = ($^O eq "MSWin32") ? 1 : 0; if ($OS_win) { eval "use Win32::SerialPort 0.11"; die "$@\n" if ($@); } else { eval "use Device::SerialPort"; die "$@\n" if ($@); } } # End BEGIN if ($OS_win) { $port = 'COM2'; $ob = Win32::SerialPort->new ($port); } else { $port = '/dev/modem'; $ob = Device::SerialPort->new ($port); } die "Can't open serial port $port: $^E\n" unless ($ob); my $baud = $ob->baudrate; my $parity = $ob->parity; my $data = $ob->databits; my $stop = $ob->stopbits; my $hshake = $ob->handshake; if ($baud) { $ob->baudrate($baud) || die "fail setting baud"; } else { $baud = 9600; defined $ob->baudrate($baud) || die "fail setting baud after 0"; } $ob->parity($parity) || die "fail setting parity"; $ob->databits($data) || die "fail setting databits"; $ob->stopbits($stop) || die "fail setting stopbits"; $ob->handshake($hshake) || die "fail setting handshake"; $ob->write_settings || die "no settings"; $baud = $ob->baudrate; $parity = $ob->parity; $data = $ob->databits; $stop = $ob->stopbits; $hshake = $ob->handshake; print "B = $baud, D = $data, S = $stop, P = $parity, H = $hshake\n"; undef $ob; Device-SerialPort-1.04/README0000644000076500007650000002773110520606534014264 0ustar keeskeesDevice::SerialPort Hello Serial Port users: If you are running Windows 95 or later, you want the Win32::SerialPort module instead of this one. It has a compatible user interface. Available from your favorite CPAN site. Since someone asked, there is not currently an equivalent for MS-DOS (and none is anticipated). This is a POSIX-based version of the Win32::Serialport module ported by Joe Doss for the MisterHouse Home Automation Package from Version 0.08 of the Win32 module. He replaced calls to the Win32 API with similar functions implemented using POSIX calls. While most of the testing has occurred on linux, the package should work on other POSIX-compliant Operating Systems. Most of the functions from Win32::SerialPort are now available. Almost all the demos and examples work with minimal modifications. Many of the methods are new with this release or 0.06, so expect a few bugs and consider everything experimental. But the intent is to "clone" the corresponding features of the Win32::SerialPort module whenever practical - see the documentation for that module as well as this one for details. Version 0.07 improved the lockfile support, added some application variables that are saved in the configuration_file, and added the ioctl-based methods status, modemlines, and write_done. These act mostly like their Win32 cousins. Since they use ioctls, they are only available on systems that "can_ioctl". Version 0.09 adds further compatibility for other OSes, including AIX, Solaris, and OpenBSD. Kees Cook is now maintaining this code for use with the Sendpage tool (http://sendpage.org/). Version 0.20 uses XS to figure out the serial/modem bits needed to do all the state fiddling. Pay close attention to the "configure" output warnings to find out about possible broken things on your system. Version 1.0.0 changes the version number scheme to be like Perl itself. COMPATIBILITY NOTES: 1. Earlier versions of this module were named SerialPort_Linux.pm or just SerialPort.pm. The examples in alpha version 0.02 (limited release only) work fine when the Namespace is updated. 2. Unlike Win32::SerialPort, this distribution uses Makefile.PL and the "standard" install sequence for CPAN modules: perl Makefile.PL make make test make install 3. The GetTickCount method has been renamed to get_tick_count to conform to normal naming style. A corresponding method has been added to the Win32 version to facilitate portability. 4. The save, start, and restart methods are now supported. The format of the configuration_file is not identical to the Win32 one. 5. Version 0.07 changes parts of the configuration_file. You will need to save a new one - files from previous versions will not work. 6. Right now, AIX will also fail some of the tests, including setting hardware flow control. I'm working on fixing this. 7. For Solaris, see the "SOLARIS TROUBLE" section below. 8. Please only use "read(255)" unless you've tested other reading methods. There have been reports of dropped characters using other functions. See the NOTES and KNOWN LIMITATIONS in the SerialPort documentation. The ".pod" is embedded in the ".pm". The comments on "-w" and "use strict" are especially relevant when you start calling this module from your own code. Special thanks to Joe Doss for the initial porting. And to Bruce Winter for the "required *.ph" list. Also thanks to the others who have contributed comments and suggestions. Thanks to Aaron Botsis for letting me play with his OpenBSD box and watching DTR lights for me. FILES: README - this file INSTALL - bare minimum instructions for installing TODO - list of other stuff in need of coding COPYING - software license Changes - for history lovers Makefile.PL - the "starting point" for traditional reasons configure - used to find the correct headers for SerialPort.xs config.h.in - used to build config.h, used by SerialPort.xs MANIFEST - distribution file list SerialPort.pm - the reason you're reading this SerialPort.xs - the C code to get all the serial bits from .h files modemtest - quick tool for checking on serial port show-tiocm.c.test - simple C tool to report TIOCM* hacks Device-SerialPort.spec - RPM .spec file for building RPMS t - test directory t/Altport.pm - stub for inheritance test t/01timing.t - tests millisecond counter in "get_tick_count" t/test1.t - tests basic port function t/test2.t - tests restarting_a_configuration and timeouts t/test3.t - Inheritance and export version of test1.t t/test4.t - Inheritance version of test2.t and "restart" eg/any_os.plx - cross-platform "conditional use" demo eg/demo1.plx - talks to a "really dumb" terminal eg/demo2.plx - "poor man's" readline and chatV eg/demo3.plx - looks like a setup menu - but only looks :-( eg/demo4.plx - simplest setup: "new", "required param" eg/demo5.plx - "waitfor" and "nextline" using lookfor eg/demo6.plx - basic tied FileHandle operations, record separators eg/demo7.plx - a Perl/Tk based terminal, event loop and callbacks eg/demo8.plx - command line terminal emulator with Term::Readkey eq/options.plx - post-install test that prints available options eg/example1.txt - examples from The Perl Journal #13 eg/example2.txt - (minimal mods for cross-platform use) eg/example3.txt eg/example4.txt eg/example5.txt eg/example6.txt eg/example7.txt eg/example8.txt autotools/* - various tools used by the "configure" script INSTALL and TEST: You will need suitable permissions to open the port. If the port is also used for logins, you will need to create a lockfile (/var/lock/LCK..ttyS0) on my Redhat 5.2 system. Just touch it, the contents are not important. They may be someday. But not yet. You might need to be "root" for that. Run 'perl Makefile.PL' followed by 'make'. This will create install files and directories. Run 'make test' with nothing connected to "/dev/ttyS1". This will run the tests and create a configuration_file. You can specify a different port to test via 'perl Makefile.PL TESTPORT='. Makefile.PL creates "t/DefaultPort.pm". You can also specify an alternate port with the Shell Variable "Makefile_Test_Port". The Benchmark routines are used to generate reports. The test suite covers many of the module methods and sets the port for 9600 baud, 1 stop, 8 data, no parity, no handshaking, and other defaults. At various points in the testing, it expects unconnected CTS and DTR lines. The module should restore any port settings on exit. But this has not been exhaustively tested yet. Tests may also be run individually by typing: 'perl test?.t Page_Delay [/dev/ttySx]' With no delay, the tests execute too rapidly to follow from a command line. Delay may be set from 0 to 5 seconds. All tests are expected to pass - I would be very interested in hearing about failures ("not ok"). These tests should be run from a command prompt. For details run "make test TEST_VERBOSE=1". SOLARIS TROUBLE: The big problem is with Solaris' handling of DTR. Depending on hardware, patchlevel, or something very mystical, if you have an "se" or "zs" serial port (run "modinfo | grep serial" to find out), you may need to correct this DTR bug by adding a line to your /etc/system file. See below... From the following URL: http://www.stokely.com/unix.serial.port.resources/tutorials.html DTR Delay Problems: By default, Suns have a three second delay in toggling dtr. If your Sun has a zs serial port you can set the variable default_dtrlow to control the number of seconds of the delay. If the variable is set to zero, dtr can be toggled many times a second. For example, in /etc/system add the line "set zs:default_dtrlow = 1" to have a 1 second delay. If your workstation has an se serial port, the /etc/system line should be "set se:se_default_dtrlow = 1". However, in initial versions of the se driver, the delay was the value of (se_default_dtrlow + 1) seconds. If you have this version of the se driver, don't set the value to -1 in /etc/system or the port will hang on open. If you need to toggle dtr quickly, you can still set the value to -1 after the terminal is opened by using adb to set the variable manually. All this is Sun bugid 4230310, fixed by patch 105924-09 or higher. The patch makes se_default_dtrlow behave like default_dtrlow (i.e. setting se_default_dtrlow to 0 will allow rapid toggling of dtr instead of once per second). So, since I have zs serial ports on my Sun, I added the line: set zs:default_dtrlow=0 so I could toggle the DTR rapidly. There are also problems with "tcdrain" never returning if there is no device attached to the serial port. This has been worked around in the tests. DEMO PROGRAMS: Connect a dumb terminal (or a PC that acts like one) to /dev/ttyS0 and setup the equivalent configuration. Starting demo1.plx should print a three line message on both the terminal and the command line. The terminal keyboard (only) now accepts characters which it prints to both screens until a CONTROL-Z is typed. Also included is demo2.plx - a truly minimal chat program. Bi-directional communication without an event loop, sockets, pipes (or much utility ;-) This one uses CAPITAL-Q from the active keyboard to quit since doesn't like CONTROL-Z. AltPort.pm and test3.t implement the "basic Inheritance test" discussed in perltoot and other documentation. It also imports the :PARAM constants. It's otherwise only slightly modified from test1.t (you'll get a different "alias" in test3.t). Run options.plx to see the available choices for various parameters along with the current values. If you have trouble, I will probably ask you to save the output of options.plx in a file and send it to me. You can specify a port name for options.plx on the command line (e.g. 'perl options.plx COM2'). You can read (many of the important) settings with demo3.plx. If you give it a (valid) configuration file on the command line, it will open the port with those parameters - so you can test simple changes: see the parity example at the end of demo3.plx. Demo4.plx is a "minimum" script showing just the basics needed to get started. Demo5.plx demonstrates various uses of the lookfor routine including setups for "waitfor" and a primitive "readline". Try them out. The default "stty" settings work with a VT-100 style terminal. You may have to set the options by hand. Use any editor. Let me know if the descriptions in the documentation are useable. And if any more options are necessary. Demo6.plx demonstrates tied FileHandles. Perl 5.005 is recommended. It "requires" 5.004. It implements timeouts on all user inputs - so you can run it "hands-off" to see what happens. Demo7.plx uses Tk to create a terminal emulator. Its included to show polling and callbacks using an event loop. Demo8.plx is a simple command-line terminal emulator contributed by Andrej Mikus. The Perl Journal #13 included an article on Controlling a Modem with Win32::SerialPort. Slightly revised versions of all the Examples from the article are included in the "eg" subdirectory. The revisions cover cross-platform use and workarounds for small timing differences. Please tell me what does and what doesn't work. The module has proven to be pretty robust. But I can't test all possible configurations. Don't trust it for anything important without complete testing. And watch for updates at: %%%% http://sendpage.org/device-serialport/ or CPAN under authors/id/C/CO/COOK or Device::SerialPort Thanks, -Kees Copyright (C) 1999, Bill Birthisel. All rights reserved. Copyright (C) 2001-2005 Kees Cook. All rights reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. Device-SerialPort-1.04/config.h.in0000644000076500007650000000356310707555366015441 0ustar keeskees/* config.h.in. Generated from configure.ac by autoheader. */ /* Define to 1 if you have the header file. */ #undef HAVE_INTTYPES_H /* Define to 1 if you have the header file. */ #undef HAVE_IOKIT_SERIAL_IOSS_H /* Define to 1 if you have the header file. */ #undef HAVE_MEMORY_H /* Define to 1 if you have the header file. */ #undef HAVE_STDINT_H /* Define to 1 if you have the header file. */ #undef HAVE_STDLIB_H /* Define to 1 if you have the header file. */ #undef HAVE_STRINGS_H /* Define to 1 if you have the header file. */ #undef HAVE_STRING_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_IOCTL_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_MODEM_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_STAT_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_TERMIOS_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_TERMIOX_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_TTYCOM_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_TYPES_H /* Define to 1 if you have the header file. */ #undef HAVE_TERMIOS_H /* Define to 1 if you have the header file. */ #undef HAVE_UNISTD_H /* Define to the address where bug reports for this package should be sent. */ #undef PACKAGE_BUGREPORT /* Define to the full name of this package. */ #undef PACKAGE_NAME /* Define to the full name and version of this package. */ #undef PACKAGE_STRING /* Define to the one symbol short name of this package. */ #undef PACKAGE_TARNAME /* Define to the version of this package. */ #undef PACKAGE_VERSION /* Define to 1 if you have the ANSI C header files. */ #undef STDC_HEADERS Device-SerialPort-1.04/SerialPort.pm0000644000076500007650000027656110707556466016054 0ustar keeskees# This is a POSIX version of the Win32::Serialport module # ported by Joe Doss, Kees Cook # Originally for use with the MisterHouse and Sendpage programs # # $Id: SerialPort.pm 313 2007-10-24 05:50:46Z keescook $ # # Copyright (C) 1999, Bill Birthisel # Copyright (C) 2000-2007 Kees Cook # kees@outflux.net, http://outflux.net/ # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # http://www.gnu.org/copyleft/gpl.html # package Device::SerialPort; use 5.006; use strict; use warnings; use POSIX qw(:termios_h); use IO::Handle; use Carp; use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); $VERSION = 1.04; require Exporter; @ISA = qw(Exporter); @EXPORT= qw(); @EXPORT_OK= qw(); %EXPORT_TAGS = (STAT => [qw( MS_CTS_ON MS_DSR_ON MS_RING_ON MS_RLSD_ON MS_DTR_ON MS_RTS_ON ST_BLOCK ST_INPUT ST_OUTPUT ST_ERROR TIOCM_CD TIOCM_RI TIOCM_DSR TIOCM_DTR TIOCM_CTS TIOCM_RTS TIOCM_LE )], PARAM => [qw( LONGsize SHORTsize OS_Error nocarp yes_true )]); Exporter::export_ok_tags('STAT', 'PARAM'); $EXPORT_TAGS{ALL} = \@EXPORT_OK; require XSLoader; XSLoader::load('Device::SerialPort', $VERSION); #### Package variable declarations #### use vars qw($IOCTL_VALUE_RTS $IOCTL_VALUE_DTR $IOCTL_VALUE_TERMIOXFLOW $ms_per_tick); # Load all the system bits we need my $bits=Device::SerialPort::Bits::get_hash(); my $ms_per_tick=undef; # ioctl values $IOCTL_VALUE_RTS = pack('L', $bits->{'TIOCM_RTS'} || 0); $IOCTL_VALUE_DTR = pack('L', $bits->{'TIOCM_DTR'} || 0); $IOCTL_VALUE_TERMIOXFLOW = (($bits->{'CTSXON'}||0) | ($bits->{'RTSXOFF'}||0)); # non-POSIX constants commonly defined in termios.ph sub CRTSCTS { return $bits->{'CRTSCTS'} || 0; } sub OCRNL { return $bits->{'OCRNL'} || 0; } sub ONLCR { return $bits->{'ONLCR'} || 0; } sub ECHOKE { return $bits->{'ECHOKE'} || 0; } sub ECHOCTL { return $bits->{'ECHOCTL'} || 0; } sub TIOCM_LE { return $bits->{'TIOCSER_TEMT'} || $bits->{'TIOCM_LE'} || 0; } # Set alternate bit names $bits->{'portable_TIOCINQ'} = $bits->{'TIOCINQ'} || $bits->{'FIONREAD'}; ## Next 4 use Win32 names for compatibility sub MS_RLSD_ON { return TIOCM_CD(); } sub TIOCM_CD { return $bits->{'TIOCM_CAR'} || $bits->{'TIOCM_CD'} || 0; } sub MS_RING_ON { return TIOCM_RI(); } sub TIOCM_RI { return $bits->{'TIOCM_RNG'} || $bits->{'TIOCM_RI'} || 0; } sub MS_CTS_ON { return TIOCM_CTS(); } sub TIOCM_CTS { return $bits->{'TIOCM_CTS'} || 0; } sub MS_DSR_ON { return TIOCM_DSR(); } sub TIOCM_DSR { return $bits->{'TIOCM_DSR'} || 0; } # For POSIX completeness sub MS_RTS_ON { return TIOCM_RTS(); } sub TIOCM_RTS { return $bits->{'TIOCM_RTS'} || 0; } sub MS_DTR_ON { return TIOCM_DTR(); } sub TIOCM_DTR { return $bits->{'TIOCM_DTR'} || 0; } # "status" sub ST_BLOCK {0} # status offsets for caller sub ST_INPUT {1} sub ST_OUTPUT {2} sub ST_ERROR {3} # latched # parameters that must be included in a "save" and "checking subs" my %validate = ( ALIAS => "alias", E_MSG => "error_msg", RCONST => "read_const_time", RTOT => "read_char_time", U_MSG => "user_msg", DVTYPE => "devicetype", HNAME => "hostname", HADDR => "hostaddr", DATYPE => "datatype", CFG_1 => "cfg_param_1", CFG_2 => "cfg_param_2", CFG_3 => "cfg_param_3", ); my @termios_fields = ( "C_CFLAG", "C_IFLAG", "C_ISPEED", "C_LFLAG", "C_OFLAG", "C_OSPEED" ); my %c_cc_fields = ( VEOF => &POSIX::VEOF, VEOL => &POSIX::VEOL, VERASE => &POSIX::VERASE, VINTR => &POSIX::VINTR, VKILL => &POSIX::VKILL, VQUIT => &POSIX::VQUIT, VSUSP => &POSIX::VSUSP, VSTART => &POSIX::VSTART, VSTOP => &POSIX::VSTOP, VMIN => &POSIX::VMIN, VTIME => &POSIX::VTIME, ); my @baudrates = qw( 0 50 75 110 134 150 200 300 600 1200 1800 2400 4800 9600 19200 38400 57600 115200 230400 460800 500000 576000 921600 1000000 1152000 2000000 2500000 3000000 3500000 4000000 ); # Build list of "valid" system baudrates my %bauds; foreach my $baud (@baudrates) { my $baudvar="B$baud"; $bauds{$baud}=$bits->{$baudvar} if (defined($bits->{$baudvar})); } my $Babble = 0; my $testactive = 0; # test mode active my @Yes_resp = ( "YES", "Y", "ON", "TRUE", "T", "1" ); my @binary_opt = ( 0, 1 ); my @byte_opt = (0, 255); my $cfg_file_sig="Device::SerialPort_Configuration_File -- DO NOT EDIT --\n"; ## my $null=[]; my $null=0; my $zero=0; # Preloaded methods go here. sub init_ms_per_tick { my $from_posix=undef; my $errors=""; # To find the real "CLK_TCK" value, it is *best* to query sysconf # for it. However, this requires access to _SC_CLK_TCK. In # modern versions of Perl (and libc) these this is correctly found # in the POSIX module. On really old versions, the hard-coded # "CLK_TCK" can be found. So, first attempt to use the POSIX # module to get what we need, and then try our internal bit # detection code, and finally fall back to the hard-coded value # before totally giving up. for (;;) { eval { $from_posix = POSIX::sysconf(&POSIX::_SC_CLK_TCK); }; last if (!$@); $errors.="$@\n"; if (defined($bits->{'_SC_CLK_TCK'})) { $from_posix = POSIX::sysconf($bits->{'_SC_CLK_TCK'}); last; } $errors.="_SC_CLK_TCK not found during compilation\n"; # According to POSIX, "CLK_TCK" is obsolete now. See # "man 2 times" and the POSIX-1996 standard eval { $from_posix = &POSIX::CLK_TCK; }; last if (!$@); $errors.="$@\n"; last; } if (!defined($from_posix) || $from_posix == 0) { die "Cannot find a useful value for _SC_CLK_TCK:\n$errors"; } $ms_per_tick = 1000.0 / $from_posix; } sub get_tick_count { # clone of Win32::GetTickCount - perhaps same 49 day problem if (!defined($ms_per_tick)) { init_ms_per_tick(); } my ($real2, $user2, $system2, $cuser2, $csystem2) = POSIX::times(); $real2 *= $ms_per_tick; ## printf "real2 = %8.0f\n", $real2; return int $real2; } sub SHORTsize { 0xffff; } # mostly for AltPort test sub LONGsize { 0xffffffff; } # mostly for AltPort test sub OS_Error { print "Device::SerialPort OS_Error\n"; } # test*.pl only - suppresses default messages sub set_test_mode_active { return unless (@_ == 2); $testactive = $_[1]; # allow "off" my @fields = @termios_fields; my $item; foreach $item (keys %c_cc_fields) { push @fields, "C_$item"; } foreach $item (keys %validate) { push @fields, "$item"; } return @fields; } sub nocarp { return $testactive } sub yes_true { my $choice = uc shift; my $ans = 0; foreach (@Yes_resp) { $ans = 1 if ( $choice eq $_ ) } return $ans; } sub new { my $proto = shift; my $class = ref($proto) || $proto; my $self = {}; my $ok = 0; # API return value my $item = 0; my $nameOrConf = shift; return start($class, $nameOrConf, @_) if (-f $nameOrConf && ! -c $nameOrConf ); $self->{NAME} = $nameOrConf; shift; # ignore "$quiet" parameter my $lockfile = shift; if ($lockfile) { $self->{LOCK} = $lockfile; my $lockf = POSIX::open($self->{LOCK}, &POSIX::O_WRONLY | &POSIX::O_CREAT | &POSIX::O_NOCTTY | &POSIX::O_EXCL); return undef if (!defined($lockf)); my $pid = "$$\n"; $ok = POSIX::write($lockf, $pid, length $pid); my $ok2 = POSIX::close($lockf); return unless ($ok && (defined $ok2)); sleep 2; # wild guess for Version 0.05 } else { $self->{LOCK} = ""; } $self->{FD}= POSIX::open($self->{NAME}, &POSIX::O_RDWR | &POSIX::O_NOCTTY | &POSIX::O_NONBLOCK); unless (defined $self->{FD}) { $self->{FD} = -1; } unless ($self->{FD} >= 0) { # the "unlink" will destroy the err code, so preserve it my $save_err=$!+0; if ($self->{LOCK}) { unlink $self->{LOCK}; $self->{LOCK} = ""; } $!=$save_err+0; return undef; } $self->{TERMIOS} = POSIX::Termios->new(); # a handle object for ioctls: read-only ok $self->{HANDLE} = new_from_fd IO::Handle ($self->{FD}, "r"); # get the current attributes $ok = $self->{TERMIOS}->getattr($self->{FD}); unless ( $ok ) { carp "can't getattr: $!"; undef $self; return undef; } # save the original values $self->{"_CFLAG"} = $self->{TERMIOS}->getcflag(); $self->{"_IFLAG"} = $self->{TERMIOS}->getiflag(); $self->{"_ISPEED"} = $self->{TERMIOS}->getispeed(); $self->{"_LFLAG"} = $self->{TERMIOS}->getlflag(); $self->{"_OFLAG"} = $self->{TERMIOS}->getoflag(); $self->{"_OSPEED"} = $self->{TERMIOS}->getospeed(); # build termiox flag anyway $self->{'TERMIOX'} = 0; # copy the original values into "current" values foreach $item (keys %c_cc_fields) { $self->{"_$item"} = $self->{TERMIOS}->getcc($c_cc_fields{$item}); } foreach $item (keys %c_cc_fields) { $self->{"C_$item"} = $self->{"_$item"}; } $self->{"C_CFLAG"} = $self->{"_CFLAG"}; $self->{"C_IFLAG"} = $self->{"_IFLAG"}; $self->{"C_ISPEED"} = $self->{"_ISPEED"}; $self->{"C_LFLAG"} = $self->{"_LFLAG"}; $self->{"C_OFLAG"} = $self->{"_OFLAG"}; $self->{"C_OSPEED"} = $self->{"_OSPEED"}; # Finally, default to "raw" mode for this package $self->{"C_IFLAG"} &= ~(IGNBRK|BRKINT|PARMRK|IGNPAR|INPCK|ISTRIP|INLCR|IGNCR|ICRNL|IXON); $self->{"C_OFLAG"} &= ~OPOST; $self->{"C_LFLAG"} &= ~(ECHO|ECHONL|ICANON|ISIG|IEXTEN); # "minicom" does some alarming things for setting up "raw", which is mostly # just the direct manipulation of the i, o, and l termios flags #$self->{"C_IFLAG"} = 0; #$self->{"C_OFLAG"} = 0; #$self->{"C_LFLAG"} = 0; # Sane port $self->{"C_IFLAG"} |= IGNBRK; $self->{"C_CFLAG"} |= (CLOCAL|CREAD); # 9600 baud $self->{"C_OSPEED"} = $bauds{"9600"}; $self->{"C_ISPEED"} = $bauds{"9600"}; # 8data bits $self->{"C_CFLAG"} &= ~CSIZE; $self->{"C_CFLAG"} |= CS8; # disable parity $self->{"C_CFLAG"} &= ~(PARENB | PARODD); # 1 stop bit $self->{"C_CFLAG"} &= ~CSTOPB; # by default, disable the OSX arbitrary baud settings $self->{"IOSSIOSPEED_BAUD"} = -1; &write_settings($self); $self->{ALIAS} = $self->{NAME}; # so "\\.\+++" can be changed # "private" data $self->{"_DEBUG"} = 0; $self->{U_MSG} = 0; $self->{E_MSG} = 0; $self->{RCONST} = 0; $self->{RTOT} = 0; $self->{"_T_INPUT"} = ""; $self->{"_LOOK"} = ""; $self->{"_LASTLOOK"} = ""; $self->{"_LASTLINE"} = ""; $self->{"_CLASTLINE"} = ""; $self->{"_SIZE"} = 1; $self->{OFS} = ""; $self->{ORS} = ""; $self->{"_LMATCH"} = ""; $self->{"_LPATT"} = ""; $self->{"_PROMPT"} = ""; $self->{"_MATCH"} = []; $self->{"_CMATCH"} = []; @{ $self->{"_MATCH"} } = "\n"; @{ $self->{"_CMATCH"} } = "\n"; $self->{DVTYPE} = "none"; $self->{HNAME} = "localhost"; $self->{HADDR} = 0; $self->{DATYPE} = "raw"; $self->{CFG_1} = "none"; $self->{CFG_2} = "none"; $self->{CFG_3} = "none"; bless ($self, $class); unless ($self->can_ioctl()) { nocarp or carp "disabling ioctl methods - system constants not found\n"; } # These might be a good idea (but we'll need to change the tests) # $self->read_char_time(0); # no time # $self->read_const_time(100); # 10th of a second return $self; } # Returns "1" on success sub write_settings { my $self = shift; my ($item, $result); # put current values into Termios structure $self->{TERMIOS}->setcflag($self->{"C_CFLAG"}); $self->{TERMIOS}->setlflag($self->{"C_LFLAG"}); $self->{TERMIOS}->setiflag($self->{"C_IFLAG"}); $self->{TERMIOS}->setoflag($self->{"C_OFLAG"}); $self->{TERMIOS}->setispeed($self->{"C_ISPEED"}); $self->{TERMIOS}->setospeed($self->{"C_OSPEED"}); foreach $item (keys %c_cc_fields) { $self->{TERMIOS}->setcc($c_cc_fields{$item}, $self->{"C_$item"}); } # setattr returns undef on failure $result = defined($self->{TERMIOS}->setattr($self->{FD}, &POSIX::TCSANOW)); # IOSSIOSPEED settings are overwritten by setattr, so this needs to be # called last. if ($self->{"IOSSIOSPEED_BAUD"} != -1 && $self->can_arbitrary_baud()) { my $speed = pack( "L", $self->{"IOSSIOSPEED_BAUD"}); $self->ioctl('IOSSIOSPEED', \$speed ); } if ($Babble) { print "wrote settings to $self->{ALIAS}\n"; } return $result; } sub save { my $self = shift; my $item; my $getsub; my $value; return unless (@_); my $filename = shift; unless ( open CF, ">$filename" ) { #carp "can't open file: $filename"; return undef; } print CF "$cfg_file_sig"; print CF "$self->{NAME}\n"; # used to "reopen" so must be DEVICE=NAME print CF "$self->{LOCK}\n"; # use lock to "open" if established # put current values from Termios structure FIRST foreach $item (@termios_fields) { printf CF "$item,%d\n", $self->{"$item"}; } foreach $item (keys %c_cc_fields) { printf CF "C_$item,%d\n", $self->{"C_$item"}; } no strict 'refs'; # for $gosub while (($item, $getsub) = each %validate) { chomp $getsub; $value = scalar &$getsub($self); print CF "$item,$value\n"; } use strict 'refs'; close CF; if ($Babble) { print "wrote file $filename for $self->{ALIAS}\n"; } 1; } # parse values for start/restart sub get_start_values { return unless (@_ == 2); my $self = shift; my $filename = shift; unless ( open CF, "<$filename" ) { carp "can't open file: $filename: $!"; return; } my ($signature, $name, $lockfile, @values) = ; close CF; unless ( $cfg_file_sig eq $signature ) { carp "Invalid signature in $filename: $signature"; return; } chomp $name; unless ( $self->{NAME} eq $name ) { carp "Invalid Port DEVICE=$self->{NAME} in $filename: $name"; return; } chomp $lockfile; if ($Babble or not $self) { print "signature = $signature"; print "name = $name\n"; if ($Babble) { print "values:\n"; foreach (@values) { print " $_"; } } } my $item; my @fields = @termios_fields; foreach $item (keys %c_cc_fields) { push @fields, "C_$item"; } my %termios; foreach $item (@fields) { $termios{$item} = 1; } my $key; my $value; my $gosub; my $fault = 0; no strict 'refs'; # for $gosub foreach $item (@values) { chomp $item; ($key, $value) = split (/,/, $item); if ($value eq "") { $fault++ } elsif (defined $termios{$key}) { $self->{"$key"} = $value; } else { $gosub = $validate{$key}; unless (defined &$gosub ($self, $value)) { carp "Invalid parameter for $key=$value "; return; } } } use strict 'refs'; if ($fault) { carp "Invalid value in $filename"; undef $self; return; } 1; } sub restart { return unless (@_ == 2); my $self = shift; my $filename = shift; get_start_values($self, $filename); write_settings($self); } sub start { my $proto = shift; my $class = ref($proto) || $proto; return unless (@_); my $filename = shift; unless ( open CF, "<$filename" ) { carp "can't open file: $filename: $!"; return; } my ($signature, $name, $lockfile, @values) = ; close CF; unless ( $cfg_file_sig eq $signature ) { carp "Invalid signature in $filename: $signature"; return; } chomp $name; chomp $lockfile; my $self = new ($class, $name, 1, $lockfile); # quiet for lock return 0 if ($lockfile and not $self); if ($Babble or not $self) { print "signature = $signature"; print "class = $class\n"; print "name = $name\n"; print "lockfile = $lockfile\n"; if ($Babble) { print "values:\n"; foreach (@values) { print " $_"; } } } if ($self) { if ( get_start_values($self, $filename) ) { write_settings ($self); } else { carp "Invalid value in $filename"; undef $self; return; } } return $self; } # true/false capabilities (read only) # currently just constants in the POSIX case sub can_baud { return 1; } sub can_databits { return 1; } sub can_stopbits { return 1; } sub can_dtrdsr { return 1; } sub can_handshake { return 1; } sub can_parity_check { return 1; } sub can_parity_config { return 1; } sub can_parity_enable { return 1; } sub can_rlsd { return 0; } # currently sub can_16bitmode { return 0; } # Win32-specific sub is_rs232 { return 1; } sub is_modem { return 0; } # Win32-specific sub can_rtscts { return 1; } # this is a flow option sub can_xonxoff { return 1; } # this is a flow option sub can_xon_char { return 1; } # use stty sub can_spec_char { return 0; } # use stty sub can_interval_timeout { return 0; } # currently sub can_total_timeout { return 1; } # currently sub binary { return 1; } sub reset_error { return 0; } # for compatibility sub can_ioctl { if (defined($bits->{'TIOCMBIS'}) && # Turn on defined($bits->{'TIOCMBIC'}) && # Turn off defined($bits->{'TIOCM_RTS'}) && # RTS value ( ( defined($bits->{'TIOCSDTR'}) && # DTR ability/value defined($bits->{'TIOCCDTR'}) ) || defined($bits->{'TIOCM_DTR'}) ) ) { return 1; } return 0; #return 0 unless ($bitset && $bitclear && $rtsout && # (($dtrset && $dtrclear) || $dtrout)); #return 1; } sub can_modemlines { return 1 if (defined($bits->{'TIOCMGET'})); return 0; } sub can_wait_modemlines { return 1 if (defined($bits->{'TIOCMIWAIT'})); return 0; } sub can_intr_count { return 1 if (defined($bits->{'TIOCGICOUNT'})); return 0; } sub can_status { return 1 if (defined($bits->{'portable_TIOCINQ'}) && defined($bits->{'TIOCOUTQ'})); return 0; #return 0 unless ($incount && $outcount); #return 1; } sub can_write_done { my ($self)=@_; return 1 if ($self->can_status && defined($bits->{'TIOCSERGETLSR'}) && TIOCM_LE); return 0; } # can we control the rts line? sub can_rts { if (defined($bits->{'TIOCMBIS'}) && defined($bits->{'TIOCMBIC'}) && defined($bits->{'TIOCM_RTS'})) { return 1; } return 0; # why are we testing for _lack_ of dtrset/clear? can BSD NOT control RTS? #return 0 unless($bitset && $bitclear && $rtsout && !($dtrset && $dtrclear)); #return 1; } # can we set arbitrary baud rates? (OSX) sub can_arbitrary_baud { return 1 if (defined($bits->{'IOSSIOSPEED'})); return 0; } sub termiox { my $self = shift; return unless ($IOCTL_VALUE_TERMIOXFLOW); my $on = shift; my $rc; $self->{'TERMIOX'}=$on ? $IOCTL_VALUE_TERMIOXFLOW : 0; my $flags=pack('SSSS',0,0,0,0); return undef unless $self->ioctl('TCGETX', \$flags); #if (!($rc=ioctl($self->{HANDLE}, $tcgetx, $flags))) { #warn "TCGETX($tcgetx) ioctl: $!\n"; #} my @vals=unpack('SSSS',$flags); $vals[0]= $on ? $IOCTL_VALUE_TERMIOXFLOW : 0; $flags=pack('SSSS',@vals); return undef unless $self->ioctl('TCSETX', \$flags); #if (!($rc=ioctl($self->{HANDLE}, $tcsetx, $flags))) { #warn "TCSETX($tcsetx) ioctl: $!\n"; #} return 1; } sub handshake { my $self = shift; if (@_) { if ( $_[0] eq "none" ) { $self->{"C_IFLAG"} &= ~(IXON | IXOFF); $self->termiox(0) if ($IOCTL_VALUE_TERMIOXFLOW); $self->{"C_CFLAG"} &= ~CRTSCTS; } elsif ( $_[0] eq "xoff" ) { $self->{"C_IFLAG"} |= (IXON | IXOFF); $self->termiox(0) if ($IOCTL_VALUE_TERMIOXFLOW); $self->{"C_CFLAG"} &= ~CRTSCTS; } elsif ( $_[0] eq "rts" ) { $self->{"C_IFLAG"} &= ~(IXON | IXOFF); $self->termiox(1) if ($IOCTL_VALUE_TERMIOXFLOW); $self->{"C_CFLAG"} |= CRTSCTS; } else { if ($self->{U_MSG} or $Babble) { carp "Can't set handshake on $self->{ALIAS}"; } return undef; } write_settings($self); } if (wantarray) { return ("none", "xoff", "rts"); } my $mask = (IXON|IXOFF); return "xoff" if ($mask == ($self->{"C_IFLAG"} & $mask)); if ($IOCTL_VALUE_TERMIOXFLOW) { return "rts" if ($self->{'TERMIOX'} & $IOCTL_VALUE_TERMIOXFLOW); } else { return "rts" if ($self->{"C_CFLAG"} & CRTSCTS); } return "none"; } sub baudrate { my ($self,$rate) = @_; my $item = 0; if (defined($rate)) { # specific baud rate if (defined $bauds{$rate}) { $self->{"C_OSPEED"} = $bauds{$rate}; $self->{"C_ISPEED"} = $bauds{$rate}; $self->{"IOSSIOSPEED_BAUD"} = -1; write_settings($self); } # arbitrary baud rate elsif ($self->can_arbitrary_baud()) { $self->{"IOSSIOSPEED_BAUD"} = $rate; write_settings($self); return $rate; } # no such baud rate else { if ($self->{U_MSG} or $Babble) { carp "Can't set baudrate ($rate) on $self->{ALIAS}"; } return 0; } } if (wantarray) { return (keys %bauds); } foreach $item (keys %bauds) { return $item if ($bauds{$item} == $self->{"C_OSPEED"}); } return 0; } # Interesting note about parity. It seems that while the "correct" thing # to do is to enable inbound parity checking (INPCK) and to strip the bits, # this doesn't seem to be sane for a large number of systems, modems, # whatever. If "INPCK" or "ISTRIP" is needed, please use the stty_inpck # and stty_istrip functions sub parity { my $self = shift; if (@_) { if ( $_[0] eq "none" ) { $self->{"C_CFLAG"} &= ~(PARENB|PARODD); } elsif ( $_[0] eq "odd" ) { $self->{"C_CFLAG"} |= (PARENB|PARODD); } elsif ( $_[0] eq "even" ) { $self->{"C_CFLAG"} |= PARENB; $self->{"C_CFLAG"} &= ~PARODD; } else { if ($self->{U_MSG} or $Babble) { carp "Can't set parity on $self->{ALIAS}"; } return undef; } return undef if (!(write_settings($self))); } if (wantarray) { return ("none", "odd", "even"); } return "none" unless ($self->{"C_CFLAG"} & PARENB); my $mask = (PARENB|PARODD); return "odd" if ($mask == ($self->{"C_CFLAG"} & $mask)); $mask = (PARENB); return "even" if ($mask == ($self->{"C_CFLAG"} & $mask)); return "unknown"; } sub databits { my $self = shift; if (@_) { if ( $_[0] == 8 ) { $self->{"C_CFLAG"} &= ~CSIZE; $self->{"C_CFLAG"} |= CS8; } elsif ( $_[0] == 7 ) { $self->{"C_CFLAG"} &= ~CSIZE; $self->{"C_CFLAG"} |= CS7; } elsif ( $_[0] == 6 ) { $self->{"C_CFLAG"} &= ~CSIZE; $self->{"C_CFLAG"} |= CS6; } elsif ( $_[0] == 5 ) { $self->{"C_CFLAG"} &= ~CSIZE; $self->{"C_CFLAG"} |= CS5; } else { if ($self->{U_MSG} or $Babble) { carp "Can't set databits on $self->{ALIAS}"; } return undef; } write_settings($self); } if (wantarray) { return (5, 6, 7, 8); } my $mask = ($self->{"C_CFLAG"} & CSIZE); return 8 if ($mask == CS8); return 7 if ($mask == CS7); return 6 if ($mask == CS6); return 5; } sub stopbits { my $self = shift; if (@_) { if ( $_[0] == 2 ) { $self->{"C_CFLAG"} |= CSTOPB; } elsif ( $_[0] == 1 ) { $self->{"C_CFLAG"} &= ~CSTOPB; } else { if ($self->{U_MSG} or $Babble) { carp "Can't set stopbits on $self->{ALIAS}"; } return undef; } write_settings($self); } if (wantarray) { return (1, 2); } return 2 if ($self->{"C_CFLAG"} & CSTOPB); return 1; } sub is_xon_char { my $self = shift; if (@_) { my $v = int shift; return if (($v < 0) or ($v > 255)); $self->{"C_VSTART"} = $v; write_settings($self); } return $self->{"C_VSTART"}; } sub is_xoff_char { my $self = shift; if (@_) { my $v = int shift; return if (($v < 0) or ($v > 255)); $self->{"C_VSTOP"} = $v; write_settings($self); } return $self->{"C_VSTOP"}; } sub is_stty_intr { my $self = shift; if (@_) { my $v = int shift; return if (($v < 0) or ($v > 255)); $self->{"C_VINTR"} = $v; write_settings($self); } return $self->{"C_VINTR"}; } sub is_stty_quit { my $self = shift; if (@_) { my $v = int shift; return if (($v < 0) or ($v > 255)); $self->{"C_VQUIT"} = $v; write_settings($self); } return $self->{"C_VQUIT"}; } sub is_stty_eof { my $self = shift; if (@_) { my $v = int shift; return if (($v < 0) or ($v > 255)); $self->{"C_VEOF"} = $v; write_settings($self); } return $self->{"C_VEOF"}; } sub is_stty_eol { my $self = shift; if (@_) { my $v = int shift; return if (($v < 0) or ($v > 255)); $self->{"C_VEOL"} = $v; write_settings($self); } return $self->{"C_VEOL"}; } sub is_stty_erase { my $self = shift; if (@_) { my $v = int shift; return if (($v < 0) or ($v > 255)); $self->{"C_VERASE"} = $v; write_settings($self); } return $self->{"C_VERASE"}; } sub is_stty_kill { my $self = shift; if (@_) { my $v = int shift; return if (($v < 0) or ($v > 255)); $self->{"C_VKILL"} = $v; write_settings($self); } return $self->{"C_VKILL"}; } sub is_stty_susp { my $self = shift; if (@_) { my $v = int shift; return if (($v < 0) or ($v > 255)); $self->{"C_VSUSP"} = $v; write_settings($self); } return $self->{"C_VSUSP"}; } sub stty_echo { my $self = shift; if (@_) { if ( yes_true( shift ) ) { $self->{"C_LFLAG"} |= ECHO; } else { $self->{"C_LFLAG"} &= ~ECHO; } write_settings($self); } return ($self->{"C_LFLAG"} & ECHO) ? 1 : 0; } sub stty_echoe { my $self = shift; if (@_) { if ( yes_true( shift ) ) { $self->{"C_LFLAG"} |= ECHOE; } else { $self->{"C_LFLAG"} &= ~ECHOE; } write_settings($self); } return ($self->{"C_LFLAG"} & ECHOE) ? 1 : 0; } sub stty_echok { my $self = shift; if (@_) { if ( yes_true( shift ) ) { $self->{"C_LFLAG"} |= ECHOK; } else { $self->{"C_LFLAG"} &= ~ECHOK; } write_settings($self); } return ($self->{"C_LFLAG"} & ECHOK) ? 1 : 0; } sub stty_echonl { my $self = shift; if (@_) { if ( yes_true( shift ) ) { $self->{"C_LFLAG"} |= ECHONL; } else { $self->{"C_LFLAG"} &= ~ECHONL; } write_settings($self); } return ($self->{"C_LFLAG"} & ECHONL) ? 1 : 0; } # non-POSIX sub stty_echoke { my $self = shift; return unless ECHOKE; if (@_) { if ( yes_true( shift ) ) { $self->{"C_LFLAG"} |= ECHOKE; } else { $self->{"C_LFLAG"} &= ~ECHOKE; } write_settings($self); } return ($self->{"C_LFLAG"} & ECHOKE) ? 1 : 0; } # non-POSIX sub stty_echoctl { my $self = shift; return unless ECHOCTL; if (@_) { if ( yes_true( shift ) ) { $self->{"C_LFLAG"} |= ECHOCTL; } else { $self->{"C_LFLAG"} &= ~ECHOCTL; } write_settings($self); } return ($self->{"C_LFLAG"} & ECHOCTL) ? 1 : 0; } # Mark parity errors with a leading "NULL" character sub stty_parmrk { my $self = shift; if (@_) { if ( yes_true( shift ) ) { $self->{"C_IFLAG"} |= PARMRK; } else { $self->{"C_IFLAG"} &= ~PARMRK; } write_settings($self); } return wantarray ? @binary_opt : ($self->{"C_IFLAG"} & PARMRK); } # Ignore parity errors (considered dangerous) sub stty_ignpar { my $self = shift; if (@_) { if ( yes_true( shift ) ) { $self->{"C_IFLAG"} |= IGNPAR; } else { $self->{"C_IFLAG"} &= ~IGNPAR; } write_settings($self); } return wantarray ? @binary_opt : ($self->{"C_IFLAG"} & IGNPAR); } # Ignore breaks sub stty_ignbrk { my $self = shift; if (@_) { if ( yes_true( shift ) ) { $self->{"C_IFLAG"} |= IGNBRK; } else { $self->{"C_IFLAG"} &= ~IGNBRK; } write_settings($self); } return ($self->{"C_IFLAG"} & IGNBRK) ? 1 : 0; } # Strip parity bit sub stty_istrip { my $self = shift; if (@_) { if ( yes_true( shift ) ) { $self->{"C_IFLAG"} |= ISTRIP; } else { $self->{"C_IFLAG"} &= ~ISTRIP; } write_settings($self); } return ($self->{"C_IFLAG"} & ISTRIP) ? 1 : 0; } # check incoming parity bit sub stty_inpck { my $self = shift; if (@_) { if ( yes_true( shift ) ) { $self->{"C_IFLAG"} |= INPCK; } else { $self->{"C_IFLAG"} &= ~INPCK; } write_settings($self); } return ($self->{"C_IFLAG"} & INPCK) ? 1 : 0; } sub stty_icrnl { my $self = shift; if (@_) { if ( yes_true( shift ) ) { $self->{"C_IFLAG"} |= ICRNL; } else { $self->{"C_IFLAG"} &= ~ICRNL; } write_settings($self); } return ($self->{"C_IFLAG"} & ICRNL) ? 1 : 0; } sub stty_igncr { my $self = shift; if (@_) { if ( yes_true( shift ) ) { $self->{"C_IFLAG"} |= IGNCR; } else { $self->{"C_IFLAG"} &= ~IGNCR; } write_settings($self); } return ($self->{"C_IFLAG"} & IGNCR) ? 1 : 0; } sub stty_inlcr { my $self = shift; if (@_) { if ( yes_true( shift ) ) { $self->{"C_IFLAG"} |= INLCR; } else { $self->{"C_IFLAG"} &= ~INLCR; } write_settings($self); } return ($self->{"C_IFLAG"} & INLCR) ? 1 : 0; } # non-POSIX sub stty_ocrnl { my $self = shift; return unless OCRNL; if (@_) { if ( yes_true( shift ) ) { $self->{"C_OFLAG"} |= OCRNL; } else { $self->{"C_OFLAG"} &= ~OCRNL; } write_settings($self); } return ($self->{"C_OFLAG"} & OCRNL) ? 1 : 0; } # non-POSIX sub stty_onlcr { my $self = shift; return unless ONLCR; if (@_) { if ( yes_true( shift ) ) { $self->{"C_OFLAG"} |= ONLCR; } else { $self->{"C_OFLAG"} &= ~ONLCR; } write_settings($self); } return ($self->{"C_OFLAG"} & ONLCR) ? 1 : 0; } sub stty_opost { my $self = shift; if (@_) { if ( yes_true( shift ) ) { $self->{"C_OFLAG"} |= OPOST; } else { $self->{"C_OFLAG"} &= ~OPOST; } write_settings($self); } return ($self->{"C_OFLAG"} & OPOST) ? 1 : 0; } sub stty_isig { my $self = shift; if (@_) { if ( yes_true( shift ) ) { $self->{"C_LFLAG"} |= ISIG; } else { $self->{"C_LFLAG"} &= ~ISIG; } write_settings($self); } return ($self->{"C_LFLAG"} & ISIG) ? 1 : 0; } sub stty_icanon { my $self = shift; if (@_) { if ( yes_true( shift ) ) { $self->{"C_LFLAG"} |= ICANON; } else { $self->{"C_LFLAG"} &= ~ICANON; } write_settings($self); } return ($self->{"C_LFLAG"} & ICANON) ? 1 : 0; } sub alias { my $self = shift; if (@_) { $self->{ALIAS} = shift; } # should return true for legal names return $self->{ALIAS}; } sub devicetype { my $self = shift; if (@_) { $self->{DVTYPE} = shift; } # return true for legal names return $self->{DVTYPE}; } sub hostname { my $self = shift; if (@_) { $self->{HNAME} = shift; } # return true for legal names return $self->{HNAME}; } sub hostaddr { my $self = shift; if (@_) { $self->{HADDR} = shift; } # return true for assigned port return $self->{HADDR}; } sub datatype { my $self = shift; if (@_) { $self->{DATYPE} = shift; } # return true for legal types return $self->{DATYPE}; } sub cfg_param_1 { my $self = shift; if (@_) { $self->{CFG_1} = shift; } # return true for legal param return $self->{CFG_1}; } sub cfg_param_2 { my $self = shift; if (@_) { $self->{CFG_2} = shift; } # return true for legal param return $self->{CFG_2}; } sub cfg_param_3 { my $self = shift; if (@_) { $self->{CFG_3} = shift; } # return true for legal param return $self->{CFG_3}; } sub buffers { my $self = shift; if (@_) { return unless (@_ == 2); } return wantarray ? (4096, 4096) : 1; } sub read_const_time { my $self = shift; if (@_) { $self->{RCONST} = (shift)/1000; # milliseconds -> select_time $self->{"C_VTIME"} = $self->{RCONST} * 10000; # wants tenths of sec $self->{"C_VMIN"} = 0; write_settings($self); } return $self->{RCONST}*1000; } sub read_char_time { my $self = shift; if (@_) { $self->{RTOT} = (shift)/1000; # milliseconds -> select_time } return $self->{RTOT}*1000; } sub read { return undef unless (@_ == 2); my $self = shift; my $wanted = shift; my $result = ""; my $ok = 0; return (0, "") unless ($wanted > 0); my $done = 0; my $count_in = 0; my $string_in = ""; my $in2 = ""; my $bufsize = 255; # VMIN max (declared as char) while ($done < $wanted) { my $size = $wanted - $done; if ($size > $bufsize) { $size = $bufsize; } ($count_in, $string_in) = $self->read_vmin($size); if ($count_in) { $in2 .= $string_in; $done += $count_in; } elsif ($done) { last; } else { return if (!defined $count_in); last; } } return ($done, $in2); } sub read_vmin { return undef unless (@_ == 2); my $self = shift; my $wanted = shift; my $result = ""; my $ok = 0; return (0, "") unless ($wanted > 0); # This appears dangerous under Solaris # if ($self->{"C_VMIN"} != $wanted) { # $self->{"C_VMIN"} = $wanted; # write_settings($self); # } my $rin = ""; vec($rin, $self->{FD}, 1) = 1; my $ein = $rin; my $tin = $self->{RCONST} + ($wanted * $self->{RTOT}); my $rout; my $wout; my $eout; my $tout; my $ready = select($rout=$rin, $wout=undef, $eout=$ein, $tout=$tin); my $got=0; if ($ready>0) { $got = POSIX::read ($self->{FD}, $result, $wanted); if (! defined $got) { return (0,"") if (&POSIX::EAGAIN == ($ok = POSIX::errno())); return (0,"") if (!$ready and (0 == $ok)); # at least Solaris acts like eof() in this case carp "Error #$ok in Device::SerialPort::read"; return; } elsif ($got == 0 && $wanted!=0) { # if read returns "0" on a non-zero request, it's EOF return; } } print "read_vmin=$got, ready=$ready, result=..$result..\n" if ($Babble); return ($got, $result); } sub are_match { my $self = shift; my $pat; my $patno = 0; my $reno = 0; my $re_next = 0; if (@_) { @{ $self->{"_MATCH"} } = @_; if ($] >= 5.005) { @{ $self->{"_CMATCH"} } = (); while ($pat = shift) { if ($re_next) { $re_next = 0; eval 'push (@{ $self->{"_CMATCH"} }, qr/$pat/)'; } else { push (@{ $self->{"_CMATCH"} }, $pat); } if ($pat eq "-re") { $re_next++; } } } else { @{ $self->{"_CMATCH"} } = @_; } } return @{ $self->{"_MATCH"} }; } sub lookclear { my $self = shift; if (nocarp && (@_ == 1)) { $self->{"_T_INPUT"} = shift; } $self->{"_LOOK"} = ""; $self->{"_LASTLOOK"} = ""; $self->{"_LMATCH"} = ""; $self->{"_LPATT"} = ""; return if (@_); 1; } sub linesize { my $self = shift; if (@_) { my $val = int shift; return if ($val < 0); $self->{"_SIZE"} = $val; } return $self->{"_SIZE"}; } sub lastline { my $self = shift; if (@_) { $self->{"_LASTLINE"} = shift; if ($] >= 5.005) { eval '$self->{"_CLASTLINE"} = qr/$self->{"_LASTLINE"}/'; } else { $self->{"_CLASTLINE"} = $self->{"_LASTLINE"}; } } return $self->{"_LASTLINE"}; } sub matchclear { my $self = shift; my $found = $self->{"_LMATCH"}; $self->{"_LMATCH"} = ""; return if (@_); return $found; } sub lastlook { my $self = shift; return if (@_); return ( $self->{"_LMATCH"}, $self->{"_LASTLOOK"}, $self->{"_LPATT"}, $self->{"_LOOK"} ); } sub lookfor { my $self = shift; my $size = 0; if (@_) { $size = shift; } my $loc = ""; my $count_in = 0; my $string_in = ""; $self->{"_LMATCH"} = ""; $self->{"_LPATT"} = ""; if ( ! $self->{"_LOOK"} ) { $loc = $self->{"_LASTLOOK"}; } if ($size) { ($count_in, $string_in) = $self->read($size); return unless ($count_in); $loc .= $string_in; } else { $loc .= $self->input; } if ($loc ne "") { my $n_char; my $mpos; my $lookbuf; my $re_next = 0; my $got_match = 0; my $pat; my @loc_char = split (//, $loc); while (defined ($n_char = shift @loc_char)) { $mpos = ord $n_char; $self->{"_LOOK"} .= $n_char; $lookbuf = $self->{"_LOOK"}; $count_in = 0; foreach $pat ( @{ $self->{"_CMATCH"} } ) { if ($pat eq "-re") { $re_next++; $count_in++; next; } if ($re_next) { $re_next = 0; # always at $lookbuf end when processing single char if ( $lookbuf =~ s/$pat//s ) { $self->{"_LMATCH"} = $&; $got_match++; } } elsif (($mpos = index($lookbuf, $pat)) > -1) { $got_match++; $lookbuf = substr ($lookbuf, 0, $mpos); $self->{"_LMATCH"} = $pat; } if ($got_match) { $self->{"_LPATT"} = $self->{"_MATCH"}[$count_in]; if (scalar @loc_char) { $self->{"_LASTLOOK"} = join("", @loc_char); } else { $self->{"_LASTLOOK"} = ""; } $self->{"_LOOK"} = ""; return $lookbuf; } $count_in++; } #### } } } return ""; } sub streamline { my $self = shift; my $size = 0; if (@_) { $size = shift; } my $loc = ""; my $mpos; my $count_in = 0; my $string_in = ""; my $re_next = 0; my $got_match = 0; my $best_pos = 0; my $pat; my $match = ""; my $before = ""; my $after = ""; my $best_match = ""; my $best_before = ""; my $best_after = ""; my $best_pat = ""; $self->{"_LMATCH"} = ""; $self->{"_LPATT"} = ""; if ( ! $self->{"_LOOK"} ) { $loc = $self->{"_LASTLOOK"}; } if ($size) { ($count_in, $string_in) = $self->read($size); return unless ($count_in); $loc .= $string_in; } else { $loc .= $self->input; } if ($loc ne "") { $self->{"_LOOK"} .= $loc; $count_in = 0; foreach $pat ( @{ $self->{"_CMATCH"} } ) { if ($pat eq "-re") { $re_next++; $count_in++; next; } if ($re_next) { $re_next = 0; if ( $self->{"_LOOK"} =~ /$pat/s ) { ( $match, $before, $after ) = ( $&, $`, $' ); $got_match++; $mpos = length($before); if ($mpos) { next if ($best_pos && ($mpos > $best_pos)); $best_pos = $mpos; $best_pat = $self->{"_MATCH"}[$count_in]; $best_match = $match; $best_before = $before; $best_after = $after; } else { $self->{"_LPATT"} = $self->{"_MATCH"}[$count_in]; $self->{"_LMATCH"} = $match; $self->{"_LASTLOOK"} = $after; $self->{"_LOOK"} = ""; return $before; # pattern at start will be best } } } elsif (($mpos = index($self->{"_LOOK"}, $pat)) > -1) { $got_match++; $before = substr ($self->{"_LOOK"}, 0, $mpos); if ($mpos) { next if ($best_pos && ($mpos > $best_pos)); $best_pos = $mpos; $best_pat = $pat; $best_match = $pat; $best_before = $before; $mpos += length($pat); $best_after = substr ($self->{"_LOOK"}, $mpos); } else { $self->{"_LPATT"} = $pat; $self->{"_LMATCH"} = $pat; $before = substr ($self->{"_LOOK"}, 0, $mpos); $mpos += length($pat); $self->{"_LASTLOOK"} = substr ($self->{"_LOOK"}, $mpos); $self->{"_LOOK"} = ""; return $before; # match at start will be best } } $count_in++; } if ($got_match) { $self->{"_LPATT"} = $best_pat; $self->{"_LMATCH"} = $best_match; $self->{"_LASTLOOK"} = $best_after; $self->{"_LOOK"} = ""; return $best_before; } } return ""; } sub input { return undef unless (@_ == 1); my $self = shift; my $ok = 0; my $result = ""; my $wanted = 255; if (nocarp && $self->{"_T_INPUT"}) { $result = $self->{"_T_INPUT"}; $self->{"_T_INPUT"} = ""; return $result; } if ( $self->{"C_VMIN"} ) { $self->{"C_VMIN"} = 0; write_settings($self); } my $got = POSIX::read ($self->{FD}, $result, $wanted); unless (defined $got) { $got = -1; } if ($got == -1) { return "" if (&POSIX::EAGAIN == ($ok = POSIX::errno())); return "" if (0 == $ok); # at least Solaris acts like eof() carp "Error #$ok in Device::SerialPort::input" } return $result; } sub write { return undef unless (@_ == 2); my $self = shift; my $wbuf = shift; my $ok; return 0 if ($wbuf eq ""); my $lbuf = length ($wbuf); my $written = POSIX::write ($self->{FD}, $wbuf, $lbuf); return $written; } sub write_drain { my $self = shift; return if (@_); return 1 if (defined POSIX::tcdrain($self->{FD})); return; } sub purge_all { my $self = shift; return if (@_); return 1 if (defined POSIX::tcflush($self->{FD}, TCIOFLUSH)); return; } sub purge_rx { my $self = shift; return if (@_); return 1 if (defined POSIX::tcflush($self->{FD}, TCIFLUSH)); return; } sub purge_tx { my $self = shift; return if (@_); return 1 if (defined POSIX::tcflush($self->{FD}, TCOFLUSH)); return; } sub buffer_max { my $self = shift; if (@_) {return undef; } return (4096, 4096); } # true/false parameters sub user_msg { my $self = shift; if (@_) { $self->{U_MSG} = yes_true ( shift ) } return wantarray ? @binary_opt : $self->{U_MSG}; } sub error_msg { my $self = shift; if (@_) { $self->{E_MSG} = yes_true ( shift ) } return wantarray ? @binary_opt : $self->{E_MSG}; } sub parity_enable { my $self = shift; if (@_) { if ( yes_true( shift ) ) { $self->{"C_CFLAG"} |= PARENB; } else { $self->{"C_CFLAG"} &= ~PARENB; } write_settings($self); } return wantarray ? @binary_opt : ($self->{"C_CFLAG"} & PARENB); } sub write_done { return unless (@_ == 2); my $self = shift; return unless ($self->can_write_done); my $rc; my $wait = yes_true ( shift ); $self->write_drain if ($wait); my $mstat = " "; my $result; for (;;) { return unless $self->ioctl('TIOCOUTQ',\$mstat); $result = unpack('L', $mstat); return (0, 0) if ($result); # characters pending return unless $self->ioctl('TIOCSERGETLSR',\$mstat); $result = (unpack('L', $mstat) & TIOCM_LE); last unless ($wait); last if ($result); # shift register empty select (undef, undef, undef, 0.02); } return $result ? (1, 0) : (0, 0); } sub modemlines { return undef unless (@_ == 1); my $self = shift; return undef unless ($self->can_modemlines); my $mstat = pack('L',0); return undef unless $self->ioctl('TIOCMGET',\$mstat); my $result = unpack('L', $mstat); if ($Babble) { printf "result = %x\n", $result; print "CTS is ON\n" if ($result & MS_CTS_ON); print "DSR is ON\n" if ($result & MS_DSR_ON); print "RING is ON\n" if ($result & MS_RING_ON); print "RLSD is ON\n" if ($result & MS_RLSD_ON); } return $result; } # Strange thing is, this function doesn't always work for me. I suspect # I have a broken serial card. Everything else in my test system doesn't # work (USB, floppy) so why not serial too? sub wait_modemlines { return undef unless (@_ == 2); my $self = shift; my $flags = shift || 0; return undef unless ($self->can_wait_modemlines); if ($Babble) { printf "wait_modemlines flag = %u\n", $flags; } my $mstat = pack('L',$flags); return $self->ioctl('TIOCMIWAIT',\$mstat); } sub intr_count { return undef unless (@_ == 1); my $self = shift; return undef unless ($self->can_intr_count); my $mstat = pack('L',0); return $self->ioctl('TIOCGICOUNT',\$mstat); my $result = unpack('L', $mstat); if ($Babble) { printf "result = %x\n", $result; } return $result; } sub status { my $self = shift; return if (@_); return unless ($self->can_status); my @stat = (0, 0, 0, 0); my $mstat = " "; return unless $self->ioctl('portable_TIOCINQ', \$mstat); $stat[ST_INPUT] = unpack('L', $mstat); return unless $self->ioctl('TIOCOUTQ', \$mstat); $stat[ST_OUTPUT] = unpack('L', $mstat); if ( $Babble or $self->{"_DEBUG"} ) { printf "Blocking Bits= %d\n", $stat[ST_BLOCK]; printf "Input Queue= %d\n", $stat[ST_INPUT]; printf "Output Queue= %d\n", $stat[ST_OUTPUT]; printf "Latched Errors= %d\n", $stat[ST_ERROR]; } return @stat; } sub dtr_active { return unless (@_ == 2); my $self = shift; return unless $self->can_dtrdsr(); my $on = yes_true( shift ); my $rc; # if we have set DTR and clear DTR, we should use it (OpenBSD) my $value=0; if (defined($bits->{'TIOCSDTR'}) && defined($bits->{'TIOCCDTR'})) { $value=0; $rc=$self->ioctl($on ? 'TIOCSDTR' : 'TIOCCDTR', \$value); } else { $value=$IOCTL_VALUE_DTR; $rc=$self->ioctl($on ? 'TIOCMBIS' : 'TIOCMBIC', \$value); } warn "dtr_active($on) ioctl: $!\n" if (!$rc); # ARG! Solaris destroys termios settings after a DTR toggle!! write_settings($self); return $rc; } sub rts_active { return unless (@_ == 2); my $self = shift; return unless ($self->can_rts()); my $on = yes_true( shift ); # returns ioctl result my $value=$IOCTL_VALUE_RTS; my $rc=$self->ioctl($on ? 'TIOCMBIS' : 'TIOCMBIC', \$value); #my $rc=ioctl($self->{HANDLE}, $on ? $bitset : $bitclear, $rtsout); warn "rts_active($on) ioctl: $!\n" if (!$rc); return $rc; } sub pulse_break_on { return unless (@_ == 2); my $self = shift; my $delay = (shift)/1000; my $length = 0; my $ok = POSIX::tcsendbreak($self->{FD}, $length); warn "could not pulse break on: $!\n" unless ($ok); select (undef, undef, undef, $delay); return $ok; } sub pulse_rts_on { return unless (@_ == 2); my $self = shift; return unless ($self->can_rts()); my $delay = (shift)/1000; $self->rts_active(1) or warn "could not pulse rts on\n"; select (undef, undef, undef, $delay); $self->rts_active(0) or warn "could not restore from rts on\n"; select (undef, undef, undef, $delay); 1; } sub pulse_dtr_on { return unless (@_ == 2); my $self = shift; return unless $self->can_ioctl(); my $delay = (shift)/1000; $self->dtr_active(1) or warn "could not pulse dtr on\n"; select (undef, undef, undef, $delay); $self->dtr_active(0) or warn "could not restore from dtr on\n"; select (undef, undef, undef, $delay); 1; } sub pulse_rts_off { return unless (@_ == 2); my $self = shift; return unless ($self->can_rts()); my $delay = (shift)/1000; $self->rts_active(0) or warn "could not pulse rts off\n"; select (undef, undef, undef, $delay); $self->rts_active(1) or warn "could not restore from rts off\n"; select (undef, undef, undef, $delay); 1; } sub pulse_dtr_off { return unless (@_ == 2); my $self = shift; return unless $self->can_ioctl(); my $delay = (shift)/1000; $self->dtr_active(0) or warn "could not pulse dtr off\n"; select (undef, undef, undef, $delay); $self->dtr_active(1) or warn "could not restore from dtr off\n"; select (undef, undef, undef, $delay); 1; } sub debug { my $self = shift; if (ref($self)) { if (@_) { $self->{"_DEBUG"} = yes_true ( shift ); } if (wantarray) { return @binary_opt; } else { my $tmp = $self->{"_DEBUG"}; nocarp || carp "Debug level: $self->{ALIAS} = $tmp"; return $self->{"_DEBUG"}; } } else { if (@_) { $Babble = yes_true ( shift ); } if (wantarray) { return @binary_opt; } else { nocarp || carp "Debug Class = $Babble"; return $Babble; } } } sub close { my $self = shift; my $ok = undef; my $item; return unless (defined $self->{NAME}); if ($Babble) { carp "Closing $self " . $self->{ALIAS}; } if ($self->{FD}) { purge_all ($self); # Gracefully handle shutdown without termios if (defined($self->{TERMIOS})) { # copy the original values into "current" values foreach $item (keys %c_cc_fields) { $self->{"C_$item"} = $self->{"_$item"}; } $self->{"C_CFLAG"} = $self->{"_CFLAG"}; $self->{"C_IFLAG"} = $self->{"_IFLAG"}; $self->{"C_ISPEED"} = $self->{"_ISPEED"}; $self->{"C_LFLAG"} = $self->{"_LFLAG"}; $self->{"C_OFLAG"} = $self->{"_OFLAG"}; $self->{"C_OSPEED"} = $self->{"_OSPEED"}; write_settings($self); } $ok = POSIX::close($self->{FD}); # we need to explicitly close this handle $self->{HANDLE}->close if (defined($self->{HANDLE}) && $self->{HANDLE}->opened); $self->{FD} = undef; $self->{HANDLE} = undef; } if ($self->{LOCK}) { unless ( unlink $self->{LOCK} ) { nocarp or carp "can't remove lockfile: $self->{LOCK}\n"; } $self->{LOCK} = ""; } $self->{NAME} = undef; $self->{ALIAS} = undef; return unless ($ok); 1; } sub ioctl { my ($self,$code,$ref) = @_; return undef unless (defined $self->{NAME}); if ($Babble) { my $num = $$ref; $num = unpack('L', $num); carp "ioctl $code($bits->{$code}) $ref: $num"; } my $magic; if (!defined($magic = $bits->{$code})) { carp "cannot ioctl '$code': no system value found\n"; return undef; } if (!ioctl($self->{HANDLE},$magic,$$ref)) { carp "$code($magic) ioctl failed: $!"; return undef; } return 1; } ##### tied FileHandle support # DESTROY this # As with the other types of ties, this method will be called when the # tied handle is about to be destroyed. This is useful for debugging and # possibly cleaning up. sub DESTROY { my $self = shift; return unless (defined $self->{NAME}); if ($self->{"_DEBUG"}) { carp "Destroying $self->{NAME}"; } $self->close; } sub TIEHANDLE { my $proto = shift; my $class = ref($proto) || $proto; return unless (@_); # my $self = start($class, shift); return new($class, @_); } # WRITE this, LIST # This method will be called when the handle is written to via the # syswrite function. sub WRITE { return if (@_ < 3); my $self = shift; my $buf = shift; my $len = shift; my $offset = 0; if (@_) { $offset = shift; } my $out2 = substr($buf, $offset, $len); return unless ($self->post_print($out2)); return length($out2); } # PRINT this, LIST # This method will be triggered every time the tied handle is printed to # with the print() function. Beyond its self reference it also expects # the list that was passed to the print function. sub PRINT { my $self = shift; return unless (@_); my $ofs = $, ? $, : ""; if ($self->{OFS}) { $ofs = $self->{OFS}; } my $ors = $\ ? $\ : ""; if ($self->{ORS}) { $ors = $self->{ORS}; } my $output = join($ofs,@_); $output .= $ors; return $self->post_print($output); } sub output_field_separator { my $self = shift; my $prev = $self->{OFS}; if (@_) { $self->{OFS} = shift; } return $prev; } sub output_record_separator { my $self = shift; my $prev = $self->{ORS}; if (@_) { $self->{ORS} = shift; } return $prev; } sub post_print { my $self = shift; return unless (@_); my $output = shift; my $to_do = length($output); my $done = 0; my $written = 0; while ($done < $to_do) { my $out2 = substr($output, $done); $written = $self->write($out2); if (! defined $written) { return; } return 0 unless ($written); $done += $written; } 1; } # PRINTF this, LIST # This method will be triggered every time the tied handle is printed to # with the printf() function. Beyond its self reference it also expects # the format and list that was passed to the printf function. sub PRINTF { my $self = shift; my $fmt = shift; return unless ($fmt); return unless (@_); my $output = sprintf($fmt, @_); $self->PRINT($output); } # READ this, LIST # This method will be called when the handle is read from via the read # or sysread functions. sub READ { return if (@_ < 3); my $buf = \$_[1]; my ($self, $junk, $size, $offset) = @_; unless (defined $offset) { $offset = 0; } my $count_in = 0; my $string_in = ""; ($count_in, $string_in) = $self->read($size); $$buf = '' unless defined $$buf; my $buflen = length $$buf; my ($tail, $head) = ('',''); if($offset >= 0){ # positive offset if($buflen > $offset + $count_in){ $tail = substr($$buf, $offset + $count_in); } if($buflen < $offset){ $head = $$buf . ("\0" x ($offset - $buflen)); } else { $head = substr($$buf, 0, $offset); } } else { # negative offset $head = substr($$buf, 0, ($buflen + $offset)); if(-$offset > $count_in){ $tail = substr($$buf, $offset + $count_in); } } # remaining unhandled case: $offset < 0 && -$offset > $buflen $$buf = $head.$string_in.$tail; return $count_in; } # READLINE this # This method will be called when the handle is read from via . # The method should return undef when there is no more data. sub READLINE { my $self = shift; return if (@_); my $count_in = 0; my $string_in = ""; my $match = ""; my $was; if (wantarray) { my @lines; for (;;) { last if ($was = $self->reset_error); # dummy, currently if ($self->stty_icanon) { ($count_in, $string_in) = $self->read_vmin(255); last if (! defined $count_in); } else { $string_in = $self->streamline($self->{"_SIZE"}); last if (! defined $string_in); $match = $self->matchclear; if ( ($string_in ne "") || ($match ne "") ) { $string_in .= $match; } } push (@lines, $string_in); last if ($string_in =~ /$self->{"_CLASTLINE"}/s); } return @lines if (@lines); return; } else { my $last_icanon = $self->stty_icanon; $self->stty_icanon(1); for (;;) { last if ($was = $self->reset_error); # dummy, currently $string_in = $self->lookfor($self->{"_SIZE"}); last if (! defined $string_in); $match = $self->matchclear; if ( ($string_in ne "") || ($match ne "") ) { $string_in .= $match; # traditional behavior $self->stty_icanon(0); return $string_in; } } $self->stty_icanon($last_icanon); return; } } # GETC this # This method will be called when the getc function is called. sub GETC { my $self = shift; my ($count, $in) = $self->read(1); if ($count == 1) { return $in; } return; } # CLOSE this # This method will be called when the handle is closed via the close # function. sub CLOSE { my $self = shift; $self->write_drain; my $success = $self->close; if ($Babble) { printf "CLOSE result:%d\n", $success; } return $success; } # FILENO this # This method will be called if we ever need the FD from the handle sub FILENO { my $self = shift; return $self->{FD}; } 1; # so the require or use succeeds __END__ =pod =head1 NAME Device::SerialPort - Linux/POSIX emulation of Win32::SerialPort functions. =head1 SYNOPSIS use Device::SerialPort qw( :PARAM :STAT 0.07 ); =head2 Constructors # $lockfile is optional $PortObj = new Device::SerialPort ($PortName, $quiet, $lockfile) || die "Can't open $PortName: $!\n"; $PortObj = start Device::SerialPort ($Configuration_File_Name) || die "Can't start $Configuration_File_Name: $!\n"; $PortObj = tie (*FH, 'Device::SerialPort', $Configuration_File_Name) || die "Can't tie using $Configuration_File_Name: $!\n"; =head2 Configuration Utility Methods $PortObj->alias("MODEM1"); $PortObj->save($Configuration_File_Name) || warn "Can't save $Configuration_File_Name: $!\n"; # currently optional after new, POSIX version expected to succeed $PortObj->write_settings; # rereads file to either return open port to a known state # or switch to a different configuration on the same port $PortObj->restart($Configuration_File_Name) || warn "Can't reread $Configuration_File_Name: $!\n"; # "app. variables" saved in $Configuration_File, not used internally $PortObj->devicetype('none'); # CM11, CM17, 'weeder', 'modem' $PortObj->hostname('localhost'); # for socket-based implementations $PortObj->hostaddr(0); # false unless specified $PortObj->datatype('raw'); # in case an application needs_to_know $PortObj->cfg_param_1('none'); # null string '' hard to save/restore $PortObj->cfg_param_2('none'); # 3 spares should be enough for now $PortObj->cfg_param_3('none'); # one may end up as a log file path # test suite use only @necessary_param = Device::SerialPort->set_test_mode_active(1); # exported by :PARAM nocarp || carp "Something fishy"; $a = SHORTsize; # 0xffff $a = LONGsize; # 0xffffffff $answer = yes_true("choice"); # 1 or 0 OS_Error unless ($API_Call_OK); # prints error =head2 Configuration Parameter Methods # most methods can be called two ways: $PortObj->handshake("xoff"); # set parameter $flowcontrol = $PortObj->handshake; # current value (scalar) # The only "list context" method calls from Win32::SerialPort # currently supported are those for baudrate, parity, databits, # stopbits, and handshake (which only accept specific input values). @handshake_opts = $PortObj->handshake; # permitted choices (list) # similar $PortObj->baudrate(9600); $PortObj->parity("odd"); $PortObj->databits(8); $PortObj->stopbits(1); # POSIX does not support 1.5 stopbits # these are essentially dummies in POSIX implementation # the calls exist to support compatibility $PortObj->buffers(4096, 4096); # returns (4096, 4096) @max_values = $PortObj->buffer_max; # returns (4096, 4096) $PortObj->reset_error; # returns 0 # true/false parameters (return scalar context only) # parameters exist, but message processing not yet fully implemented $PortObj->user_msg(ON); # built-in instead of warn/die above $PortObj->error_msg(ON); # translate error bitmasks and carp $PortObj->parity_enable(F); # faults during input $PortObj->debug(0); # true/false capabilities (read only) # most are just constants in the POSIX case $PortObj->can_baud; # 1 $PortObj->can_databits; # 1 $PortObj->can_stopbits; # 1 $PortObj->can_dtrdsr; # 1 $PortObj->can_handshake; # 1 $PortObj->can_parity_check; # 1 $PortObj->can_parity_config; # 1 $PortObj->can_parity_enable; # 1 $PortObj->can_rlsd; # 0 currently $PortObj->can_16bitmode; # 0 Win32-specific $PortObj->is_rs232; # 1 $PortObj->is_modem; # 0 Win32-specific $PortObj->can_rtscts; # 1 $PortObj->can_xonxoff; # 1 $PortObj->can_xon_char; # 1 use stty $PortObj->can_spec_char; # 0 use stty $PortObj->can_interval_timeout; # 0 currently $PortObj->can_total_timeout; # 1 currently $PortObj->can_ioctl; # automatically detected $PortObj->can_status; # automatically detected $PortObj->can_write_done; # automatically detected $PortObj->can_modemlines; # automatically detected $PortObj->can_wait_modemlines;# automatically detected $PortObj->can_intr_count; # automatically detected $PortObj->can_arbitrary_baud; # automatically detected =head2 Operating Methods ($count_in, $string_in) = $PortObj->read($InBytes); warn "read unsuccessful\n" unless ($count_in == $InBytes); $count_out = $PortObj->write($output_string); warn "write failed\n" unless ($count_out); warn "write incomplete\n" if ( $count_out != length($output_string) ); if ($string_in = $PortObj->input) { PortObj->write($string_in); } # simple echo with no control character processing if ($PortObj->can_wait_modemlines) { $rc = $PortObj->wait_modemlines( MS_RLSD_ON ); if (!$rc) { print "carrier detect changed\n"; } } if ($PortObj->can_modemlines) { $ModemStatus = $PortObj->modemlines; if ($ModemStatus & $PortObj->MS_RLSD_ON) { print "carrier detected\n"; } } if ($PortObj->can_intr_count) { $count = $PortObj->intr_count(); print "got $count interrupts\n"; } if ($PortObj->can_arbitrary_baud) { print "this port can set arbitrary baud rates\n"; } ($BlockingFlags, $InBytes, $OutBytes, $ErrorFlags) = $PortObj->status; # same format for compatibility. Only $InBytes and $OutBytes are # currently returned (on linux). Others are 0. # Check return value of "can_status" to see if this call is valid. ($done, $count_out) = $PortObj->write_done(0); # POSIX defaults to background write. Currently $count_out always 0. # $done set when hardware finished transmitting and shared line can # be released for other use. Ioctl may not work on all OSs. # Check return value of "can_write_done" to see if this call is valid. $PortObj->write_drain; # POSIX alternative to Win32 write_done(1) # set when software is finished transmitting $PortObj->purge_all; $PortObj->purge_rx; $PortObj->purge_tx; # controlling outputs from the port $PortObj->dtr_active(T); # sends outputs direct to hardware $PortObj->rts_active(Yes); # return status of ioctl call # return undef on failure $PortObj->pulse_break_on($milliseconds); # off version is implausible $PortObj->pulse_rts_on($milliseconds); $PortObj->pulse_rts_off($milliseconds); $PortObj->pulse_dtr_on($milliseconds); $PortObj->pulse_dtr_off($milliseconds); # sets_bit, delays, resets_bit, delays # returns undef if unsuccessful or ioctls not implemented $PortObj->read_const_time(100); # const time for read (milliseconds) $PortObj->read_char_time(5); # avg time between read char $milliseconds = $PortObj->get_tick_count; =head2 Methods used with Tied FileHandles $PortObj = tie (*FH, 'Device::SerialPort', $Configuration_File_Name) || die "Can't tie: $!\n"; ## TIEHANDLE ## print FH "text"; ## PRINT ## $char = getc FH; ## GETC ## syswrite FH, $out, length($out), 0; ## WRITE ## $line = ; ## READLINE ## @lines = ; ## READLINE ## printf FH "received: %s", $line; ## PRINTF ## read (FH, $in, 5, 0) or die "$!"; ## READ ## sysread (FH, $in, 5, 0) or die "$!"; ## READ ## close FH || warn "close failed"; ## CLOSE ## undef $PortObj; untie *FH; ## DESTROY ## $PortObj->linesize(10); # with READLINE $PortObj->lastline("_GOT_ME_"); # with READLINE, list only ## with PRINT and PRINTF, return previous value of separator $old_ors = $PortObj->output_record_separator("RECORD"); $old_ofs = $PortObj->output_field_separator("COMMA"); =head2 Destructors $PortObj->close || warn "close failed"; # release port to OS - needed to reopen # close will not usually DESTROY the object # also called as: close FH || warn "close failed"; undef $PortObj; # preferred unless reopen expected since it triggers DESTROY # calls $PortObj->close but does not confirm success # MUST precede untie - do all three IN THIS SEQUENCE before re-tie. untie *FH; =head2 Methods for I/O Processing $PortObj->are_match("text", "\n"); # possible end strings $PortObj->lookclear; # empty buffers $PortObj->write("Feed Me:"); # initial prompt $PortObj->is_prompt("More Food:"); # not implemented my $gotit = ""; until ("" ne $gotit) { $gotit = $PortObj->lookfor; # poll until data ready die "Aborted without match\n" unless (defined $gotit); sleep 1; # polling sample time } printf "gotit = %s\n", $gotit; # input BEFORE the match my ($match, $after, $pattern, $instead) = $PortObj->lastlook; # input that MATCHED, input AFTER the match, PATTERN that matched # input received INSTEAD when timeout without match printf "lastlook-match = %s -after = %s -pattern = %s\n", $match, $after, $pattern; $gotit = $PortObj->lookfor($count); # block until $count chars received $PortObj->are_match("-re", "pattern", "text"); # possible match strings: "pattern" is a regular expression, # "text" is a literal string =head1 DESCRIPTION This module provides an object-based user interface essentially identical to the one provided by the Win32::SerialPort module. =head2 Initialization The primary constructor is B with either a F, or a F specified. With a F, this will open the port and create the object. The port is not yet ready for read/write access. First, the desired I must be established. Since these are tuning constants for an underlying hardware driver in the Operating System, they are all checked for validity by the methods that set them. The B method updates the port (and will return True under POSIX). Ports are opened for binary transfers. A separate C is not needed. $PortObj = new Device::SerialPort ($PortName, $quiet, $lockfile) || die "Can't open $PortName: $!\n"; The C<$quiet> parameter is ignored and is only there for compatibility with Win32::SerialPort. The C<$lockfile> parameter is optional. It will attempt to create a file (containing just the current process id) at the location specified. This file will be automatically deleted when the C<$PortObj> is no longer used (by DESTROY). You would usually request C<$lockfile> with C<$quiet> true to disable messages while attempting to obtain exclusive ownership of the port via the lock. Lockfiles are experimental in Version 0.07. They are intended for use with other applications. No attempt is made to resolve port aliases (/dev/modem == /dev/ttySx) or to deal with login processes such as getty and uugetty. Using a F with B or by using second constructor, B, scripts can be simplified if they need a constant setup. It executes all the steps from B to B based on a previously saved configuration. This constructor will return C on a bad configuration file or failure of a validity check. The returned object is ready for access. This is new and experimental for Version 0.055. $PortObj2 = start Device::SerialPort ($Configuration_File_Name) || die; The third constructor, B, will combine the B with Perl's support for tied FileHandles (see I). Device::SerialPort will implement the complete set of methods: TIEHANDLE, PRINT, PRINTF, WRITE, READ, GETC, READLINE, CLOSE, and DESTROY. Tied FileHandle support is new with Version 0.04 and the READ and READLINE methods were added in Version 0.06. In "scalar context", READLINE sets B to do character processing and calls B. It restores B after the read. In "list context", READLINE does Canonical (line) reads if B is set or calls B if it is not. (B is not altered). The B choice allows duplicating the operation of Win32::SerialPort for cross-platform scripts. The implementation attempts to mimic STDIN/STDOUT behaviour as closely as possible: calls block until done and data strings that exceed internal buffers are divided transparently into multiple calls. In Version 0.06, the output separators C<$,> and C<$\> are also applied to PRINT if set. The B and B methods can set I versions of C<$,> and C<$\> if desired. Since PRINTF is treated internally as a single record PRINT, C<$\> will be applied. Output separators are not applied to WRITE (called as C). The input_record_separator C<$/> is not explicitly supported - but an identical function can be obtained with a suitable B setting. $PortObj2 = tie (*FH, 'Device::SerialPort', $Configuration_File_Name) || die; The tied FileHandle methods may be combined with the Device::SerialPort methods for B, and B as well as other methods. The typical restrictions against mixing B with B do not apply. Since both B<(tied) read> and B call the same C<$ob-EREAD> method, and since a separate C<$ob-Eread> method has existed for some time in Device::SerialPort, you should always use B with the tied interface (when it is implemented). =over 8 Certain parameters I be set before executing B. Others will attempt to deduce defaults from the hardware or from other parameters. The I parameters are: =item baudrate Any legal value. =item parity One of the following: "none", "odd", "even". By default, incoming parity is not checked. This mimics the behavior of most terminal programs (like "minicom"). If you need parity checking enabled, please use the "stty_inpck" and "stty_istrip" functions. =item databits An integer from 5 to 8. =item stopbits Legal values are 1 and 2. =item handshake One of the following: "none", "rts", "xoff". =back Some individual parameters (eg. baudrate) can be changed after the initialization is completed. These will be validated and will update the I as required. The B method will write the current parameters to a file that B and B can use to reestablish a functional setup. $PortObj = new Win32::SerialPort ($PortName, $quiet) || die "Can't open $PortName: $^E\n"; # $quiet is optional $PortObj->user_msg(ON); $PortObj->databits(8); $PortObj->baudrate(9600); $PortObj->parity("none"); $PortObj->stopbits(1); $PortObj->handshake("rts"); $PortObj->write_settings || undef $PortObj; $PortObj->save($Configuration_File_Name); $PortObj->baudrate(300); $PortObj->restart($Configuration_File_Name); # back to 9600 baud $PortObj->close || die "failed to close"; undef $PortObj; # frees memory back to perl =head2 Configuration Utility Methods Use B to convert the name used by "built-in" messages. $PortObj->alias("MODEM1"); Starting in Version 0.07, a number of I are saved in B<$Configuration_File>. These parameters are not used internally. But methods allow setting and reading them. The intent is to facilitate the use of separate I to create the files. Then an application can use B as the Constructor and not bother with command line processing or managing its own small configuration file. The default values and number of parameters is subject to change. $PortObj->devicetype('none'); $PortObj->hostname('localhost'); # for socket-based implementations $PortObj->hostaddr(0); # a "false" value $PortObj->datatype('raw'); # 'record' is another possibility $PortObj->cfg_param_1('none'); $PortObj->cfg_param_2('none'); # 3 spares should be enough for now $PortObj->cfg_param_3('none'); =head2 Configuration and Capability Methods The Win32 Serial Comm API provides extensive information concerning the capabilities and options available for a specific port (and instance). This module will return suitable responses to facilitate porting code from that environment. The B method is a clone of the I function. It matches a corresponding method in I. It returns time in milliseconds - but can be used in cross-platform scripts. =over 8 Binary selections will accept as I any of the following: C<("YES", "Y", "ON", "TRUE", "T", "1", 1)> (upper/lower/mixed case) Anything else is I. There are a large number of possible configuration and option parameters. To facilitate checking option validity in scripts, most configuration methods can be used in two different ways: =item method called with an argument The parameter is set to the argument, if valid. An invalid argument returns I (undef) and the parameter is unchanged. The function will also I if B<$user_msg> is I. The port will be updated immediately if allowed (an automatic B is called). =item method called with no argument in scalar context The current value is returned. If the value is not initialized either directly or by default, return "undef" which will parse to I. For binary selections (true/false), return the current value. All current values from "multivalue" selections will parse to I. =item method called with no argument in list context Methods which only accept a limited number of specific input values return a list consisting of all acceptable choices. The null list C<(undef)> will be returned for failed calls in list context (e.g. for an invalid or unexpected argument). Only the baudrate, parity, databits, stopbits, and handshake methods currently support this feature. =back =head2 Operating Methods Version 0.04 adds B methods for the I bits. The B methods assume the bit is in the opposite state when the method is called. They set the requested state, delay the specified number of milliseconds, set the opposite state, and again delay the specified time. These methods are designed to support devices, such as the X10 "FireCracker" control and some modems, which require pulses on these lines to signal specific events or data. Timing for the I part of B is handled by I, which sends a 250-500 millisecond BREAK pulse. It is I guaranteed to block until done. $PortObj->pulse_break_on($milliseconds); $PortObj->pulse_rts_on($milliseconds); $PortObj->pulse_rts_off($milliseconds); $PortObj->pulse_dtr_on($milliseconds); $PortObj->pulse_dtr_off($milliseconds); In Version 0.05, these calls and the B and B calls verify the parameters and any required I, and return C unless the call succeeds. You can use the B method to see if the required constants are available. On Version 0.04, the module would not load unless I was found at startup. =head2 Stty Shortcuts Version 0.06 adds primitive methods to modify port parameters that would otherwise require a C command. These act much like the identically-named methods in Win32::SerialPort. However, they are initialized from "current stty settings" when the port is opened rather than from defaults. And like I, they are passed to the serial driver and apply to all operations rather than only to I/O processed via the B method or the I methods. Each returns the current setting for the parameter. There are no "global" or "combination" parameters - you still need C for that. The methods which handle CHAR parameters set and return values as C. This corresponds to the settings in the I. You are unlikely to actually want to modify most of these. They reflect the special characters which can be set by I. $PortObj->is_xon_char($num_char); # VSTART (stty start=.) $PortObj->is_xoff_char($num_char); # VSTOP $PortObj->is_stty_intr($num_char); # VINTR $PortObj->is_stty_quit($num_char); # VQUIT $PortObj->is_stty_eof($num_char); # VEOF $PortObj->is_stty_eol($num_char); # VEOL $PortObj->is_stty_erase($num_char); # VERASE $PortObj->is_stty_kill($num_char); # VKILL $PortObj->is_stty_susp($num_char); # VSUSP Binary settings supported by POSIX will return 0 or 1. Several parameters settable by I do not yet have shortcut methods. Contact me if you need one that is not supported. These are the common choices. Try C if you are not sure what they do. $PortObj->stty_echo; $PortObj->stty_echoe; $PortObj->stty_echok; $PortObj->stty_echonl; $PortObj->stty_ignbrk; $PortObj->stty_istrip; $PortObj->stty_inpck; $PortObj->stty_parmrk; $PortObj->stty_ignpar; $PortObj->stty_icrnl; $PortObj->stty_igncr; $PortObj->stty_inlcr; $PortObj->stty_opost; $PortObj->stty_isig; $PortObj->stty_icanon; The following methods require successfully loading I. They will return C if the needed constants are not found. But the method calls may still be used without syntax errors or warnings even in that case. $PortObj->stty_ocrlf; $PortObj->stty_onlcr; $PortObj->stty_echoke; $PortObj->stty_echoctl; =head2 Lookfor and I/O Processing Some communications programs have a different need - to collect (or discard) input until a specific pattern is detected. For lines, the pattern is a line-termination. But there are also requirements to search for other strings in the input such as "username:" and "password:". The B method provides a consistant mechanism for solving this problem. It searches input character-by-character looking for a match to any of the elements of an array set using the B method. It returns the entire input up to the match pattern if a match is found. If no match is found, it returns "" unless an input error or abort is detected (which returns undef). Unlike Win32::SerialPort, B does not handle backspace, echo, and other character processing. It expects the serial driver to handle those and to be controlled via I. For interacting with humans, you will probably want C during B to obtain familiar command-line response. The actual match and the characters after it (if any) may also be viewed using the B method. It also adopts the convention from Expect.pm that match strings are literal text (tested using B) unless preceeded in the B list by a B<"-re",> entry. The default B list is C<("\n")>, which matches complete lines. my ($match, $after, $pattern, $instead) = $PortObj->lastlook; # input that MATCHED, input AFTER the match, PATTERN that matched # input received INSTEAD when timeout without match ("" if match) $PortObj->are_match("text1", "-re", "pattern", "text2"); # possible match strings: "pattern" is a regular expression, # "text1" and "text2" are literal strings Everything in B is still experimental. Please let me know if you use it (or can't use it), so I can confirm bug fixes don't break your code. For literal strings, C<$match> and C<$pattern> should be identical. The C<$instead> value returns the internal buffer tested by the match logic. A successful match or a B resets it to "" - so it is only useful for error handling such as timeout processing or reporting unexpected responses. The B method is designed to be sampled periodically (polled). Any characters after the match pattern are saved for a subsequent B. Internally, B is implemented using the nonblocking B method when called with no parameter. If called with a count, B calls C<$PortObj-Eread(count)> which blocks until the B is I or a I occurs. The blocking alternative should not be used unless a fault time has been defined using B. It exists mostly to support the I functions B and BFHE>. When B is active, even the non-blocking calls will not return data until the line is complete. The internal buffers used by B may be purged by the B method (which also clears the last match). For testing, B can accept a string which is "looped back" to the next B. This feature is enabled only when C. Normally, B will return C if given parameters. It still purges the buffers and last_match in that case (but nothing is "looped back"). You will want B when exercising loopback. The B method is designed to handle the "special case" where the match string is the first character(s) received by B. In this case, C<$lookfor_return == "">, B does not provide a clear indication that a match was found. The B returns the same C<$match> that would be returned by B and resets it to "" without resetting any of the other buffers. Since the B already searched I the match, B is used to both detect and step-over "blank" lines. The character-by-character processing used by B is fine for interactive activities and tasks which expect short responses. But it has too much "overhead" to handle fast data streams.There is also a B method which is a fast, line-oriented alternative with just pattern searching. Since B uses the same internal buffers, the B methods act the same in both cases. In fact, calls to B and B can be interleaved if desired (e.g. an interactive task that starts an upload and returns to interactive activity when it is complete). There are two additional methods for supporting "list context" input: B sets an "end_of_file" I, and B permits changing the "packet size" in the blocking read operation to allow tuning performance to data characteristics. These two only apply during B. The default for B is 1. There is no default for the B method. The I set by B and B will be pre-compiled using the I construct on Perl 5.005 and higher. This doubled B and B speed in my tests with I - but actual improvements depend on both patterns and input data. The functionality of B includes a limited subset of the capabilities found in Austin Schutz's I for Unix (and Tcl's expect which it resembles). The C<$before, $match, $pattern, and $after> return values are available if someone needs to create an "expect" subroutine for porting a script. When using multiple patterns, there is one important functional difference: I looks at each pattern in turn and returns the first match found; B and B test all patterns and return the one found I in the input if more than one matches. =head2 Exports Nothing is exported by default. The following tags can be used to have large sets of symbols exported: =over 4 =item :PARAM Utility subroutines and constants for parameter setting and test: LONGsize SHORTsize nocarp yes_true OS_Error =item :STAT The Constants named BM_* and CE_* are omitted. But the modem status (MS_*) Constants are defined for possible use with B and B. They are assigned to corresponding functions, but the bit position will be different from that on Win32. Which incoming bits are active: MS_CTS_ON - Clear to send MS_DSR_ON - Data set ready MS_RING_ON - Ring indicator MS_RLSD_ON - Carrier detected MS_RTS_ON - Request to send (might not exist on Win32) MS_DTR_ON - Data terminal ready (might not exist on Win32) If you want to write more POSIX-looking code, you can use the constants seen there, instead of the Win32 versions: TIOCM_CTS, TIOCM_DSR, TIOCM_RI, TIOCM_CD, TIOCM_RTS, and TIOCM_DTR Offsets into the array returned by B ST_BLOCK ST_INPUT ST_OUTPUT ST_ERROR =item :ALL All of the above. Except for the I, there is not really a good reason to do this. =back =head1 PINOUT Here is a handy pinout map, showing each line and signal on a standard DB9 connector: =over 8 =item 1 DCD Data Carrier Detect =item 2 RD Receive Data =item 3 TD Transmit Data =item 4 DTR Data Terminal Ready =item 5 SG Signal Ground =item 6 DSR Data Set Ready =item 7 RTS Request to Send =item 8 CTS Clear to Send =item 9 RI Ring Indicator =back =head1 NOTES The object returned by B is NOT a I. You will be disappointed if you try to use it as one. e.g. the following is WRONG!! print $PortObj "some text"; This module uses I extensively. Raw API calls are B unforgiving. You will certainly want to start perl with the B<-w> switch. If you can, B as well. Try to ferret out all the syntax and usage problems BEFORE issuing the API calls (many of which modify tuning constants in hardware device drivers....not where you want to look for bugs). With all the options, this module needs a good tutorial. It doesn't have one yet. =head1 EXAMPLE It is recommended to always use "read(255)" due to some unexpected behavior with the termios under some operating systems (Linux and Solaris at least). To deal with this, a routine is usually needed to read from the serial port until you have what you want. This is a quick example of how to do that: 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"; } =head1 PORTING For a serial port to work under Unix, you need the ability to do several types of operations. With POSIX, these operations are implemented with a set of "tc*" functions. However, not all Unix systems follow this correctly. In those cases, the functions change, but the variables used as parameters generally turn out to be the same. =over 4 =item Get/Set RTS This is only available through the bit-set(TIOCMBIS)/bit-clear(TIOCMBIC) ioctl function using the RTS value(TIOCM_RTS). ioctl($handle,$on ? $TIOCMBIS : $TIOCMBIC, $TIOCM_RTS); =item Get/Set DTR This is available through the bit-set(TIOCMBIS)/bit-clear(TIOCMBIC) ioctl function using the DTR value(TIOCM_DTR) ioctl($handle,$on ? $TIOCMBIS : $TIOCMBIC, $TIOCM_DTR); or available through the DTRSET/DTRCLEAR ioctl functions, if they exist. ioctl($handle,$on ? $TIOCSDTR : $TIOCCDTR, 0); =item Get modem lines To read Clear To Send (CTS), Data Set Ready (DSR), Ring Indicator (RING), and Carrier Detect (CD/RLSD), the TIOCMGET ioctl function must be used. ioctl($handle, $TIOCMGET, $status); To decode the individual modem lines, some bits have multiple possible constants: =over 4 =item Clear To Send (CTS) TIOCM_CTS =item Data Set Ready (DSR) TIOCM_DSR =item Ring Indicator (RING) TIOCM_RNG TIOCM_RI =item Carrier Detect (CD/RLSD) TIOCM_CAR TIOCM_CD =back =item Get Buffer Status To get information about the state of the serial port input and output buffers, the TIOCINQ and TIOCOUTQ ioctl functions must be used. I'm not totally sure what is returned by these functions across all Unix systems. Under Linux, it is the integer number of characters in the buffer. ioctl($handle,$in ? $TIOCINQ : $TIOCOUTQ, $count); $count = unpack('i',$count); =item Get Line Status To get information about the state of the serial transmission line (to see if a write has made its way totally out of the serial port buffer), the TIOCSERGETLSR ioctl function must be used. Additionally, the "Get Buffer Status" methods must be functioning, as well as having the first bit of the result set (Linux is TIOCSER_TEMT, others unknown, but we've been using TIOCM_LE even though that should be returned from the TIOCMGET ioctl). ioctl($handle,$TIOCSERGETLSR, $status); $done = (unpack('i', $status) & $TIOCSER_TEMT); =item Set Flow Control Some Unix systems require special TCGETX/TCSETX ioctls functions and the CTSXON/RTSXOFF constants to turn on and off CTS/RTS "hard" flow control instead of just using the normal POSIX tcsetattr calls. ioctl($handle, $TCGETX, $flags); @bytes = unpack('SSSS',$flags); $bytes[0] = $on ? ($CTSXON | $RTSXOFF) : 0; $flags = pack('SSSS',@bytes); ioctl($handle, $TCSETX, $flags); =back =head1 KNOWN LIMITATIONS The current version of the module has been tested with Perl 5.003 and above. It was initially ported from Win32 and was designed to be used without requiring a compiler or using XS. Since everything is (sometimes convoluted but still pure) Perl, you can fix flaws and change limits if required. But please file a bug report if you do. The B method, and tied methods which call it, currently can use a fixed timeout which approximates behavior of the I B and B methods. It is used internally by I and I. The timeout is reset for each 255-byte segment. Hence, for large B, use a B suitable for a 255-byte read. All of this is expeimental in Version 0.055. $PortObj->read_const_time(500); # 500 milliseconds = 0.5 seconds $PortObj->read_char_time(5); # avg time between read char The timing model defines the total time allowed to complete the operation. A fixed overhead time is added to the product of bytes and per_byte_time. Read_Total = B + (B * bytes_to_read) Write timeouts and B timeouts are not currently supported. On some machines, reads larger than 4,096 bytes may be truncated at 4,096, regardless of the read size or read timing settings used. In this case, try turning on or increasing the inter-character delay on your serial device. Also try setting the read size to $PortObj->read(1) or $PortObj->read(255) and performing multiple reads until the transfer is completed. =head1 BUGS See the limitations about lockfiles. Experiment if you like. With all the I, we don't need any more. But there probably are some. Please send comments and bug reports to kees@outflux.net. =head1 Win32::SerialPort & Win32API::CommPort =head2 Win32::SerialPort Functions Not Currently Supported $LatchErrorFlags = $PortObj->reset_error; $PortObj->read_interval(100); # max time between read char $PortObj->write_char_time(5); $PortObj->write_const_time(100); =head2 Functions Handled in a POSIX system by "stty" xon_limit xoff_limit xon_char xoff_char eof_char event_char error_char stty_intr stty_quit stty_eof stty_eol stty_erase stty_kill stty_clear is_stty_clear stty_bsdel stty_echoke stty_echoctl stty_ocrnl stty_onlcr =head2 Win32::SerialPort Functions Not Ported to POSIX transmit_char =head2 Win32API::CommPort Functions Not Ported to POSIX init_done fetch_DCB update_DCB initialize are_buffers are_baudrate are_handshake are_parity are_databits are_stopbits is_handshake xmit_imm_char is_baudrate is_parity is_databits is_write_char_time debug_comm is_xon_limit is_xoff_limit is_read_const_time suspend_tx is_eof_char is_event_char is_read_char_time is_read_buf is_write_buf is_buffers is_read_interval is_error_char resume_tx is_stopbits is_write_const_time is_binary is_status write_bg is_parity_enable is_modemlines read_bg read_done break_active xoff_active is_read_buf is_write_buf xon_active =head2 "raw" Win32 API Calls and Constants A large number of Win32-specific elements have been omitted. Most of these are only available in Win32::SerialPort and Win32API::CommPort as optional Exports. The list includes the following: =over 4 =item :RAW The API Wrapper Methods and Constants used only to support them including PURGE_*, SET*, CLR*, EV_*, and ERROR_IO* =item :COMMPROP The Constants used for Feature and Properties Detection including BAUD_*, PST_*, PCF_*, SP_*, DATABITS_*, STOPBITS_*, PARITY_*, and COMMPROP_INITIALIZED =item :DCB The constants for the I including CBR_*, DTR_*, RTS_*, *PARITY, *STOPBIT*, and FM_* =back =head2 Compatibility This code implements the functions required to support the MisterHouse Home Automation software by Bruce Winter. It does not attempt to support functions from Win32::SerialPort such as B that already have POSIX implementations or to replicate I. However, the supported functions are intended to clone the equivalent functions in Win32::SerialPort and Win32API::CommPort. Any discrepancies or omissions should be considered bugs and reported to the maintainer. =head1 AUTHORS Based on Win32::SerialPort.pm, Version 0.8, by Bill Birthisel Ported to linux/POSIX by Joe Doss for MisterHouse Ported to Solaris/POSIX by Kees Cook for Sendpage Ported to BSD/POSIX by Kees Cook Ported to Perl XS by Kees Cook Currently maintained by: Kees Cook, kees@outflux.net, http://outflux.net/ =head1 SEE ALSO Win32API::CommPort Win32::SerialPort perltoot - Tom Christiansen's Object-Oriented Tutorial =head1 COPYRIGHT Copyright (C) 1999, Bill Birthisel. All rights reserved. Copyright (C) 2000-2007, Kees Cook. All rights reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut # /* vi:set ai ts=4 sw=4 expandtab: */ Device-SerialPort-1.04/Changes0000644000076500007650000001465010707557001014674 0ustar keeskeesRevision history for Perl extension Device::SerialPort. 1.04 2007-10-23 (Kees) * Update autoconf files. * Use standard Perl module versioning. 1.3.1 2007-07-20 (Kees) * Correct arbitrary baud setting. 1.3.0 2007-07-20 (Kees) * SerialPort.{pm,xs}, configure.ac: add arbitrary baud rate setting as suggested by Steven Michalske. * Disabled default port tests, initial switch to Test::More. 1.2.1 2007-06-16 (Kees) * SerialPort.pm: correction to READ by Martin Hans * SerialPort.pm: corrected "close" call noticed by David R. Wilson * Added knowledge of FIONREAD noticed by Darrin Chandler * Fixed up white-space issues. 1.2.0 2004-11-09 (Kees) * configure.ac: corrected version number here too. * SerialPort.pm: added wait_modemlines, intr_count. * SerialPort.xs, configure.ac: added TIOCMIWAIT, TIOCGICOUNT * white space cleanups. 1.0.2 2004-05-10 (Kees) * Makefile.PL: added an OSX serial port default * SerialPort.pm: patch for EOF handling by Arne Georg Gleditsch. On a read for more than 0 bytes, and "select" finishes, but we get a 0 back, then we assume EOF. * corrected version in .spec file. 1.0.1 2004-03-29 (Kees) * small typo in bits processing for can_ioctl (thanks to Rick Ballard and John Eng for finding this!) 1.0.0 2004-02-23 (Kees) * fixed logic in READ tie function from Jaakko Yli-Luukko * added RPM .spec packaging support * adding debian packaging support * updated version number to first stable release * fixing up failure return codes in data,parity,flow functions * cleaning up default settings for parmrk, istrip, etc * split off stty_parmrk * setting defaults of 9600, 8N1, no flow in "new" * added MS_DTR_ON and MS_DSR_ON * clearly documenting "carrier" bit * added automatic system baud rate detection * added modem line reporting to "modemtest" * documented "modemtest" * I think I finally found the parity problem that has been plauging this code since I took it over! 0.22 2003-06-18 (Kees) * added a notice about 4096 read limits on some machines noticed by Ed Morandi. * built an rpm .spec file with the help of cpan2rpm. * adding TESTPORT=... as a Makefile.PL option to not step on MakeMaker's feet. * making "modemtest" an installable script (which adds #! to top). * cleaning up "modemtest" args and output. * reversing configure report so "best" case reports "yes" for all. * handling ancient libcs with odd POSIX.pm _SC_CLK_TCK behavior with diagnostic help from David Dyck * added test case explicitly for get_tick_count 0.21 2003-06-12 (Kees) * don't release files at midnight any more: forgot SerialPort.xs 0.20 2003-06-12 (Kees) * fixed some truth bugs found by David Dyck * totally rewrote serial bit detection code to use "normal" perl XS routines. Had to even toss in a "configure" script to make it really robust. * jumped up to version 0.20 just because it's just a big change to the build process. Everything else appears undisturbed, but I want to give some time for testing it out on other architectures. 0.13 2002-05-31 (Kees) * added 'sys/modem.ph' for broken HPUX headers * fixed *BSD tiocmget and tick counts, care of joerg_wunsch@interface-systems.de * fixed the HPUX tioc* stuff, care of "Chang, Jerry" 0.12 2001-10-24 (Kees) * found a place where HANDLE was staying open * corrected FD-success test (0 *is* a valid fd number) 0.11 Tue Jul 17 23:32:55 CDT 2001 (Kees) * patch from James Mitchell to allow TIEHANDLE to use a device port in addition to a config file * updated documentation to reflect above patch * added FILENO function, per James Mitchell's suggestion * detecting vmin settings for broken Solaris tools. * added "modemtest" 0.10 Tue Feb 13 08:52:54 CST 2001 (Kees) * fixed broken tests * improved auto-detection of ioctl methods * got Linux working 100% (even with tests) * got Solaris working 100% (even with tests) 0.09 Thu Jan 25 09:59:24 CST 2001 (Kees) * added support for other OSes * corrected DTR activation code 0.07 Tue Sep 07 22:41:53 CDT 1999 * add status, write_done, modemlines methods * add saved utility parameters and methods (hostname, et.al) * save lockfile data in configuration_file 0.06 Fri Aug 07 17:49:40 1999 * ported demos 5,6,7 from Win32 * rename GetTickCount method to get_tick_count * add stty_xxx shortcut methods * add lookfor, streamline, are_match, READLINE and related methods * add output_record and output_field separator support * add return values to purge_xx and write_drain 0.055 Sat Aug 07 14:13:48 1999 * interim test release for configuration files, defaults, bug fixes * added tests, demos, and examples 0.051 Tue Aug 03 10:12:14 1999 * test?.t changes for Sun testing 0.05 Wed Jul 28 23:53:38 1999 * now uses standard MakeMaker install sequence with make * alternate port for "make test" not yet supported * delete lib subdirectories, make copies SerialPort.pm to blib * AltPort.pm moved to t, "use lib" paths revised * Add can_ioctl and allow operation if "asm/termios.ph" not found * Add error and sanity checking to xxx_active and pulse_xxx methods * Document $quiet option for new method * Add preliminary lockfile support 0.04 Wed Jul 21 23:53:38 1999 * original version; created by h2xs 1.18 * MakeMaker templates merged with pre-existing code * Add RTS, BREAK, DTR control * Add GetTickCount method (clone of Win32::GetTickCount) * Add read_const_time and read_char_time * Add SHORTsize, LONGsize, test3.t and AltPort.pm for testing * Add partial tied FileHandle support * Documentation improvements * Ported some of the Win32::SerialPort examples and demos 0.03 * Test version for ioctl support. 0.02 * Complete rewrite of the pod documentation. * module now maintained by Bill Birthisel. * Add PARAM: tags to %EXPORT_TAGS. * Rename "tact" to "nocarp". * Allow "parity_enable" and "set_test_mode_active" to accept FALSE. * Add "defined" tests for POSIX tests which return "undef" on fail. * Add the "can_xxx" methods with suitable return values. * Initialize "user_msg", "error_msg", and "debug" to FALSE. * Add "write_drain", "debug", and "reset_error" methods. * Revise "baudrate", "parity", "databits", "stopbits", and "handshake" to return current values in scalar context and permitted choices in list context. All values in same format as setting arguments. 0.01 * This is a POSIX version of the Win32::Serialport module ported by Joe Doss for MisterHouse from Version 0.08. Device-SerialPort-1.04/SerialPort.xs0000644000076500007650000000776710650163560016054 0ustar keeskees#include "EXTERN.h" #include "perl.h" #include "XSUB.h" /* include our configure-created config file */ #include "config.h" /* First step: include all the files we think we may need to get all the silly serial and modem bits defined. This should be exactly the same as what's in the autoconf scripts. */ #ifdef HAVE_UNISTD_H # include #endif #ifdef HAVE_SYS_IOCTL_H # include #endif #ifdef HAVE_TERMIOS_H # include #endif #ifdef HAVE_SYS_TERMIOX_H # include #endif #ifdef HAVE_SYS_TERMIOS_H # include #endif #ifdef HAVE_SYS_TTYCOM_H # include #endif #ifdef HAVE_SYS_MODEM_H # include #endif #ifdef HAVE_IOKIT_SERIAL_IOSS_H # include #endif #define ADD_TO_HASH(v) { \ key = #v; \ value = newSViv(v); \ hv_store(hv, key, strlen(key), value, 0); \ } /* Hide this junk in the "Bits" namespace */ MODULE = Device::SerialPort PACKAGE = Device::SerialPort::Bits SV * get_hash() PREINIT: HV * hv; char * key; SV * value; PROTOTYPE: CODE: /* initialize the hash */ hv = newHV(); #ifdef _SC_CLK_TCK ADD_TO_HASH(_SC_CLK_TCK) #endif #ifdef TIOCMBIS ADD_TO_HASH(TIOCMBIS) #endif #ifdef TIOCMBIC ADD_TO_HASH(TIOCMBIC) #endif #ifdef TIOCMGET ADD_TO_HASH(TIOCMGET) #endif #ifdef CRTSCTS ADD_TO_HASH(CRTSCTS) #endif #ifdef OCRNL ADD_TO_HASH(OCRNL) #endif #ifdef ONLCR ADD_TO_HASH(ONLCR) #endif #ifdef ECHOKE ADD_TO_HASH(ECHOKE) #endif #ifdef ECHOCTL ADD_TO_HASH(ECHOCTL) #endif #ifdef TIOCM_CAR ADD_TO_HASH(TIOCM_CAR) #endif #ifdef TIOCM_CD ADD_TO_HASH(TIOCM_CD) #endif #ifdef TIOCM_RNG ADD_TO_HASH(TIOCM_RNG) #endif #ifdef TIOCM_RI ADD_TO_HASH(TIOCM_RI) #endif #ifdef TIOCM_CTS ADD_TO_HASH(TIOCM_CTS) #endif #ifdef TIOCM_DSR ADD_TO_HASH(TIOCM_DSR) #endif #ifdef TIOCINQ ADD_TO_HASH(TIOCINQ) #endif #ifdef TIOCOUTQ ADD_TO_HASH(TIOCOUTQ) #endif #ifdef TIOCSER_TEMT ADD_TO_HASH(TIOCSER_TEMT) #endif #ifdef TIOCM_LE ADD_TO_HASH(TIOCM_LE) #endif #ifdef TIOCSERGETLSR ADD_TO_HASH(TIOCSERGETLSR) #endif #ifdef TIOCSDTR ADD_TO_HASH(TIOCSDTR) #endif #ifdef TIOCCDTR ADD_TO_HASH(TIOCCDTR) #endif #ifdef TIOCM_RTS ADD_TO_HASH(TIOCM_RTS) #endif #ifdef TIOCM_DTR ADD_TO_HASH(TIOCM_DTR) #endif #ifdef TIOCMIWAIT ADD_TO_HASH(TIOCMIWAIT) #endif #ifdef TIOCGICOUNT ADD_TO_HASH(TIOCGICOUNT) #endif #ifdef CTSXON ADD_TO_HASH(CTSXON) #endif #ifdef RTSXOFF ADD_TO_HASH(RTSXOFF) #endif #ifdef TCGETX ADD_TO_HASH(TCGETX) #endif #ifdef TCSETX ADD_TO_HASH(TCSETX) #endif /* Baud rates */ #ifdef IOSSIOSPEED ADD_TO_HASH(IOSSIOSPEED) #endif #ifdef B0 ADD_TO_HASH(B0) #endif #ifdef B50 ADD_TO_HASH(B50) #endif #ifdef B75 ADD_TO_HASH(B75) #endif #ifdef B110 ADD_TO_HASH(B110) #endif #ifdef B134 ADD_TO_HASH(B134) #endif #ifdef B150 ADD_TO_HASH(B150) #endif #ifdef B200 ADD_TO_HASH(B200) #endif #ifdef B300 ADD_TO_HASH(B300) #endif #ifdef B600 ADD_TO_HASH(B600) #endif #ifdef B1200 ADD_TO_HASH(B1200) #endif #ifdef B1800 ADD_TO_HASH(B1800) #endif #ifdef B2400 ADD_TO_HASH(B2400) #endif #ifdef B4800 ADD_TO_HASH(B4800) #endif #ifdef B9600 ADD_TO_HASH(B9600) #endif #ifdef B19200 ADD_TO_HASH(B19200) #endif #ifdef B38400 ADD_TO_HASH(B38400) #endif #ifdef B57600 ADD_TO_HASH(B57600) #endif #ifdef B115200 ADD_TO_HASH(B115200) #endif #ifdef B230400 ADD_TO_HASH(B230400) #endif #ifdef B460800 ADD_TO_HASH(B460800) #endif #ifdef B500000 ADD_TO_HASH(B500000) #endif #ifdef B576000 ADD_TO_HASH(B576000) #endif #ifdef B921600 ADD_TO_HASH(B921600) #endif #ifdef B1000000 ADD_TO_HASH(B1000000) #endif #ifdef B1152000 ADD_TO_HASH(B1152000) #endif #ifdef B2000000 ADD_TO_HASH(B2000000) #endif #ifdef B2500000 ADD_TO_HASH(B2500000) #endif #ifdef B3000000 ADD_TO_HASH(B3000000) #endif #ifdef B3500000 ADD_TO_HASH(B3500000) #endif #ifdef B4000000 ADD_TO_HASH(B4000000) #endif RETVAL = newRV_noinc((SV*)hv); OUTPUT: RETVAL Device-SerialPort-1.04/TODO0000644000076500007650000000107310650175764014075 0ustar keeskees High - document intr_count and wait_modemlines - spread POD docs out across the module - export the POSIX names too, MS_* is for optional porting compatibility - fix AIX hardware flow control (whats wrong with it?) Medium - fix lockfile support (maybe using a generic File::Lock routine?) - create a method to call "new" without a device name (cleaner way to test) - split up tests so we can do non-device testing (as the default) - make error handling behavior an option (don't die on device failure) Low - add a mechanism to set any modem lines in one function call Device-SerialPort-1.04/configure0000755000076500007650000051030110707556022015304 0ustar keeskees#! /bin/sh # From configure.ac Revision: 312 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.61 for Device::SerialPort 1.04. # # Report bugs to . # # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, # 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. # This configure script is free software; the Free Software Foundation # gives unlimited permission to copy, distribute and modify it. ## --------------------- ## ## M4sh Initialization. ## ## --------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then emulate sh NULLCMD=: # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac fi # PATH needs CR # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then echo "#! /bin/sh" >conf$$.sh echo "exit 0" >>conf$$.sh chmod +x conf$$.sh if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then PATH_SEPARATOR=';' else PATH_SEPARATOR=: fi rm -f conf$$.sh fi # Support unset when possible. if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then as_unset=unset else as_unset=false fi # IFS # We need space, tab and new line, in precisely that order. Quoting is # there to prevent editors from complaining about space-tab. # (If _AS_PATH_WALK were called with IFS unset, it would disable word # splitting by setting IFS to empty value.) as_nl=' ' IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. case $0 in *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 { (exit 1); exit 1; } fi # Work around bugs in pre-3.0 UWIN ksh. for as_var in ENV MAIL MAILPATH do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var done PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. for as_var in \ LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \ LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \ LC_TELEPHONE LC_TIME do if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then eval $as_var=C; export $as_var else ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var fi done # Required to use basename. if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi # Name of the executable. as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # CDPATH. $as_unset CDPATH if test "x$CONFIG_SHELL" = x; then if (eval ":") 2>/dev/null; then as_have_required=yes else as_have_required=no fi if test $as_have_required = yes && (eval ": (as_func_return () { (exit \$1) } as_func_success () { as_func_return 0 } as_func_failure () { as_func_return 1 } as_func_ret_success () { return 0 } as_func_ret_failure () { return 1 } exitcode=0 if as_func_success; then : else exitcode=1 echo as_func_success failed. fi if as_func_failure; then exitcode=1 echo as_func_failure succeeded. fi if as_func_ret_success; then : else exitcode=1 echo as_func_ret_success failed. fi if as_func_ret_failure; then exitcode=1 echo as_func_ret_failure succeeded. fi if ( set x; as_func_ret_success y && test x = \"\$1\" ); then : else exitcode=1 echo positional parameters were not saved. fi test \$exitcode = 0) || { (exit 1); exit 1; } ( as_lineno_1=\$LINENO as_lineno_2=\$LINENO test \"x\$as_lineno_1\" != \"x\$as_lineno_2\" && test \"x\`expr \$as_lineno_1 + 1\`\" = \"x\$as_lineno_2\") || { (exit 1); exit 1; } ") 2> /dev/null; then : else as_candidate_shells= as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. case $as_dir in /*) for as_base in sh bash ksh sh5; do as_candidate_shells="$as_candidate_shells $as_dir/$as_base" done;; esac done IFS=$as_save_IFS for as_shell in $as_candidate_shells $SHELL; do # Try only shells that exist, to save several forks. if { test -f "$as_shell" || test -f "$as_shell.exe"; } && { ("$as_shell") 2> /dev/null <<\_ASEOF if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then emulate sh NULLCMD=: # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac fi : _ASEOF }; then CONFIG_SHELL=$as_shell as_have_required=yes if { "$as_shell" 2> /dev/null <<\_ASEOF if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then emulate sh NULLCMD=: # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac fi : (as_func_return () { (exit $1) } as_func_success () { as_func_return 0 } as_func_failure () { as_func_return 1 } as_func_ret_success () { return 0 } as_func_ret_failure () { return 1 } exitcode=0 if as_func_success; then : else exitcode=1 echo as_func_success failed. fi if as_func_failure; then exitcode=1 echo as_func_failure succeeded. fi if as_func_ret_success; then : else exitcode=1 echo as_func_ret_success failed. fi if as_func_ret_failure; then exitcode=1 echo as_func_ret_failure succeeded. fi if ( set x; as_func_ret_success y && test x = "$1" ); then : else exitcode=1 echo positional parameters were not saved. fi test $exitcode = 0) || { (exit 1); exit 1; } ( as_lineno_1=$LINENO as_lineno_2=$LINENO test "x$as_lineno_1" != "x$as_lineno_2" && test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2") || { (exit 1); exit 1; } _ASEOF }; then break fi fi done if test "x$CONFIG_SHELL" != x; then for as_var in BASH_ENV ENV do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var done export CONFIG_SHELL exec "$CONFIG_SHELL" "$as_myself" ${1+"$@"} fi if test $as_have_required = no; then echo This script requires a shell more modern than all the echo shells that I found on your system. Please install a echo modern shell, or manually run the script under such a echo shell if you do have one. { (exit 1); exit 1; } fi fi fi (eval "as_func_return () { (exit \$1) } as_func_success () { as_func_return 0 } as_func_failure () { as_func_return 1 } as_func_ret_success () { return 0 } as_func_ret_failure () { return 1 } exitcode=0 if as_func_success; then : else exitcode=1 echo as_func_success failed. fi if as_func_failure; then exitcode=1 echo as_func_failure succeeded. fi if as_func_ret_success; then : else exitcode=1 echo as_func_ret_success failed. fi if as_func_ret_failure; then exitcode=1 echo as_func_ret_failure succeeded. fi if ( set x; as_func_ret_success y && test x = \"\$1\" ); then : else exitcode=1 echo positional parameters were not saved. fi test \$exitcode = 0") || { echo No shell found that supports shell functions. echo Please tell autoconf@gnu.org about your system, echo including any error possibly output before this echo message } as_lineno_1=$LINENO as_lineno_2=$LINENO test "x$as_lineno_1" != "x$as_lineno_2" && test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2" || { # Create $as_me.lineno as a copy of $as_myself, but with $LINENO # uniformly replaced by the line number. The first 'sed' inserts a # line-number line after each line using $LINENO; the second 'sed' # does the real work. The second script uses 'N' to pair each # line-number line with the line containing $LINENO, and appends # trailing '-' during substitution so that $LINENO is not a special # case at line end. # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the # scripts with optimization help from Paolo Bonzini. Blame Lee # E. McMahon (1931-1989) for sed's syntax. :-) sed -n ' p /[$]LINENO/= ' <$as_myself | sed ' s/[$]LINENO.*/&-/ t lineno b :lineno N :loop s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ t loop s/-\n.*// ' >$as_me.lineno && chmod +x "$as_me.lineno" || { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2 { (exit 1); exit 1; }; } # Don't try to exec as it changes $[0], causing all sort of problems # (the dirname of $[0] is not the place where we might find the # original and so on. Autoconf is especially sensitive to this). . "./$as_me.lineno" # Exit status is that of the last command. exit } if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in -n*) case `echo 'x\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. *) ECHO_C='\c';; esac;; *) ECHO_N='-n';; esac if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir fi echo >conf$$.file if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -p'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -p' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -p' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null if mkdir -p . 2>/dev/null; then as_mkdir_p=: else test -d ./-p && rmdir ./-p as_mkdir_p=false fi if test -x / >/dev/null 2>&1; then as_test_x='test -x' else if ls -dL / >/dev/null 2>&1; then as_ls_L_option=L else as_ls_L_option= fi as_test_x=' eval sh -c '\'' if test -d "$1"; then test -d "$1/."; else case $1 in -*)set "./$1";; esac; case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in ???[sx]*):;;*)false;;esac;fi '\'' sh ' fi as_executable_p=$as_test_x # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" exec 7<&0 &1 # Name of the host. # hostname on some systems (SVR3.2, Linux) returns a bogus exit status, # so uname gets run too. ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` # # Initializations. # ac_default_prefix=/usr/local ac_clean_files= ac_config_libobj_dir=. LIBOBJS= cross_compiling=no subdirs= MFLAGS= MAKEFLAGS= SHELL=${CONFIG_SHELL-/bin/sh} # Identity of this package. PACKAGE_NAME='Device::SerialPort' PACKAGE_TARNAME='device--serialport' PACKAGE_VERSION='1.04' PACKAGE_STRING='Device::SerialPort 1.04' PACKAGE_BUGREPORT='devser-bugs@outflux.net' ac_unique_file="SerialPort.xs" # Factoring default headers for most tests. ac_includes_default="\ #include #ifdef HAVE_SYS_TYPES_H # include #endif #ifdef HAVE_SYS_STAT_H # include #endif #ifdef STDC_HEADERS # include # include #else # ifdef HAVE_STDLIB_H # include # endif #endif #ifdef HAVE_STRING_H # if !defined STDC_HEADERS && defined HAVE_MEMORY_H # include # endif # include #endif #ifdef HAVE_STRINGS_H # include #endif #ifdef HAVE_INTTYPES_H # include #endif #ifdef HAVE_STDINT_H # include #endif #ifdef HAVE_UNISTD_H # include #endif" ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datarootdir datadir sysconfdir sharedstatedir localstatedir includedir oldincludedir docdir infodir htmldir dvidir pdfdir psdir libdir localedir mandir DEFS ECHO_C ECHO_N ECHO_T LIBS build_alias host_alias target_alias CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT CPP GREP EGREP LIBOBJS LTLIBOBJS' ac_subst_files='' ac_precious_vars='build_alias host_alias target_alias CC CFLAGS LDFLAGS LIBS CPPFLAGS CPP' # Initialize some variables set by options. ac_init_help= ac_init_version=false # The variables have the same names as the options, with # dashes changed to underlines. cache_file=/dev/null exec_prefix=NONE no_create= no_recursion= prefix=NONE program_prefix=NONE program_suffix=NONE program_transform_name=s,x,x, silent= site= srcdir= verbose= x_includes=NONE x_libraries=NONE # Installation directory options. # These are left unexpanded so users can "make install exec_prefix=/foo" # and all the variables that are supposed to be based on exec_prefix # by default will actually change. # Use braces instead of parens because sh, perl, etc. also accept them. # (The list follows the same order as the GNU Coding Standards.) bindir='${exec_prefix}/bin' sbindir='${exec_prefix}/sbin' libexecdir='${exec_prefix}/libexec' datarootdir='${prefix}/share' datadir='${datarootdir}' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' includedir='${prefix}/include' oldincludedir='/usr/include' docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' infodir='${datarootdir}/info' htmldir='${docdir}' dvidir='${docdir}' pdfdir='${docdir}' psdir='${docdir}' libdir='${exec_prefix}/lib' localedir='${datarootdir}/locale' mandir='${datarootdir}/man' ac_prev= ac_dashdash= for ac_option do # If the previous option needs an argument, assign it. if test -n "$ac_prev"; then eval $ac_prev=\$ac_option ac_prev= continue fi case $ac_option in *=*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; *) ac_optarg=yes ;; esac # Accept the important Cygnus configure options, so we can diagnose typos. case $ac_dashdash$ac_option in --) ac_dashdash=yes ;; -bindir | --bindir | --bindi | --bind | --bin | --bi) ac_prev=bindir ;; -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) bindir=$ac_optarg ;; -build | --build | --buil | --bui | --bu) ac_prev=build_alias ;; -build=* | --build=* | --buil=* | --bui=* | --bu=*) build_alias=$ac_optarg ;; -cache-file | --cache-file | --cache-fil | --cache-fi \ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) ac_prev=cache_file ;; -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) cache_file=$ac_optarg ;; --config-cache | -C) cache_file=config.cache ;; -datadir | --datadir | --datadi | --datad) ac_prev=datadir ;; -datadir=* | --datadir=* | --datadi=* | --datad=*) datadir=$ac_optarg ;; -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ | --dataroo | --dataro | --datar) ac_prev=datarootdir ;; -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) datarootdir=$ac_optarg ;; -disable-* | --disable-*) ac_feature=`expr "x$ac_option" : 'x-*disable-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_feature" : ".*[^-._$as_cr_alnum]" >/dev/null && { echo "$as_me: error: invalid feature name: $ac_feature" >&2 { (exit 1); exit 1; }; } ac_feature=`echo $ac_feature | sed 's/[-.]/_/g'` eval enable_$ac_feature=no ;; -docdir | --docdir | --docdi | --doc | --do) ac_prev=docdir ;; -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) docdir=$ac_optarg ;; -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) ac_prev=dvidir ;; -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) dvidir=$ac_optarg ;; -enable-* | --enable-*) ac_feature=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_feature" : ".*[^-._$as_cr_alnum]" >/dev/null && { echo "$as_me: error: invalid feature name: $ac_feature" >&2 { (exit 1); exit 1; }; } ac_feature=`echo $ac_feature | sed 's/[-.]/_/g'` eval enable_$ac_feature=\$ac_optarg ;; -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ | --exec | --exe | --ex) ac_prev=exec_prefix ;; -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ | --exec=* | --exe=* | --ex=*) exec_prefix=$ac_optarg ;; -gas | --gas | --ga | --g) # Obsolete; use --with-gas. with_gas=yes ;; -help | --help | --hel | --he | -h) ac_init_help=long ;; -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) ac_init_help=recursive ;; -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) ac_init_help=short ;; -host | --host | --hos | --ho) ac_prev=host_alias ;; -host=* | --host=* | --hos=* | --ho=*) host_alias=$ac_optarg ;; -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) ac_prev=htmldir ;; -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ | --ht=*) htmldir=$ac_optarg ;; -includedir | --includedir | --includedi | --included | --include \ | --includ | --inclu | --incl | --inc) ac_prev=includedir ;; -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ | --includ=* | --inclu=* | --incl=* | --inc=*) includedir=$ac_optarg ;; -infodir | --infodir | --infodi | --infod | --info | --inf) ac_prev=infodir ;; -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) infodir=$ac_optarg ;; -libdir | --libdir | --libdi | --libd) ac_prev=libdir ;; -libdir=* | --libdir=* | --libdi=* | --libd=*) libdir=$ac_optarg ;; -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ | --libexe | --libex | --libe) ac_prev=libexecdir ;; -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ | --libexe=* | --libex=* | --libe=*) libexecdir=$ac_optarg ;; -localedir | --localedir | --localedi | --localed | --locale) ac_prev=localedir ;; -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) localedir=$ac_optarg ;; -localstatedir | --localstatedir | --localstatedi | --localstated \ | --localstate | --localstat | --localsta | --localst | --locals) ac_prev=localstatedir ;; -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) localstatedir=$ac_optarg ;; -mandir | --mandir | --mandi | --mand | --man | --ma | --m) ac_prev=mandir ;; -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) mandir=$ac_optarg ;; -nfp | --nfp | --nf) # Obsolete; use --without-fp. with_fp=no ;; -no-create | --no-create | --no-creat | --no-crea | --no-cre \ | --no-cr | --no-c | -n) no_create=yes ;; -no-recursion | --no-recursion | --no-recursio | --no-recursi \ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) no_recursion=yes ;; -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ | --oldin | --oldi | --old | --ol | --o) ac_prev=oldincludedir ;; -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) oldincludedir=$ac_optarg ;; -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) ac_prev=prefix ;; -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) prefix=$ac_optarg ;; -program-prefix | --program-prefix | --program-prefi | --program-pref \ | --program-pre | --program-pr | --program-p) ac_prev=program_prefix ;; -program-prefix=* | --program-prefix=* | --program-prefi=* \ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) program_prefix=$ac_optarg ;; -program-suffix | --program-suffix | --program-suffi | --program-suff \ | --program-suf | --program-su | --program-s) ac_prev=program_suffix ;; -program-suffix=* | --program-suffix=* | --program-suffi=* \ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) program_suffix=$ac_optarg ;; -program-transform-name | --program-transform-name \ | --program-transform-nam | --program-transform-na \ | --program-transform-n | --program-transform- \ | --program-transform | --program-transfor \ | --program-transfo | --program-transf \ | --program-trans | --program-tran \ | --progr-tra | --program-tr | --program-t) ac_prev=program_transform_name ;; -program-transform-name=* | --program-transform-name=* \ | --program-transform-nam=* | --program-transform-na=* \ | --program-transform-n=* | --program-transform-=* \ | --program-transform=* | --program-transfor=* \ | --program-transfo=* | --program-transf=* \ | --program-trans=* | --program-tran=* \ | --progr-tra=* | --program-tr=* | --program-t=*) program_transform_name=$ac_optarg ;; -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) ac_prev=pdfdir ;; -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) pdfdir=$ac_optarg ;; -psdir | --psdir | --psdi | --psd | --ps) ac_prev=psdir ;; -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) psdir=$ac_optarg ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) silent=yes ;; -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ | --sbi=* | --sb=*) sbindir=$ac_optarg ;; -sharedstatedir | --sharedstatedir | --sharedstatedi \ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ | --sharedst | --shareds | --shared | --share | --shar \ | --sha | --sh) ac_prev=sharedstatedir ;; -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ | --sha=* | --sh=*) sharedstatedir=$ac_optarg ;; -site | --site | --sit) ac_prev=site ;; -site=* | --site=* | --sit=*) site=$ac_optarg ;; -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) ac_prev=srcdir ;; -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) srcdir=$ac_optarg ;; -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ | --syscon | --sysco | --sysc | --sys | --sy) ac_prev=sysconfdir ;; -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) sysconfdir=$ac_optarg ;; -target | --target | --targe | --targ | --tar | --ta | --t) ac_prev=target_alias ;; -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) target_alias=$ac_optarg ;; -v | -verbose | --verbose | --verbos | --verbo | --verb) verbose=yes ;; -version | --version | --versio | --versi | --vers | -V) ac_init_version=: ;; -with-* | --with-*) ac_package=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_package" : ".*[^-._$as_cr_alnum]" >/dev/null && { echo "$as_me: error: invalid package name: $ac_package" >&2 { (exit 1); exit 1; }; } ac_package=`echo $ac_package | sed 's/[-.]/_/g'` eval with_$ac_package=\$ac_optarg ;; -without-* | --without-*) ac_package=`expr "x$ac_option" : 'x-*without-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_package" : ".*[^-._$as_cr_alnum]" >/dev/null && { echo "$as_me: error: invalid package name: $ac_package" >&2 { (exit 1); exit 1; }; } ac_package=`echo $ac_package | sed 's/[-.]/_/g'` eval with_$ac_package=no ;; --x) # Obsolete; use --with-x. with_x=yes ;; -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ | --x-incl | --x-inc | --x-in | --x-i) ac_prev=x_includes ;; -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) x_includes=$ac_optarg ;; -x-libraries | --x-libraries | --x-librarie | --x-librari \ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) ac_prev=x_libraries ;; -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) x_libraries=$ac_optarg ;; -*) { echo "$as_me: error: unrecognized option: $ac_option Try \`$0 --help' for more information." >&2 { (exit 1); exit 1; }; } ;; *=*) ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` # Reject names that are not valid shell variable names. expr "x$ac_envvar" : ".*[^_$as_cr_alnum]" >/dev/null && { echo "$as_me: error: invalid variable name: $ac_envvar" >&2 { (exit 1); exit 1; }; } eval $ac_envvar=\$ac_optarg export $ac_envvar ;; *) # FIXME: should be removed in autoconf 3.0. echo "$as_me: WARNING: you should use --build, --host, --target" >&2 expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && echo "$as_me: WARNING: invalid host type: $ac_option" >&2 : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option} ;; esac done if test -n "$ac_prev"; then ac_option=--`echo $ac_prev | sed 's/_/-/g'` { echo "$as_me: error: missing argument to $ac_option" >&2 { (exit 1); exit 1; }; } fi # Be sure to have absolute directory names. for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ datadir sysconfdir sharedstatedir localstatedir includedir \ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ libdir localedir mandir do eval ac_val=\$$ac_var case $ac_val in [\\/$]* | ?:[\\/]* ) continue;; NONE | '' ) case $ac_var in *prefix ) continue;; esac;; esac { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2 { (exit 1); exit 1; }; } done # There might be people who depend on the old broken behavior: `$host' # used to hold the argument of --host etc. # FIXME: To remove some day. build=$build_alias host=$host_alias target=$target_alias # FIXME: To remove some day. if test "x$host_alias" != x; then if test "x$build_alias" = x; then cross_compiling=maybe echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host. If a cross compiler is detected then cross compile mode will be used." >&2 elif test "x$build_alias" != "x$host_alias"; then cross_compiling=yes fi fi ac_tool_prefix= test -n "$host_alias" && ac_tool_prefix=$host_alias- test "$silent" = yes && exec 6>/dev/null ac_pwd=`pwd` && test -n "$ac_pwd" && ac_ls_di=`ls -di .` && ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || { echo "$as_me: error: Working directory cannot be determined" >&2 { (exit 1); exit 1; }; } test "X$ac_ls_di" = "X$ac_pwd_ls_di" || { echo "$as_me: error: pwd does not report name of working directory" >&2 { (exit 1); exit 1; }; } # Find the source files, if location was not specified. if test -z "$srcdir"; then ac_srcdir_defaulted=yes # Try the directory containing this script, then the parent directory. ac_confdir=`$as_dirname -- "$0" || $as_expr X"$0" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$0" : 'X\(//\)[^/]' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || echo X"$0" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` srcdir=$ac_confdir if test ! -r "$srcdir/$ac_unique_file"; then srcdir=.. fi else ac_srcdir_defaulted=no fi if test ! -r "$srcdir/$ac_unique_file"; then test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." { echo "$as_me: error: cannot find sources ($ac_unique_file) in $srcdir" >&2 { (exit 1); exit 1; }; } fi ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" ac_abs_confdir=`( cd "$srcdir" && test -r "./$ac_unique_file" || { echo "$as_me: error: $ac_msg" >&2 { (exit 1); exit 1; }; } pwd)` # When building in place, set srcdir=. if test "$ac_abs_confdir" = "$ac_pwd"; then srcdir=. fi # Remove unnecessary trailing slashes from srcdir. # Double slashes in file names in object file debugging info # mess up M-x gdb in Emacs. case $srcdir in */) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; esac for ac_var in $ac_precious_vars; do eval ac_env_${ac_var}_set=\${${ac_var}+set} eval ac_env_${ac_var}_value=\$${ac_var} eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} eval ac_cv_env_${ac_var}_value=\$${ac_var} done # # Report the --help message. # if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF \`configure' configures Device::SerialPort 1.04 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... To assign environment variables (e.g., CC, CFLAGS...), specify them as VAR=VALUE. See below for descriptions of some of the useful variables. Defaults for the options are specified in brackets. Configuration: -h, --help display this help and exit --help=short display options specific to this package --help=recursive display the short help of all the included packages -V, --version display version information and exit -q, --quiet, --silent do not print \`checking...' messages --cache-file=FILE cache test results in FILE [disabled] -C, --config-cache alias for \`--cache-file=config.cache' -n, --no-create do not create output files --srcdir=DIR find the sources in DIR [configure dir or \`..'] Installation directories: --prefix=PREFIX install architecture-independent files in PREFIX [$ac_default_prefix] --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX [PREFIX] By default, \`make install' will install all the files in \`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify an installation prefix other than \`$ac_default_prefix' using \`--prefix', for instance \`--prefix=\$HOME'. For better control, use the options below. Fine tuning of the installation directories: --bindir=DIR user executables [EPREFIX/bin] --sbindir=DIR system admin executables [EPREFIX/sbin] --libexecdir=DIR program executables [EPREFIX/libexec] --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --oldincludedir=DIR C header files for non-gcc [/usr/include] --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] --datadir=DIR read-only architecture-independent data [DATAROOTDIR] --infodir=DIR info documentation [DATAROOTDIR/info] --localedir=DIR locale-dependent data [DATAROOTDIR/locale] --mandir=DIR man documentation [DATAROOTDIR/man] --docdir=DIR documentation root [DATAROOTDIR/doc/device--serialport] --htmldir=DIR html documentation [DOCDIR] --dvidir=DIR dvi documentation [DOCDIR] --pdfdir=DIR pdf documentation [DOCDIR] --psdir=DIR ps documentation [DOCDIR] _ACEOF cat <<\_ACEOF _ACEOF fi if test -n "$ac_init_help"; then case $ac_init_help in short | recursive ) echo "Configuration of Device::SerialPort 1.04:";; esac cat <<\_ACEOF Some influential environment variables: CC C compiler command CFLAGS C compiler flags LDFLAGS linker flags, e.g. -L if you have libraries in a nonstandard directory LIBS libraries to pass to the linker, e.g. -l CPPFLAGS C/C++/Objective C preprocessor flags, e.g. -I if you have headers in a nonstandard directory CPP C preprocessor Use these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations. Report bugs to . _ACEOF ac_status=$? fi if test "$ac_init_help" = "recursive"; then # If there are subdirs, report their specific --help. for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue test -d "$ac_dir" || continue ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,/..,g;s,/,,'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix cd "$ac_dir" || { ac_status=$?; continue; } # Check for guested configure. if test -f "$ac_srcdir/configure.gnu"; then echo && $SHELL "$ac_srcdir/configure.gnu" --help=recursive elif test -f "$ac_srcdir/configure"; then echo && $SHELL "$ac_srcdir/configure" --help=recursive else echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 fi || ac_status=$? cd "$ac_pwd" || { ac_status=$?; break; } done fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF Device::SerialPort configure 1.04 generated by GNU Autoconf 2.61 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. _ACEOF exit fi cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. It was created by Device::SerialPort $as_me 1.04, which was generated by GNU Autoconf 2.61. Invocation command line was $ $0 $@ _ACEOF exec 5>>config.log { cat <<_ASUNAME ## --------- ## ## Platform. ## ## --------- ## hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` uname -m = `(uname -m) 2>/dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` /bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` /bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` /usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` /bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` /bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` _ASUNAME as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. echo "PATH: $as_dir" done IFS=$as_save_IFS } >&5 cat >&5 <<_ACEOF ## ----------- ## ## Core tests. ## ## ----------- ## _ACEOF # Keep a trace of the command line. # Strip out --no-create and --no-recursion so they do not pile up. # Strip out --silent because we don't want to record it for future runs. # Also quote any args containing shell meta-characters. # Make two passes to allow for proper duplicate-argument suppression. ac_configure_args= ac_configure_args0= ac_configure_args1= ac_must_keep_next=false for ac_pass in 1 2 do for ac_arg do case $ac_arg in -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) continue ;; *\'*) ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; esac case $ac_pass in 1) ac_configure_args0="$ac_configure_args0 '$ac_arg'" ;; 2) ac_configure_args1="$ac_configure_args1 '$ac_arg'" if test $ac_must_keep_next = true; then ac_must_keep_next=false # Got value, back to normal. else case $ac_arg in *=* | --config-cache | -C | -disable-* | --disable-* \ | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ | -with-* | --with-* | -without-* | --without-* | --x) case "$ac_configure_args0 " in "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; esac ;; -* ) ac_must_keep_next=true ;; esac fi ac_configure_args="$ac_configure_args '$ac_arg'" ;; esac done done $as_unset ac_configure_args0 || test "${ac_configure_args0+set}" != set || { ac_configure_args0=; export ac_configure_args0; } $as_unset ac_configure_args1 || test "${ac_configure_args1+set}" != set || { ac_configure_args1=; export ac_configure_args1; } # When interrupted or exit'd, cleanup temporary files, and complete # config.log. We remove comments because anyway the quotes in there # would cause problems or look ugly. # WARNING: Use '\'' to represent an apostrophe within the trap. # WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. trap 'exit_status=$? # Save into config.log some information that might help in debugging. { echo cat <<\_ASBOX ## ---------------- ## ## Cache variables. ## ## ---------------- ## _ASBOX echo # The following way of writing the cache mishandles newlines in values, ( for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { echo "$as_me:$LINENO: WARNING: Cache variable $ac_var contains a newline." >&5 echo "$as_me: WARNING: Cache variable $ac_var contains a newline." >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( *) $as_unset $ac_var ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( *${as_nl}ac_space=\ *) sed -n \ "s/'\''/'\''\\\\'\'''\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" ;; #( *) sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) echo cat <<\_ASBOX ## ----------------- ## ## Output variables. ## ## ----------------- ## _ASBOX echo for ac_var in $ac_subst_vars do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac echo "$ac_var='\''$ac_val'\''" done | sort echo if test -n "$ac_subst_files"; then cat <<\_ASBOX ## ------------------- ## ## File substitutions. ## ## ------------------- ## _ASBOX echo for ac_var in $ac_subst_files do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac echo "$ac_var='\''$ac_val'\''" done | sort echo fi if test -s confdefs.h; then cat <<\_ASBOX ## ----------- ## ## confdefs.h. ## ## ----------- ## _ASBOX echo cat confdefs.h echo fi test "$ac_signal" != 0 && echo "$as_me: caught signal $ac_signal" echo "$as_me: exit $exit_status" } >&5 rm -f core *.core core.conftest.* && rm -f -r conftest* confdefs* conf$$* $ac_clean_files && exit $exit_status ' 0 for ac_signal in 1 2 13 15; do trap 'ac_signal='$ac_signal'; { (exit 1); exit 1; }' $ac_signal done ac_signal=0 # confdefs.h avoids OS command line length limits that DEFS can exceed. rm -f -r conftest* confdefs.h # Predefined preprocessor variables. cat >>confdefs.h <<_ACEOF #define PACKAGE_NAME "$PACKAGE_NAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_TARNAME "$PACKAGE_TARNAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_VERSION "$PACKAGE_VERSION" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_STRING "$PACKAGE_STRING" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" _ACEOF # Let the site file select an alternate cache file if it wants to. # Prefer explicitly selected file to automatically selected ones. if test -n "$CONFIG_SITE"; then set x "$CONFIG_SITE" elif test "x$prefix" != xNONE; then set x "$prefix/share/config.site" "$prefix/etc/config.site" else set x "$ac_default_prefix/share/config.site" \ "$ac_default_prefix/etc/config.site" fi shift for ac_site_file do if test -r "$ac_site_file"; then { echo "$as_me:$LINENO: loading site script $ac_site_file" >&5 echo "$as_me: loading site script $ac_site_file" >&6;} sed 's/^/| /' "$ac_site_file" >&5 . "$ac_site_file" fi done if test -r "$cache_file"; then # Some versions of bash will fail to source /dev/null (special # files actually), so we avoid doing that. if test -f "$cache_file"; then { echo "$as_me:$LINENO: loading cache $cache_file" >&5 echo "$as_me: loading cache $cache_file" >&6;} case $cache_file in [\\/]* | ?:[\\/]* ) . "$cache_file";; *) . "./$cache_file";; esac fi else { echo "$as_me:$LINENO: creating cache $cache_file" >&5 echo "$as_me: creating cache $cache_file" >&6;} >$cache_file fi # Check that the precious variables saved in the cache have kept the same # value. ac_cache_corrupted=false for ac_var in $ac_precious_vars; do eval ac_old_set=\$ac_cv_env_${ac_var}_set eval ac_new_set=\$ac_env_${ac_var}_set eval ac_old_val=\$ac_cv_env_${ac_var}_value eval ac_new_val=\$ac_env_${ac_var}_value case $ac_old_set,$ac_new_set in set,) { echo "$as_me:$LINENO: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} ac_cache_corrupted=: ;; ,set) { echo "$as_me:$LINENO: error: \`$ac_var' was not set in the previous run" >&5 echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} ac_cache_corrupted=: ;; ,);; *) if test "x$ac_old_val" != "x$ac_new_val"; then { echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5 echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} { echo "$as_me:$LINENO: former value: $ac_old_val" >&5 echo "$as_me: former value: $ac_old_val" >&2;} { echo "$as_me:$LINENO: current value: $ac_new_val" >&5 echo "$as_me: current value: $ac_new_val" >&2;} ac_cache_corrupted=: fi;; esac # Pass precious variables to config.status. if test "$ac_new_set" = set; then case $ac_new_val in *\'*) ac_arg=$ac_var=`echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; *) ac_arg=$ac_var=$ac_new_val ;; esac case " $ac_configure_args " in *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. *) ac_configure_args="$ac_configure_args '$ac_arg'" ;; esac fi done if $ac_cache_corrupted; then { echo "$as_me:$LINENO: error: changes in the environment can compromise the build" >&5 echo "$as_me: error: changes in the environment can compromise the build" >&2;} { { echo "$as_me:$LINENO: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5 echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&2;} { (exit 1); exit 1; }; } fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_config_headers="$ac_config_headers config.h" ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. set dummy ${ac_tool_prefix}gcc; ac_word=$2 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="${ac_tool_prefix}gcc" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { echo "$as_me:$LINENO: result: $CC" >&5 echo "${ECHO_T}$CC" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } fi fi if test -z "$ac_cv_prog_CC"; then ac_ct_CC=$CC # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_ac_ct_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_CC="gcc" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 echo "${ECHO_T}$ac_ct_CC" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } fi if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools whose name does not start with the host triplet. If you think this configuration is useful to you, please write to autoconf@gnu.org." >&5 echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools whose name does not start with the host triplet. If you think this configuration is useful to you, please write to autoconf@gnu.org." >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi else CC="$ac_cv_prog_CC" fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. set dummy ${ac_tool_prefix}cc; ac_word=$2 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="${ac_tool_prefix}cc" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { echo "$as_me:$LINENO: result: $CC" >&5 echo "${ECHO_T}$CC" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } fi fi fi if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else ac_prog_rejected=no as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue fi ac_cv_prog_CC="cc" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS if test $ac_prog_rejected = yes; then # We found a bogon in the path, so make sure we never use it. set dummy $ac_cv_prog_CC shift if test $# != 0; then # We chose a different compiler from the bogus one. # However, it has the same basename, so the bogon will be chosen # first if we set CC to just the basename; use the full file name. shift ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" fi fi fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { echo "$as_me:$LINENO: result: $CC" >&5 echo "${ECHO_T}$CC" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } fi fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then for ac_prog in cl.exe do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="$ac_tool_prefix$ac_prog" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { echo "$as_me:$LINENO: result: $CC" >&5 echo "${ECHO_T}$CC" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } fi test -n "$CC" && break done fi if test -z "$CC"; then ac_ct_CC=$CC for ac_prog in cl.exe do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_ac_ct_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_CC="$ac_prog" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 echo "${ECHO_T}$ac_ct_CC" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } fi test -n "$ac_ct_CC" && break done if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools whose name does not start with the host triplet. If you think this configuration is useful to you, please write to autoconf@gnu.org." >&5 echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools whose name does not start with the host triplet. If you think this configuration is useful to you, please write to autoconf@gnu.org." >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi fi fi test -z "$CC" && { { echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH See \`config.log' for more details." >&5 echo "$as_me: error: no acceptable C compiler found in \$PATH See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } # Provide some information about the compiler. echo "$as_me:$LINENO: checking for C compiler version" >&5 ac_compiler=`set X $ac_compile; echo $2` { (ac_try="$ac_compiler --version >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compiler --version >&5") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } { (ac_try="$ac_compiler -v >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compiler -v >&5") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } { (ac_try="$ac_compiler -V >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compiler -V >&5") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { ; return 0; } _ACEOF ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files a.out a.exe b.out" # Try to create an executable without -o first, disregard a.out. # It will help us diagnose broken compilers, and finding out an intuition # of exeext. { echo "$as_me:$LINENO: checking for C compiler default output file name" >&5 echo $ECHO_N "checking for C compiler default output file name... $ECHO_C" >&6; } ac_link_default=`echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` # # List of possible output files, starting from the most likely. # The algorithm is not robust to junk in `.', hence go to wildcards (a.*) # only as a last resort. b.out is created by i960 compilers. ac_files='a_out.exe a.exe conftest.exe a.out conftest a.* conftest.* b.out' # # The IRIX 6 linker writes into existing files which may not be # executable, retaining their permissions. Remove them first so a # subsequent execution test works. ac_rmfiles= for ac_file in $ac_files do case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.o | *.obj ) ;; * ) ac_rmfiles="$ac_rmfiles $ac_file";; esac done rm -f $ac_rmfiles if { (ac_try="$ac_link_default" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link_default") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; then # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. # So ignore a value of `no', otherwise this would lead to `EXEEXT = no' # in a Makefile. We should not override ac_cv_exeext if it was cached, # so that the user can short-circuit this test for compilers unknown to # Autoconf. for ac_file in $ac_files '' do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.o | *.obj ) ;; [ab].out ) # We found the default executable, but exeext='' is most # certainly right. break;; *.* ) if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; then :; else ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` fi # We set ac_cv_exeext here because the later test for it is not # safe: cross compilers may not add the suffix if given an `-o' # argument, so we may need to know it at that point already. # Even if this section looks crufty: it has the advantage of # actually working. break;; * ) break;; esac done test "$ac_cv_exeext" = no && ac_cv_exeext= else ac_file='' fi { echo "$as_me:$LINENO: result: $ac_file" >&5 echo "${ECHO_T}$ac_file" >&6; } if test -z "$ac_file"; then echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { echo "$as_me:$LINENO: error: C compiler cannot create executables See \`config.log' for more details." >&5 echo "$as_me: error: C compiler cannot create executables See \`config.log' for more details." >&2;} { (exit 77); exit 77; }; } fi ac_exeext=$ac_cv_exeext # Check that the compiler produces executables we can run. If not, either # the compiler is broken, or we cross compile. { echo "$as_me:$LINENO: checking whether the C compiler works" >&5 echo $ECHO_N "checking whether the C compiler works... $ECHO_C" >&6; } # FIXME: These cross compiler hacks should be removed for Autoconf 3.0 # If not cross compiling, check that we can run a simple program. if test "$cross_compiling" != yes; then if { ac_try='./$ac_file' { (case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_try") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then cross_compiling=no else if test "$cross_compiling" = maybe; then cross_compiling=yes else { { echo "$as_me:$LINENO: error: cannot run C compiled programs. If you meant to cross compile, use \`--host'. See \`config.log' for more details." >&5 echo "$as_me: error: cannot run C compiled programs. If you meant to cross compile, use \`--host'. See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } fi fi fi { echo "$as_me:$LINENO: result: yes" >&5 echo "${ECHO_T}yes" >&6; } rm -f a.out a.exe conftest$ac_cv_exeext b.out ac_clean_files=$ac_clean_files_save # Check that the compiler produces executables we can run. If not, either # the compiler is broken, or we cross compile. { echo "$as_me:$LINENO: checking whether we are cross compiling" >&5 echo $ECHO_N "checking whether we are cross compiling... $ECHO_C" >&6; } { echo "$as_me:$LINENO: result: $cross_compiling" >&5 echo "${ECHO_T}$cross_compiling" >&6; } { echo "$as_me:$LINENO: checking for suffix of executables" >&5 echo $ECHO_N "checking for suffix of executables... $ECHO_C" >&6; } if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; then # If both `conftest.exe' and `conftest' are `present' (well, observable) # catch `conftest.exe'. For instance with Cygwin, `ls conftest' will # work properly (i.e., refer to `conftest.exe'), while it won't with # `rm'. for ac_file in conftest.exe conftest conftest.*; do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.o | *.obj ) ;; *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` break;; * ) break;; esac done else { { echo "$as_me:$LINENO: error: cannot compute suffix of executables: cannot compile and link See \`config.log' for more details." >&5 echo "$as_me: error: cannot compute suffix of executables: cannot compile and link See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } fi rm -f conftest$ac_cv_exeext { echo "$as_me:$LINENO: result: $ac_cv_exeext" >&5 echo "${ECHO_T}$ac_cv_exeext" >&6; } rm -f conftest.$ac_ext EXEEXT=$ac_cv_exeext ac_exeext=$EXEEXT { echo "$as_me:$LINENO: checking for suffix of object files" >&5 echo $ECHO_N "checking for suffix of object files... $ECHO_C" >&6; } if test "${ac_cv_objext+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.o conftest.obj if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; then for ac_file in conftest.o conftest.obj conftest.*; do test -f "$ac_file" || continue; case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf ) ;; *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` break;; esac done else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { echo "$as_me:$LINENO: error: cannot compute suffix of object files: cannot compile See \`config.log' for more details." >&5 echo "$as_me: error: cannot compute suffix of object files: cannot compile See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } fi rm -f conftest.$ac_cv_objext conftest.$ac_ext fi { echo "$as_me:$LINENO: result: $ac_cv_objext" >&5 echo "${ECHO_T}$ac_cv_objext" >&6; } OBJEXT=$ac_cv_objext ac_objext=$OBJEXT { echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5 echo $ECHO_N "checking whether we are using the GNU C compiler... $ECHO_C" >&6; } if test "${ac_cv_c_compiler_gnu+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { #ifndef __GNUC__ choke me #endif ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_compiler_gnu=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_compiler_gnu=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_c_compiler_gnu=$ac_compiler_gnu fi { echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5 echo "${ECHO_T}$ac_cv_c_compiler_gnu" >&6; } GCC=`test $ac_compiler_gnu = yes && echo yes` ac_test_CFLAGS=${CFLAGS+set} ac_save_CFLAGS=$CFLAGS { echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5 echo $ECHO_N "checking whether $CC accepts -g... $ECHO_C" >&6; } if test "${ac_cv_prog_cc_g+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_save_c_werror_flag=$ac_c_werror_flag ac_c_werror_flag=yes ac_cv_prog_cc_g=no CFLAGS="-g" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_cv_prog_cc_g=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 CFLAGS="" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then : else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_c_werror_flag=$ac_save_c_werror_flag CFLAGS="-g" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_cv_prog_cc_g=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_c_werror_flag=$ac_save_c_werror_flag fi { echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5 echo "${ECHO_T}$ac_cv_prog_cc_g" >&6; } if test "$ac_test_CFLAGS" = set; then CFLAGS=$ac_save_CFLAGS elif test $ac_cv_prog_cc_g = yes; then if test "$GCC" = yes; then CFLAGS="-g -O2" else CFLAGS="-g" fi else if test "$GCC" = yes; then CFLAGS="-O2" else CFLAGS= fi fi { echo "$as_me:$LINENO: checking for $CC option to accept ISO C89" >&5 echo $ECHO_N "checking for $CC option to accept ISO C89... $ECHO_C" >&6; } if test "${ac_cv_prog_cc_c89+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_cv_prog_cc_c89=no ac_save_CC=$CC cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include #include #include /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ struct buf { int x; }; FILE * (*rcsopen) (struct buf *, struct stat *, int); static char *e (p, i) char **p; int i; { return p[i]; } static char *f (char * (*g) (char **, int), char **p, ...) { char *s; va_list v; va_start (v,p); s = g (p, va_arg (v,int)); va_end (v); return s; } /* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has function prototypes and stuff, but not '\xHH' hex character constants. These don't provoke an error unfortunately, instead are silently treated as 'x'. The following induces an error, until -std is added to get proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an array size at least. It's necessary to write '\x00'==0 to get something that's true only with -std. */ int osf4_cc_array ['\x00' == 0 ? 1 : -1]; /* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters inside strings and character constants. */ #define FOO(x) 'x' int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; int test (int i, double x); struct s1 {int (*f) (int a);}; struct s2 {int (*f) (double a);}; int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); int argc; char **argv; int main () { return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; ; return 0; } _ACEOF for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" do CC="$ac_save_CC $ac_arg" rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_cv_prog_cc_c89=$ac_arg else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f core conftest.err conftest.$ac_objext test "x$ac_cv_prog_cc_c89" != "xno" && break done rm -f conftest.$ac_ext CC=$ac_save_CC fi # AC_CACHE_VAL case "x$ac_cv_prog_cc_c89" in x) { echo "$as_me:$LINENO: result: none needed" >&5 echo "${ECHO_T}none needed" >&6; } ;; xno) { echo "$as_me:$LINENO: result: unsupported" >&5 echo "${ECHO_T}unsupported" >&6; } ;; *) CC="$CC $ac_cv_prog_cc_c89" { echo "$as_me:$LINENO: result: $ac_cv_prog_cc_c89" >&5 echo "${ECHO_T}$ac_cv_prog_cc_c89" >&6; } ;; esac ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu case $ac_cv_prog_cc_stdc in no) ac_cv_prog_cc_c99=no; ac_cv_prog_cc_c89=no ;; *) { echo "$as_me:$LINENO: checking for $CC option to accept ISO C99" >&5 echo $ECHO_N "checking for $CC option to accept ISO C99... $ECHO_C" >&6; } if test "${ac_cv_prog_cc_c99+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_cv_prog_cc_c99=no ac_save_CC=$CC cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include #include #include #include // Check varargs macros. These examples are taken from C99 6.10.3.5. #define debug(...) fprintf (stderr, __VA_ARGS__) #define showlist(...) puts (#__VA_ARGS__) #define report(test,...) ((test) ? puts (#test) : printf (__VA_ARGS__)) static void test_varargs_macros (void) { int x = 1234; int y = 5678; debug ("Flag"); debug ("X = %d\n", x); showlist (The first, second, and third items.); report (x>y, "x is %d but y is %d", x, y); } // Check long long types. #define BIG64 18446744073709551615ull #define BIG32 4294967295ul #define BIG_OK (BIG64 / BIG32 == 4294967297ull && BIG64 % BIG32 == 0) #if !BIG_OK your preprocessor is broken; #endif #if BIG_OK #else your preprocessor is broken; #endif static long long int bignum = -9223372036854775807LL; static unsigned long long int ubignum = BIG64; struct incomplete_array { int datasize; double data[]; }; struct named_init { int number; const wchar_t *name; double average; }; typedef const char *ccp; static inline int test_restrict (ccp restrict text) { // See if C++-style comments work. // Iterate through items via the restricted pointer. // Also check for declarations in for loops. for (unsigned int i = 0; *(text+i) != '\0'; ++i) continue; return 0; } // Check varargs and va_copy. static void test_varargs (const char *format, ...) { va_list args; va_start (args, format); va_list args_copy; va_copy (args_copy, args); const char *str; int number; float fnumber; while (*format) { switch (*format++) { case 's': // string str = va_arg (args_copy, const char *); break; case 'd': // int number = va_arg (args_copy, int); break; case 'f': // float fnumber = va_arg (args_copy, double); break; default: break; } } va_end (args_copy); va_end (args); } int main () { // Check bool. _Bool success = false; // Check restrict. if (test_restrict ("String literal") == 0) success = true; char *restrict newvar = "Another string"; // Check varargs. test_varargs ("s, d' f .", "string", 65, 34.234); test_varargs_macros (); // Check flexible array members. struct incomplete_array *ia = malloc (sizeof (struct incomplete_array) + (sizeof (double) * 10)); ia->datasize = 10; for (int i = 0; i < ia->datasize; ++i) ia->data[i] = i * 1.234; // Check named initializers. struct named_init ni = { .number = 34, .name = L"Test wide string", .average = 543.34343, }; ni.number = 58; int dynamic_array[ni.number]; dynamic_array[ni.number - 1] = 543; // work around unused variable warnings return (!success || bignum == 0LL || ubignum == 0uLL || newvar[0] == 'x' || dynamic_array[ni.number - 1] != 543); ; return 0; } _ACEOF for ac_arg in '' -std=gnu99 -c99 -qlanglvl=extc99 do CC="$ac_save_CC $ac_arg" rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_cv_prog_cc_c99=$ac_arg else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f core conftest.err conftest.$ac_objext test "x$ac_cv_prog_cc_c99" != "xno" && break done rm -f conftest.$ac_ext CC=$ac_save_CC fi # AC_CACHE_VAL case "x$ac_cv_prog_cc_c99" in x) { echo "$as_me:$LINENO: result: none needed" >&5 echo "${ECHO_T}none needed" >&6; } ;; xno) { echo "$as_me:$LINENO: result: unsupported" >&5 echo "${ECHO_T}unsupported" >&6; } ;; *) CC="$CC $ac_cv_prog_cc_c99" { echo "$as_me:$LINENO: result: $ac_cv_prog_cc_c99" >&5 echo "${ECHO_T}$ac_cv_prog_cc_c99" >&6; } ;; esac if test "x$ac_cv_prog_cc_c99" != xno; then ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c99 else { echo "$as_me:$LINENO: checking for $CC option to accept ISO C89" >&5 echo $ECHO_N "checking for $CC option to accept ISO C89... $ECHO_C" >&6; } if test "${ac_cv_prog_cc_c89+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_cv_prog_cc_c89=no ac_save_CC=$CC cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include #include #include /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ struct buf { int x; }; FILE * (*rcsopen) (struct buf *, struct stat *, int); static char *e (p, i) char **p; int i; { return p[i]; } static char *f (char * (*g) (char **, int), char **p, ...) { char *s; va_list v; va_start (v,p); s = g (p, va_arg (v,int)); va_end (v); return s; } /* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has function prototypes and stuff, but not '\xHH' hex character constants. These don't provoke an error unfortunately, instead are silently treated as 'x'. The following induces an error, until -std is added to get proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an array size at least. It's necessary to write '\x00'==0 to get something that's true only with -std. */ int osf4_cc_array ['\x00' == 0 ? 1 : -1]; /* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters inside strings and character constants. */ #define FOO(x) 'x' int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; int test (int i, double x); struct s1 {int (*f) (int a);}; struct s2 {int (*f) (double a);}; int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); int argc; char **argv; int main () { return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; ; return 0; } _ACEOF for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" do CC="$ac_save_CC $ac_arg" rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_cv_prog_cc_c89=$ac_arg else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f core conftest.err conftest.$ac_objext test "x$ac_cv_prog_cc_c89" != "xno" && break done rm -f conftest.$ac_ext CC=$ac_save_CC fi # AC_CACHE_VAL case "x$ac_cv_prog_cc_c89" in x) { echo "$as_me:$LINENO: result: none needed" >&5 echo "${ECHO_T}none needed" >&6; } ;; xno) { echo "$as_me:$LINENO: result: unsupported" >&5 echo "${ECHO_T}unsupported" >&6; } ;; *) CC="$CC $ac_cv_prog_cc_c89" { echo "$as_me:$LINENO: result: $ac_cv_prog_cc_c89" >&5 echo "${ECHO_T}$ac_cv_prog_cc_c89" >&6; } ;; esac if test "x$ac_cv_prog_cc_c89" != xno; then ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c89 else ac_cv_prog_cc_stdc=no fi fi ;; esac { echo "$as_me:$LINENO: checking for $CC option to accept ISO Standard C" >&5 echo $ECHO_N "checking for $CC option to accept ISO Standard C... $ECHO_C" >&6; } if test "${ac_cv_prog_cc_stdc+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 fi case $ac_cv_prog_cc_stdc in no) { echo "$as_me:$LINENO: result: unsupported" >&5 echo "${ECHO_T}unsupported" >&6; } ;; '') { echo "$as_me:$LINENO: result: none needed" >&5 echo "${ECHO_T}none needed" >&6; } ;; *) { echo "$as_me:$LINENO: result: $ac_cv_prog_cc_stdc" >&5 echo "${ECHO_T}$ac_cv_prog_cc_stdc" >&6; } ;; esac ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { echo "$as_me:$LINENO: checking how to run the C preprocessor" >&5 echo $ECHO_N "checking how to run the C preprocessor... $ECHO_C" >&6; } # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= fi if test -z "$CPP"; then if test "${ac_cv_prog_CPP+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else # Double quotes because CPP needs to be expanded for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" do ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if { (ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then : else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 # Broken: fails on valid input. continue fi rm -f conftest.err conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _ACEOF if { (ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then # Broken: success on invalid input. continue else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.err conftest.$ac_ext if $ac_preproc_ok; then break fi done ac_cv_prog_CPP=$CPP fi CPP=$ac_cv_prog_CPP else ac_cv_prog_CPP=$CPP fi { echo "$as_me:$LINENO: result: $CPP" >&5 echo "${ECHO_T}$CPP" >&6; } ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if { (ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then : else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 # Broken: fails on valid input. continue fi rm -f conftest.err conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _ACEOF if { (ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then # Broken: success on invalid input. continue else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.err conftest.$ac_ext if $ac_preproc_ok; then : else { { echo "$as_me:$LINENO: error: C preprocessor \"$CPP\" fails sanity check See \`config.log' for more details." >&5 echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { echo "$as_me:$LINENO: checking for grep that handles long lines and -e" >&5 echo $ECHO_N "checking for grep that handles long lines and -e... $ECHO_C" >&6; } if test "${ac_cv_path_GREP+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else # Extract the first word of "grep ggrep" to use in msg output if test -z "$GREP"; then set dummy grep ggrep; ac_prog_name=$2 if test "${ac_cv_path_GREP+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_path_GREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in grep ggrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue # Check for GNU ac_path_GREP and select it if it is found. # Check for GNU $ac_path_GREP case `"$ac_path_GREP" --version 2>&1` in *GNU*) ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; *) ac_count=0 echo $ECHO_N "0123456789$ECHO_C" >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" echo 'GREP' >> "conftest.nl" "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break ac_count=`expr $ac_count + 1` if test $ac_count -gt ${ac_path_GREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_GREP_found && break 3 done done done IFS=$as_save_IFS fi GREP="$ac_cv_path_GREP" if test -z "$GREP"; then { { echo "$as_me:$LINENO: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5 echo "$as_me: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;} { (exit 1); exit 1; }; } fi else ac_cv_path_GREP=$GREP fi fi { echo "$as_me:$LINENO: result: $ac_cv_path_GREP" >&5 echo "${ECHO_T}$ac_cv_path_GREP" >&6; } GREP="$ac_cv_path_GREP" { echo "$as_me:$LINENO: checking for egrep" >&5 echo $ECHO_N "checking for egrep... $ECHO_C" >&6; } if test "${ac_cv_path_EGREP+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 then ac_cv_path_EGREP="$GREP -E" else # Extract the first word of "egrep" to use in msg output if test -z "$EGREP"; then set dummy egrep; ac_prog_name=$2 if test "${ac_cv_path_EGREP+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_path_EGREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in egrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue # Check for GNU ac_path_EGREP and select it if it is found. # Check for GNU $ac_path_EGREP case `"$ac_path_EGREP" --version 2>&1` in *GNU*) ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; *) ac_count=0 echo $ECHO_N "0123456789$ECHO_C" >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" echo 'EGREP' >> "conftest.nl" "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break ac_count=`expr $ac_count + 1` if test $ac_count -gt ${ac_path_EGREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_EGREP_found && break 3 done done done IFS=$as_save_IFS fi EGREP="$ac_cv_path_EGREP" if test -z "$EGREP"; then { { echo "$as_me:$LINENO: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5 echo "$as_me: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;} { (exit 1); exit 1; }; } fi else ac_cv_path_EGREP=$EGREP fi fi fi { echo "$as_me:$LINENO: result: $ac_cv_path_EGREP" >&5 echo "${ECHO_T}$ac_cv_path_EGREP" >&6; } EGREP="$ac_cv_path_EGREP" { echo "$as_me:$LINENO: checking for ANSI C header files" >&5 echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6; } if test "${ac_cv_header_stdc+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include #include #include int main () { ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_cv_header_stdc=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_header_stdc=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "memchr" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "free" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. if test "$cross_compiling" = yes; then : else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include #if ((' ' & 0x0FF) == 0x020) # define ISLOWER(c) ('a' <= (c) && (c) <= 'z') # define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) #else # define ISLOWER(c) \ (('a' <= (c) && (c) <= 'i') \ || ('j' <= (c) && (c) <= 'r') \ || ('s' <= (c) && (c) <= 'z')) # define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) #endif #define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) int main () { int i; for (i = 0; i < 256; i++) if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) return 2; return 0; } _ACEOF rm -f conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='./conftest$ac_exeext' { (case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_try") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then : else echo "$as_me: program exited with status $ac_status" >&5 echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) ac_cv_header_stdc=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi fi fi { echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5 echo "${ECHO_T}$ac_cv_header_stdc" >&6; } if test $ac_cv_header_stdc = yes; then cat >>confdefs.h <<\_ACEOF #define STDC_HEADERS 1 _ACEOF fi { echo "$as_me:$LINENO: checking for library containing strerror" >&5 echo $ECHO_N "checking for library containing strerror... $ECHO_C" >&6; } if test "${ac_cv_search_strerror+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_func_search_save_LIBS=$LIBS cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char strerror (); int main () { return strerror (); ; return 0; } _ACEOF for ac_lib in '' cposix; do if test -z "$ac_lib"; then ac_res="none required" else ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi rm -f conftest.$ac_objext conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && $as_test_x conftest$ac_exeext; then ac_cv_search_strerror=$ac_res else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext if test "${ac_cv_search_strerror+set}" = set; then break fi done if test "${ac_cv_search_strerror+set}" = set; then : else ac_cv_search_strerror=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi { echo "$as_me:$LINENO: result: $ac_cv_search_strerror" >&5 echo "${ECHO_T}$ac_cv_search_strerror" >&6; } ac_res=$ac_cv_search_strerror if test "$ac_res" != no; then test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" fi # On IRIX 5.3, sys/types and inttypes.h are conflicting. for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ inttypes.h stdint.h unistd.h do as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` { echo "$as_me:$LINENO: checking for $ac_header" >&5 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default #include <$ac_header> _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then eval "$as_ac_Header=yes" else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 eval "$as_ac_Header=no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi ac_res=`eval echo '${'$as_ac_Header'}'` { echo "$as_me:$LINENO: result: $ac_res" >&5 echo "${ECHO_T}$ac_res" >&6; } if test `eval echo '${'$as_ac_Header'}'` = yes; then cat >>confdefs.h <<_ACEOF #define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done for ac_header in sys/ioctl.h do as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then { echo "$as_me:$LINENO: checking for $ac_header" >&5 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then echo $ECHO_N "(cached) $ECHO_C" >&6 fi ac_res=`eval echo '${'$as_ac_Header'}'` { echo "$as_me:$LINENO: result: $ac_res" >&5 echo "${ECHO_T}$ac_res" >&6; } else # Is the header compilable? { echo "$as_me:$LINENO: checking $ac_header usability" >&5 echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default #include <$ac_header> _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_header_compiler=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_compiler=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 echo "${ECHO_T}$ac_header_compiler" >&6; } # Is the header present? { echo "$as_me:$LINENO: checking $ac_header presence" >&5 echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include <$ac_header> _ACEOF if { (ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then ac_header_preproc=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_preproc=no fi rm -f conftest.err conftest.$ac_ext { echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 echo "${ECHO_T}$ac_header_preproc" >&6; } # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in yes:no: ) { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} ac_header_preproc=yes ;; no:yes:* ) { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} ( cat <<\_ASBOX ## -------------------------------------- ## ## Report this to devser-bugs@outflux.net ## ## -------------------------------------- ## _ASBOX ) | sed "s/^/$as_me: WARNING: /" >&2 ;; esac { echo "$as_me:$LINENO: checking for $ac_header" >&5 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then echo $ECHO_N "(cached) $ECHO_C" >&6 else eval "$as_ac_Header=\$ac_header_preproc" fi ac_res=`eval echo '${'$as_ac_Header'}'` { echo "$as_me:$LINENO: result: $ac_res" >&5 echo "${ECHO_T}$ac_res" >&6; } fi if test `eval echo '${'$as_ac_Header'}'` = yes; then cat >>confdefs.h <<_ACEOF #define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done for ac_header in termios.h do as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then { echo "$as_me:$LINENO: checking for $ac_header" >&5 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then echo $ECHO_N "(cached) $ECHO_C" >&6 fi ac_res=`eval echo '${'$as_ac_Header'}'` { echo "$as_me:$LINENO: result: $ac_res" >&5 echo "${ECHO_T}$ac_res" >&6; } else # Is the header compilable? { echo "$as_me:$LINENO: checking $ac_header usability" >&5 echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default #include <$ac_header> _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_header_compiler=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_compiler=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 echo "${ECHO_T}$ac_header_compiler" >&6; } # Is the header present? { echo "$as_me:$LINENO: checking $ac_header presence" >&5 echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include <$ac_header> _ACEOF if { (ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then ac_header_preproc=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_preproc=no fi rm -f conftest.err conftest.$ac_ext { echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 echo "${ECHO_T}$ac_header_preproc" >&6; } # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in yes:no: ) { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} ac_header_preproc=yes ;; no:yes:* ) { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} ( cat <<\_ASBOX ## -------------------------------------- ## ## Report this to devser-bugs@outflux.net ## ## -------------------------------------- ## _ASBOX ) | sed "s/^/$as_me: WARNING: /" >&2 ;; esac { echo "$as_me:$LINENO: checking for $ac_header" >&5 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then echo $ECHO_N "(cached) $ECHO_C" >&6 else eval "$as_ac_Header=\$ac_header_preproc" fi ac_res=`eval echo '${'$as_ac_Header'}'` { echo "$as_me:$LINENO: result: $ac_res" >&5 echo "${ECHO_T}$ac_res" >&6; } fi if test `eval echo '${'$as_ac_Header'}'` = yes; then cat >>confdefs.h <<_ACEOF #define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done for ac_header in sys/termiox.h do as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then { echo "$as_me:$LINENO: checking for $ac_header" >&5 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then echo $ECHO_N "(cached) $ECHO_C" >&6 fi ac_res=`eval echo '${'$as_ac_Header'}'` { echo "$as_me:$LINENO: result: $ac_res" >&5 echo "${ECHO_T}$ac_res" >&6; } else # Is the header compilable? { echo "$as_me:$LINENO: checking $ac_header usability" >&5 echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default #include <$ac_header> _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_header_compiler=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_compiler=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 echo "${ECHO_T}$ac_header_compiler" >&6; } # Is the header present? { echo "$as_me:$LINENO: checking $ac_header presence" >&5 echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include <$ac_header> _ACEOF if { (ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then ac_header_preproc=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_preproc=no fi rm -f conftest.err conftest.$ac_ext { echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 echo "${ECHO_T}$ac_header_preproc" >&6; } # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in yes:no: ) { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} ac_header_preproc=yes ;; no:yes:* ) { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} ( cat <<\_ASBOX ## -------------------------------------- ## ## Report this to devser-bugs@outflux.net ## ## -------------------------------------- ## _ASBOX ) | sed "s/^/$as_me: WARNING: /" >&2 ;; esac { echo "$as_me:$LINENO: checking for $ac_header" >&5 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then echo $ECHO_N "(cached) $ECHO_C" >&6 else eval "$as_ac_Header=\$ac_header_preproc" fi ac_res=`eval echo '${'$as_ac_Header'}'` { echo "$as_me:$LINENO: result: $ac_res" >&5 echo "${ECHO_T}$ac_res" >&6; } fi if test `eval echo '${'$as_ac_Header'}'` = yes; then cat >>confdefs.h <<_ACEOF #define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done for ac_header in sys/termios.h do as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then { echo "$as_me:$LINENO: checking for $ac_header" >&5 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then echo $ECHO_N "(cached) $ECHO_C" >&6 fi ac_res=`eval echo '${'$as_ac_Header'}'` { echo "$as_me:$LINENO: result: $ac_res" >&5 echo "${ECHO_T}$ac_res" >&6; } else # Is the header compilable? { echo "$as_me:$LINENO: checking $ac_header usability" >&5 echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default #include <$ac_header> _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_header_compiler=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_compiler=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 echo "${ECHO_T}$ac_header_compiler" >&6; } # Is the header present? { echo "$as_me:$LINENO: checking $ac_header presence" >&5 echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include <$ac_header> _ACEOF if { (ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then ac_header_preproc=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_preproc=no fi rm -f conftest.err conftest.$ac_ext { echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 echo "${ECHO_T}$ac_header_preproc" >&6; } # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in yes:no: ) { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} ac_header_preproc=yes ;; no:yes:* ) { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} ( cat <<\_ASBOX ## -------------------------------------- ## ## Report this to devser-bugs@outflux.net ## ## -------------------------------------- ## _ASBOX ) | sed "s/^/$as_me: WARNING: /" >&2 ;; esac { echo "$as_me:$LINENO: checking for $ac_header" >&5 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then echo $ECHO_N "(cached) $ECHO_C" >&6 else eval "$as_ac_Header=\$ac_header_preproc" fi ac_res=`eval echo '${'$as_ac_Header'}'` { echo "$as_me:$LINENO: result: $ac_res" >&5 echo "${ECHO_T}$ac_res" >&6; } fi if test `eval echo '${'$as_ac_Header'}'` = yes; then cat >>confdefs.h <<_ACEOF #define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done for ac_header in sys/ttycom.h do as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then { echo "$as_me:$LINENO: checking for $ac_header" >&5 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then echo $ECHO_N "(cached) $ECHO_C" >&6 fi ac_res=`eval echo '${'$as_ac_Header'}'` { echo "$as_me:$LINENO: result: $ac_res" >&5 echo "${ECHO_T}$ac_res" >&6; } else # Is the header compilable? { echo "$as_me:$LINENO: checking $ac_header usability" >&5 echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default #include <$ac_header> _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_header_compiler=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_compiler=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 echo "${ECHO_T}$ac_header_compiler" >&6; } # Is the header present? { echo "$as_me:$LINENO: checking $ac_header presence" >&5 echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include <$ac_header> _ACEOF if { (ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then ac_header_preproc=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_preproc=no fi rm -f conftest.err conftest.$ac_ext { echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 echo "${ECHO_T}$ac_header_preproc" >&6; } # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in yes:no: ) { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} ac_header_preproc=yes ;; no:yes:* ) { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} ( cat <<\_ASBOX ## -------------------------------------- ## ## Report this to devser-bugs@outflux.net ## ## -------------------------------------- ## _ASBOX ) | sed "s/^/$as_me: WARNING: /" >&2 ;; esac { echo "$as_me:$LINENO: checking for $ac_header" >&5 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then echo $ECHO_N "(cached) $ECHO_C" >&6 else eval "$as_ac_Header=\$ac_header_preproc" fi ac_res=`eval echo '${'$as_ac_Header'}'` { echo "$as_me:$LINENO: result: $ac_res" >&5 echo "${ECHO_T}$ac_res" >&6; } fi if test `eval echo '${'$as_ac_Header'}'` = yes; then cat >>confdefs.h <<_ACEOF #define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done for ac_header in sys/modem.h do as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then { echo "$as_me:$LINENO: checking for $ac_header" >&5 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then echo $ECHO_N "(cached) $ECHO_C" >&6 fi ac_res=`eval echo '${'$as_ac_Header'}'` { echo "$as_me:$LINENO: result: $ac_res" >&5 echo "${ECHO_T}$ac_res" >&6; } else # Is the header compilable? { echo "$as_me:$LINENO: checking $ac_header usability" >&5 echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default #include <$ac_header> _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_header_compiler=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_compiler=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 echo "${ECHO_T}$ac_header_compiler" >&6; } # Is the header present? { echo "$as_me:$LINENO: checking $ac_header presence" >&5 echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include <$ac_header> _ACEOF if { (ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then ac_header_preproc=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_preproc=no fi rm -f conftest.err conftest.$ac_ext { echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 echo "${ECHO_T}$ac_header_preproc" >&6; } # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in yes:no: ) { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} ac_header_preproc=yes ;; no:yes:* ) { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} ( cat <<\_ASBOX ## -------------------------------------- ## ## Report this to devser-bugs@outflux.net ## ## -------------------------------------- ## _ASBOX ) | sed "s/^/$as_me: WARNING: /" >&2 ;; esac { echo "$as_me:$LINENO: checking for $ac_header" >&5 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then echo $ECHO_N "(cached) $ECHO_C" >&6 else eval "$as_ac_Header=\$ac_header_preproc" fi ac_res=`eval echo '${'$as_ac_Header'}'` { echo "$as_me:$LINENO: result: $ac_res" >&5 echo "${ECHO_T}$ac_res" >&6; } fi if test `eval echo '${'$as_ac_Header'}'` = yes; then cat >>confdefs.h <<_ACEOF #define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done for ac_header in IOKit/serial/ioss.h do as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then { echo "$as_me:$LINENO: checking for $ac_header" >&5 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then echo $ECHO_N "(cached) $ECHO_C" >&6 fi ac_res=`eval echo '${'$as_ac_Header'}'` { echo "$as_me:$LINENO: result: $ac_res" >&5 echo "${ECHO_T}$ac_res" >&6; } else # Is the header compilable? { echo "$as_me:$LINENO: checking $ac_header usability" >&5 echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default #include <$ac_header> _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_header_compiler=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_compiler=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 echo "${ECHO_T}$ac_header_compiler" >&6; } # Is the header present? { echo "$as_me:$LINENO: checking $ac_header presence" >&5 echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include <$ac_header> _ACEOF if { (ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then ac_header_preproc=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_preproc=no fi rm -f conftest.err conftest.$ac_ext { echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 echo "${ECHO_T}$ac_header_preproc" >&6; } # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in yes:no: ) { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} ac_header_preproc=yes ;; no:yes:* ) { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} ( cat <<\_ASBOX ## -------------------------------------- ## ## Report this to devser-bugs@outflux.net ## ## -------------------------------------- ## _ASBOX ) | sed "s/^/$as_me: WARNING: /" >&2 ;; esac { echo "$as_me:$LINENO: checking for $ac_header" >&5 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then echo $ECHO_N "(cached) $ECHO_C" >&6 else eval "$as_ac_Header=\$ac_header_preproc" fi ac_res=`eval echo '${'$as_ac_Header'}'` { echo "$as_me:$LINENO: result: $ac_res" >&5 echo "${ECHO_T}$ac_res" >&6; } fi if test `eval echo '${'$as_ac_Header'}'` = yes; then cat >>confdefs.h <<_ACEOF #define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu for check_define in \ _SC_CLK_TCK \ TIOCMBIS TIOCMBIC TIOCMGET \ CRTSCTS OCRNL ONLCR ECHOKE ECHOCTL \ TIOCM_CAR TIOCM_CD TIOCM_RNG TIOCM_RI TIOCM_CTS TIOCM_DSR \ TIOCMIWAIT TIOCGICOUNT \ TIOCINQ FIONREAD \ TIOCOUTQ \ TIOCSER_TEMT TIOCM_LE \ TIOCSERGETLSR \ TIOCSDTR TIOCCDTR \ TIOCM_RTS TIOCM_DTR \ CTSXON RTSXOFF TCGETX TCSETX \ IOSSIOSPEED \ B0 B50 B75 B110 B134 B150 B200 B300 B600 \ B1200 B1800 B2400 B4800 B9600 B19200 B38400 B57600 \ B115200 B230400 B460800 B500000 B576000 B921600 B1000000 \ B1152000 B1500000 B2000000 B2500000 B3000000 B3500000 B4000000 \ ; do { echo "$as_me:$LINENO: checking definition of $check_define" >&5 echo $ECHO_N "checking definition of $check_define... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #ifdef HAVE_UNISTD_H # include #endif #ifdef HAVE_SYS_IOCTL_H # include #endif #ifdef HAVE_TERMIOS_H # include #endif #ifdef HAVE_SYS_TERMIOX_H # include #endif #ifdef HAVE_SYS_TERMIOS_H # include #endif #ifdef HAVE_SYS_TTYCOM_H # include #endif #ifdef HAVE_SYS_MODEM_H # include #endif #ifdef HAVE_IOKIT_SERIAL_IOSS_H # include #endif int main () { int a=$check_define ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && $as_test_x conftest$ac_exeext; then eval "check_got_$check_define=yes" { echo "$as_me:$LINENO: result: found" >&5 echo "${ECHO_T}found" >&6; } else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 eval "check_got_$check_define=no" { echo "$as_me:$LINENO: result: missing" >&5 echo "${ECHO_T}missing" >&6; } fi rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext done { echo "$as_me:$LINENO: checking serial control via ioctl" >&5 echo $ECHO_N "checking serial control via ioctl... $ECHO_C" >&6; } if test "$check_got_TIOCMBIS" = "yes" && test "$check_got_TIOCMBIC" = "yes"; then { echo "$as_me:$LINENO: result: yes" >&5 echo "${ECHO_T}yes" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } { echo "$as_me:$LINENO: WARNING: Without ioctl support, most serial control functions are missing" >&5 echo "$as_me: WARNING: Without ioctl support, most serial control functions are missing" >&2;} fi { echo "$as_me:$LINENO: checking read/write of RTS signal" >&5 echo $ECHO_N "checking read/write of RTS signal... $ECHO_C" >&6; } if test "$check_got_TIOCMBIS" = "yes" && test "$check_got_TIOCMBIC" = "yes" && test "$check_got_TIOCM_RTS" = "yes"; then { echo "$as_me:$LINENO: result: yes" >&5 echo "${ECHO_T}yes" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } { echo "$as_me:$LINENO: WARNING: You will not be able to check or change the RTS line (direct flow control)" >&5 echo "$as_me: WARNING: You will not be able to check or change the RTS line (direct flow control)" >&2;} fi { echo "$as_me:$LINENO: checking read/write of DTR signal" >&5 echo $ECHO_N "checking read/write of DTR signal... $ECHO_C" >&6; } if test "$check_got_TIOCMBIS" = "yes" && test "$check_got_TIOCMBIC" = "yes" && test "$check_got_TIOCM_DTR" = "yes"; then { echo "$as_me:$LINENO: result: yes" >&5 echo "${ECHO_T}yes" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } { echo "$as_me:$LINENO: WARNING: You will not be able to check or change the DTR line (modem hang up)" >&5 echo "$as_me: WARNING: You will not be able to check or change the DTR line (modem hang up)" >&2;} fi { echo "$as_me:$LINENO: checking read access to modem lines" >&5 echo $ECHO_N "checking read access to modem lines... $ECHO_C" >&6; } if test "$check_got_TIOCMGET" = "yes"; then { echo "$as_me:$LINENO: result: yes" >&5 echo "${ECHO_T}yes" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } { echo "$as_me:$LINENO: WARNING: You will not be able to check modem status lines (carrier, ring, etc)" >&5 echo "$as_me: WARNING: You will not be able to check modem status lines (carrier, ring, etc)" >&2;} fi { echo "$as_me:$LINENO: checking read access to buffer status" >&5 echo $ECHO_N "checking read access to buffer status... $ECHO_C" >&6; } if test "$check_got_TIOCINQ" = "yes" && test "$check_got_TIOCOUTQ" = "yes"; then { echo "$as_me:$LINENO: result: yes" >&5 echo "${ECHO_T}yes" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } { echo "$as_me:$LINENO: WARNING: You will not be able to check the serial buffer state (to test for flushes)" >&5 echo "$as_me: WARNING: You will not be able to check the serial buffer state (to test for flushes)" >&2;} fi { echo "$as_me:$LINENO: checking read access to serial line status" >&5 echo $ECHO_N "checking read access to serial line status... $ECHO_C" >&6; } if test "$check_got_TIOCSERGETLSR" = "yes"; then { echo "$as_me:$LINENO: result: yes" >&5 echo "${ECHO_T}yes" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } { echo "$as_me:$LINENO: WARNING: You will not be able to check serial line status (to do full write flush)" >&5 echo "$as_me: WARNING: You will not be able to check serial line status (to do full write flush)" >&2;} fi { echo "$as_me:$LINENO: checking normal CTS/RTS flow control" >&5 echo $ECHO_N "checking normal CTS/RTS flow control... $ECHO_C" >&6; } if test "$check_got_CTSXON" = "yes" && test "$check_got_RTSXOFF" = "yes" && test "$check_got_TCGETX" = "yes" && test "$check_got_TCSETX" = "yes"; then { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } { echo "$as_me:$LINENO: WARNING: Your system does CTS/RTS flow control strangely. Hopefully, we can work around it" >&5 echo "$as_me: WARNING: Your system does CTS/RTS flow control strangely. Hopefully, we can work around it" >&2;} else { echo "$as_me:$LINENO: result: yes" >&5 echo "${ECHO_T}yes" >&6; } fi cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure # tests run on this system so they can be shared between configure # scripts and configure runs, see configure's option --config-cache. # It is not useful on other systems. If it contains results you don't # want to keep, you may remove or edit it. # # config.status only pays attention to the cache file if you give it # the --recheck option to rerun configure. # # `ac_cv_env_foo' variables (set or unset) will be overridden when # loading this file, other *unset* `ac_cv_foo' will be assigned the # following values. _ACEOF # The following way of writing the cache mishandles newlines in values, # but we know of no workaround that is simple, portable, and efficient. # So, we kill variables containing newlines. # Ultrix sh set writes to stderr and can't be redirected directly, # and sets the high bit in the cache file unless we assign to the vars. ( for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { echo "$as_me:$LINENO: WARNING: Cache variable $ac_var contains a newline." >&5 echo "$as_me: WARNING: Cache variable $ac_var contains a newline." >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( *) $as_unset $ac_var ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space=' '; set) 2>&1` in #( *${as_nl}ac_space=\ *) # `set' does not quote correctly, so add quotes (double-quote # substitution turns \\\\ into \\, and sed turns \\ into \). sed -n \ "s/'/'\\\\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" ;; #( *) # `set' quotes correctly as required by POSIX, so do not add quotes. sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) | sed ' /^ac_cv_env_/b end t clear :clear s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ t end s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ :end' >>confcache if diff "$cache_file" confcache >/dev/null 2>&1; then :; else if test -w "$cache_file"; then test "x$cache_file" != "x/dev/null" && { echo "$as_me:$LINENO: updating cache $cache_file" >&5 echo "$as_me: updating cache $cache_file" >&6;} cat confcache >$cache_file else { echo "$as_me:$LINENO: not updating unwritable cache $cache_file" >&5 echo "$as_me: not updating unwritable cache $cache_file" >&6;} fi fi rm -f confcache test "x$prefix" = xNONE && prefix=$ac_default_prefix # Let make expand exec_prefix. test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' DEFS=-DHAVE_CONFIG_H ac_libobjs= ac_ltlibobjs= for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue # 1. Remove the extension, and $U if already installed. ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' ac_i=`echo "$ac_i" | sed "$ac_script"` # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR # will be set to the directory where LIBOBJS objects are built. ac_libobjs="$ac_libobjs \${LIBOBJDIR}$ac_i\$U.$ac_objext" ac_ltlibobjs="$ac_ltlibobjs \${LIBOBJDIR}$ac_i"'$U.lo' done LIBOBJS=$ac_libobjs LTLIBOBJS=$ac_ltlibobjs : ${CONFIG_STATUS=./config.status} ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files $CONFIG_STATUS" { echo "$as_me:$LINENO: creating $CONFIG_STATUS" >&5 echo "$as_me: creating $CONFIG_STATUS" >&6;} cat >$CONFIG_STATUS <<_ACEOF #! $SHELL # Generated by $as_me. # Run this file to recreate the current configuration. # Compiler output produced by configure, useful for debugging # configure, is in config.log if it exists. debug=false ac_cs_recheck=false ac_cs_silent=false SHELL=\${CONFIG_SHELL-$SHELL} _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF ## --------------------- ## ## M4sh Initialization. ## ## --------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then emulate sh NULLCMD=: # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac fi # PATH needs CR # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then echo "#! /bin/sh" >conf$$.sh echo "exit 0" >>conf$$.sh chmod +x conf$$.sh if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then PATH_SEPARATOR=';' else PATH_SEPARATOR=: fi rm -f conf$$.sh fi # Support unset when possible. if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then as_unset=unset else as_unset=false fi # IFS # We need space, tab and new line, in precisely that order. Quoting is # there to prevent editors from complaining about space-tab. # (If _AS_PATH_WALK were called with IFS unset, it would disable word # splitting by setting IFS to empty value.) as_nl=' ' IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. case $0 in *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 { (exit 1); exit 1; } fi # Work around bugs in pre-3.0 UWIN ksh. for as_var in ENV MAIL MAILPATH do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var done PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. for as_var in \ LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \ LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \ LC_TELEPHONE LC_TIME do if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then eval $as_var=C; export $as_var else ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var fi done # Required to use basename. if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi # Name of the executable. as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # CDPATH. $as_unset CDPATH as_lineno_1=$LINENO as_lineno_2=$LINENO test "x$as_lineno_1" != "x$as_lineno_2" && test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2" || { # Create $as_me.lineno as a copy of $as_myself, but with $LINENO # uniformly replaced by the line number. The first 'sed' inserts a # line-number line after each line using $LINENO; the second 'sed' # does the real work. The second script uses 'N' to pair each # line-number line with the line containing $LINENO, and appends # trailing '-' during substitution so that $LINENO is not a special # case at line end. # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the # scripts with optimization help from Paolo Bonzini. Blame Lee # E. McMahon (1931-1989) for sed's syntax. :-) sed -n ' p /[$]LINENO/= ' <$as_myself | sed ' s/[$]LINENO.*/&-/ t lineno b :lineno N :loop s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ t loop s/-\n.*// ' >$as_me.lineno && chmod +x "$as_me.lineno" || { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2 { (exit 1); exit 1; }; } # Don't try to exec as it changes $[0], causing all sort of problems # (the dirname of $[0] is not the place where we might find the # original and so on. Autoconf is especially sensitive to this). . "./$as_me.lineno" # Exit status is that of the last command. exit } if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in -n*) case `echo 'x\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. *) ECHO_C='\c';; esac;; *) ECHO_N='-n';; esac if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir fi echo >conf$$.file if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -p'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -p' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -p' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null if mkdir -p . 2>/dev/null; then as_mkdir_p=: else test -d ./-p && rmdir ./-p as_mkdir_p=false fi if test -x / >/dev/null 2>&1; then as_test_x='test -x' else if ls -dL / >/dev/null 2>&1; then as_ls_L_option=L else as_ls_L_option= fi as_test_x=' eval sh -c '\'' if test -d "$1"; then test -d "$1/."; else case $1 in -*)set "./$1";; esac; case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in ???[sx]*):;;*)false;;esac;fi '\'' sh ' fi as_executable_p=$as_test_x # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" exec 6>&1 # Save the log message, to keep $[0] and so on meaningful, and to # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" This file was extended by Device::SerialPort $as_me 1.04, which was generated by GNU Autoconf 2.61. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS CONFIG_LINKS = $CONFIG_LINKS CONFIG_COMMANDS = $CONFIG_COMMANDS $ $0 $@ on `(hostname || uname -n) 2>/dev/null | sed 1q` " _ACEOF cat >>$CONFIG_STATUS <<_ACEOF # Files that config.status was made for. config_headers="$ac_config_headers" _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF ac_cs_usage="\ \`$as_me' instantiates files from templates according to the current configuration. Usage: $0 [OPTIONS] [FILE]... -h, --help print this help, then exit -V, --version print version number and configuration settings, then exit -q, --quiet do not print progress messages -d, --debug don't remove temporary files --recheck update $as_me by reconfiguring in the same conditions --header=FILE[:TEMPLATE] instantiate the configuration header FILE Configuration headers: $config_headers Report bugs to ." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF ac_cs_version="\\ Device::SerialPort config.status 1.04 configured by $0, generated by GNU Autoconf 2.61, with options \\"`echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\" Copyright (C) 2006 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." ac_pwd='$ac_pwd' srcdir='$srcdir' _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF # If no file are specified by the user, then we need to provide default # value. By we need to know if files were specified by the user. ac_need_defaults=: while test $# != 0 do case $1 in --*=*) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` ac_shift=: ;; *) ac_option=$1 ac_optarg=$2 ac_shift=shift ;; esac case $ac_option in # Handling of the options. -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) ac_cs_recheck=: ;; --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) echo "$ac_cs_version"; exit ;; --debug | --debu | --deb | --de | --d | -d ) debug=: ;; --header | --heade | --head | --hea ) $ac_shift CONFIG_HEADERS="$CONFIG_HEADERS $ac_optarg" ac_need_defaults=false;; --he | --h) # Conflict between --help and --header { echo "$as_me: error: ambiguous option: $1 Try \`$0 --help' for more information." >&2 { (exit 1); exit 1; }; };; --help | --hel | -h ) echo "$ac_cs_usage"; exit ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil | --si | --s) ac_cs_silent=: ;; # This is an error. -*) { echo "$as_me: error: unrecognized option: $1 Try \`$0 --help' for more information." >&2 { (exit 1); exit 1; }; } ;; *) ac_config_targets="$ac_config_targets $1" ac_need_defaults=false ;; esac shift done ac_configure_extra_args= if $ac_cs_silent; then exec 6>/dev/null ac_configure_extra_args="$ac_configure_extra_args --silent" fi _ACEOF cat >>$CONFIG_STATUS <<_ACEOF if \$ac_cs_recheck; then echo "running CONFIG_SHELL=$SHELL $SHELL $0 "$ac_configure_args \$ac_configure_extra_args " --no-create --no-recursion" >&6 CONFIG_SHELL=$SHELL export CONFIG_SHELL exec $SHELL "$0"$ac_configure_args \$ac_configure_extra_args --no-create --no-recursion fi _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF exec 5>>config.log { echo sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX ## Running $as_me. ## _ASBOX echo "$ac_log" } >&5 _ACEOF cat >>$CONFIG_STATUS <<_ACEOF _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF # Handling of arguments. for ac_config_target in $ac_config_targets do case $ac_config_target in "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;; *) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5 echo "$as_me: error: invalid argument: $ac_config_target" >&2;} { (exit 1); exit 1; }; };; esac done # If the user did not use the arguments to specify the items to instantiate, # then the envvar interface is used. Set only those that are not. # We use the long form for the default assignment because of an extremely # bizarre bug on SunOS 4.1.3. if $ac_need_defaults; then test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers fi # Have a temporary directory for convenience. Make it in the build tree # simply because there is no reason against having it here, and in addition, # creating and moving files from /tmp can sometimes cause problems. # Hook for its removal unless debugging. # Note that there is a small window in which the directory will not be cleaned: # after its creation but before its name has been assigned to `$tmp'. $debug || { tmp= trap 'exit_status=$? { test -z "$tmp" || test ! -d "$tmp" || rm -fr "$tmp"; } && exit $exit_status ' 0 trap '{ (exit 1); exit 1; }' 1 2 13 15 } # Create a (secure) tmp directory for tmp files. { tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" } || { tmp=./conf$$-$RANDOM (umask 077 && mkdir "$tmp") } || { echo "$me: cannot create a temporary directory in ." >&2 { (exit 1); exit 1; } } for ac_tag in :H $CONFIG_HEADERS do case $ac_tag in :[FHLC]) ac_mode=$ac_tag; continue;; esac case $ac_mode$ac_tag in :[FHL]*:*);; :L* | :C*:*) { { echo "$as_me:$LINENO: error: Invalid tag $ac_tag." >&5 echo "$as_me: error: Invalid tag $ac_tag." >&2;} { (exit 1); exit 1; }; };; :[FH]-) ac_tag=-:-;; :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; esac ac_save_IFS=$IFS IFS=: set x $ac_tag IFS=$ac_save_IFS shift ac_file=$1 shift case $ac_mode in :L) ac_source=$1;; :[FH]) ac_file_inputs= for ac_f do case $ac_f in -) ac_f="$tmp/stdin";; *) # Look for the file first in the build tree, then in the source tree # (if the path is not absolute). The absolute path cannot be DOS-style, # because $ac_f cannot contain `:'. test -f "$ac_f" || case $ac_f in [\\/$]*) false;; *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; esac || { { echo "$as_me:$LINENO: error: cannot find input file: $ac_f" >&5 echo "$as_me: error: cannot find input file: $ac_f" >&2;} { (exit 1); exit 1; }; };; esac ac_file_inputs="$ac_file_inputs $ac_f" done # Let's still pretend it is `configure' which instantiates (i.e., don't # use $as_me), people would be surprised to read: # /* config.h. Generated by config.status. */ configure_input="Generated from "`IFS=: echo $* | sed 's|^[^:]*/||;s|:[^:]*/|, |g'`" by configure." if test x"$ac_file" != x-; then configure_input="$ac_file. $configure_input" { echo "$as_me:$LINENO: creating $ac_file" >&5 echo "$as_me: creating $ac_file" >&6;} fi case $ac_tag in *:-:* | *:-) cat >"$tmp/stdin";; esac ;; esac ac_dir=`$as_dirname -- "$ac_file" || $as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$ac_file" : 'X\(//\)[^/]' \| \ X"$ac_file" : 'X\(//\)$' \| \ X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || echo X"$ac_file" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` { as_dir="$ac_dir" case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || { $as_mkdir_p && mkdir -p "$as_dir"; } || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" } || test -d "$as_dir" || { { echo "$as_me:$LINENO: error: cannot create directory $as_dir" >&5 echo "$as_me: error: cannot create directory $as_dir" >&2;} { (exit 1); exit 1; }; }; } ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,/..,g;s,/,,'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix case $ac_mode in :H) # # CONFIG_HEADER # _ACEOF # Transform confdefs.h into a sed script `conftest.defines', that # substitutes the proper values into config.h.in to produce config.h. rm -f conftest.defines conftest.tail # First, append a space to every undef/define line, to ease matching. echo 's/$/ /' >conftest.defines # Then, protect against being on the right side of a sed subst, or in # an unquoted here document, in config.status. If some macros were # called several times there might be several #defines for the same # symbol, which is useless. But do not sort them, since the last # AC_DEFINE must be honored. ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]* # These sed commands are passed to sed as "A NAME B PARAMS C VALUE D", where # NAME is the cpp macro being defined, VALUE is the value it is being given. # PARAMS is the parameter list in the macro definition--in most cases, it's # just an empty string. ac_dA='s,^\\([ #]*\\)[^ ]*\\([ ]*' ac_dB='\\)[ (].*,\\1define\\2' ac_dC=' ' ac_dD=' ,' uniq confdefs.h | sed -n ' t rset :rset s/^[ ]*#[ ]*define[ ][ ]*// t ok d :ok s/[\\&,]/\\&/g s/^\('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/ '"$ac_dA"'\1'"$ac_dB"'\2'"${ac_dC}"'\3'"$ac_dD"'/p s/^\('"$ac_word_re"'\)[ ]*\(.*\)/'"$ac_dA"'\1'"$ac_dB$ac_dC"'\2'"$ac_dD"'/p ' >>conftest.defines # Remove the space that was appended to ease matching. # Then replace #undef with comments. This is necessary, for # example, in the case of _POSIX_SOURCE, which is predefined and required # on some systems where configure will not decide to define it. # (The regexp can be short, since the line contains either #define or #undef.) echo 's/ $// s,^[ #]*u.*,/* & */,' >>conftest.defines # Break up conftest.defines: ac_max_sed_lines=50 # First sed command is: sed -f defines.sed $ac_file_inputs >"$tmp/out1" # Second one is: sed -f defines.sed "$tmp/out1" >"$tmp/out2" # Third one will be: sed -f defines.sed "$tmp/out2" >"$tmp/out1" # et cetera. ac_in='$ac_file_inputs' ac_out='"$tmp/out1"' ac_nxt='"$tmp/out2"' while : do # Write a here document: cat >>$CONFIG_STATUS <<_ACEOF # First, check the format of the line: cat >"\$tmp/defines.sed" <<\\CEOF /^[ ]*#[ ]*undef[ ][ ]*$ac_word_re[ ]*\$/b def /^[ ]*#[ ]*define[ ][ ]*$ac_word_re[( ]/b def b :def _ACEOF sed ${ac_max_sed_lines}q conftest.defines >>$CONFIG_STATUS echo 'CEOF sed -f "$tmp/defines.sed"' "$ac_in >$ac_out" >>$CONFIG_STATUS ac_in=$ac_out; ac_out=$ac_nxt; ac_nxt=$ac_in sed 1,${ac_max_sed_lines}d conftest.defines >conftest.tail grep . conftest.tail >/dev/null || break rm -f conftest.defines mv conftest.tail conftest.defines done rm -f conftest.defines conftest.tail echo "ac_result=$ac_in" >>$CONFIG_STATUS cat >>$CONFIG_STATUS <<\_ACEOF if test x"$ac_file" != x-; then echo "/* $configure_input */" >"$tmp/config.h" cat "$ac_result" >>"$tmp/config.h" if diff $ac_file "$tmp/config.h" >/dev/null 2>&1; then { echo "$as_me:$LINENO: $ac_file is unchanged" >&5 echo "$as_me: $ac_file is unchanged" >&6;} else rm -f $ac_file mv "$tmp/config.h" $ac_file fi else echo "/* $configure_input */" cat "$ac_result" fi rm -f "$tmp/out12" ;; esac done # for ac_tag { (exit 0); exit 0; } _ACEOF chmod +x $CONFIG_STATUS ac_clean_files=$ac_clean_files_save # configure is writing to config.log, and then calls config.status. # config.status does its own redirection, appending to config.log. # Unfortunately, on DOS this fails, as config.log is still kept open # by configure, so config.status won't be able to write to it; its # output is simply discarded. So we exec the FD to /dev/null, # effectively closing config.log, so it can be properly (re)opened and # appended to by config.status. When coming back to configure, we # need to make the FD available again. if test "$no_create" != yes; then ac_cs_success=: ac_config_status_args= test "$silent" = yes && ac_config_status_args="$ac_config_status_args --quiet" exec 5>/dev/null $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false exec 5>>config.log # Use ||, not &&, to avoid exiting from the if with $? = 1, which # would make configure fail if this is the last instruction. $ac_cs_success || { (exit 1); exit 1; } fi Device-SerialPort-1.04/show-tiocm.c.test0000644000076500007650000000113210520606534016602 0ustar keeskees#include // for TIOCM* stuff... #define TRY_TIOCM #ifdef TRY_TIOCM # include #endif // for TC* stuff... #define TRY_TC #ifdef TRY_TC # include #endif int main() { #ifdef TRY_TIOCM printf("eval \"sub %s { 0x%x }\";\n","TIOCMBIS", TIOCMBIS); printf("eval \"sub %s { 0x%x }\";\n","TIOCMBIC", TIOCMBIC); printf("eval \"sub %s { 0x%x }\";\n","TIOCMGET", TIOCMGET); #endif #ifdef TRY_TC printf("eval \"sub %s { 0x%x }\";\n","TCGETX", TCGETX); printf("eval \"sub %s { 0x%x }\";\n","TCSETX", TCSETX); #endif return 0; } Device-SerialPort-1.04/META.yml0000644000076500007650000000053310707557125014654 0ustar keeskees# http://module-build.sourceforge.net/META-spec.html #XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX# name: Device-SerialPort version: 1.04 version_from: SerialPort.pm installdirs: site requires: Test::More: 0 distribution_type: module generated_by: ExtUtils::MakeMaker version 6.30_01