
Protocol::Modbus::Transaction - Modbus protocol request/response transaction

use Protocol::Modbus;
# Initialize protocol object
my $proto = Protocol::Modbus->new( driver=>'TCP' );
# Get a request object
my $req = $proto->request(
function => Protocol::Modbus::FUNC_READ_COILS, # or 0x01
address => 0x1234,
quantity => 1,
unit => 0x07, # Only has sense for Modbus/TCP
);
# Init transaction and execute it, obtaining a response
my $trn = Protocol::Modbus::Transaction->new( request=>$req );
my $res = $trn->execute();
# Pretty-print response on stdout
print $response . "\n"; # Modbus Response PDU(......)
# ...
# Parse response
# ...

Implements the basic Modbus transaction model, with request / response cycle. Also responsible of raising exceptions (see Protocol::Modbus::Exception class).

Returns the protocol object in use. Should be an instance of Protocol::Modbus or its subclasses.
Get/set request object. Should be an instance of Protocol::Modbus::Request class.
Get/set response object. Should be an instance of Protocol::Modbus::Response class.
Executes transaction, sending request to proper channel (depending on protocol at this time). Returns a Protocol::Modbus::Response object in case of successful transaction. Returns a Protocol::Modbus::Exception object in case of failure and exception raised.


Cosimo Streppone, <cosimo@cpan.org>

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