Compare commits
12 Commits
bc113e2015
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 3576461e03 | |||
| 9603093b62 | |||
| 20eda9fc42 | |||
| 516551f15d | |||
| aef92e33e8 | |||
| 2f9937867b | |||
| e8686cbe35 | |||
| 6249dd6074 | |||
| 4ea8ce944f | |||
| 790dcd2259 | |||
| 5043618bf8 | |||
| d8fb6cae01 |
@@ -16,4 +16,5 @@ target_link_libraries(usbserial-dw ${Boost_LIBRARIES})
|
||||
#target_link_libraries(usbserial-dw ${CMAKE_THREAD_LIBS_INIT})
|
||||
|
||||
## Install
|
||||
install(TARGETS usbserial-dw DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||
install(TARGETS usbserial-dw
|
||||
RUNTIME DESTINATION bin ${CMAKE_INSTALL_BINDIR})
|
||||
51
main.cpp
51
main.cpp
@@ -30,6 +30,7 @@
|
||||
#include <boost/algorithm/string/split.hpp>
|
||||
|
||||
#include <boost/program_options.hpp>
|
||||
#include <boost/format.hpp>
|
||||
|
||||
#include "TimeoutSerial.h"
|
||||
#include "YmodemFileReceive.h"
|
||||
@@ -38,6 +39,7 @@
|
||||
|
||||
using namespace std;
|
||||
using namespace boost;
|
||||
using boost::format;
|
||||
namespace po = boost::program_options;
|
||||
|
||||
typedef vector< string > split_vector_type;
|
||||
@@ -112,7 +114,7 @@ int main(int argc, char* argv[])
|
||||
float pressure = NAN;
|
||||
po::variables_map vm;
|
||||
std::string port,path,filename;
|
||||
int speed;
|
||||
int speed,brightness = 0,saturation = 0 ,contrast = 0;
|
||||
|
||||
po::options_description desc("Allowed options");
|
||||
desc.add_options()
|
||||
@@ -124,7 +126,10 @@ int main(int argc, char* argv[])
|
||||
("path", po::value<string>(&path)->default_value("/tmp"),"directory for file of capture")
|
||||
("capture", "capture photo of camera")
|
||||
("port", po::value<string>(&port)->default_value("/dev/ttyUSB0"), "port to read from")
|
||||
("speed", po::value<int>(&speed)->default_value(115200), "speed read from port")
|
||||
("speed", po::value<int>(&speed)->default_value(460800), "speed read from port")
|
||||
("brightness", po::value<int>(&brightness)->implicit_value(0), "set brightness")
|
||||
("saturation", po::value<int>(&saturation)->implicit_value(0), "set saturation")
|
||||
("contrast", po::value<int>(&contrast)->implicit_value(0), "set contrast")
|
||||
("temperature", "get and print temprature")
|
||||
("humidity", "get and print humidity")
|
||||
("pressure", "get and print pressure")
|
||||
@@ -182,6 +187,8 @@ int main(int argc, char* argv[])
|
||||
boost::this_thread::sleep(posix_time::milliseconds(5000));
|
||||
|
||||
if (! vm.count("noreset")) {
|
||||
serial.writeString("\r\n\r\n");
|
||||
boost::this_thread::sleep(posix_time::milliseconds(300));
|
||||
line = serial.readStringUntil("\n");
|
||||
trim(line);
|
||||
BOOST_LOG_TRIVIAL(debug) << line;
|
||||
@@ -189,6 +196,7 @@ int main(int argc, char* argv[])
|
||||
|
||||
if (vm.count("measure") || vm.count("temperature") || vm.count("pressure") || vm.count("humidity")) {
|
||||
serial.writeString("measure\r\n");
|
||||
boost::this_thread::sleep(posix_time::milliseconds(100));
|
||||
|
||||
for (;;) {
|
||||
line = serial.readStringUntil("\n");
|
||||
@@ -214,6 +222,7 @@ int main(int argc, char* argv[])
|
||||
cout << "tlak = " << pressure << endl;
|
||||
}
|
||||
|
||||
|
||||
if (vm.count("temperature")) {
|
||||
cout << temperature << endl;
|
||||
}
|
||||
@@ -229,22 +238,44 @@ int main(int argc, char* argv[])
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (vm.count("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")) {
|
||||
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")) {
|
||||
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));
|
||||
|
||||
|
||||
@@ -7,14 +7,14 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=usbserial-dw
|
||||
PKG_VERSION:=0.3.0
|
||||
PKG_RELEASE:=3
|
||||
PKG_VERSION:=0.3.7
|
||||
PKG_RELEASE:=2
|
||||
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_URL:=https://git.bh.ttx.sk/jaro/usbserial-dw.git
|
||||
PKG_MIRROR_HASH:=
|
||||
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
|
||||
PKG_SOURCE_VERSION:=31db3b78d6d306d4aa33fcd831312feb56592118
|
||||
PKG_SOURCE_VERSION:=9603093b622b972c321e10982fa881f922dca690
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
|
||||
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_SOURCE_VERSION)
|
||||
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_SOURCE_VERSION)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
config capture
|
||||
option port /dev/ttyUSB0
|
||||
option speed 115200
|
||||
option speed 460800
|
||||
option directory /tmp
|
||||
option file camera.jpg
|
||||
option url https://meranie.bh.ttx.sk/upload/image
|
||||
|
||||
@@ -19,8 +19,10 @@ parse_capture() {
|
||||
config_get _file "$section" "file"
|
||||
config_get _url "$section" "url"
|
||||
|
||||
echo $PROG --port $_port --speed $_speed --path $_dir --file $_file --capture
|
||||
$PROG --port $_port --speed $_speed --path $_dir --file $_file --capture
|
||||
cd $_dir
|
||||
cd $_dir
|
||||
echo $CURL -X POST -F "submit=OK" -F "file=@camera.jpg" $_url
|
||||
$CURL -X POST -F "submit=OK" -F "file=@camera.jpg" $_url
|
||||
rm $_file
|
||||
}
|
||||
@@ -39,10 +41,12 @@ parse_post() {
|
||||
_hum=`$PROG --humidity`
|
||||
_pre=`$PROG --pressure`
|
||||
|
||||
$_mqtt_prg -h $_host -t $_topic/temperature -m N:$_tmp
|
||||
$_mqtt_prg -h $_host -t $_topic/humidity -m N:$_hum
|
||||
$_mqtt_prg -h $_host -t $_topic/pressure -m N:$_pre
|
||||
|
||||
echo $_mqtt_prg -h $_host -t $_topic/temperature -m N:${_tmp}
|
||||
$_mqtt_prg -h $_host -t $_topic/temperature -m N:${_tmp}
|
||||
echo $_mqtt_prg -h $_host -t $_topic/humidity -m N:${_hum}
|
||||
$_mqtt_prg -h $_host -t $_topic/humidity -m N:${_hum}
|
||||
echo $_mqtt_prg -h $_host -t $_topic/pressure -m N:${_pre}
|
||||
$_mqtt_prg -h $_host -t $_topic/pressure -m N:${_pre}}
|
||||
}
|
||||
|
||||
start() {
|
||||
|
||||
Reference in New Issue
Block a user