The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Device::Modbus::TCP::Client - Perl client for Modbus TCP communications

SYNOPSIS

#! /usr/bin/perl

use Device::Modbus::TCP::Client; use Data::Dumper; use strict; use warnings; use v5.10;

my $client = Device::Modbus::TCP::Client->new( host => '192.168.1.34', );

my $req = $client->read_holding_registers( unit => 3, address => 2, quantity => 1 );

say Dumper $req; $client->send_request($req) || die "Send error: $!"; my $response = $client->receive_response; say Dumper $response;

$client->disconnect;

DESCRIPTION

This module is part of Device::Modbus::TCP, a distribution which implements the Modbus TCP protocol on top of Device::Modbus.

Device::Modbus::TCP::Client inherits from Device::Modbus::Client, and adds the capability of communicating via TCP sockets. As such, Device::Modbus::TCP::Client implements the constructor only. Please see Device::Modbus::Client for most of the documentation.

METHODS

new

This method creates and returns a Device::Modbus::TCP::Client object. It takes the following arguments:

host

127.0.0.1 by default

port

502 by default.

timeout

Defaults to 2 seconds.

socket

Returns the IO::Socket::INET object used by the client.

connected

Returns true if the socket object exists and if it is connected.

disconnect

This method closes the socket connection:

 $client->disconnect;

SEE ALSO

Most of the functionality is described in Device::Modbus::Client.

Other distributions

These are other implementations of Modbus in Perl which may be well suited for your application: Protocol::Modbus, MBclient, mbserverd.

GITHUB REPOSITORY

You can find the repository of this distribution in GitHub.

AUTHOR

Julio Fraire, <julio.fraire@gmail.com>

COPYRIGHT AND LICENSE

Copyright (C) 2015 by Julio Fraire This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.14.2 or, at your option, any later version of Perl 5 you may have available.