From ee126beb7dd8454cf7c7b7b29c067b6e13186331 Mon Sep 17 00:00:00 2001 From: ntruchsess Date: Wed, 4 Jun 2014 20:06:44 +0000 Subject: [PATCH] FRM: update Device::Firmata to 0.56 (adds new method 'sysex_send') git-svn-id: https://svn.fhem.de/fhem/trunk@6061 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/lib/Device/Firmata.pm | 4 ++-- fhem/FHEM/lib/Device/Firmata/Platform.pm | 6 ++++++ fhem/FHEM/lib/Device/Firmata/Protocol.pm | 20 ++++++++++++++++++++ 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/fhem/FHEM/lib/Device/Firmata.pm b/fhem/FHEM/lib/Device/Firmata.pm index 307ae88a6..517a706f7 100644 --- a/fhem/FHEM/lib/Device/Firmata.pm +++ b/fhem/FHEM/lib/Device/Firmata.pm @@ -15,11 +15,11 @@ Device::Firmata - Perl interface to Firmata for the arduino platform. =head1 VERSION -Version 0.50 +Version 0.56 =cut -our $VERSION = '0.55'; +our $VERSION = '0.56'; our $DEBUG = 0; diff --git a/fhem/FHEM/lib/Device/Firmata/Platform.pm b/fhem/FHEM/lib/Device/Firmata/Platform.pm index 678e330da..17e1269ee 100644 --- a/fhem/FHEM/lib/Device/Firmata/Platform.pm +++ b/fhem/FHEM/lib/Device/Firmata/Platform.pm @@ -570,6 +570,12 @@ sub sampling_interval { return $self->{io}->data_write($sampling_interval_packet); } +sub sysex_send { + my ( $self, @sysex_data ) = @_; + my $sysex_packet = $self->{protocol}->packet_sysex(@sysex_data); + return $self->{io}->data_write($sysex_packet); +} + sub i2c_write { my ($self,$address,@data) = @_; return $self->{io}->data_write($self->{protocol}->packet_i2c_request($address,0x0,@data)); diff --git a/fhem/FHEM/lib/Device/Firmata/Protocol.pm b/fhem/FHEM/lib/Device/Firmata/Protocol.pm index 72c098f2c..0e4acd3f4 100644 --- a/fhem/FHEM/lib/Device/Firmata/Protocol.pm +++ b/fhem/FHEM/lib/Device/Firmata/Protocol.pm @@ -365,6 +365,26 @@ sub message_prepare { return $packet; } +=head2 packet_sysex + +create a binary packet containing a sysex-message + +=cut + +sub packet_sysex { + + my ( $self, @sysex_data ) = @_; + + my $protocol_version = $self->{protocol_version}; + my $protocol_commands = $COMMANDS->{$protocol_version}; + + my $bytes = @sysex_data + 2; + my $packet = pack "C" x $bytes, $protocol_commands->{START_SYSEX}, + @sysex_data, + $protocol_commands->{END_SYSEX}; + return $packet; +} + =head2 packet_sysex_command create a binary packet containing a sysex-command