Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fix for latest Reflex.

  • Loading branch information...
commit f9ce8becbaef573bb8cbe1690645aaeb37bb214b 1 parent 3d051b1
Rocco Caputo authored

Showing 2 changed files with 12 additions and 9 deletions. Show diff stats Hide diff stats

  1. +9 2 Firmata.pm
  2. +3 7 test.pl
11 Firmata.pm
@@ -3,14 +3,21 @@ package Firmata;
3 3 use Moose;
4 4 extends 'Reflex::Base';
5 5 use Reflex::Trait::EmitsOnChange qw(emits);
  6 +use Reflex::Callbacks qw(make_emitter make_terminal_emitter);
6 7
7 8 use Carp qw(croak);
8 9
9 10 # TODO - This would rock more as a role.
10 11
11 12 has handle => ( isa => 'FileHandle', is => 'rw' );
  13 +has active => ( is => 'ro', isa => 'Bool', default => 1 );
12 14
13   -with 'Reflex::Role::Streaming' => { handle => 'handle' };
  15 +with 'Reflex::Role::Streaming' => {
  16 + att_handle => 'handle',
  17 + att_active => 'active',
  18 + cb_error => make_emitter(on_error => "error"),
  19 + cb_closed => make_terminal_emitter(on_closed => "closed"),
  20 +};
14 21
15 22 has buffer => ( isa => 'Str', is => 'rw', default => '' );
16 23
@@ -115,7 +122,7 @@ sub digital_set {
115 122 sub on_handle_data {
116 123 my ($self, $args) = @_;
117 124
118   - my $buffer = $self->buffer() . $args->{data};
  125 + my $buffer = $self->buffer() . ($args->octets());
119 126
120 127 # TODO - Cheezy, slow. Do better.
121 128
10 test.pl
@@ -45,13 +45,13 @@
45 45
46 46 while (defined( my $e = $device->next() )) {
47 47
48   - if ($e->{name} eq "version") {
  48 + if ($e->_name() eq "version") {
49 49 # Request capabilities.
50 50 $device->put_handle("\xF0\x6B\xF7");
51 51 next;
52 52 }
53 53
54   - if ($e->{name} eq "capabilities") {
  54 + if ($e->_name() eq "capabilities") {
55 55 #$device->analog_in( 1 );
56 56 #$device->analog_report( 1, 1 );
57 57
@@ -75,9 +75,5 @@
75 75 next;
76 76 }
77 77
78   - print "--- $e->{name}\n";
79   - foreach my $key (sort keys %{$e->{arg}}) {
80   - next if $key eq "_sender";
81   - print "$key: $e->{arg}{$key}\n";
82   - }
  78 + print $e->dump(), "\n";
83 79 }

0 comments on commit f9ce8be

Please sign in to comment.
Something went wrong with that request. Please try again.