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).
Protocol::Modbus::Exception
Returns the protocol object in use. Should be an instance of Protocol::Modbus or its subclasses.
Protocol::Modbus
Get/set request object. Should be an instance of Protocol::Modbus::Request class.
Protocol::Modbus::Request
Get/set response object. Should be an instance of Protocol::Modbus::Response class.
Protocol::Modbus::Response
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.
3 POD Errors
The following errors were encountered while parsing the POD:
=over should be: '=over' or '=over positive_number'
You forgot a '=back' before '=head1'
To install Protocol::Modbus, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Protocol::Modbus
CPAN shell
perl -MCPAN -e shell install Protocol::Modbus
For more information on module installation, please visit the detailed CPAN module installation guide.