First usable version on RS Pro
This commit is contained in:
16
main.cpp
16
main.cpp
@@ -128,6 +128,7 @@ 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")
|
||||||
|
("reboot", "reboot ESP32 CAM")
|
||||||
("noraw", "do not set raw mode")
|
("noraw", "do not set raw mode")
|
||||||
("noreset", "do not set zero on lines DTR a RST")
|
("noreset", "do not set zero on lines DTR a RST")
|
||||||
;
|
;
|
||||||
@@ -161,10 +162,23 @@ int main(int argc, char* argv[])
|
|||||||
serial.setDTR(false);
|
serial.setDTR(false);
|
||||||
serial.setRTS(false);
|
serial.setRTS(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! vm.count("noraw")) {
|
if (! vm.count("noraw")) {
|
||||||
serial.setRAW();
|
serial.setRAW();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (vm.count("reset")) {
|
||||||
|
serial.setDTR(true);
|
||||||
|
serial.setRTS(true);
|
||||||
|
|
||||||
|
serial.writeString("reboot\r\n");
|
||||||
|
boost::this_thread::sleep(posix_time::milliseconds(1000));
|
||||||
|
|
||||||
|
serial.setDTR(false);
|
||||||
|
serial.setRTS(false);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
boost::this_thread::sleep(posix_time::milliseconds(5000));
|
boost::this_thread::sleep(posix_time::milliseconds(5000));
|
||||||
|
|
||||||
if (! vm.count("noreset")) {
|
if (! vm.count("noreset")) {
|
||||||
@@ -233,8 +247,6 @@ 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);
|
|
||||||
|
|
||||||
modem.setSerialPort(&serial);
|
modem.setSerialPort(&serial);
|
||||||
modem.setFilePath(path);
|
modem.setFilePath(path);
|
||||||
|
|||||||
@@ -7,8 +7,8 @@
|
|||||||
include $(TOPDIR)/rules.mk
|
include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
PKG_NAME:=usbserial-dw
|
PKG_NAME:=usbserial-dw
|
||||||
PKG_VERSION:=0.2.4
|
PKG_VERSION:=0.3.0
|
||||||
PKG_RELEASE:=15
|
PKG_RELEASE:=1
|
||||||
|
|
||||||
PKG_SOURCE_PROTO:=git
|
PKG_SOURCE_PROTO:=git
|
||||||
PKG_SOURCE_URL:=https://git.bh.ttx.sk/jaro/usbserial-dw.git
|
PKG_SOURCE_URL:=https://git.bh.ttx.sk/jaro/usbserial-dw.git
|
||||||
@@ -64,6 +64,7 @@ define Package/usbserial-dw/install
|
|||||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/usbserial-dw $(1)/usr/bin/usbserial-dw
|
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/usbserial-dw $(1)/usr/bin/usbserial-dw
|
||||||
$(INSTALL_DIR) $(1)/etc/config
|
$(INSTALL_DIR) $(1)/etc/config
|
||||||
$(INSTALL_DATA) ./files/usbserial-dw.config $(1)/etc/config/usbserial
|
$(INSTALL_DATA) ./files/usbserial-dw.config $(1)/etc/config/usbserial
|
||||||
|
$(INSTALL_BIN) ./files/usbserial-dw.sh $(1)/usr/bin/usbserial.sh
|
||||||
endef
|
endef
|
||||||
|
|
||||||
define Package/usbserial-dw/conffiles
|
define Package/usbserial-dw/conffiles
|
||||||
|
|||||||
@@ -1,51 +1,58 @@
|
|||||||
#!/bin/sh /etc/rc.common
|
#!/bin/sh /etc/rc.common
|
||||||
# Copyright (C) 2018 wongsyrone
|
# Copyright (C) 2018 wongsyrone
|
||||||
|
|
||||||
. /lib/functions.sh
|
. /lib/functions.sh
|
||||||
|
|
||||||
PROG=/usr/bin/usbserial-dw
|
PROG=/usr/bin/usbserial-dw
|
||||||
CURL=/usr/bin/curl
|
CURL=/usr/bin/curl
|
||||||
|
|
||||||
parse_capture() {
|
parse_capture() {
|
||||||
local section="$1"
|
local section="$1"
|
||||||
local _port
|
local _port
|
||||||
local _speed
|
local _speed
|
||||||
local _dir
|
local _dir
|
||||||
local _file
|
local _file
|
||||||
|
|
||||||
config_get _port "$section" "port"
|
config_get _port "$section" "port"
|
||||||
config_get _speed "$section" "speed"
|
config_get _speed "$section" "speed"
|
||||||
config_get _dir "$section" "dir"
|
config_get _dir "$section" "directory"
|
||||||
config_get _file "$section" "file"
|
config_get _file "$section" "file"
|
||||||
config_get _url "$section" "url"
|
config_get _url "$section" "url"
|
||||||
|
|
||||||
$PROG --port $_port --speed $_speed --dir $_dir --file $_file
|
$PROG --port $_port --speed $_speed --path $_dir --file $_file --capture
|
||||||
cd $_dir
|
cd $_dir
|
||||||
$CURL -v -X POST -F "submit=OK" -F "file=@camera.jpg" $_url
|
$CURL -X POST -F "submit=OK" -F "file=@camera.jpg" $_url
|
||||||
rm $_file
|
rm $_file
|
||||||
}
|
}
|
||||||
|
|
||||||
parse_post() {
|
parse_post() {
|
||||||
local section="$1"
|
local section="$1"
|
||||||
local _host
|
local _host
|
||||||
local _topic
|
local _topic
|
||||||
local _mqtt_prg
|
local _mqtt_prg
|
||||||
|
|
||||||
config_get _host "$section" "host"
|
config_get _host "$section" "host"
|
||||||
config_get _topic "$section" "topic"
|
config_get _topic "$section" "topic"
|
||||||
config_get _mqtt_prg "$section" "mqtt_prg"
|
config_get _mqtt_prg "$section" "mqtt_prg"
|
||||||
|
|
||||||
_tmp=`$PROG --temperature`
|
_tmp=`$PROG --temperature`
|
||||||
_hum=`$PROG --humidity`
|
_hum=`$PROG --humidity`
|
||||||
_pre=`$PROG --pressure`
|
_pre=`$PROG --pressure`
|
||||||
|
|
||||||
$_mqtt_prg -h $_host -t $_topic/temperature -m N:$_tmp
|
$_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/humidity -m N:$_hum
|
||||||
$_mqtt_prg -h $_host -t $_topic/pressure -m N:$_pre
|
$_mqtt_prg -h $_host -t $_topic/pressure -m N:$_pre
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
config_load usbserial
|
start() {
|
||||||
config_foreach parse_capture capture
|
echo "[OK] Starting USB serial"
|
||||||
config_foreach parse_post post
|
config_load usbserial
|
||||||
|
config_foreach parse_capture capture
|
||||||
|
config_foreach parse_post post
|
||||||
|
}
|
||||||
|
|
||||||
|
stop() {
|
||||||
|
echo "[OK] Stoping USB serial"
|
||||||
|
killall -9 $PROG
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user