=head1 NAME

smartmeter-readout - Read data from an IEC 62056-21 smart meter

=head1 SYNOPSIS

smartmeter-readout [OPTIONS] DEVICE

=head1 DESCRIPTION

B<smartmeter-readout> communicates with the smart meter connected to
the serial port C<DEVICE> and reads out a full data telegram.

=head1 OPTIONS

=over 8

=item B<-h|--help>

Show the help message.

=item B<-d|--debug>

Print debugging output.

=item B<-r|--register REGISTER[/LABEL[/FACTOR/FORMAT]]>

By default, all registers read from the smart meter are shown. When
this option is used, only the specified registers are shown.

When B<LABEL> is specified, an optional label is printed along with
the value.

B<FACTOR> specifies an optional multiplication factor.

B<FORMAT> specifies a sprintf-style format (default: %f)

The option may be specified multiple times.

=item B<-c|--continuous>

Enable continuous reading mode. Reads telegrams until the program is
stopped using CTRL-C.

=item B<-w|--wait SECS> 

Time to wait between two readouts (when running in continuous reading
mode).

=item B<-n|--no-lock>

Don't check for lock files (potentially dangerous). This will speed up
the program by two seconds.

=item B<--callback PROGRAM>

After each telegram is read, the specified B<PROGRAM> is called and
the output is piped into that program. If the program's exit status is
different from 0, B<smartmeter-readout> quits with the same status
(especially relevant when running in continuous mode).

=item B<--retries RETRIES>

How many times to retry getting a telegram. If no telegram could be read, the
program quits with status 1. Defaults to 5 retries.

=back

B<smartmeter-readout> was reported to work with the following meters:

=over 8

=item * Iskraemeco MT174

=item * Landis+Gyr E230

=back

Registers returned on an Iskraemeco MT174 smart meter:

=over 8

=item * B<0.0.0>: Device address

=item * B<0.2.0>: Firmware version

=item * B<1.8.0>: Positive active energy total (kWh)

=item * B<1.8.1>, B<1.8.2>: Positive active energy in tariff 1 and 2 (kWh)

=item * B<2.8.0>: Negative active energy total (kWh)

=item * B<2.8.1>, B<2.8.2>: Negative active energy in tariff 1 and 2 (kWh)

=item * B<31.7.0>, B<51.7.0>, B<71.7.0>: Instantaneous current in phase L1, L2 and L3 (A)

=item * B<32.7.0>, B<52.7.0>, B<72.7.0>: Instantaneous voltage in phase L1, L2 and L3 (V)

=item * B<33.7.0>, B<53.7.0>, B<73.7.0>: Power factor in phase L1, L2 and L3 (cos phi)

=item * B<36.7.0>, B<56.7.0>, B<76.7.0>: Instantaneous power in phase L1, L2 and L3 (kW)

=item * B<C.1.0>: Meter serial number.

=item * B<C.1.1>: Meter type.

=item * B<C.1.6>: Firmware checksum.

=item * B<C.7.0>: Power outages counter.

=item * B<C.7.1>, B<C.7.2>, B<C.7.3>: Power outages counter on phase L1, L2 and L3.

=item * B<F.F.0>: Fatal error meter status.

=back

=head1 COPYRIGHT AND LICENSE

Copyright (C) 2017-2018 Oliver Hitz

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at
your option) any later version.

This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
USA.

