#include <iostream>
#include <modbuspp.h>
using namespace std;
int main (int argc, char **argv) {
string port = string ("/dev/ttyUSB0");
if (argc > 1) {
port = argv[1];
}
cout <<
"Reads coils of slave[" << slv.
number() <<
"] on " <<
bool coil[5];
if (ncoils > 0) {
cout << "coils: ";
for (int i = 0; i < ncoils; i++) {
cout << coil[i];
}
cout << endl;
}
else {
cerr <<
"Unable to read coils ! " << mb.
lastError() << endl;
exit (EXIT_FAILURE);
}
}
else {
cerr <<
"Unable to open MODBUS connection to " << port <<
" : " << mb.
lastError() << endl;
exit (EXIT_FAILURE);
}
return 0;
}