Control-CLI

 view release on metacpan or  search on metacpan

lib/Control/CLI.pm  view on Meta::CPAN

		print $string1, $$stringRef, $string2;
	}
	return;
}


########################################## Internal Private Methods ##########################################

sub _check_query { # Internal method to process Query Device Status escape sequences
	my ($self, $pkgsub, $bufRef) = @_;
	if (length $self->{QUERYBUFFER}) { # If an escape sequence fragment was cashed
		$$bufRef = join('', $self->{QUERYBUFFER}, $$bufRef); # prepend it to new output
		$self->{QUERYBUFFER} = '';
	}
	if ($$bufRef =~ /(\e(?:\[.?)?)$/){ # If output stream ends with \e, or \e[ or \e[.
		# We could be looking at an escape sequence fragment; we check if it partially matches $VT100_QueryDeviceStatus
		my $escFrag = $1;
		if ($VT100_QueryDeviceStatus =~ /^\Q$escFrag\E/){	# If it does,
			$$bufRef =~ s/\Q$escFrag\E$//;			# we strip it
			$self->{QUERYBUFFER} .= $escFrag;		# and cache it
		}
	}
	return unless $$bufRef =~ s/\Q$VT100_QueryDeviceStatus\E//go;
	# A Query Device Status escape sequence was found and removed from output buffer
	$self->_put($pkgsub, \$VT100_ReportDeviceOk); # Send a Report Device OK escape sequence
	return;

lib/Control/CLI.pm  view on Meta::CPAN

  	[Read_attempts		=> $numberOfReadAttemps,]
  	[Readwait_timer		=> $millisecs,]
  	[Data_with_error	=> $flag,]
  	[Blocking		=> $flag,]
  	[Timeout		=> $secs,]
  	[Return_reference	=> $flag,]
  	[Binmode		=> $binmode,]
  	[Errmode		=> $errmode,]
  );

If blocking is enabled - see blocking() - this method implements an initial blocking read followed by a number of non-blocking reads. The intention is that we expect to receive at least some data and then we wait a little longer to make sure we have ...
For the initial blocking read, if no data is available, the method will wait until expiry of timeout. If a timeout occurs, then the error mode action is performed as with the regular read() method in blocking mode. See errmode().
If blocking is disabled then no initial blocking read is performed, instead the method will move directly to the non-blocking reads (in this case the "timeout" and "errmode" arguments are not applicable).
Once some data has been read or blocking is disabled, then the method will perform a number of non-blocking reads at certain time intervals to ensure that any subsequent data is also read before returning.
The time interval is by default 100 milliseconds and can be either set via the readwait_timer() method or by specifying the optional "readwait_timer" argument which will override whatever value is globally set for the object. See readwait_timer().
The number of non-blocking reads is dependent on whether more data is received or not but a certain number of consecutive reads with no more data received will make the method return. By default that number is 5 and can be either set via the read_att...
Therefore note that this method will always introduce a delay of "readwait_timer" milliseconds times the value of "read_attempts" and faster response times can be obtained using the regular read() method.
In the event that some data was initially read, but a read error occured while trying to read in subsequent data (for example the connection was lost), the "data_with_error" flag will determine how the readwait method behaves. If the "data_with_error...
Returns either a hard reference to data read or the data itself, depending on the applicable setting of return_reference. See return_reference().

In blocking mode, if no error or timeout, this method will always return a defined non-empty string.

lib/Control/CLI.pm  view on Meta::CPAN

	until ($ok) {
		
		<do other stuff here..>
	
		($ok, $partialOutput) = $obj->cmd_poll;
		die $obj->errmsg unless defined $ok;	# Timeout
		$output .= $partialOutput;
	}
	print "Complete command output:\n", $output;

Note that $partialOutput returned will always terminate at output line boundaries (i.e. you can be sure that the last line is complete and not a fragment waiting for more output from device) so the output can be safely parsed for any seeked informato...

=item *

If you only want to retrieve the command output at the end:
	
	$ok = $obj->cmd(Poll_syntax => 1, Command => "show command", Blocking => 0);
	until ($ok) {
		
		<do other stuff here..>
	



( run in 0.680 second using v1.01-cache-2.11-cpan-364913b4093 )