forderud / BatterySimulator

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

Teensy battery emulator with driver #23

Closed forderud closed 1 month ago

forderud commented 1 month ago

Alternative to #33 for battery emulation.

image

Idea

USB protocol

  1. Header: Send BATTERY\0 (8bytes), BATTERY_INFORMATION struct (36bytes) and a BATTERY_STATUS struct (16bytes) to host,
  2. Afterwards, send BATTERY_STATUS structs (16bytes) on-demand to host when the status changes.

USB pipe: Use IN interrupt endpoint (max 64byte package size, max 255ms polling interval)

Teensy firmware

Teensy dev setup: https://www.pjrc.com/teensy/td_download.html

Implement the protocol above and transmit battery charge changes periodically.

Open questions:

Battery driver

Class=Battery - can most likely be combined with USB client driver

Notes:

Implementation stages

  1. Write Teensy firmware
  2. Write a simple USB client driver that exposes IOCTL_BATTERY_QUERY_INFORMATION and IOCTL_BATTERY_QUERY_STATUS to user-space.
  3. Merge USB driver with simbatt sample

Links

forderud commented 1 month ago

Closed in favor of #33