Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re^5: Need help with Modbus

by olibo (Initiate)
on Aug 17, 2013 at 14:46 UTC ( #1049840=note: print w/ replies, xml ) Need Help??


in reply to Re^4: Need help with Modbus
in thread Need help with Modbus

Thats not a Modbus-Response. It`s only a output of your request. For more information check this example -> http://cpansearch.perl.org/src/COSIMO/Protocol-Modbus-0.09/examples/read_coils_full_api.pl Which charger you want to use?


Comment on Re^5: Need help with Modbus
Re^6: Need help with Modbus
by Khen1950fx (Canon) on Aug 18, 2013 at 05:32 UTC
    I haven't looked at ModBus since that post. Could you post a snippet to demonstrate the charger that you use?
      With Modbus 0.9 -> see http://search.cpan.org/~cosimo/Protocol-Modbus/lib/Protocol/Modbus/Transaction.pm ---
      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 => 4016, # Register dispavgVpv from MidNight Charger quantity => 1, ); # 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 $res . "\n"; # Modbus Response PDU(......)
      ##############################################
      or you can use MBClient -> https://github.com/sourceperl/MBclient
      use strict; use MBclient; my $m = MBclient->new(); # define server target $m->host("localhost"); $m->unit_id(1); # read 16 bits register from ad 0 to 9 my $words = $m->read_holding_registers(4100, 40); # First 40 Register +of MidNight Charger # print words foreach my $word (@$words) { print $word."\n"; } # clean exit $m->close(); exit 0;

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1049840]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (8)
As of 2015-07-03 06:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (48 votes), past polls