.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.40) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "SerialPort 3pm" .TH SerialPort 3pm "2020-11-09" "perl v5.32.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Device::SerialPort \- Linux/POSIX emulation of Win32::SerialPort functions. .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& use Device::SerialPort qw( :PARAM :STAT 0.07 ); .Ve .SS "Constructors" .IX Subsection "Constructors" .Vb 3 \& # $lockfile is optional \& $PortObj = new Device::SerialPort ($PortName, $quiet, $lockfile) \& || die "Can\*(Aqt open $PortName: $!\en"; \& \& $PortObj = start Device::SerialPort ($Configuration_File_Name) \& || die "Can\*(Aqt start $Configuration_File_Name: $!\en"; \& \& $PortObj = tie (*FH, \*(AqDevice::SerialPort\*(Aq, $Configuration_File_Name) \& || die "Can\*(Aqt tie using $Configuration_File_Name: $!\en"; .Ve .SS "Configuration Utility Methods" .IX Subsection "Configuration Utility Methods" .Vb 1 \& $PortObj\->alias("MODEM1"); \& \& $PortObj\->save($Configuration_File_Name) \& || warn "Can\*(Aqt save $Configuration_File_Name: $!\en"; \& \& # 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\*(Aqt reread $Configuration_File_Name: $!\en"; \& \& # "app. variables" saved in $Configuration_File, not used internally \& $PortObj\->devicetype(\*(Aqnone\*(Aq); # CM11, CM17, \*(Aqweeder\*(Aq, \*(Aqmodem\*(Aq \& $PortObj\->hostname(\*(Aqlocalhost\*(Aq); # for socket\-based implementations \& $PortObj\->hostaddr(0); # false unless specified \& $PortObj\->datatype(\*(Aqraw\*(Aq); # in case an application needs_to_know \& $PortObj\->cfg_param_1(\*(Aqnone\*(Aq); # null string \*(Aq\*(Aq hard to save/restore \& $PortObj\->cfg_param_2(\*(Aqnone\*(Aq); # 3 spares should be enough for now \& $PortObj\->cfg_param_3(\*(Aqnone\*(Aq); # 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 .Ve .SS "Configuration Parameter Methods" .IX Subsection "Configuration Parameter Methods" .Vb 3 \& # 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 .Ve .SS "Operating Methods" .IX Subsection "Operating Methods" .Vb 2 \& ($count_in, $string_in) = $PortObj\->read($InBytes); \& warn "read unsuccessful\en" unless ($count_in == $InBytes); \& \& $count_out = $PortObj\->write($output_string); \& warn "write failed\en" unless ($count_out); \& warn "write incomplete\en" 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\en"; } \& } \& \& if ($PortObj\->can_modemlines) { \& $ModemStatus = $PortObj\->modemlines; \& if ($ModemStatus & $PortObj\->MS_RLSD_ON) { print "carrier detected\en"; } \& } \& \& if ($PortObj\->can_intr_count) { \& $count = $PortObj\->intr_count(); \& print "got $count interrupts\en"; \& } \& \& if ($PortObj\->can_arbitrary_baud) { \& print "this port can set arbitrary baud rates\en"; \& } \& \& ($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; .Ve .SS "Methods used with Tied FileHandles" .IX Subsection "Methods used with Tied FileHandles" .Vb 2 \& $PortObj = tie (*FH, \*(AqDevice::SerialPort\*(Aq, $Configuration_File_Name) \& || die "Can\*(Aqt tie: $!\en"; ## 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"); .Ve .SS "Destructors" .IX Subsection "Destructors" .Vb 4 \& $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; .Ve .SS "Methods for I/O Processing" .IX Subsection "Methods for I/O Processing" .Vb 4 \& $PortObj\->are_match("text", "\en"); # 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\en" unless (defined $gotit); \& sleep 1; # polling sample time \& } \& \& printf "gotit = %s\en", $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\en", \& $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 .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" This module provides an object-based user interface essentially identical to the one provided by the Win32::SerialPort module. .SS "Initialization" .IX Subsection "Initialization" The primary constructor is \fBnew\fR with either a \fIPortName\fR, or a \&\fIConfiguretion File\fR specified. With a \fIPortName\fR, this will open the port and create the object. The port is not yet ready for read/write access. First, the desired \fIparameter settings\fR 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 \fBwrite_settings\fR method updates the port (and will return True under \s-1POSIX\s0). Ports are opened for binary transfers. A separate \f(CW\*(C`binmode\*(C'\fR is not needed. .PP .Vb 2 \& $PortObj = new Device::SerialPort ($PortName, $quiet, $lockfile) \& || die "Can\*(Aqt open $PortName: $!\en"; .Ve .PP The \f(CW$quiet\fR parameter is ignored and is only there for compatibility with Win32::SerialPort. The \f(CW$lockfile\fR 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 \&\f(CW$PortObj\fR is no longer used (by \s-1DESTROY\s0). You would usually request \&\f(CW$lockfile\fR with \f(CW$quiet\fR 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. .PP Using a \fIConfiguration File\fR with \fBnew\fR or by using second constructor, \&\fBstart\fR, scripts can be simplified if they need a constant setup. It executes all the steps from \fBnew\fR to \fBwrite_settings\fR based on a previously saved configuration. This constructor will return \f(CW\*(C`undef\*(C'\fR 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. .PP .Vb 2 \& $PortObj2 = start Device::SerialPort ($Configuration_File_Name) \& || die; .Ve .PP The third constructor, \fBtie\fR, will combine the \fBstart\fR with Perl's support for tied FileHandles (see \fIperltie\fR). Device::SerialPort will implement the complete set of methods: \s-1TIEHANDLE, PRINT, PRINTF, WRITE, READ, GETC, READLINE, CLOSE,\s0 and \s-1DESTROY.\s0 Tied FileHandle support is new with Version 0.04 and the \s-1READ\s0 and \s-1READLINE\s0 methods were added in Version 0.06. In \*(L"scalar context\*(R", \s-1READLINE\s0 sets \fBstty_icanon\fR to do character processing and calls \fBlookfor\fR. It restores \fBstty_icanon\fR after the read. In \*(L"list context\*(R", \s-1READLINE\s0 does Canonical (line) reads if \&\fBstty_icanon\fR is set or calls \fBstreamline\fR if it is not. (\fBstty_icanon\fR is not altered). The \fBstreamline\fR choice allows duplicating the operation of Win32::SerialPort for cross-platform scripts. .PP The implementation attempts to mimic \s-1STDIN/STDOUT\s0 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 \f(CW$,\fR and \f(CW\*(C`$\e\*(C'\fR are also applied to \s-1PRINT\s0 if set. The \fBoutput_record_separator\fR and \fBoutput_field_separator\fR methods can set \&\fIPort-FileHandle-Specific\fR versions of \f(CW$,\fR and \f(CW\*(C`$\e\*(C'\fR if desired. Since \&\s-1PRINTF\s0 is treated internally as a single record \s-1PRINT,\s0 \f(CW\*(C`$\e\*(C'\fR will be applied. Output separators are not applied to \s-1WRITE\s0 (called as \&\f(CW\*(C`syswrite FH, $scalar, $length, [$offset]\*(C'\fR). The input_record_separator \f(CW$/\fR is not explicitly supported \- but an identical function can be obtained with a suitable \fBare_match\fR setting. .PP .Vb 2 \& $PortObj2 = tie (*FH, \*(AqDevice::SerialPort\*(Aq, $Configuration_File_Name) \& || die; .Ve .PP The tied FileHandle methods may be combined with the Device::SerialPort methods for \fBread, input\fR, and \fBwrite\fR as well as other methods. The typical restrictions against mixing \fBprint\fR with \fBsyswrite\fR do not apply. Since both \fB(tied) read\fR and \fBsysread\fR call the same \f(CW\*(C`$ob\->READ\*(C'\fR method, and since a separate \f(CW\*(C`$ob\->read\*(C'\fR method has existed for some time in Device::SerialPort, you should always use \fBsysread\fR with the tied interface (when it is implemented). .PP Certain parameters \fI\s-1SHOULD\s0\fR be set before executing \fBwrite_settings\fR. Others will attempt to deduce defaults from the hardware or from other parameters. The \fIRequired\fR parameters are: .IP "baudrate" 8 .IX Item "baudrate" Any legal value. .IP "parity" 8 .IX Item "parity" One of the following: \*(L"none\*(R", \*(L"odd\*(R", \*(L"even\*(R". .Sp By default, incoming parity is not checked. This mimics the behavior of most terminal programs (like \*(L"minicom\*(R"). If you need parity checking enabled, please use the \*(L"stty_inpck\*(R" and \*(L"stty_istrip\*(R" functions. .IP "databits" 8 .IX Item "databits" An integer from 5 to 8. .IP "stopbits" 8 .IX Item "stopbits" Legal values are 1 and 2. .IP "handshake" 8 .IX Item "handshake" One of the following: \*(L"none\*(R", \*(L"rts\*(R", \*(L"xoff\*(R". .PP Some individual parameters (eg. baudrate) can be changed after the initialization is completed. These will be validated and will update the \fIserial driver\fR as required. The \fBsave\fR method will write the current parameters to a file that \fBstart, tie,\fR and \&\fBrestart\fR can use to reestablish a functional setup. .PP .Vb 2 \& $PortObj = new Win32::SerialPort ($PortName, $quiet) \& || die "Can\*(Aqt open $PortName: $^E\en"; # $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 .Ve .SS "Configuration Utility Methods" .IX Subsection "Configuration Utility Methods" Use \fBalias\fR to convert the name used by \*(L"built-in\*(R" messages. .PP .Vb 1 \& $PortObj\->alias("MODEM1"); .Ve .PP Starting in Version 0.07, a number of \fIApplication Variables\fR are saved in \fB\f(CB$Configuration_File\fB\fR. These parameters are not used internally. But methods allow setting and reading them. The intent is to facilitate the use of separate \fIconfiguration scripts\fR to create the files. Then an application can use \fBstart\fR 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. .PP .Vb 7 \& $PortObj\->devicetype(\*(Aqnone\*(Aq); \& $PortObj\->hostname(\*(Aqlocalhost\*(Aq); # for socket\-based implementations \& $PortObj\->hostaddr(0); # a "false" value \& $PortObj\->datatype(\*(Aqraw\*(Aq); # \*(Aqrecord\*(Aq is another possibility \& $PortObj\->cfg_param_1(\*(Aqnone\*(Aq); \& $PortObj\->cfg_param_2(\*(Aqnone\*(Aq); # 3 spares should be enough for now \& $PortObj\->cfg_param_3(\*(Aqnone\*(Aq); .Ve .SS "Configuration and Capability Methods" .IX Subsection "Configuration and Capability Methods" The Win32 Serial Comm \s-1API\s0 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. .PP The \fBget_tick_count\fR method is a clone of the \fI\f(BIWin32::GetTickCount()\fI\fR function. It matches a corresponding method in \fIWin32::CommPort\fR. It returns time in milliseconds \- but can be used in cross-platform scripts. .PP Binary selections will accept as \fItrue\fR any of the following: \&\f(CW\*(C`("YES", "Y", "ON", "TRUE", "T", "1", 1)\*(C'\fR (upper/lower/mixed case) Anything else is \fIfalse\fR. .PP 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: .IP "method called with an argument" 8 .IX Item "method called with an argument" The parameter is set to the argument, if valid. An invalid argument returns \fIfalse\fR (undef) and the parameter is unchanged. The function will also \fIcarp\fR if \fB\f(CB$user_msg\fB\fR is \fItrue\fR. The port will be updated immediately if allowed (an automatic \fBwrite_settings\fR is called). .IP "method called with no argument in scalar context" 8 .IX 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 \*(L"undef\*(R" which will parse to \fIfalse\fR. For binary selections (true/false), return the current value. All current values from \*(L"multivalue\*(R" selections will parse to \fItrue\fR. .IP "method called with no argument in list context" 8 .IX 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 \&\f(CW\*(C`(undef)\*(C'\fR 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. .SS "Operating Methods" .IX Subsection "Operating Methods" Version 0.04 adds \fBpulse\fR methods for the \fI\s-1RTS, BREAK,\s0 and \s-1DTR\s0\fR bits. The \&\fBpulse\fR 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 \*(L"FireCracker\*(R" control and some modems, which require pulses on these lines to signal specific events or data. Timing for the \fIactive\fR part of \fBpulse_break_on\fR is handled by \fI\f(BIPOSIX::tcsendbreak\fI\|(0)\fR, which sends a 250\-500 millisecond \&\s-1BREAK\s0 pulse. It is \fI\s-1NOT\s0\fR guaranteed to block until done. .PP .Vb 5 \& $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); .Ve .PP In Version 0.05, these calls and the \fBrts_active\fR and \fBdtr_active\fR calls verify the parameters and any required \fIioctl constants\fR, and return \f(CW\*(C`undef\*(C'\fR unless the call succeeds. You can use the \fBcan_ioctl\fR method to see if the required constants are available. On Version 0.04, the module would not load unless \fIasm/termios.ph\fR was found at startup. .SS "Stty Shortcuts" .IX Subsection "Stty Shortcuts" Version 0.06 adds primitive methods to modify port parameters that would otherwise require a \f(CW\*(C`system("stty...");\*(C'\fR command. These act much like the identically-named methods in Win32::SerialPort. However, they are initialized from \*(L"current stty settings\*(R" when the port is opened rather than from defaults. And like \fIstty settings\fR, they are passed to the serial driver and apply to all operations rather than only to I/O processed via the \fBlookfor\fR method or the \fItied FileHandle\fR methods. Each returns the current setting for the parameter. There are no \*(L"global\*(R" or \*(L"combination\*(R" parameters \- you still need \f(CW\*(C`system("stty...")\*(C'\fR for that. .PP The methods which handle \s-1CHAR\s0 parameters set and return values as \f(CW\*(C`ord(CHAR)\*(C'\fR. This corresponds to the settings in the \fI\s-1POSIX\s0 termios cc_field array\fR. You are unlikely to actually want to modify most of these. They reflect the special characters which can be set by \fIstty\fR. .PP .Vb 9 \& $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 .Ve .PP Binary settings supported by \s-1POSIX\s0 will return 0 or 1. Several parameters settable by \fIstty\fR do not yet have shortcut methods. Contact me if you need one that is not supported. These are the common choices. Try \f(CW\*(C`man stty\*(C'\fR if you are not sure what they do. .PP .Vb 10 \& $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; .Ve .PP The following methods require successfully loading \fIioctl constants\fR. They will return \f(CW\*(C`undef\*(C'\fR if the needed constants are not found. But the method calls may still be used without syntax errors or warnings even in that case. .PP .Vb 4 \& $PortObj\->stty_ocrlf; \& $PortObj\->stty_onlcr; \& $PortObj\->stty_echoke; \& $PortObj\->stty_echoctl; .Ve .SS "Lookfor and I/O Processing" .IX Subsection "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 \*(L"username:\*(R" and \*(L"password:\*(R". The \&\fBlookfor\fR method provides a consistent 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 \fBare_match\fR 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). .PP Unlike Win32::SerialPort, \fBlookfor\fR does not handle backspace, echo, and other character processing. It expects the serial driver to handle those and to be controlled via \fIstty\fR. For interacting with humans, you will probably want \f(CWstty_icanon(1)\fR during \fBlookfor\fR to obtain familiar command-line response. The actual match and the characters after it (if any) may also be viewed using the \fBlastlook\fR method. It also adopts the convention from Expect.pm that match strings are literal text (tested using \&\fBindex\fR) unless preceded in the \fBare_match\fR list by a \fB\*(L"\-re\*(R",\fR entry. The default \fBare_match\fR list is \f(CW\*(C`("\en")\*(C'\fR, which matches complete lines. .PP .Vb 3 \& 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 .Ve .PP Everything in \fBlookfor\fR 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, \f(CW$match\fR and \f(CW$pattern\fR should be identical. The \&\f(CW$instead\fR value returns the internal buffer tested by the match logic. A successful match or a \fBlookclear\fR resets it to "" \- so it is only useful for error handling such as timeout processing or reporting unexpected responses. .PP The \fBlookfor\fR method is designed to be sampled periodically (polled). Any characters after the match pattern are saved for a subsequent \fBlookfor\fR. Internally, \fBlookfor\fR is implemented using the nonblocking \fBinput\fR method when called with no parameter. If called with a count, \fBlookfor\fR calls \&\f(CW\*(C`$PortObj\->read(count)\*(C'\fR which blocks until the \fBread\fR is \fIComplete\fR or a \fITimeout\fR occurs. The blocking alternative should not be used unless a fault time has been defined using \fBread_interval, read_const_time, and read_char_time\fR. It exists mostly to support the \fItied FileHandle\fR functions \fBsysread, getc,\fR and \fB<\s-1FH\s0>\fR. When \fBstty_icanon\fR is active, even the non-blocking calls will not return data until the line is complete. .PP The internal buffers used by \fBlookfor\fR may be purged by the \fBlookclear\fR method (which also clears the last match). For testing, \fBlookclear\fR can accept a string which is \*(L"looped back\*(R" to the next \fBinput\fR. This feature is enabled only when \f(CWset_test_mode_active(1)\fR. Normally, \fBlookclear\fR will return \f(CW\*(C`undef\*(C'\fR if given parameters. It still purges the buffers and last_match in that case (but nothing is \*(L"looped back\*(R"). You will want \&\fB\fBstty_echo\fB\|(0)\fR when exercising loopback. .PP The \fBmatchclear\fR method is designed to handle the \&\*(L"special case\*(R" where the match string is the first character(s) received by \fBlookfor\fR. In this case, \f(CW\*(C`$lookfor_return == ""\*(C'\fR, \fBlookfor\fR does not provide a clear indication that a match was found. The \fBmatchclear\fR returns the same \f(CW$match\fR that would be returned by \fBlastlook\fR and resets it to "" without resetting any of the other buffers. Since the \&\fBlookfor\fR already searched \fIthrough\fR the match, \fBmatchclear\fR is used to both detect and step-over \*(L"blank\*(R" lines. .PP The character-by-character processing used by \fBlookfor\fR is fine for interactive activities and tasks which expect short responses. But it has too much \*(L"overhead\*(R" to handle fast data streams.There is also a \&\fBstreamline\fR method which is a fast, line-oriented alternative with just pattern searching. Since \fBstreamline\fR uses the same internal buffers, the \fBlookclear, lastlook, are_match, and matchclear\fR methods act the same in both cases. In fact, calls to \fBstreamline\fR and \fBlookfor\fR can be interleaved if desired (e.g. an interactive task that starts an upload and returns to interactive activity when it is complete). .PP There are two additional methods for supporting \*(L"list context\*(R" input: \&\fBlastline\fR sets an \*(L"end_of_file\*(R" \fIRegular Expression\fR, and \fBlinesize\fR permits changing the \*(L"packet size\*(R" in the blocking read operation to allow tuning performance to data characteristics. These two only apply during \&\fB\s-1READLINE\s0\fR. The default for \fBlinesize\fR is 1. There is no default for the \fBlastline\fR method. .PP The \fIRegular Expressions\fR set by \fBare_match\fR and \fBlastline\fR will be pre-compiled using the \fIqr//\fR construct on Perl 5.005 and higher. This doubled \fBlookfor\fR and \fBstreamline\fR speed in my tests with \&\fIRegular Expressions\fR \- but actual improvements depend on both patterns and input data. .PP The functionality of \fBlookfor\fR includes a limited subset of the capabilities found in Austin Schutz's \fIExpect.pm\fR for Unix (and Tcl's expect which it resembles). The \f(CW\*(C`$before, $match, $pattern, and $after\*(C'\fR return values are available if someone needs to create an \*(L"expect\*(R" subroutine for porting a script. When using multiple patterns, there is one important functional difference: \fIExpect.pm\fR looks at each pattern in turn and returns the first match found; \fBlookfor\fR and \fBstreamline\fR test all patterns and return the one found \fIearliest\fR in the input if more than one matches. .SS "Exports" .IX Subsection "Exports" Nothing is exported by default. The following tags can be used to have large sets of symbols exported: .IP ":PARAM" 4 .IX Item ":PARAM" Utility subroutines and constants for parameter setting and test: .Sp .Vb 2 \& LONGsize SHORTsize nocarp yes_true \& OS_Error .Ve .IP ":STAT" 4 .IX Item ":STAT" The Constants named BM_* and CE_* are omitted. But the modem status (MS_*) Constants are defined for possible use with \fBmodemlines\fR and \&\fBwait_modemlines\fR. They are assigned to corresponding functions, but the bit position will be different from that on Win32. .Sp Which incoming bits are active: .Sp .Vb 6 \& 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) .Ve .Sp If you want to write more POSIX-looking code, you can use the constants seen there, instead of the Win32 versions: .Sp .Vb 1 \& TIOCM_CTS, TIOCM_DSR, TIOCM_RI, TIOCM_CD, TIOCM_RTS, and TIOCM_DTR .Ve .Sp Offsets into the array returned by \fBstatus:\fR .Sp .Vb 1 \& ST_BLOCK ST_INPUT ST_OUTPUT ST_ERROR .Ve .IP ":ALL" 4 .IX Item ":ALL" All of the above. Except for the \fItest suite\fR, there is not really a good reason to do this. .SH "PINOUT" .IX Header "PINOUT" Here is a handy pinout map, showing each line and signal on a standard \s-1DB9\s0 connector: .IP "1 \s-1DCD\s0" 8 .IX Item "1 DCD" Data Carrier Detect .IP "2 \s-1RD\s0" 8 .IX Item "2 RD" Receive Data .IP "3 \s-1TD\s0" 8 .IX Item "3 TD" Transmit Data .IP "4 \s-1DTR\s0" 8 .IX Item "4 DTR" Data Terminal Ready .IP "5 \s-1SG\s0" 8 .IX Item "5 SG" Signal Ground .IP "6 \s-1DSR\s0" 8 .IX Item "6 DSR" Data Set Ready .IP "7 \s-1RTS\s0" 8 .IX Item "7 RTS" Request to Send .IP "8 \s-1CTS\s0" 8 .IX Item "8 CTS" Clear to Send .IP "9 \s-1RI\s0" 8 .IX Item "9 RI" Ring Indicator .SH "NOTES" .IX Header "NOTES" The object returned by \fBnew\fR is \s-1NOT\s0 a \fIFilehandle\fR. You will be disappointed if you try to use it as one. .PP e.g. the following is \s-1WRONG\s0!! .PP .Vb 1 \& print $PortObj "some text"; .Ve .PP This module uses \fI\s-1POSIX\s0 termios\fR extensively. Raw \s-1API\s0 calls are \fBvery\fR unforgiving. You will certainly want to start perl with the \fB\-w\fR switch. If you can, \fBuse strict\fR as well. Try to ferret out all the syntax and usage problems \s-1BEFORE\s0 issuing the \s-1API\s0 calls (many of which modify tuning constants in hardware device drivers....not where you want to look for bugs). .PP With all the options, this module needs a good tutorial. It doesn't have one yet. .SH "EXAMPLE" .IX Header "EXAMPLE" It is recommended to always use \*(L"read(255)\*(R" 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: .PP .Vb 1 \& 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\*(Aqt 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\en"; \& } .Ve .SH "PORTING" .IX Header "PORTING" For a serial port to work under Unix, you need the ability to do several types of operations. With \s-1POSIX,\s0 these operations are implemented with a set of \*(L"tc*\*(R" 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. .IP "Get/Set \s-1RTS\s0" 4 .IX Item "Get/Set RTS" This is only available through the bit\-set(\s-1TIOCMBIS\s0)/bit\-clear(\s-1TIOCMBIC\s0) ioctl function using the \s-1RTS\s0 value(\s-1TIOCM_RTS\s0). .Sp .Vb 1 \& ioctl($handle,$on ? $TIOCMBIS : $TIOCMBIC, $TIOCM_RTS); .Ve .IP "Get/Set \s-1DTR\s0" 4 .IX Item "Get/Set DTR" This is available through the bit\-set(\s-1TIOCMBIS\s0)/bit\-clear(\s-1TIOCMBIC\s0) ioctl function using the \s-1DTR\s0 value(\s-1TIOCM_DTR\s0) .Sp .Vb 1 \& ioctl($handle,$on ? $TIOCMBIS : $TIOCMBIC, $TIOCM_DTR); .Ve .Sp or available through the \s-1DTRSET/DTRCLEAR\s0 ioctl functions, if they exist. .Sp .Vb 1 \& ioctl($handle,$on ? $TIOCSDTR : $TIOCCDTR, 0); .Ve .IP "Get modem lines" 4 .IX Item "Get modem lines" To read Clear To Send (\s-1CTS\s0), Data Set Ready (\s-1DSR\s0), Ring Indicator (\s-1RING\s0), and Carrier Detect (\s-1CD/RLSD\s0), the \s-1TIOCMGET\s0 ioctl function must be used. .Sp .Vb 1 \& ioctl($handle, $TIOCMGET, $status); .Ve .Sp To decode the individual modem lines, some bits have multiple possible constants: .RS 4 .IP "Clear To Send (\s-1CTS\s0)" 4 .IX Item "Clear To Send (CTS)" \&\s-1TIOCM_CTS\s0 .IP "Data Set Ready (\s-1DSR\s0)" 4 .IX Item "Data Set Ready (DSR)" \&\s-1TIOCM_DSR\s0 .IP "Ring Indicator (\s-1RING\s0)" 4 .IX Item "Ring Indicator (RING)" \&\s-1TIOCM_RNG TIOCM_RI\s0 .IP "Carrier Detect (\s-1CD/RLSD\s0)" 4 .IX Item "Carrier Detect (CD/RLSD)" \&\s-1TIOCM_CAR TIOCM_CD\s0 .RE .RS 4 .RE .IP "Get Buffer Status" 4 .IX Item "Get Buffer Status" To get information about the state of the serial port input and output buffers, the \s-1TIOCINQ\s0 and \s-1TIOCOUTQ\s0 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. .Sp .Vb 2 \& ioctl($handle,$in ? $TIOCINQ : $TIOCOUTQ, $count); \& $count = unpack(\*(Aqi\*(Aq,$count); .Ve .IP "Get Line Status" 4 .IX 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 \s-1TIOCSERGETLSR\s0 ioctl function must be used. Additionally, the \*(L"Get Buffer Status\*(R" methods must be functioning, as well as having the first bit of the result set (Linux is \s-1TIOCSER_TEMT,\s0 others unknown, but we've been using \s-1TIOCM_LE\s0 even though that should be returned from the \s-1TIOCMGET\s0 ioctl). .Sp .Vb 2 \& ioctl($handle,$TIOCSERGETLSR, $status); \& $done = (unpack(\*(Aqi\*(Aq, $status) & $TIOCSER_TEMT); .Ve .IP "Set Flow Control" 4 .IX Item "Set Flow Control" Some Unix systems require special \s-1TCGETX/TCSETX\s0 ioctls functions and the \&\s-1CTSXON/RTSXOFF\s0 constants to turn on and off \s-1CTS/RTS\s0 \*(L"hard\*(R" flow control instead of just using the normal \s-1POSIX\s0 tcsetattr calls. .Sp .Vb 5 \& ioctl($handle, $TCGETX, $flags); \& @bytes = unpack(\*(AqSSSS\*(Aq,$flags); \& $bytes[0] = $on ? ($CTSXON | $RTSXOFF) : 0; \& $flags = pack(\*(AqSSSS\*(Aq,@bytes); \& ioctl($handle, $TCSETX, $flags); .Ve .SH "KNOWN LIMITATIONS" .IX Header "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 \s-1XS.\s0 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. .PP The \fBread\fR method, and tied methods which call it, currently can use a fixed timeout which approximates behavior of the \fIWin32::SerialPort\fR \&\fBread_const_time\fR and \fBread_char_time\fR methods. It is used internally by \fIselect\fR. If the timeout is set to zero, the \fBread\fR call will return immediately. A \fBread\fR larger than 255 bytes will be split internally into 255\-byte \s-1POSIX\s0 calls due to limitations of \fIselect\fR and \fI\s-1VMIN\s0\fR. The timeout is reset for each 255\-byte segment. Hence, for large \fBreads\fR, use a \fBread_const_time\fR suitable for a 255\-byte read. All of this is expeimental in Version 0.055. .PP .Vb 2 \& $PortObj\->read_const_time(500); # 500 milliseconds = 0.5 seconds \& $PortObj\->read_char_time(5); # avg time between read char .Ve .PP 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. .PP Read_Total = \fBread_const_time\fR + (\fBread_char_time\fR * bytes_to_read) .PP Write timeouts and \fBread_interval\fR timeouts are not currently supported. .PP 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 .PP .Vb 1 \& $PortObj\->read(1) or $PortObj\->read(255) .Ve .PP and performing multiple reads until the transfer is completed. .SH "BUGS" .IX Header "BUGS" See the limitations about lockfiles. Experiment if you like. .PP With all the \fIcurrently unimplemented features\fR, we don't need any more. But there probably are some. .PP Please send comments and bug reports to kees@outflux.net. .SH "Win32::SerialPort & Win32API::CommPort" .IX Header "Win32::SerialPort & Win32API::CommPort" .SS "Win32::SerialPort Functions Not Currently Supported" .IX Subsection "Win32::SerialPort Functions Not Currently Supported" .Vb 1 \& $LatchErrorFlags = $PortObj\->reset_error; \& \& $PortObj\->read_interval(100); # max time between read char \& $PortObj\->write_char_time(5); \& $PortObj\->write_const_time(100); .Ve .ie n .SS "Functions Handled in a \s-1POSIX\s0 system by ""stty""" .el .SS "Functions Handled in a \s-1POSIX\s0 system by ``stty''" .IX Subsection "Functions Handled in a POSIX system by stty" .Vb 5 \& 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 .Ve .SS "Win32::SerialPort Functions Not Ported to \s-1POSIX\s0" .IX Subsection "Win32::SerialPort Functions Not Ported to POSIX" .Vb 1 \& transmit_char .Ve .SS "Win32API::CommPort Functions Not Ported to \s-1POSIX\s0" .IX Subsection "Win32API::CommPort Functions Not Ported to POSIX" .Vb 11 \& 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 .Ve .ie n .SS """raw"" Win32 \s-1API\s0 Calls and Constants" .el .SS "``raw'' Win32 \s-1API\s0 Calls and Constants" .IX Subsection "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: .IP ":RAW" 4 .IX Item ":RAW" The \s-1API\s0 Wrapper Methods and Constants used only to support them including PURGE_*, SET*, CLR*, EV_*, and ERROR_IO* .IP ":COMMPROP" 4 .IX Item ":COMMPROP" The Constants used for Feature and Properties Detection including BAUD_*, PST_*, PCF_*, SP_*, DATABITS_*, STOPBITS_*, PARITY_*, and \&\s-1COMMPROP_INITIALIZED\s0 .IP ":DCB" 4 .IX Item ":DCB" The constants for the \fIWin32 Device Control Block\fR including CBR_*, DTR_*, RTS_*, *PARITY, *STOPBIT*, and FM_* .SS "Compatibility" .IX Subsection "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 \fBstty_emulation\fR that already have \s-1POSIX\s0 implementations or to replicate \fIWin32 idosyncracies\fR. 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. .SH "AUTHORS" .IX Header "AUTHORS" .Vb 5 \& 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/ .Ve .SH "SEE ALSO" .IX Header "SEE ALSO" Win32API::CommPort .PP Win32::SerialPort .PP perltoot \- Tom Christiansen's Object-Oriented Tutorial .SH "COPYRIGHT" .IX Header "COPYRIGHT" .Vb 2 \& Copyright (C) 1999, Bill Birthisel. All rights reserved. \& Copyright (C) 2000\-2007, Kees Cook. All rights reserved. .Ve .PP This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.