From 3ffc3ebd58526453da03063a0ec55ba71ec2fdf8 Mon Sep 17 00:00:00 2001 From: Jaro Date: Wed, 1 Sep 2021 08:05:36 +0200 Subject: [PATCH] Add noreset and noraw options --- main.cpp | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/main.cpp b/main.cpp index f51faf0..96328ca 100755 --- a/main.cpp +++ b/main.cpp @@ -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);