NAME
Lab::Bus::MODBUS_RS232 - Perl extension for interfacing with instruments via RS232/RS485 using the MODBUS RTU protocol
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.
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
AUTHOR/COPYRIGHT
(c) Florian Olbrich 2010
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.