Prior to this change, if the clock thread is disabled, then
disconnecting and reconnecting the X52 device would cause the daemon to
not detect the transition. As a result, the daemon would stay in a state
where it thinks the device is still connected, and therefore, not
actually apply any of the saved configuration, until it received a
SIGHUP to refresh the configuration.
This change adds a routine that sends a dummy vendor command. This
vendor command does nothing on my X52 Pro (VID 06a3, PID 0762), but
serves as a check to see if the daemon can send vendor commands to the
device. If the device is indeed disconnected, then that is a sufficient
indicator to disable the update thread and re-enable the acquisition
thread.
Prior to this change, the update thread was only checking on
device_update_needed. However, this causes an issue when calling any of
the set methods where the update thread fires, fails to find a device,
and signals the acquisition thread every 50 ms, since the update flag
was never cleared.
This change adds a thread enable flag for the update thread. The update
thread will check that both the thread enable flag and the update needed
flag are set before proceeding with the call to libx52_update.
Some libx52 APIs, notably the clock related ones, can return
LIBX52_ERROR_TRY_AGAIN. This is not a real error, but it is useful
information. It indicates to the application that there is no change
applied to the internal state, and that it should wait until trying
again.
Given that the clock thread calls the libx52_set_clock method every
second, treating the TRY_AGAIN state as a failure and logging it causes
a lot of spurious noise in the logs. This change ensures that the API
returns a real error before logging it.
Having the trace log in there adds unnecessary logging for no real
reason. It is better to disable the log here to help trace other
portions of the daemon.