Add noreset and noraw options

This commit is contained in:
2021-09-01 08:05:36 +02:00
parent 1a93945ab8
commit 3ffc3ebd58

View File

@@ -125,6 +125,8 @@ int main(int argc, char* argv[])
("temperature", "get and print temprature") ("temperature", "get and print temprature")
("humidity", "get and print humidity") ("humidity", "get and print humidity")
("pressure", "get and print pressure") ("pressure", "get and print pressure")
("noraw", "do not set raw mode")
("noreset", "do not set zero on lines DTR a RST")
; ;
try { try {
@@ -150,14 +152,21 @@ int main(int argc, char* argv[])
BOOST_LOG_TRIVIAL(debug) << "Starting Program on " << port ; BOOST_LOG_TRIVIAL(debug) << "Starting Program on " << port ;
TimeoutSerial serial(port,speed); TimeoutSerial serial(port,speed);
serial.setTimeout(posix_time::seconds(5)); serial.setTimeout(posix_time::seconds(5));
serial.setDTR(false); if (! vm.count("noreset")) {
serial.setRTS(false); serial.setDTR(false);
serial.setRAW(); serial.setRTS(false);
}
if (! vm.count("noraw")) {
serial.setRAW();
}
boost::this_thread::sleep(posix_time::milliseconds(5000)); boost::this_thread::sleep(posix_time::milliseconds(5000));
line = serial.readStringUntil("\n"); if (! vm.count("noreset")) {
trim(line); line = serial.readStringUntil("\n");
BOOST_LOG_TRIVIAL(debug) << line; trim(line);
BOOST_LOG_TRIVIAL(debug) << line;
}
if (vm.count("measure") || vm.count("temperature") || vm.count("pressure") || vm.count("humidity")) { if (vm.count("measure") || vm.count("temperature") || vm.count("pressure") || vm.count("humidity")) {
serial.writeString("measure\r\n"); serial.writeString("measure\r\n");
@@ -219,8 +228,8 @@ int main(int argc, char* argv[])
serial.writeString("rb\r\n"); serial.writeString("rb\r\n");
boost::this_thread::sleep(posix_time::milliseconds(100)); boost::this_thread::sleep(posix_time::milliseconds(100));
serial.readChar(1); //serial.readChar(1);
serial.readChar(1); //serial.readChar(1);
modem.setSerialPort(&serial); modem.setSerialPort(&serial);
modem.setFilePath(path); modem.setFilePath(path);