Commit Graph

292 Commits

Author SHA1 Message Date
Jonas Malaco 32fbf61a31 Prepare for release v1.3.3 2020-02-18 02:29:23 -03:00
Jonas Malaco fd4ccd70d0 Only explicitly clear already enqueued HID reports
Commit 2050d0b ("Traverse all hid/hidraw queued reports and return the
last one") aggressively started to clear all enqueued reports whenever a
read was done on a HID using hidapi.

While that seemed to work ok, it could cause important reports to be
lost, which might eventually break some drivers.  As no contributor has
enough devices to test all drivers, it is better to be conservative and
only explicitly clear enqueued reports.

Notably, it is wiser to clear the queue before any writes that precede
one or more reads.  This will clear stale data that has already been
queued, but will not risk loosing expected responses.  And drivers that
expect reads to match specific writes should already be prepared to
handle what is left.

The objective is not definitively clear all previous reports, but simply
to avoid acting on (or forwarding to the user) stale data.  The subtle
difference is that _stale_ presumes a delay of more than infinitesimal
length.

Related: #87 ("1.3.2 regression: kraken_two.get_status() returns wrong
fan RPM value")
2020-02-18 02:22:43 -03:00
Jonas Malaco 5de9973cb7 Traverse all hid/hidraw queued reports and return the last one
As incoming HID reports are queued by the OS, HidapiDevice.read() would
return stale data to the drivers.  The drivers assume the reads aren't
queued because that's not necessary with the currently supported
devices.

This didn't affect the liquidctl CLI as the connection to HIDAPI
wouldn't last long enough for too much data to be queued and lost.  But
for downstream projects like GKraken this was a significant regression
from liquidctl 1.1.0.

To keep the behavior consistent between the HIDAPI and Libusb backends,
traverse all queued (incoming) reports until the last one is found, and
only return it.

Related: #87 ("1.3.2 regression: kraken_two.get_status() returns wrong
fan RPM value")
Reported-by: @leinardi
2020-02-18 02:21:32 -03:00
Jonas Malaco 5eec74357f Forward hid option from UsbHidDriver.find_supported_devices
When searching for devices using find_supported_devices, the hid option
was not forwarded by UsbHidDriver to the corresponding find_devices bus
method.

As a result, it wasn't possible to select among the hid, hidraw or usb
APIs when instantiating devices this way.
2020-02-18 02:21:32 -03:00
Jonas Malaco a4e6c27dd9 Add HUE+ identifiers to HUE 2 devices
HUE 2 devices can control HUE+ accessories, but SmartDeviceV2Driver was
lacking the necessary identifiers.

Add those from OpenRGB (GPL2+).[1][2].

[1] 2104c975be/Controllers/Hue2Controller/Hue2Controller.cpp (L61-69)
[2] 2104c975be/LICENSE (L293-308)
2020-02-18 02:21:32 -03:00
Jonas Malaco fb9ec1fdb0 Prepare for release v1.3.2 2019-12-11 09:27:26 -03:00
Jonas Malaco 0f5188f7ca Parse fan info from correct status message
commit 1f76c5caef on 'master'.

The Smart Device V2 regularly sends both b'6702' and b'6704' prefixed
status messages, and the fan (speed) information is in the first one.

Commit 2538baec0b accidentally changed the code to wait for (and try
to parse as fan information) the incorrect message; this fixes it.

Fixes: 2538baec0b ("Move the reporting of SDV2 firmware and LED infos
to initialize")
Fixes: #71 ("Smart Device V2 fan status issue")
Reported-by: @CaseySJ
Suggested-by: @CaseySJ
2019-12-11 09:24:01 -03:00
Jonas Malaco a148f0df24 Prepare for patch release v1.3.1 2019-11-23 04:32:39 -03:00
Jonas Malaco 2c71ba347d Fix parsing of --verbose in commands other than list
Explicitly mentioning `--verbose` causes docopt to threat it differently
and no longer accept it as part of `[options]`.

Fixes: 229b56b70e ("Add `initialize all` variant for initializing[...]")
2019-11-20 04:20:23 -03:00
Jonas Malaco 9049e4c874 Prepare for 1.3.0 2019-11-17 03:29:18 -03:00
Jonas Malaco d1766dfeeb Drop the dependency to appdirs 2019-11-17 00:03:45 -03:00
Jonas Malaco 01c03be3d0 Compute the data directory on Windows directly with %ProgramData% 2019-11-17 00:03:08 -03:00
Jonas Malaco 5099594b5b Steer users away from --device and toward --match
Device IDs are unstable and costly to compute, meaning that both users
and liquidctl need to spend extra time when dealing when them.

Additionally, selecting devices by "name" is more natural.
2019-11-16 19:54:37 -03:00
Jonas Malaco 05bb8bffc9 Add --match <substring> to allow filtering devices by description
For now a simple case-insensitive comparison is used, but this could
easily be extended to use some type of pattern matching.

A few short option aliases have also been added:

 - `-m` for `--match`
 - `-n` for `--pick`
2019-11-16 19:54:15 -03:00
Jonas Malaco 4706ceb6ef Switch to a managed key-value storage and conform to XDG basedir spec
On Linux and other platforms the new RuntimeStorage object conforms to
the XDG basedir spec and supports XDG_RUNTIME_DIR, falling back to
/var/run, and reads check both possible locations.  On the other hand,
/usr[/local]/share is no longer a candidate location.

The subdirectories used by the Legacy 690LC driver have dropped the
release number, but now include 'legacy' as a reference to their owner.

The base directory on Windows no longer includes the appauthor, but
remains whatever is computed by appdirs.site_data_dir.  Appdirs appears
to solve quite a number of potential issues and we don't to deal with
them here (yet?).

There have been no effective changes to the base path on MacOS.
2019-11-14 18:58:49 -03:00
Jonas Malaco 3d6c7d5b0b Restore experimental tag for the NZXT Kraken X31/X41/X61 family
Commit bf27bfb81b ("Mark old drivers that are stable as such") stated:

> NZXT Kraken X31, X41, X61: know to work *with limitations,* but no
> recent *bug* reports.  The limitations are minor and allow for a very
> resilient driver, that should even work with other devices.

However since then an issue was opened that qualifies to me as
significant: #66 ("Kraken X61 pump makes grinding noises with
liquidctl/libusbK").

While I'm not sure that's really a bug, and the user doesn't seem
interested in providing any additional details, I think it's wise to
keep these devices marked as experimental for at least one more release.

Still regarding this issue:

 - the user failed to notice that the recommended driver was WinUSB;
 while that could absolutely be my fault, and I've since patched the
 README to make it more clear, I'm not conviced the rest of the issue
 isn't just about (following) the documentation

 - we don't really know the legacy Krakens behave with the libusbK
 driver, and it seems that the issue persisted reboots but went away
 when the Asetek driver was restored, suggesting a possible connection

Related: #67 ("Keep track of --legacy-690lc")
2019-11-13 06:04:19 -03:00
Jonas Malaco 8ddd80b555 Refresh all the documentation to better support the HUE 2 Ambient 2019-11-10 09:49:59 -03:00
Jonas Malaco 675f8465fa Add Missing identifier for 250 mm HUE 2 LED strips 2019-11-10 09:30:49 -03:00
Michał Lower 3ebd0aae20
Update documentation to include HUE 2 Ambient kit 2019-11-10 13:16:42 +01:00
Michał Lower 02eeb2d9b9
Add HUE 2 Ambient device ID to SmartDeviceDriverV2 2019-11-10 12:31:57 +01:00
Jonas Malaco 110e16bd04
Merge pull request #64 from jonasmalacofilho/add-support-for-hue2
Add support for the NZXT HUE 2
2019-11-10 09:58:22 +00:00
Jonas Malaco 2538baec0b Move the reporting of SDV2 firmware and LED infos to initialize 2019-11-08 10:11:13 -03:00
Jonas Malaco 17e44aa9ef Allow initialize methods to optionally return status tuples 2019-11-08 10:06:16 -03:00
Jonas Malaco 9fa79f1040 Fix assertion of valid responses in retry loops
The assert statements would always evaluate to True, so in the unlikely
event that all three attempts failed, no error would be raised.

This also simplifies the code by removing local attempt variables, as
they were not used.
2019-11-07 03:27:00 -03:00
Jonas Malaco b710cacd09 Only build messages once, independent of number of attempts 2019-11-07 03:00:10 -03:00
Jonas Malaco 7f534ca38d Release the device once done with status 2019-11-07 02:58:53 -03:00
Jonas Malaco 00f16764c7 Prepare for v1.3.0rc1 2019-11-03 01:41:02 -03:00
Jonas Malaco d57ead74f2 Reword file description for copyright notice 2019-11-03 00:37:00 -03:00
Jonas Malaco 6f6f73392d Review the new device discovery and fix docs and one interface 2019-11-03 00:31:59 -03:00
Jonas Malaco ea4d75fd2b Add documentation for the HUE 2 2019-11-02 23:58:35 -03:00
Jonas Malaco 075bc20018 Add HUE 2 device ID to SmartDeviceDriverV2 2019-11-02 23:06:37 -03:00
Jonas Malaco 9245e7395e Fix driver docstrings 2019-11-02 23:06:26 -03:00
Jonas Malaco bf538b1e7d Fix driver name 2019-11-02 23:06:26 -03:00
Jonas Malaco 03efa25dd5 Simplify the status loop for V2 devices
- only wait for the necessary messages
 - never wait for the unused 0x6704 message
 - prepare to support the HUE 2, which doesn't output any 0x67 messages
2019-11-02 22:58:15 -03:00
Jonas Malaco ced0ede948 Fix undefined name when building 'wings' mode for SDV2
Commit da6c38a47e ("Fix uninitialized list") failed to correctly the
issue.  This should do it.

While pre-allocating the list is not strictly necessary, we choose that
route for clarity: the later assignments can use explicit offsets,
instead of list.append.
2019-11-02 01:47:03 -03:00
Jonas Malaco 76a78acc69 Fix device name for H110i GTX 2019-11-02 00:48:08 -03:00
Jonas Malaco c6a2f99c05 Fix device name for Corsair H80i GT
While the corresponding 240 mm AIO has a GTX suffix, the 120 mm uses the
GT suffix.[1]

[1] https://www.corsair.com/pt/en/company/press-release/new-corsair-hydro-series-h100i-gtx-and-h80i-gt-are-cooler-than-ever
2019-11-02 00:48:03 -03:00
Jonas Malaco 855c08bba4 Optimize platform test for darwin 2019-11-01 18:26:07 -03:00
Jonas Malaco 31404deb2a Ensure the HID enumeration order is stable on macOS
On macOS the `hid.enumerate` implementation is based on

    CFSetRef IOHIDManagerCopyDevices(IOHIDManagerRef manager);[1]

and `CFSet` is an unordered collection.[2]

To restore the stability of both `--device` and `--pick`, the results
from enumerate are now sorted when the platform is macOS.

Related: #65 ("Device identifiers on subsequent calls on macOS")

[1] https://github.com/libusb/hidapi/blob/hidapi-0.9.0/mac/hid.c#L410
[2] https://developer.apple.com/documentation/corefoundation/cfset-rgt
2019-11-01 18:25:08 -03:00
Jonas Malaco c27d7d754b Don't log the data path unless the driver is actually being used 2019-10-31 06:58:21 -03:00
Jonas Malaco bf27bfb81b Mark old drivers that are stable as such
This is done in preparation to the upcoming v1.3.0 release, which
introduces support for many new devices.

Corsair H80i v2, H100i v2, H115i: known to work and no recent bug reports.

NZXT Kraken X31, X41, X61: know to work *with limitations,* but no
recent *bug* reports.  The limitations are minor and allow for a very
resilient driver, that should even work with other devices.

NZXT Grid+ V3: already supported for almost a year, and there have been
no bug reports.  Unfortunately, I don't remember seeing any confirmation
that it works, so I'm going mostly by how long it's been in liquidctl.
2019-10-31 06:45:15 -03:00
Jonas Malaco 8a8f02b42d Don't connect/disconnect twice when running status 2019-10-31 02:27:05 -03:00
Jonas Malaco e7217f4110 Don't try to reattach the kernel driver more than once 2019-10-31 02:26:40 -03:00
Jonas Malaco 229b56b70e Add `initialize all` variant for initializing multiple devices at once 2019-10-28 04:46:23 -03:00
Jonas Malaco c387f6c389 Normalize all copyright information
- normalize all liquidctl copyright notices
 - update and normalize all "incorporates" notices
 - add copyright notice and license for Python to Windows builds
 - fix PyUSB to 1.0.2 on Windows builds (latest release; BSD 3-clause)¹

¹ Since PyUSB 1.0.2 a new maintainer has changed the project to the
Apache license.  But there have been no releases since, and maintenance
appears to have all but halted.
2019-10-28 02:16:36 -03:00
Jonas Malaco fca66b873e Remove unnecessary imports 2019-10-27 02:37:03 -03:00
Jonas Malaco 46178ff7ae Fix missing outer loop 2019-10-27 02:32:49 -03:00
Jonas Malaco da6c38a47e Fix uninitialized list 2019-10-27 02:32:36 -03:00
Jonas Malaco 4975833b3f Fix typos introduced when unifying clamp 2019-10-27 02:32:12 -03:00
Jonas Malaco cec8b0de36 Replace ad-hoc implementations with liquidctl.util.clamp 2019-10-27 02:24:09 -03:00