Experimental libwinhid backend for usbhid-ups (Windows only)#3335
Experimental libwinhid backend for usbhid-ups (Windows only)#3335MysteryDove wants to merge 5 commits intonetworkupstools:masterfrom
Conversation
…, reorder HID parsing index
|
❌ Build nut 2.8.4.4276-master failed (commit 1018d75723 by @MysteryDove) |
|
This looks promising, thanks! The indentation is a bit jumpy when I looked at it in GitHub WebUI (tabs vs spaces?) and the two aliases for Notably, does the resulting program need linking with Also, I wonder if the methods you've added to |
I have make few rounds of refactoring of this patch, beginning with using Thanks for the advice and I will make the code cleaner. |
|
For the second part, my goal is make it acting like a replacement of libusb under windows to provide alternative of transporting data besides libusb for HID devices ONLY (But it has drawback of not getting any raw data from USB interface), I think current code should already be capable for testing with other USB-capable drivers (I'm assuming all USB-capable drivers are a sub-driver of usbhid-ups since I'm not having full context of the NUT project, and also windows hid api obviously works straighfoward with usbhid-ups) |
Well, actually yes, for USB HID that should be the case. Other USB cases include numerous Megatec Qx protocol handlers, mostly under Skimming through sources, I see that |
|
@jimklimov Fixed for typo and indent now, Under assist of Claude Opus 4.6, A major refactor is also done I've walk through For newly added |
|
❌ Build nut 2.8.4.4292-master failed (commit 1fcfada43c by @MysteryDove) |
|
✅ Build nut 2.8.4.4293-master completed (commit 23fb3e32de by @MysteryDove) |
Proof of concept stage
While working on my own STM32 project to simulate USB HID UPS, I've made a python script to read windows HID API and it works as expected. So I'm looking for some ways to port that so I can use nut on windows without any additional drivers.
I'm working on an experimental, native Windows HID backend (
libwinhid) for theusbhid-upsdriver to try avoid the libusb's problem of fetching raw bytes from Windows system claimed HID UPS device. So that no extra driver likeWinUSBorZadigis needed.For enumeration I'm using setupapi.dll
For HID device:
HidD_GetPreparsedDataandHidP_GetCapsto read collection mappings.HidD_GetFeature / HidD_SetFeatureto handle feature reports.The current implementation is kinda messy, takes Windows capabilities to reconstruct a descriptor, route back to
Parse_ReportDesc()to parse that, And continue the remaining logic as untouched, but few functions are introduced here to deal with improper HID descriptor Parsing. The code is not cleaned and completly tested yet, but it's working now with apchid subdriver with correct data reading now.To use current updated code, pollonly and experimentalhid(newly added) is required:
Looking for test result and idea how to improve this to make the code works better