-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed formating of Firmata.pm as Windows line-endings break automatic…
… install from CPAN
- Loading branch information
1 parent
e0dbfd3
commit 2de4797
Showing
2 changed files
with
123 additions
and
119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,47 @@ | ||
Revision history for Device-Firmata | ||
|
||
0.50 2010.08.31-2011.02.16 - Aki Mimoto | ||
implementig all protocol basics and releasing Device::Firmata on Github | ||
|
||
2011.03.23 - Chris Fedde | ||
reorganizing as CPAN ready module | ||
|
||
2012.12.13-2013.08.11 - Norbert Truchsess | ||
adding all missing protocol-features (1-Wire, I2C, Servo ...) | ||
adding observers for all suitable protocols | ||
|
||
Valdas Kondrotas: various bugfixes and enhancements. | ||
0.60 2014.06.28 - Norbert Truchsess | ||
Fixed formating of Firmata.pm as Windows line-endings break automatic install from CPAN | ||
|
||
0.51 2013.09.10/23:00 - Brett Carroll | ||
Changed IO.pm to use Win32::SerialPort instead of Win32::Serialport on Windows platforms | ||
Norbert Truchsess: fix handle onewire in capability-response | ||
0.59 2014.06.26 - Norbert Truchsess | ||
Fix a bug in the parser incorrectly skipping single 0x30 bytes | ||
|
||
0.52 2013.11.22 - Norbert Truchsess | ||
add Firmata over Ethernet | ||
0.58 2014.06.26 - Yanick Champoux | ||
cosmetic change to POD for CPAN | ||
|
||
0.53 2014.03.03 - Norbert Truchsess | ||
add rotary-encoder protocol | ||
0.57 2014.06.12 - Norbert Truchsess | ||
Fixed building dist for cpan | ||
|
||
0.54 2014.03.04 - Norbert Truchsess | ||
add stepper-motor protocol | ||
0.56 2014.06.04 - Norbert Truchsess | ||
add generic method sysex_send to Platform.pl | ||
|
||
0.55 2014.04.17 - Norbert Truchsess | ||
fix digital-input message interference with output pins on same port | ||
|
||
0.56 2014.06.04 - Norbert Truchsess | ||
add generic method sysex_send to Platform.pl | ||
0.54 2014.03.04 - Norbert Truchsess | ||
add stepper-motor protocol | ||
|
||
0.57 2014.06.12 - Norbert Truchsess | ||
Fixed building dist for cpan | ||
0.53 2014.03.03 - Norbert Truchsess | ||
add rotary-encoder protocol | ||
|
||
0.52 2013.11.22 - Norbert Truchsess | ||
add Firmata over Ethernet | ||
|
||
0.51 2013.09.10/23:00 - Brett Carroll | ||
Changed IO.pm to use Win32::SerialPort instead of Win32::Serialport on Windows platforms | ||
Norbert Truchsess: fix handle onewire in capability-response | ||
|
||
0.50 2012.12.13-2013.08.11 - Norbert Truchsess | ||
adding all missing protocol-features (1-Wire, I2C, Servo ...) | ||
adding observers for all suitable protocols | ||
|
||
0.58 2014.06.26 - Yanick Champoux | ||
cosmetic change to POD for CPAN | ||
Valdas Kondrotas: various bugfixes and enhancements. | ||
|
||
2011.03.23 - Chris Fedde | ||
reorganizing as CPAN ready module | ||
|
||
0.59 2014.06.26 - Norbert Truchsess | ||
Fix a bug in the parser incorrectly skipping single 0x30 bytes | ||
2011.02.16 Aki Mimoto | ||
implementig all protocol basics and releasing Device::Firmata on Github | ||
|
||
2010.08.31 Aki Mimoto | ||
start of development |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,91 +1,89 @@ | ||
package Device::Firmata; | ||
|
||
use strict; | ||
use warnings; | ||
|
||
use Device::Firmata::Constants; | ||
use Device::Firmata::Base | ||
ISA => 'Device::Firmata::Base', | ||
FIRMATA_ATTRIBS => { | ||
}; | ||
|
||
=head1 NAME | ||
Device::Firmata - Perl interface to Firmata for the arduino platform. | ||
=head1 VERSION | ||
Version 0.59 | ||
=cut | ||
|
||
our $VERSION = '0.59'; | ||
our $DEBUG = 0; | ||
|
||
|
||
=head1 SYNOPSIS | ||
use strict; | ||
use warnings; | ||
use Device::Firmata::Constants qw/ :all /; | ||
use Device::Firmata; | ||
use Time::HiRes 'sleep'; | ||
$|++; | ||
my $led_pin = 13; | ||
my $device = Device::Firmata->open('/dev/ttyUSB0') or die "Could not connect to Firmata Server"; | ||
$device->pin_mode($led_pin=>PIN_OUTPUT); | ||
my $iteration = 0; | ||
while (1) { | ||
my $strobe_state = $iteration++%2; | ||
$device->digital_write($led_pin=>$strobe_state); | ||
sleep 0.5; | ||
} | ||
=head1 SUBROUTINES/METHODS | ||
=head2 open | ||
establish serial connection with an Arduino micro-controller. Single argument is the name of the device file mapped to the arduino. Typically '/dev/ttyUSB0' or 'COM9' | ||
=cut | ||
|
||
sub open { | ||
# -------------------------------------------------- | ||
# Establish a connection to Arduino via the serial port | ||
# | ||
my ( $self, $serial_port, $opts ) = @_; | ||
|
||
# We're going to try and create the device connection first... | ||
my $package = "Device::Firmata::Platform"; | ||
eval "require $package"; | ||
my $serialio = "Device::Firmata::IO::SerialIO"; | ||
eval "require $serialio"; | ||
|
||
my $io = $serialio->open( $serial_port, $opts ); | ||
my $platform = $package->attach( $io, $opts ) or die "Could not connect to Firmata Server"; | ||
|
||
# Figure out what platform we're running on | ||
$platform->probe; | ||
|
||
return $platform; | ||
} | ||
|
||
sub listen { | ||
# -------------------------------------------------- | ||
# Listen on socket and wait for Arduino to establish a connection | ||
# | ||
my ( $pkg, $ip, $port, $opts ) = @_; | ||
|
||
my $netio = "Device::Firmata::IO::NetIO"; | ||
eval "require $netio"; | ||
|
||
return $netio->listen( $ip, $port, $opts ) or die "Could not bind to socket"; | ||
|
||
} | ||
|
||
1; | ||
package Device::Firmata; | ||
|
||
use strict; | ||
use warnings; | ||
|
||
use Device::Firmata::Constants; | ||
use Device::Firmata::Base | ||
ISA => 'Device::Firmata::Base', | ||
FIRMATA_ATTRIBS => { | ||
}; | ||
|
||
=head1 NAME | ||
Device::Firmata - Perl interface to Firmata for the arduino platform. | ||
=head1 VERSION | ||
Version 0.60 | ||
=cut | ||
|
||
our $VERSION = '0.60'; | ||
our $DEBUG = 0; | ||
|
||
|
||
=head1 SYNOPSIS | ||
use strict; | ||
use warnings; | ||
use Device::Firmata::Constants qw/ :all /; | ||
use Device::Firmata; | ||
use Time::HiRes 'sleep'; | ||
$|++; | ||
my $led_pin = 13; | ||
my $device = Device::Firmata->open('/dev/ttyUSB0') or die "Could not connect to Firmata Server"; | ||
$device->pin_mode($led_pin=>PIN_OUTPUT); | ||
my $iteration = 0; | ||
while (1) { | ||
my $strobe_state = $iteration++%2; | ||
$device->digital_write($led_pin=>$strobe_state); | ||
sleep 0.5; | ||
} | ||
=head1 SUBROUTINES/METHODS | ||
=head2 open | ||
establish serial connection with an Arduino micro-controller. Single argument is the name of the device file mapped to the arduino. Typically '/dev/ttyUSB0' or 'COM9' | ||
=cut | ||
|
||
sub open { | ||
# -------------------------------------------------- | ||
# Establish a connection to Arduino via the serial port | ||
# | ||
my ( $self, $serial_port, $opts ) = @_; | ||
|
||
# We're going to try and create the device connection first... | ||
my $package = "Device::Firmata::Platform"; | ||
eval "require $package"; | ||
my $serialio = "Device::Firmata::IO::SerialIO"; | ||
eval "require $serialio"; | ||
|
||
my $io = $serialio->open( $serial_port, $opts ); | ||
my $platform = $package->attach( $io, $opts ) or die "Could not connect to Firmata Server"; | ||
|
||
# Figure out what platform we're running on | ||
$platform->probe; | ||
return $platform; | ||
} | ||
|
||
sub listen { | ||
# -------------------------------------------------- | ||
# Listen on socket and wait for Arduino to establish a connection | ||
# | ||
my ( $pkg, $ip, $port, $opts ) = @_; | ||
|
||
my $netio = "Device::Firmata::IO::NetIO"; | ||
eval "require $netio"; | ||
|
||
return $netio->listen( $ip, $port, $opts ) or die "Could not bind to socket"; | ||
} | ||
|
||
1; |