omnibus commit. hid stats. dac trait improvements. refactor to state machine style.
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
from dataclasses import dataclass
|
||||
import struct
|
||||
from time import sleep
|
||||
from typing import Self
|
||||
import hid
|
||||
|
||||
VID = 0x1209
|
||||
PID = 0xCC1D
|
||||
INTERVAL = 0.1
|
||||
|
||||
|
||||
@dataclass
|
||||
class AudioTelemetry:
|
||||
STRUCT = "<LLLLL"
|
||||
LEN = struct.calcsize(STRUCT)
|
||||
|
||||
average_buffer_fill: int
|
||||
frame_count: int
|
||||
dac_underflow_count: int
|
||||
usb_underflow_count: int
|
||||
dac_overflow_count: int
|
||||
|
||||
def from_bytes(b: bytes) -> Self:
|
||||
if len(b) != AudioTelemetry.LEN:
|
||||
raise ValueError(f"wrong size report ({len(b)} != {AudioTelemetry.LEN})")
|
||||
fields = struct.unpack(AudioTelemetry.STRUCT, b)
|
||||
return AudioTelemetry(*fields)
|
||||
|
||||
|
||||
def main():
|
||||
with hid.Device(VID, PID) as h:
|
||||
while True:
|
||||
report = AudioTelemetry.from_bytes(h.read(AudioTelemetry.LEN))
|
||||
print(f"{report}")
|
||||
sleep(INTERVAL)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,10 @@
|
||||
[project]
|
||||
name = "guac-scripts"
|
||||
version = "0.1.0"
|
||||
description = "Scripts to work with GUAC devices"
|
||||
readme = "README.md"
|
||||
requires-python = ">=3.12"
|
||||
dependencies = [
|
||||
"hid>=1.0.9",
|
||||
"rich-click>=1.9.7",
|
||||
]
|
||||
Reference in New Issue
Block a user