++ed by:

1 non-PAUSE user.

Andreas K. Hüttel
and 4 contributors


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


        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.


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.



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.


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


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 )


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 )


This is a prototype...



 (c) Florian Olbrich 2010

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