Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

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 port 502, then do I format the like this? $proto = Protocol::Modbus->new( driver => 'TCP', transport => 'TCP', ip=>'', 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?

Replies are listed 'Best First'.
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 => '', 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 -> Which charger you want to use?

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://950259]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (3)
As of 2018-02-19 05:01 GMT
Find Nodes?
    Voting Booth?
    When it is dark outside I am happiest to see ...

    Results (258 votes). Check out past polls.