Add daemon subcommand

When an Atrus device is attached to a host computer, this daemon should
be started. It's responsible for doing upgrades, if needed, and
continuously polling for diagnostics. Output is written to the syslog.

The current implementation has a limitation when multiple devices are
attached.  If device A is attached, the daemon should start. When device B
is attached, no new deamon should start. However, if A or B is then
detached, the daemon will stop, and the remaining device will not have a
daemon to communicate with. B will also not receive any updates, since
updates are provisioned only when the daemon starts. This shouldn't be a
problem since multiple devices aren't a major use case, but it should be
fixed in the future.

Note that this change also break CLI compatibility for the upgrade
subcommand. The --debug option is now accepted globally and not per
subcommand, e.g.,

$ atrusctl upgrade --debug ...

should from now be

$ atrusctl --debug upgrade ...

BUG=b:35860685
TEST=Ran `atrusctl daemon <file>` on a guado. Verified that the process
was daemonized and its output written to syslog. Verified that output
from other subcommands were printed to stdout/stderr.

Change-Id: I31b415612614d8f1eb5590a890c6af5a55d986ee
Signed-off-by: Emil Lundmark <emil@limesaudio.com>
Reviewed-on: https://chromium-review.googlesource.com/447636
Reviewed-by: Dmitry Torokhov <dtor@chromium.org>
12 files changed
tree: 3cbcaaaedd95e44be7d1f30ba350f19e95dd29fd
  1. conf/
  2. src/
  3. .clang-format
  4. .clang-tidy
  5. .gitignore
  6. CMakeLists.txt
  7. LICENSE.md
  8. PRESUBMIT.cfg
  9. README.md
README.md

atrusctl

This tool is used to interact with an Atrus device.

Requirements

The GNU C Library, libusb 1.0 and libudev are required. GNU C is required because the program utilizes argp.

Building

CMake is used for building the application.

Here is an example of how to build:

$ mkdir build/
$ cd build/
$ cmake ..
$ make

You can also install it on your machine by running:

$ make install

Using

Run the following to see the help section of the application.

$ atrusctl --help

Also, make sure you have read and write access to the USB device. This may be done by, e.g., setting appropriate udev rules.

License

Individual files are tagged with SPDX-License-Identifier to indicate its license instead of including the full license text. See the SPDX License List for more information.