Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^2: Need help with Modbus

by pashanoid (Scribe)
on Jan 27, 2012 at 04:40 UTC ( #950259=note: print w/ replies, xml ) Need Help??


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

Thank you! However, could you please elaborate: if my IP is 192.168.0.57 port 502, then do I format the like this? $proto = Protocol::Modbus->new( driver => 'TCP', transport => 'TCP', ip=>'192.168.0.57', port=>'502' );

if in c ret = read_input_registers(&mb_param, SUNSAVERMPPT, 0x0000, 75, data); Then Which are the function, address and quantity? in my $request4 = $proto->request( function => 4, address => 1, quantity => 1, );

Which handle/variable gets the modbus reply?


Comment on Re^2: Need help with Modbus
Re^3: Need help with Modbus
by Khen1950fx (Canon) on Jan 27, 2012 at 06:50 UTC

    The $req variable gets the modbus reply.

    #!/usr/bin/perl -l use strict; use warnings; use Protocol::Modbus; $|=1; my $modbus = Protocol::Modbus->new( driver => 'TCP', transport => 'TCP', ); my $trs = Protocol::Modbus::Transport->new( driver => 'TCP', address => '192.168.0.57', port => 502, timeout => 3, ); my $req = $modbus->request( function => 4, address => 1, quantity => 75, value => 0x0000, ); print "=" x 60; print "Response: ", $req; print "=" x 60; $trs->disconnect;
      Hello. Did this work for you? I am trying to communicate with a charge controller that supports modbus/tcp but when I modify code above I don't even see traffic leave my host. I get a response from the program that looks like "Response: ModbusRequest PDU(000000000006ff040001000a)" but I don't know what that means. I am going crazy over this. Please help. Thank you.
        The module's author has not yet completely finished the module. It doesn't interface with PLC devices. It only generates modbus protocol messages at this time. For more info, see Modbus Specifications and Guides.
        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?

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (5)
As of 2014-09-22 22:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (206 votes), past polls