view release on metacpan or search on metacpan
Be aware that most perlTk applications have a central event loop.
User actions, such as mouse clicks, key presses, window exposures, etc
will generate 'events' that the script will process. When a perlTk
application is running, its 'MainLoop' call will accept these events
and then dispatch them to appropriate callbacks associated with the
appropriate widgets.
Ptkdb has its own event loop that runs whenever you've stopped at a
breakpoint and entered the debugger. However, it can accept events
that are generated by other perlTk windows and dispatch their
callbacks. The problem here is that the application is supposed to be
'stopped', and logically the application should not be able to process
events.
A future version of ptkdb will have an extension that will 'filter'
events so that application events are not processed while the debugger
view all matches for this distribution
view release on metacpan or search on metacpan
Be aware that most perlTk applications have a central event loop.
User actions, such as mouse clicks, key presses, window exposures, etc
will generate 'events' that the script will process. When a perlTk
application is running, its 'MainLoop' call will accept these events
and then dispatch them to appropriate callbacks associated with the
appropriate widgets.
Ptkdb has its own event loop that runs whenever you've stopped at a
breakpoint and entered the debugger. However, it can accept events
that are generated by other perlTk windows and dispatch their
callbacks. The problem here is that the application is supposed to be
'stopped', and logically the application should not be able to process
events.
=head2 Debugging CGI Scripts
view all matches for this distribution
view release on metacpan or search on metacpan
Be aware that most perlTk applications have a central event loop.
User actions, such as mouse clicks, key presses, window exposures, etc
will generate 'events' that the script will process. When a perlTk
application is running, its 'MainLoop' call will accept these events
and then dispatch them to appropriate callbacks associated with the
appropriate widgets.
=head2 Debugging CGI Scripts
One advantage of ptkdb over the builtin debugger(-d) is that it can be
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Developer/Dashboard.pm view on Meta::CPAN
render boilerplate. C<stream_data()> and C<stream_value()> now use
C<XMLHttpRequest> progress events for browser-visible incremental updates, so
a saved C</ajax/...> endpoint that prints early output updates the DOM before
the request finishes. Those helpers support plain text, JSON, and HTML output
modes, and the saved Ajax endpoint bindings now run after the page declares
its endpoint root object, so C<$(document).ready(...)> callbacks can call
helpers such as C<fetch_value(endpoints.foo, '#foo')> on first render.
Saved browser workspaces that render response inspection panels should place
their Response Body and Response Headers tabs below the response C<pre> box so
the main response payload stays visible while the tabbed details remain
reachable without jumping away from the current result.
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Device/Ericsson/AccessoryMenu.pm view on Meta::CPAN
=head2 control
Respond to what the phone is sending back over the port, invoking
callbacks and all that jazz.
=cut
sub control {
my $self = shift;
view all matches for this distribution
view release on metacpan or search on metacpan
Changes
CONTRIBUTING
environment
examples/example-blink.pl
examples/example-callbacks.pl
examples/example-i2c.pl
examples/example-matrix-draw.pl
examples/example-matrix-time.pl
examples/example-matrix-time2.pl
examples/example-matrix.pl
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Device/GPS.pm view on Meta::CPAN
is => 'ro',
isa => 'Device::GPS::Connection',
required => 1,
);
has '_callbacks' => (
is => 'ro',
isa => 'HashRef[ArrayRef[CodeRef]]',
default => sub {{
CALLBACK_POSITION => [],
CALLBACK_ACTIVE_SATS => [],
lib/Device/GPS.pm view on Meta::CPAN
sub add_callback
{
my ($self, $type, $callback) = @_;
push @{ $self->_callbacks->{$type} }, $callback;
return 1;
}
sub parse_next
{
lib/Device/GPS.pm view on Meta::CPAN
my ($type, @data) = split /,/, $sentence;
my $checksum = pop @data;
# TODO verify checksum
@data = $self->_convert_data_by_type( $type, @data );
foreach my $callback (@{ $self->_callbacks->{$type} }) {
$callback->(@data);
}
return 1;
}
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Device/PaloAlto/Firewall/Test.pm view on Meta::CPAN
my %args = validate(@_,
{
percent => {
type => SCALAR,
default => 1,
callbacks => {
'valid_percent' => sub{ $_[0] > 0 and $_[0] <= 100; }
},
}
}
);
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Device/SaleaeLogic.pm view on Meta::CPAN
=head1 DESCRIPTION
=head2 WHAT CAN THE SDK DO ?
The SDK provided by Saleae Logic registers a bunch of callbacks and then invokes
them with some inputs like data and the device identifiers. Multiple devices can
be handled with the same callback functions. The device SDK creates a separate
thread to manage its callbacks. The SDK supports Logic and Logic16 devices.
We mimic the same functionality where one object created by
C<Device::SaleaeLogic> can handle any number of Saleae Logic devices
simultaneously connected to the computer via USB port. Hence, you will see each
callback having 2 default arguments: the object itself and a device ID.
lib/Device/SaleaeLogic.pm view on Meta::CPAN
=over 4
=item C<new(%options)>
You should use this function to create a Device::SaleaeLogic object and
setup the callbacks to be invoked by the Device SDK.
The following are the callbacks and other options that you need or may want to setup:
=over 8
=item C<on_connect>
lib/Device/SaleaeLogic.pm view on Meta::CPAN
The way to invoke this method is as below:
$self->begin();
This method should B<not> be invoked from any callback provided to the C<new()>
function. It has to be invoked from outside of the callbacks as shown in
F<share/example.pl> in the distribution.
=item C<DESTROY()>
This method gets automatically called by Perl when destroying the object created
lib/Device/SaleaeLogic.pm view on Meta::CPAN
The way to invoke this method is as below:
my $dev_id = $self->get_device_id($id);
This method can be invoked from any callback provided to the C<new()> function
or from outside the callbacks as long as you have a copy of the
Device::SaleaeLogic object created by C<new()> and a copy of the C<$id> as well.
=item C<is_usb2($id)>
This method informs the user if the Saleae Logic device is connected via a USB
lib/Device/SaleaeLogic.pm view on Meta::CPAN
# ... it may determine the speed with which you may be able to sample
# ... but it is still not very useful
}
This method can be invoked from any callback provided to the C<new()> function
or from outside the callbacks as long as you have a copy of the
Device::SaleaeLogic object created by C<new()> and a copy of the C<$id> as well.
=item C<is_streaming($id)>
This method informs the user whether the device with ID C<$id> is streaming data
lib/Device/SaleaeLogic.pm view on Meta::CPAN
# ... do something ...
# ... look at the section for read_start() for an example ...
}
This method can be invoked from any callback provided to the C<new()> function
or from outside the callbacks as long as you have a copy of the
Device::SaleaeLogic object created by C<new()> and a copy of the C<$id> as well.
=item C<get_channel_count($id)>
This method returns the number of channels on the device with ID C<$id>. Most
lib/Device/SaleaeLogic.pm view on Meta::CPAN
The way to invoke this method is as below:
my $chcnt = $self->get_channel_count($id);
This method can be invoked from any callback provided to the C<new()> function
or from outside the callbacks as long as you have a copy of the
Device::SaleaeLogic object created by C<new()> and a copy of the C<$id> as well.
=item C<get_sample_rate($id)>
This method returns the current sampling rate of the device with ID C<$id> in
lib/Device/SaleaeLogic.pm view on Meta::CPAN
The way to invoke this method is as below:
my $rate = $self->get_sample_rate($id);
This method can be invoked from any callback provided to the C<new()> function
or from outside the callbacks as long as you have a copy of the
Device::SaleaeLogic object created by C<new()> and a copy of the C<$id> as well.
=item C<set_sample_rate($id, $rate)>
This method sets the sampling rate to the value C<$rate> in Hz for the device
lib/Device/SaleaeLogic.pm view on Meta::CPAN
my $rate = 500000;
$self->set_sample_rate($id, $rate);
This method can be invoked from any callback provided to the C<new()> function
or from outside the callbacks as long as you have a copy of the
Device::SaleaeLogic object created by C<new()> and a copy of the C<$id> as well.
=item C<get_supported_sample_rates($id)>
This method returns an array reference of all the supported sample rates for the
lib/Device/SaleaeLogic.pm view on Meta::CPAN
my $rates = $self->get_supported_sample_rates($id);
print "Supported rates in Hz: ", join (", ", @$rates), "\n";
This method can be invoked from any callback provided to the C<new()> function
or from outside the callbacks as long as you have a copy of the
Device::SaleaeLogic object created by C<new()> and a copy of the C<$id> as well.
=item C<is_logic16($id)>
This method returns the value 1 if the device with ID C<$id> is a Logic16
lib/Device/SaleaeLogic.pm view on Meta::CPAN
The way to invoke this method is as below:
print "I am a Logic16 device\n" if $self->is_logic16($id);
This method can be invoked from any callback provided to the C<new()> function
or from outside the callbacks as long as you have a copy of the
Device::SaleaeLogic object created by C<new()> and a copy of the C<$id> as well.
=item C<is_logic($id)>
This method returns the value 1 if the device with ID C<$id> is a Logic device.
lib/Device/SaleaeLogic.pm view on Meta::CPAN
The way to invoke this method is as below:
print "I am a Logic device\n" if $self->is_logic($id);
This method can be invoked from any callback provided to the C<new()> function
or from outside the callbacks as long as you have a copy of the
Device::SaleaeLogic object created by C<new()> and a copy of the C<$id> as well.
=item C<get_use5volts($id)>
This method returns 1 or 0, if the Logic16 device with ID C<$id> is running in 5V mode.
lib/Device/SaleaeLogic.pm view on Meta::CPAN
The way to invoke this method is as below:
print "I am in 5V mode\n" if $self->get_use5volts($id);
This method can be invoked from any callback provided to the C<new()> function
or from outside the callbacks as long as you have a copy of the
Device::SaleaeLogic object created by C<new()> and a copy of the C<$id> as well.
=item C<set_use5volts($id, $flag)>
This method sets the 5V mode to be either 1 or 0 for the Logic16 device given by
lib/Device/SaleaeLogic.pm view on Meta::CPAN
The way to invoke this method is as below:
$self->set_use5volts($id, 1);
This method can be invoked from any callback provided to the C<new()> function
or from outside the callbacks as long as you have a copy of the
Device::SaleaeLogic object created by C<new()> and a copy of the C<$id> as well.
=item C<get_active_channels($id)>
This method returns an array reference of the indexes of all the active channels
lib/Device/SaleaeLogic.pm view on Meta::CPAN
my $channels = $self->get_active_channels($id);
print "Active Channels: ", join (", ", @$channels), "\n" if $channels;
This method can be invoked from any callback provided to the C<new()> function
or from outside the callbacks as long as you have a copy of the
Device::SaleaeLogic object created by C<new()> and a copy of the C<$id> as well.
=item C<set_active_channels($id, $aref)>
This method takes an array reference C<$aref> with the values being the indexes
lib/Device/SaleaeLogic.pm view on Meta::CPAN
my $channels = [0, 2, 4, 8, 10, 12, 14 ];
$self->set_active_channels($id, $channels);
This method can be invoked from any callback provided to the C<new()> function
or from outside the callbacks as long as you have a copy of the
Device::SaleaeLogic object created by C<new()> and a copy of the C<$id> as well.
=item C<read_start($id)>
This method starts the data sampling from the Logic or Logic16 device given by
lib/Device/SaleaeLogic.pm view on Meta::CPAN
unless ($self->is_streaming($id)) {
$self->read_start($id);
}
This method should B<not> be invoked from any callback provided to the C<new()>
function. It has to be invoked from outside of the callbacks as shown in
F<share/example.pl> in the distribution.
=item C<stop($id)>
This method stops the data streaming that is currently happening for the Logic
lib/Device/SaleaeLogic.pm view on Meta::CPAN
if ($self->is_streaming($id)) {
$self->stop($id);
}
This method can be invoked from any callback provided to the C<new()> function
or from outside the callbacks as long as you have a copy of the
Device::SaleaeLogic object created by C<new()> and a copy of the C<$id> as well.
=item C<write_start($id)>
This method starts the data writing to the Logic device given by
lib/Device/SaleaeLogic.pm view on Meta::CPAN
The way to invoke it is this:
$self->write_start($id);
This method should B<not> be invoked from any callback provided to the C<new()>
function. It has to be invoked from outside of the callbacks.
=back
=head2 EXPORT
view all matches for this distribution
view release on metacpan or search on metacpan
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
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
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Device/WebIO/Dancer.pm view on Meta::CPAN
return send_file( '/etc/hosts',
streaming => 1,
system_path => 1,
content_type => $mime_type,
callbacks => {
around_content => sub {
my ($writer, $chunk) = @_;
my $buf;
while( read( $in_fh, $buf, VID_READ_LENGTH ) ) {
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Device/WebIO/RaspberryPi.pm view on Meta::CPAN
is => 'rw',
default => sub {[
8000
]},
);
has '_vid_stream_callbacks' => (
is => 'rw',
default => sub {[]},
);
has '_vid_stream_callback_types' => (
is => 'rw',
lib/Device/WebIO/RaspberryPi.pm view on Meta::CPAN
sub vid_stream_callback
{
my ($self, $pin, $type, $callback) = @_;
die "Do not support type '$type'" unless exists $ALLOWED_VIDEO_TYPES{$type};
$self->_vid_stream_callbacks->[$pin] = $callback;
$self->_vid_stream_callback_types->[$pin] = $type;
return 1;
}
sub vid_stream_begin_loop
lib/Device/WebIO/RaspberryPi.pm view on Meta::CPAN
my ($self, $channel) = @_;
my $width = $self->vid_width( $channel );
my $height = $self->vid_height( $channel );
my $fps = $self->vid_fps( $channel );
my $bitrate = $self->vid_kbps( $channel );
my $callback = $self->_vid_stream_callbacks->[$channel];
my $type = $self->_vid_stream_callback_types->[$channel];
my $use_audio = $self->vid_use_audio;
my $audio_dev = $self->vid_audio_input_device;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Device/WebIO.pm view on Meta::CPAN
=head3 digital_input_begin_loop
digital_input_begin_loop( $name );
Start the loop that will trigger callbacks.
=head2 Input AnyEvent
These can be used if the device does the C<DigitalInputAnyEvent> role.
lib/Device/WebIO.pm view on Meta::CPAN
=head3 vid_stream_begin_loop
vid_stream_begin_loop( $name, $channel );
Start the loop that will trigger callbacks.
=head2 Still Image
=head3 img_channels
view all matches for this distribution