NAME

Lab::Bus::MODBUS_RS232 - RS232/RS485 MODBUS RTU protocol bus

VERSION

version 3.642

SYNOPSIS

use Lab::Bus::MODBUS_RS232;
my $h = Lab::Bus::MODBUS_RS232->new({
	Interface => 'RS232',
	Port => 'COM1|/dev/ttyUSB1'
	slave_address => '1'
});

COM1 is the Windows notation, /dev/ttyUSB1 the Linux equivalent. Use as needed.

DESCRIPTION

This is an interface package for Lab::Measurement to communicate via RS232/RS485 with a MODBUS RTU enabled device. It uses Lab::Bus::RS232 (RS485 can be done using a RS232<->RS485 converter for now). It's main use is to calculate the checksums needed by MODBUS RTU.

Refer to your device for the correct port configuration.

As of yet, this driver does NOT fully implement all MODBUS RTU functions. Only the function codes 3 and 6 are provided.

CONSTRUCTOR

new

All parameters are used as by Device::SerialPort respectively Lab::Bus::RS232. 'port' is needed in every case. Default value for timeout is 500ms and can be set by the parameter "Timeout". Other options you probably have to set: Handshake, Baudrate, Databits, Stopbits and Parity.

METHODS

Used by Lab::Connection. Not for direct use!!!

connectionRead

Reads data. Arguments: function (0x01,0x02,0x03,0x04 - "Read Coils", "Read Discrete Inputs", "Read Holding Registers", "Read Input Registers") slave_address (0xFF) mem_address ( 0xFFFF, Address of first word ) mem_count ( 0xFFFF, Count of words to read )

connectionWrite

Send data to instrument. Arguments:

function (0x05,0x06,0x0F,0x10 - "Write Single Coil", "Write Single Register", "Write Multiple Coils", "Write Multiple Registers")

Currently only 0x06 is implemented.

slave_address (0xFF)

mem_address ( 0xFFFF, Address of word )

Value ( 0xFFFF, value to write to mem_address )

CAVEATS/BUGS

This is a prototype...

SEE ALSO

COPYRIGHT AND LICENSE

This software is copyright (c) 2018 by the Lab::Measurement team; in detail:

Copyright 2011-2012  Andreas K. Huettel, Florian Olbrich
          2016       Simon Reinhardt
          2017       Andreas K. Huettel

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.