Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add writeBlockData method #2

Merged
merged 1 commit into from Dec 30, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 9 additions & 1 deletion README.pod
Expand Up @@ -6,7 +6,7 @@ Device::SMBus - Perl interface for smbus using libi2c-dev library.

=head1 VERSION

version 1.05
version 1.06

=head1 SYNOPSIS

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
22 changes: 22 additions & 0 deletions lib/Device/SMBus.pm
Expand Up @@ -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

Expand Down