forderud / BatterySimulator

Driver to simulate multi-battery setups and test Windows power management
MIT License
14 stars 1 forks source link

Arduino HIP battery emulator #33

Closed forderud closed 3 months ago

forderud commented 3 months ago

Alternative to #23 for battery emulation.

Idea

Use existing hidbatt driver that's included in Windows (see https://support.moonpoint.com/os/windows/server2012/UPS/)

Links:

forderud commented 3 months ago

HID architecture documents "HID UPS battery" to have Usage page=0x0084, Usage=0x0004 and Access mode=Shared.

hidbatt.inf content:


[Version]
Signature="$WINDOWS NT$"
Class=Battery
ClassGuid={72631e54-78a4-11d0-bcf7-00aa00b7b32a}
Provider=%MSFT%
DriverVer = 06/21/2006,10.0.19041.1

[SourceDisksNames]
3426=windows cd

[SourceDisksFiles]
hidbatt.sys = 3426

[DestinationDirs]
DefaultDestDir = 12

[ControlFlags]
BasicDriverOk = *
ExcludeFromSelect = *

[Manufacturer]
%MSFT%=Microsoft,NTamd64

[Microsoft.NTamd64]
%HID_DEVICE_BATTERY.DeviceDesc% = HidBatt_Inst,HID_DEVICE_UP:0084_U:0004

[HidBatt_Inst]
CopyFiles = HidBattInstCopyFiles
Include = battery.inf
Needs = Battery_Inst

[HidBattInstCopyFiles]
hidbatt.sys,,,0x100

[HidBatt_Inst.Services]
AddService=HidBatt,%SPSVCINST_ASSOCSERVICE%,HidBatt_Service_Inst

[HidBatt_Service_Inst]
DisplayName    = %HidBatt.SvcDesc%
ServiceType    = %SERVICE_KERNEL_DRIVER%
StartType      = %SERVICE_DEMAND_START%
ErrorControl   = %SERVICE_ERROR_NORMAL%
ServiceBinary  = %12%\HidBatt.sys

[strings]
;Localizable Strings
MSFT                     = "Microsoft"
HID_DEVICE_BATTERY.DeviceDesc = "HID UPS Battery"
HidBatt.SvcDesc          = "HID UPS Battery Driver"

;Non-Localizable Strings
SPSVCINST_ASSOCSERVICE   = 0x00000002
SERVICE_KERNEL_DRIVER    = 1
SERVICE_DEMAND_START     = 3
SERVICE_ERROR_NORMAL     = 1
forderud commented 3 months ago

Completed in 7222549a744c57efc65c42e6bcb9c77d54b735f2