Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

add writeBlockData method #2

Merged
merged 1 commit into from

2 participants

@jonathanstowe

Hi,
Thanks for making Device::SMBus.

I have used it to make Device::PiGlow and it works great.

I noticed that you implemented the XS code for the block write but didn't expose it in the Perl API, this implements that.

I've actually implemented it directly in my code, and it works fine as implemented (for what I wanted to do.) So know rush to make a release :)

Because I don't have a device that I can read from I didn't implement the read block data :)

@shantanubhadoria shantanubhadoria merged commit 2300b56 into from
@shantanubhadoria

Thanks for this addition.
I will put it into the next release.
Cheers,
-Shantanu Bhadoria

@shantanubhadoria shantanubhadoria referenced this pull request from a commit
Shantanu Bhadoria v1.06
 - spelling fixes [Shantanu Bhadoria]
 - Added more documentation, used mailmap to remove duplicates in
   contributors information, Thanks to git shortlog:
   https://www.kernel.org/pub/software/scm/git/docs/git-shortlog.html
   [Shantanu Bhadoria]
 - Merge pull request #2 from jonathanstowe/master

   add writeBlockData method [Shantanu Bhadoria]
 - add writeBlockData method [Jonathan Stowe]
8fa8a0f
@jonathanstowe
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 20, 2013
  1. @jonathanstowe
This page is out of date. Refresh to see the latest.
Showing with 31 additions and 1 deletion.
  1. +9 −1 README.pod
  2. +22 −0 lib/Device/SMBus.pm
View
10 README.pod
@@ -6,7 +6,7 @@ Device::SMBus - Perl interface for smbus using libi2c-dev library.
=head1 VERSION
-version 1.05
+version 1.06
=head1 SYNOPSIS
@@ -137,6 +137,13 @@ $self->writeWordData($register_address,$value)
$self->processCall($register_address,$value)
+=head2 writeBlockData
+
+$self->writeBlockData($register_address, $values)
+
+Writes a maximum of 32 bytes in a single block to the i2c device. The supplied $values should be
+an array ref containing the bytes to be written.
+
=head2 DEMOLISH
Destructor
@@ -229,3 +236,4 @@ This software is copyright (c) 2013 by Shantanu Bhadoria.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
+=cut
View
22 lib/Device/SMBus.pm
@@ -196,6 +196,28 @@ sub processCall {
my $retval = Device::SMBus::_processCall($self->I2CBusFilenumber,$register_address,$value);
}
+=method writeBlockData
+
+$self->writeBlockData($register_address, $values)
+
+Writes a maximum of 32 bytes in a single block to the i2c device. The supplied $values should be
+an array ref containing the bytes to be written.
+
+The register address should be one that is at the beginning of a contiguous block of registers of equal lengh
+to the array of values passed. Not adhering to this will almost certainly result in unexpected behaviour in
+the device.
+
+=cut
+
+sub writeBlockData {
+ my ( $self, $register_address, $values ) = @_;
+
+ my $value = pack "C*", @{$values};
+
+ my $retval = Device::SMBus::_writeI2CBlockData($self->I2CBusFilenumber,$register_address, $value);
+ return $retval;
+}
+
# Preloaded methods go here.
=method DEMOLISH
Something went wrong with that request. Please try again.