diff options
author | Evgeny Zinoviev <me@ch1p.io> | 2021-05-22 15:25:18 +0300 |
---|---|---|
committer | Evgeny Zinoviev <me@ch1p.io> | 2021-05-22 15:25:18 +0300 |
commit | a06039d788c64fd7288e85e7435e966b0e2abe51 (patch) | |
tree | 3263cec8c3e12f9697c16178d1f99cc66c93a376 /src/inverterd.cc | |
parent | e2df212b9f03835fe3fbe990ec45c00be43b40a3 (diff) |
inverterd: add --delay option
Diffstat (limited to 'src/inverterd.cc')
-rw-r--r-- | src/inverterd.cc | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/inverterd.cc b/src/inverterd.cc index 4e7e750..057431c 100644 --- a/src/inverterd.cc +++ b/src/inverterd.cc @@ -7,6 +7,7 @@ #include <ios> #include <getopt.h> +#include "numeric_types.h" #include "common.h" #include "voltronic/device.h" #include "voltronic/exceptions.h" @@ -29,6 +30,7 @@ static void usage(const char* progname) { " --device <DEVICE>: 'usb' (default), 'serial' or 'pseudo'\n" " --timeout <TIMEOUT>: Device timeout in ms (default: " << voltronic::Device::TIMEOUT << ")\n" " --cache-timeout <TIMEOUT>\n" + " --delay <DELAY>: Delay between commands in ms (default: 0)\n" " Cache validity time, in ms (default: " << server::Server::CACHE_TIMEOUT << ")\n" " --verbose: Be verbose\n" "\n"; @@ -53,8 +55,9 @@ static void usage(const char* progname) { int main(int argc, char *argv[]) { // common params - uint64_t timeout = voltronic::Device::TIMEOUT; - uint64_t cacheTimeout = server::Server::CACHE_TIMEOUT; + u64 timeout = voltronic::Device::TIMEOUT; + u64 cacheTimeout = server::Server::CACHE_TIMEOUT; + u64 delay = 0; bool verbose = false; // server params @@ -80,6 +83,7 @@ int main(int argc, char *argv[]) { {"verbose", no_argument, nullptr, LO_VERBOSE}, {"timeout", required_argument, nullptr, LO_TIMEOUT}, {"cache-timeout", required_argument, nullptr, LO_CACHE_TIMEOUT}, + {"delay", required_argument, nullptr, LO_DELAY}, {"device", required_argument, nullptr, LO_DEVICE}, {"usb-vendor-id", required_argument, nullptr, LO_USB_VENDOR_ID}, {"usb-device-id", required_argument, nullptr, LO_USB_DEVICE_ID}, @@ -139,6 +143,10 @@ int main(int argc, char *argv[]) { cacheTimeout = std::stoull(arg); break; + case LO_DELAY: + delay = std::stoull(arg); + break; + case LO_USB_VENDOR_ID: try { if (arg.size() != 4) @@ -266,6 +274,7 @@ int main(int argc, char *argv[]) { server::Server server(dev); server.setVerbose(verbose); + server.setDelay(delay); server.setCacheTimeout(cacheTimeout); server.start(host, port); |