From aef92e33e859fcd7dbc18a8064c1a88f0708a3ad Mon Sep 17 00:00:00 2001 From: Jaro Date: Fri, 15 Oct 2021 21:18:39 +0200 Subject: [PATCH] fix and log --- main.cpp | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/main.cpp b/main.cpp index 7df1c81..fb84a50 100755 --- a/main.cpp +++ b/main.cpp @@ -219,6 +219,7 @@ int main(int argc, char* argv[]) cout << "tlak = " << pressure << endl; } + if (vm.count("temperature")) { cout << temperature << endl; } @@ -233,38 +234,45 @@ int main(int argc, char* argv[]) return 0; } - + if (vm.count("brightness")) { - serial.writeString(str(format("bright %d\r\n") % brightness)); + string s = str(format("bright %d\r\n") % brightness); + BOOST_LOG_TRIVIAL(debug) << "SET " << s ; + serial.writeString(s); + boost::this_thread::sleep(posix_time::milliseconds(100)); } if (vm.count("saturation")) { - serial.writeString(str(format("satur %d\r\n") % saturation)); + string s = str(format("satur %d\r\n") % saturation); + BOOST_LOG_TRIVIAL(debug) << "SET " << s ; + serial.writeString(s); + boost::this_thread::sleep(posix_time::milliseconds(100)); } if (vm.count("contrast")) { - serial.writeString(str(format("contr %d\r\n") % contrast)); + string s = str(format("contr %d\r\n") % contrast); + BOOST_LOG_TRIVIAL(debug) << "SET " << s ; + serial.writeString(s); + boost::this_thread::sleep(posix_time::milliseconds(100)); } - - + if (vm.count("capture")) { serial.writeString("capture\r\n"); boost::this_thread::sleep(posix_time::milliseconds(100)); - serial.setTimeout(posix_time::milliseconds(500)); try { - for (;;) { - line = serial.readStringUntil("\r\n"); - if (line.rfind("[OK]",0) == 0) - cout << line << endl; - } - } catch (...) { + for (;;) { + line = serial.readStringUntil("\r\n"); + if (line.rfind("[OK]",0) == 0) + cout << line << endl; + } + } catch (...) { } - + serial.writeString("rb\r\n"); boost::this_thread::sleep(posix_time::milliseconds(100));