Subject: | INA219.pm |
Date: | Sun, 4 Nov 2018 17:27:12 -0600 |
To: | bug-Device-Chip-INA219 [...] rt.cpan.org |
From: | john <john [...] tonebridge.com> |
Hello,
I am using Device::Chip::INA219 with
Device::Chip::Adapter::LinuxKernel. With D::C::INA219 unmodified I get
this error with this code:
#!/usr/bin/perl
use strict;
use warnings;
use Device::Chip::INA219;
use Device::Chip::Adapter;
my $ADAPTER = "LinuxKernel";
my $MOUNTPARAMS = 'bus=/dev/i2c-1,addr=0x40';
my $ina = Device::Chip::INA219->new;
$ina->mount_from_paramstr(
Device::Chip::Adapter->new_from_description( $ADAPTER ),
$MOUNTPARAMS,
)->get;
my $vbus = $ina->read_bus_voltage->get / 1000;
print "vbus: $vbus\n";
I get this error from the mount_from_paramstr call:
Missing required parameter 'bus' at
/usr/share/perl5/site_perl/Device/Chip.pm line 128.
If I change D::C::INA219 "sub I2C_options" to include passing of the
%params then things work OK:
|sub I2C_options { my $self = shift; my %params = @_; my $addr = delete
$params{addr} // 0x40; $addr = oct $addr if $addr =~ m/^0/; return (
%params, # pass the parameters along addr => $addr, max_bitrate =>
100E3, ); } Is this a required change to D::C::INA219 or am I missing
something? |