#include <iostream>
#include <string>
#include <modbuspp.h>
using namespace std;
int main (int argc, char **argv) {
string port ("/dev/ttyUSB0");
if (argc > 1) {
port = argv[1];
}
cout <<
"Reads input registers of slave[" << slv.
number() <<
"] on " <<
uint16_t values[2];
cout << "R0=" << values[0] << endl;
cout << "R1=" << values[1] << endl;
}
else {
cerr <<
"Unable to read input registers ! " << mb.
lastError() << endl;
exit (EXIT_FAILURE);
}
}
else {
cerr <<
"Unable to open MODBUS connection to " << port <<
" : " << mb.
lastError() << endl;
exit (EXIT_FAILURE);
}
return 0;
}