libmodbus on a Solar Inverter

262 views
Skip to first unread message

shaddow

unread,
Jun 21, 2012, 12:19:29 AM6/21/12
to libm...@googlegroups.com
Hello

I am trying to get to read my Growatt Solar Inverter via my usb/rs232 /dev/cuaU1 port on FreeBSD 8.2-RELEASE amd64.

I have got libmodbus installed with no problems.

I have been working on a modified version of sunsavertest by Tom Rinehart.

But where I am coming stuck is trying to get "modbus_read_input_registers" to work.

I see things transmitting but I am not getting any data back

I have used (On WindowsXP)  modbuspoll, it sees the inverter on the com port,
speed 9600 Parity; None, Data; 8, Stop; one, Handshake; None
slave ID ; 1
Function; 04
Address; 1

I have in the script (main parts pasted).

modbus_t *ctx;
int rc;
uint16_t data[34];
ctx = modbus_new_rtu("/dev/cuaU1", 9600, 'N', 8, 1);
modbus_set_slave(ctx, 1);
rc = modbus_read_input_registers(ctx, 1, 4, data);

I have tried other settings in input_reg but no work :(

I am not a programer by trade so I am only going by other peoples examples.

I need it to read about 34 data points, and am going to get rrdtools & php to read it to create graphs.

BUT just getting it to read the input_registers would be great

Can some one help PLEASE.

Stéphane Raimbault

unread,
Jun 21, 2012, 7:41:20 AM6/21/12
to libm...@googlegroups.com
2012/6/21 shaddow <shaneh...@gmail.com>
Are you able to read something with modpoll?
Holding registers are more common than input registers.
Address 1 under modpoll is address 0 in libmodbus.

Stéphane 

shaddow

unread,
Jun 21, 2012, 9:01:04 PM6/21/12
to libm...@googlegroups.com

Stephane Raimbault

unread,
Jun 26, 2012, 9:10:23 AM6/26/12
to libm...@googlegroups.com
I don't think modpoll is able to display queries, you can use Wireshark (may be you need this http://wiki.wireshark.org/CaptureSetup/USB) to compare the queries of modpoll with the queries of libmodbus and understand why your device doesn't answer.

 

shaddow

unread,
Jun 26, 2012, 8:13:50 PM6/26/12
to libm...@googlegroups.com
The program I am using to give out the stats is "http://www.modbustools.com/modbus_poll.asp"  but that is on windows.

I need to get some thing to work of FreeBSD that is why I an trying to get libmodbus to work.

The machine I am using is a production machine so it can not run wireshark with out braking other things on the system.
Reply all
Reply to author
Forward
0 new messages