Topping DX5 II CLI
English | 简体中文
Python package and CLI for the Topping DX5 II (VID 0x152A / PID 0x8750, control protocol on
HID MI_02): read every device setting, write individual fields, switch the output port and the EQ
preset, and manage the PEQ presets stored on the device.
The protocol has no public documentation. It was reverse engineered from the Topping Home web
bundle and then verified field by field on a real device (firmware 2.58). Frame layout, command
numbers and field maps live in the module docstrings of src/dx5ii/constants.py and
src/dx5ii/protocol.py.
Web Home support starts with DX5 II firmware V2.39. This CLI has only been verified against
firmware 2.58, so confirm the device is at 2.39 or newer — or update it to 2.58 — before relying
on it.
Install
pip install dx5ii-cli
Only hidapi is required — the device just has to be reachable from Topping Web Home. The
official app itself does not need to be running.
Confirm the install:
dx5ii --version # dx5ii version
dx5ii --devices # list HID interfaces, check the DX5 II is visible
dx5ii --fast # read the state once
--devices is the quickest connectivity check: it sends no protocol frames, it only enumerates HID.
From source:
git clone <repo> && cd dx5ii
pip install -e .
Without installing:
export PYTHONPATH=/path/to/dx5ii/src # Windows PowerShell: $env:PYTHONPATH = '...\dx5ii\src'
python -m dx5ii get
CLI
dx5ii # full state, including the preset list
dx5ii --fast # same, skip the preset upload
dx5ii --json # JSON output
dx5ii status --frames # state plus every frame read (ms since open)
dx5ii devices # same interface list as --devices
dx5ii --devices # list HID interfaces (+ firmware), mark the protocol one
dx5ii --set-output hp_balanced # switch output only, then read back
dx5ii peq on # turn EQ on (same as set peq on)
dx5ii peq off # turn EQ off
dx5ii peq switch Dynamic # switch preset by name or index
dx5ii scene recall c1 # restore device scene C1, report what changed
dx5ii scene save c1 # overwrite C1 with the current state
dx5ii --set-config Dynamic # the same, kept as a top-level flag
dx5ii --set-output hp_balanced --set-config Dynamic
The first line of dx5ii output carries the device's firmware version, read from the USB
bcdDevice descriptor (release_number in JSON), e.g. firmware=2.58.
--json keeps the readable name as the value and puts the device index beside it under
<key>_raw: {"output": "hp_balanced", "output_raw": 4}. The same holds for the before /
after blocks of a switch report. Option-name arrays carry their mask in the settings block
(output_option_mask), and booleans stay booleans. Scripts that prefer numbers read the *_raw
key; nothing has to be parsed out of a display string.
--set-config also ends a Topping Home cloud preview. While a cloud config is playing, the
device keeps its stored slot, so an index that already matches the stored slot still needs the
switch — that write is what returns the device to a local preset:
before : output=hp_balanced stored=2 (IER-M7.Harman) playing=cloud
config 2 -> 2 (left cloud preview)
after : output=hp_balanced stored=2 (IER-M7.Harman) playing=local
Three rules for scripts:
changedmeans the device state really changed. Leaving a preview counts, sochangedistrueeven whenfrom == to; what changed isplaying, notstored.left_previewappears on the action only when a preview was ended; its value is"cloud"or"audition". Ordinary switches do not carry the key.- The top-level
changedfollows the same rule, andokstill means "the value read back after the switch equals the target".
Skipping is only safe when the device both stores the target and plays a local slot. If
0x7137 does not answer, playing_source is "unknown" and the switch is sent anyway.
Field access:
dx5ii get # every field, grouped
dx5ii get output theme volume # selected fields
dx5ii set brightness medium # write one field, print before -> after
dx5ii set theme blue language en # write several at once
dx5ii raw 0x7137 --pt read # raw frame, print the reply
dx5ii raw 0x710C --pt read --total 1 # raw frame with explicit total/cur
dx5ii watch 5 # dump unsolicited frames for 5 s
dx5ii watch -f # follow new frames until Ctrl-C (opens the push session)
dx5ii watch -f --cmd 0x7137 --json # one JSON object per matching frame
dx5ii manual # the user manual, shipped with the package
dx5ii manual peq # one section; --list shows them all
dx5ii manual peq --markdown # raw markdown instead of terminal text
raw prints the frames the device sends back: each line decodes cmd, pt, total, cur
and data, but nothing is interpreted into named fields and no scaling is applied. A 0x710C
reply is 52 lines and 0x7137 is three, one 32-bit word each; data is shown in both decimal
and hex. When you send a multi-frame command yourself, set --total and --cur, because the
device only accepts consecutive frame numbers. --wait MS widens the collection window when a
reply is longer than the default 800 ms, and raw echoes the frame it sent as a tx line
before the replies.
Every command also accepts --trace PATH, which appends each frame written to the device and
each report read back to PATH as one JSON object per line
({"t": seconds, "dir": "tx"|"rx", "hex": "..."}). Use it when a reading disagrees with the
device panel: the trace shows the exact bytes on both sides, so a wrong checksum, frame count
or payload encoding is visible without reading the source.
There are 43 fields; dx5ii --help lists them all. Grouped:
| Group | Fields |
|---|---|
| Power & host | power power-trigger home-page theme brightness language screen-timeout dim-screen-type trigger-out |
| I/O | input output input-option output-option input-mode spdif-mode headphone-gain balance polarity |
| Audio | volume mute pcm-filter line-mode uac volume-step vu-bar-mode vu-level dc-detect crossfeed-type crossfeed-conv crossfeed-simple bluetooth aptx remote |
| Memory | volume-memory peq-memory crossfeed-memory |
| Keys | multifunction-key double-key remote-a-key remote-b-key remote-mute-mode |
| Device | device-name (read-only) peq (on/off) |
Sample rate is not a field: it is reported by 0x710F on its own and shows up in the sampling
section of the full dx5ii / dx5ii get output.
Accepted values: on/off, true/false, enum names (hp_balanced, aurora), indices, mask
lists (input-option usb,bt), volumes (-40.0) and timeouts (off/10s/30s/60s).
PEQ presets
dx5ii configs # current source, stored slot and slots
dx5ii peq list # presets, stored one marked with ←
dx5ii peq show Dynamic # per-band freq/gain/Q, both channels
dx5ii peq import delta.txt --name MyPreset # import one Device section of an APO config
dx5ii peq copy Dynamic MyPreset # duplicate a preset
dx5ii peq export MyPreset delta-export.txt # write a preset back as APO text
dx5ii peq rename MyPreset Better # names are limited to 14 UTF-8 bytes
dx5ii peq delete MyPreset --switch Dynamic
dx5ii peq preview MyPreset # audition it without storing it
dx5ii peq preview --from-apo delta.txt # audition a file, create nothing
dx5ii peq preview --stop # go back to the stored slot
dx5ii peq overwrite MyPreset --from-apo delta.txt # replace a stored preset in place
dx5ii peq overwrite MyPreset --copy Other --backup before.json
peq import, peq copy and peq delete only ever add or remove a preset. To change what a stored preset
holds, use peq overwrite below; there is no per-band editor that leaves the rest alone.
peq preview plays a preset from the unit's scratch filter set without storing it;
--from-apo does the same for an Equalizer APO file, parsing it exactly like peq import
but creating no preset. The bands go
through the per-band live-parameter commands (0x9101-0x9B0A), which the device only accepts
inside a preview; one of them sent on its own does nothing. The stored slot is untouched, and
--stop writes the preview meta back to inactive. A preset whose left channel is disabled (peq list
marks it L disabled) keeps that bit in the preview, so the audition sounds the way the preset does. If the process dies before --stop the unit
keeps playing the scratch set: dx5ii --set-config <slot> ends it, but the preview itself cannot
be reopened afterwards.
peq overwrite replaces a stored preset in place. --from-apo FILE, --copy PRESET or --last
picks the content; the preset keeps its name. It clears an active preview first, because writes
made during a preview land in the scratch set instead of the preset. When the target is not the
playing slot, the output moves to it for the write and back afterwards. --backup PATH stores the
current 78-word block before writing, --dry-run prints how many commands would be sent.
The preview hand-off used by --last lives in ~/.dx5ii/last-preview.json
(%LOCALAPPDATA%\\dx5ii\\last-preview.json or the system temp directory when neither is
writable). It holds only the last previewed config. pip uninstall dx5ii-cli does not remove it,
so delete that file by hand if you want it gone.
--from-apo reads the Device: section named after the connected unit (the name dx5ii --devices
prints); a file with no Device: line is taken as describing that one device. The device stores
PK, LP, HP, LS and HS bands; any other type (BP, NE, ...) stops the import with an error
instead of being dropped, and more than 11 filters in one section is an error too.
HP / LP lines carry no Gain in Equalizer APO and are imported at 0 dB. A Preamp: line
is written into the preset's preamp words (-12 to +12 dB). Nothing is imported silently.
Exit codes: 0 OK, 2 device/argument error, 3 write not observed on read-back.
Library
from dx5ii import Dx5ii, apply_changes
with Dx5ii() as dev:
state = dev.snapshot() # device/settings/identity/sampling/peq/configs/pushed
print(state["settings"]["volume_db"])
dev.set_output("hp_balanced") # returns the settings after the switch
dev.set_config_index(2) # 0x110E, returns the index read back
with Dx5ii() as dev: # switch both at once, keep a rollback point
snap = dev.snapshot()
report = apply_changes(dev, snap, want_output="hp_balanced",
want_config="IER-M7.Harman")
print(report["before"]["stored_index"], report["after"]["stored_index"])
PEQ:
from dx5ii import Dx5ii, read_presets, create_preset, parse_apo_filters
with Dx5ii() as dev:
presets = read_presets(dev)
print(presets["stored_index"], [p["name"] for p in presets["presets"]])
left = parse_apo_filters(open("delta.txt").read())
create_preset(dev, "Imported", left) # right channel copies the left one
Field encoding works on its own:
from dx5ii import encode_field
frames = encode_field("volume", -40.0, {"volume_step": "half_db"})
# [(28034, 80, 1, 1)] -> cmd, data, total, cur
Every exported function and method carries type hints and ships py.typed.
Protocol notes
- Frame: 16 bytes
22 33 <pt> <total> <cur> <cmdHi> <cmdLo> <data32 BE> <crcHi> <crcLo> 66 77 00, prefixed with a0x00report id when written through hidapi.ptis0x10for reads and0x20for writes; replies always carry0x20. - Multi-frame:
totalis the frame count andcurthe index.0x710C(read settings) answers with 52 frames and0x1120(preset upload) with 393; reading a single frame looks like "the device is not responding". - PEQ block: 78 uint32 words —
0..3name (UTF-8, little-endian, NUL padded),4enabled flag,5and7hashes,8..40left channel 11 bands × 3 words,41..73right channel,74..77padding. Each band:packed = enabled | type<<8 | gain_tenth_db<<16, thenfreq_hz, thenq*10000; types are1=PK 4=LS 5=HS. - Uploads must use 74 frames, not 78. The device only consumes the first 74 words; sending 78 is silently ignored.
Layout
| Module | Responsibility |
|---|---|
constants.py |
command ids, enum tables, settings word layout |
protocol.py |
frame codec, name decoding, volume conversion |
stream.py |
multi-frame collector: a reply is done at curFrame == totalFrameLen - 1 |
device.py |
HID handle: open, send/receive, per-command reads, snapshot assembly |
interpreter.py |
frame sequences → state dict (pure, testable offline) |
fields.py |
field table, value encoding, read-back extraction |
bands.py |
PEQ band codec, APO text parser |
peq.py |
preset read/create/delete/rename |
actions.py |
high-level "switch port + switch preset" with rollback info |
formatting.py |
terminal output |
cli.py |
argparse subcommands and entry point |
Everything except device.py is hardware-free, so recorded frames are enough for unit tests.
Known limitations
- Device name is read-only.
0x7127has no receive handler in the firmware. - Switching UAC re-enumerates the device. After
uac1the USB descriptors are rebuilt and the next write returns-1; wait ~3 s and reopen. - Nine actions only work through
raw(disable-controller,call-c1/c2,execute-remote-a/b,heartbeat,save-c1/c2,clear-pairing) because they have no read-back. A factory reset israw 0x710B 1 --force; it is no longer asetfield. - Switching the output port also changes EQ and volume. Both are remembered per port.
0x1206is read-only; use0x110Eto switch presets.rawrefuses two commands:0x710B(factory reset) and0x712E(firmware update mode). The second one drops the device off USB and it does not come back until a firmware image is written. Pass--forceonly when that is what you want.- A cloud config's name and bands are not readable. While Topping Home plays a cloud config the
device reports only a
sourcebyte and two hashes through0x7137;0x1206keeps naming the stored local slot.configs.playingsays what is audible (local/cloud/audition/unknown) andconfigs.stored_index/stored_namesay what is stored, so the two cannot be confused.playing.slot_indexis null unless the device plays a local slot. playingnames the selected slot, not filtering. With PEQ switched off the device still keeps a slot selected, soconfigs.enabledisfalsewhileplaying.sourcestayslocal; the text output printsplaying none (PEQ off)and marks the slotselected.
Tests
python -m unittest discover -s tests -t tests -v
261 cases, pure functions only (frame codec, field encoding, PEQ block codec, sequence interpretation, the multi-frame collector and read-session state machines, the write confirmation wait, the temporary preview handshake). No device needed.
License
MIT — see LICENSE.
Metadata
Release files for dx5ii-cli 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| dx5ii_cli-0.1.1.tar.gz | 107.1 kB | Without provenance | Details for dx5ii_cli-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| dx5ii_cli-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for dx5ii_cli-0.1.1-py3-none-any.whl |
Total release size: 191.9 kB
Release files / dx5ii_cli-0.1.1.tar.gz
| Download URL | dx5ii_cli-0.1.1.tar.gz |
|---|---|
| Size | 107.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
97a964b1242c11a9ed0a1d8a6006827c2e5704dea25c0bb7b1d69f1a696db06a
|
|
BLAKE2b-256 checksum How to use checksums |
1b7f1bf3c086d47f6680e8271fae2002e983c966be05497d6ba853bc5bd9a80b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.9
|
Release files / dx5ii_cli-0.1.1-py3-none-any.whl
| Download URL | dx5ii_cli-0.1.1-py3-none-any.whl |
|---|---|
| Size | 84.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
68a96fa4a0d8c86f89e22df5063d8e712b1dbb13172834d63ed18c98f34d99bf
|
|
BLAKE2b-256 checksum How to use checksums |
c93a9ce5d14ef4477c2a906b767dddd17972777586ecd77ceb85a66830885631
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.9
|
Security for dx5ii-cli 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.