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