Hello,
last week I bought a M203. I would like to read the digital inputs with the MODBUS protocol. I tried to use the neuron_tcp_modbus_server with libmodbus but the results are wrong, they change at every reading. Here my code:
mb = modbus_new_tcp("192.1681.1.102", 502);
//modbus_set_slave(mb, 2);
modbus_connect(mb);
/* Read 16 bit sfrom the address 0 */
modbus_read_bits(mb, 0, 16, tab_reg);
modbus_close(mb);
modbus_free(mb);
for (int i = 0; i < 16; i++) {
std::cout << static_cast<uint8_t>(tab_reg[i]) << std::flush;
std::cout <<",";
}
Any suggestions?
Thanks.