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(......) #### 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;