diff --git a/COPYING b/COPYING index e664699..60b4d39 100644 --- a/COPYING +++ b/COPYING @@ -22,7 +22,7 @@ Contributers: * Uwe Grohnwaldt * Markus Bergkvist -LICENSE (the BSD lisence): +LICENSE (the BSD license): Copyright (c) 2010-2012, Raditex Control AB All rights reserved. diff --git a/bin/Makefile.am b/bin/Makefile.am index 7710550..f2462cf 100644 --- a/bin/Makefile.am +++ b/bin/Makefile.am @@ -65,3 +65,24 @@ mbus_serial_switch_baudrate_LDFLAGS = -L$(top_builddir)/mbus mbus_serial_switch_baudrate_LDADD = -lmbus mbus_serial_switch_baudrate_SOURCES = mbus-serial-switch-baudrate.c +# man pages +dist_man_MANS = libmbus.1 \ + mbus-tcp-scan.1 \ + mbus-tcp-request-data.1 \ + mbus-tcp-request-data-multi-reply.1 \ + mbus-tcp-select-secondary.1 \ + mbus-tcp-scan-secondary.1 \ + mbus-serial-scan.1 \ + mbus-serial-request-data.1 \ + mbus-serial-request-data-multi-reply.1 \ + mbus-serial-select-secondary.1 \ + mbus-serial-scan-secondary.1 \ + mbus-serial-switch-baudrate.1 + +.pod.1: + pod2man --release=$(VERSION) --center=$(PACKAGE) $< \ + >.pod2man.tmp.$$$$ 2>/dev/null && mv -f .pod2man.tmp.$$$$ $@ || true + @if grep '\' $@ >/dev/null 2>&1; \ + then \ + echo "$@ has some POD errors!"; false; \ + fi diff --git a/bin/libmbus.pod b/bin/libmbus.pod new file mode 100644 index 0000000..e85b02e --- /dev/null +++ b/bin/libmbus.pod @@ -0,0 +1,125 @@ +=head1 NAME + +libmbus (utilities) - support utilities to the libmbus. libmbus is an open +source M-bus (Meter-Bus) library. The Meter-Bus is a standard for reading out +meter data from electricity meters, heat meters, gas meters, etc. The role +of the libmbus library is to decode/encode M-bus data, and to handle +the communication with M-Bus devices. + +=head1 SYNOPSIS + +B [-b BAUDRATE] device address target-baudrate + +B [-d] [-b BAUDRATE] device + +B [-d] host port + +B [-d] [-b BAUDRATE] device [address-mask] + +B host port [address-mask] + +B [-d] [-b BAUDRATE] device mbus-address + +B [-d] host port mbus-address + +B [-d] [-b BAUDRATE] device mbus-address + +B [-d] host port mbus-address + +B [-b BAUDRATE] device secondary-mbus-address + +B host port secondary-mbus-address + +=head1 DESCRIPTION + +B - attempts to switch the communication speed of +the MBus device. + +B, B - sequentially scan for devices on MBus bus +using primary addresses. + +B, B - scan for devices on +MBus bus using secondary addresses. The scan is not sequential. + +B, B - read data from given device. +Supports both primary and secondary address types. + +B, B - read +data from given device supporting multi-telegram (up to 16 frames) reply. Can be also +used for single telegram as mbus-serial-request-data or mbus-tcp-request-data. +Supports both primary and secondary address types. + +B, B - perform single secondary +address select to check what device responds. + +=head1 OPTIONS + +There are following options/parameters: + +=over 4 + +=item B<-b> I + +For serial communication, use given I (integer in Bd). If not used then +default baudrate of 9600 will be used. + +=item B<-d> + +Enable debugging messages. + +=item B + +For serial communication, the serial device which represents the MBus (gateway). +Typically something like /dev/ttyS0, /dev/ttyUSB0, etc. + +=item B + +For TCP communciation, the host which represents the MBus (gateway). + +=item B + +For TCP communciation, the port on the host which represents the MBus (gateway). + +=item B
+ +MBus device primary address. An integer between 1 and 250. + +=item B + +Address mask for secondary address scan - you can restrict the search by supplying +an optional address mask on the form 'FFFFFFFFFFFFFFFF' where F is a wildcard +character. + +=item B + +MBus device address. Could be a primary address (an integer between 1 and 250) or +a secondary address (sixteen digit hexadecimal number). + +=item B + +MBus secondary address of the device. Sixteen digit hexadecimal number. + +=item B + +For serial communication, the baudrate to which the device should be switched. + +=back + + +=head1 EXAMPLES + +Scan for MBus devices on the serial port: + + mbus-serial-scan -d -b 2400 /dev/ttyS0 + +Try to switch baud rate of a device on address 59 from 2400Bd to 9600Bd: + + mbus-serial-switch-baudrate -b 2400 /dev/ttyUSB0 59 9600 + +=head1 SEE ALSO + +S and S + +=head1 AUTHORS + +See S and S diff --git a/bin/mbus-serial-request-data-multi-reply.1 b/bin/mbus-serial-request-data-multi-reply.1 new file mode 100644 index 0000000..df8a67a --- /dev/null +++ b/bin/mbus-serial-request-data-multi-reply.1 @@ -0,0 +1,2 @@ +.so man1/libmbus.1 + diff --git a/bin/mbus-serial-request-data.1 b/bin/mbus-serial-request-data.1 new file mode 100644 index 0000000..df8a67a --- /dev/null +++ b/bin/mbus-serial-request-data.1 @@ -0,0 +1,2 @@ +.so man1/libmbus.1 + diff --git a/bin/mbus-serial-scan-secondary.1 b/bin/mbus-serial-scan-secondary.1 new file mode 100644 index 0000000..df8a67a --- /dev/null +++ b/bin/mbus-serial-scan-secondary.1 @@ -0,0 +1,2 @@ +.so man1/libmbus.1 + diff --git a/bin/mbus-serial-scan.1 b/bin/mbus-serial-scan.1 new file mode 100644 index 0000000..df8a67a --- /dev/null +++ b/bin/mbus-serial-scan.1 @@ -0,0 +1,2 @@ +.so man1/libmbus.1 + diff --git a/bin/mbus-serial-select-secondary.1 b/bin/mbus-serial-select-secondary.1 new file mode 100644 index 0000000..df8a67a --- /dev/null +++ b/bin/mbus-serial-select-secondary.1 @@ -0,0 +1,2 @@ +.so man1/libmbus.1 + diff --git a/bin/mbus-serial-switch-baudrate.1 b/bin/mbus-serial-switch-baudrate.1 new file mode 100644 index 0000000..df8a67a --- /dev/null +++ b/bin/mbus-serial-switch-baudrate.1 @@ -0,0 +1,2 @@ +.so man1/libmbus.1 + diff --git a/bin/mbus-tcp-request-data-multi-reply.1 b/bin/mbus-tcp-request-data-multi-reply.1 new file mode 100644 index 0000000..df8a67a --- /dev/null +++ b/bin/mbus-tcp-request-data-multi-reply.1 @@ -0,0 +1,2 @@ +.so man1/libmbus.1 + diff --git a/bin/mbus-tcp-request-data.1 b/bin/mbus-tcp-request-data.1 new file mode 100644 index 0000000..df8a67a --- /dev/null +++ b/bin/mbus-tcp-request-data.1 @@ -0,0 +1,2 @@ +.so man1/libmbus.1 + diff --git a/bin/mbus-tcp-scan-secondary.1 b/bin/mbus-tcp-scan-secondary.1 new file mode 100644 index 0000000..df8a67a --- /dev/null +++ b/bin/mbus-tcp-scan-secondary.1 @@ -0,0 +1,2 @@ +.so man1/libmbus.1 + diff --git a/bin/mbus-tcp-scan.1 b/bin/mbus-tcp-scan.1 new file mode 100644 index 0000000..df8a67a --- /dev/null +++ b/bin/mbus-tcp-scan.1 @@ -0,0 +1,2 @@ +.so man1/libmbus.1 + diff --git a/bin/mbus-tcp-select-secondary.1 b/bin/mbus-tcp-select-secondary.1 new file mode 100644 index 0000000..df8a67a --- /dev/null +++ b/bin/mbus-tcp-select-secondary.1 @@ -0,0 +1,2 @@ +.so man1/libmbus.1 + diff --git a/mbus/mbus-serial.c b/mbus/mbus-serial.c index 5880e27..a63a23b 100755 --- a/mbus/mbus-serial.c +++ b/mbus/mbus-serial.c @@ -111,6 +111,11 @@ mbus_serial_set_baudrate(mbus_handle *handle, int baudrate) serial_data->t.c_cc[VTIME] = 12; // Timeout in 1/10 sec break; + case 600: + speed = B600; + serial_data->t.c_cc[VTIME] = 6; // Timeout in 1/10 sec + break; + case 1200: speed = B1200; serial_data->t.c_cc[VTIME] = 4; // Timeout in 1/10 sec @@ -121,11 +126,26 @@ mbus_serial_set_baudrate(mbus_handle *handle, int baudrate) serial_data->t.c_cc[VTIME] = 2; // Timeout in 1/10 sec break; + case 4800: + speed = B4800; + serial_data->t.c_cc[VTIME] = 2; // Timeout in 1/10 sec + break; + case 9600: speed = B9600; serial_data->t.c_cc[VTIME] = 1; // Timeout in 1/10 sec break; + case 19200: + speed = B19200; + serial_data->t.c_cc[VTIME] = 1; // Timeout in 1/10 sec + break; + + case 38400: + speed = B38400; + serial_data->t.c_cc[VTIME] = 1; // Timeout in 1/10 sec + break; + default: return -1; // unsupported baudrate }