feat(k1): add USB networking, device management and acquisition recovery

This commit is contained in:
DCCONSTRUCTIONS
2026-11-04 00:42:57 +03:00
parent 14c3c7c2b6
commit 038337783f
78 changed files with 4612 additions and 384 deletions
+241
View File
@@ -0,0 +1,241 @@
# K1 USB Ethernet on the onboard computer
## Scope
The USB path replaces only K1 → Node radio transport. Node → Control Station
delivery, its bounded preview budget, recording, and the shared spatial viewer
retain their existing implementations. Wireless enrollment remains available.
No Lixel Studio or OpenAPI SDK runtime is introduced.
The physically qualified environment is one owner-controlled LixelKity K1,
firmware V3.0.2, and the prepared Ubuntu 24.04 amd64 onboard computer. This is
not clean-OS, multi-device, active-scan cable-disconnect or endurance acceptance.
## Discovery and admission
`usb_network.py` observes Linux sysfs for the qualified XGRIDS RNDIS device
(2207:0019, product `XGRIDS Device`, driver `rndis_host`). The peer address comes
from NetworkManager's DHCP server identifier. The kernel route must use that
exact USB interface, a local source address, and no gateway. There is no
hardcoded peer IP, interface name, USB port, subnet scan or Wi-Fi fallback.
The probe never changes NetworkManager, USB mode, routes or host permissions.
A hash of the USB serial supplies stable discovery identity. Enumeration and
route evidence have a separate generation that changes on re-enumeration.
USB identity alone is insufficient: the existing read-only Verify transaction
must obtain DeviceInfo, validate the supported firmware, and check the durable
device identity pin before committing semantic topology. Commit repeats the
USB generation and address checks. A changed attachment invalidates its lease.
`NodeK1UsbObserver` supplies this evidence to the existing facade under the
Node operation lock. It does not issue START. A live wireless dialogue is not
silently taken over. After admission the existing connection monitor owns
recovery; the observer does not repeatedly reopen an unchanged connection.
If terminal local cleanup retires control while USB remains attached, the
observer re-enters the same read-only Verify transaction. An active receiver,
nonterminal acquisition or concurrent reconfiguration still excludes that
handoff. Enumeration never clears a physical START/STOP record.
USB is a transport value in the existing semantic topology, physical command
journal and active acquisition checkpoint. It is deliberately not a Wi-Fi
provisioning mode. The original START/STOP sequence and reconciliation rules
remain authoritative; reconnecting is not permission to replay START.
## Physical qualification, 2026-11-02
The original application dialogue executor was used over the enumerated USB
network route. One START and one STOP were sent; no extra command retries were
inserted. The device reported SCANNING and subsequently READY.
- 1,725 consecutive point-cloud frames; no missing sequence numbers.
- 6,817,911 decoded points and 1,755 pose messages; zero decode/rejection errors.
- Approximately 9.83 cloud frames/s and 3.1 Mbit/s raw application payload.
- The existing camera gateway produced 265 unique, decodable H.264 frames,
800 × 600 at approximately 10 fps, in a bounded camera capture.
- The interface reported 9 receive frame errors across approximately 70,983
received packets. There were no application sequence gaps in this sample;
the lower-level errors remain an explicit qualification limitation.
These are K1 → Node measurements, not browser latency or end-to-end delivery
acceptance. Raw captures and private identifiers remain outside source control.
## Installation and remaining acceptance
The optional `mission-core-xgrids-k1` Debian package owns the runtime change.
Its pre-install check requires the existing `prepare-safe` result, then stops
only the K1 service. The public package preserves the provisioned application
credential and durable journals. Node, VESC and USB-CAN configurations are not
modified. Version 0.1.31 is the retained rollback artifact.
Hardware qualification precedes the product gate: automatic inventory,
Observatory project modal, START, cloud/camera preview, STOP and recovery must
be checked using the installed package and normal Control Station interface.
Do not infer product acceptance from the engineering capture alone.
The installed 0.1.32 product test confirmed automatic USB inventory, the
existing Observatory project modal, START, camera preview, and the custom
point-cloud viewport. Two short runs completed STOP normally. A longer run
received 28,532 cloud frames / 112,720,068 points with zero decoder errors.
This does not establish sequence continuity or operator-preview latency for
the longer run.
At the end of that run, STOP received an application success response, but
the bounded wait did not acquire final READY evidence. The device later showed
steady green. The existing **Check K1 state** action obtained fresh evidence,
closed the acquisition recovery checkpoint and restored `prepare-safe: true`.
Neither START nor STOP was replayed. This separates physical command acceptance
from a confirmed final state; an ACK alone is not completion.
Version 0.1.33 addresses the Node adapter's unchanged-USB observation latch
and preserves the USB label when its control socket is retired. The canonical
command/reconciliation pipeline and installer safety gate remain unchanged.
Device reboot, power-off commands, active-scan USB interruption and clean-Ubuntu
installation are still separate acceptance gates.
The 0.1.33 installed follow-up run confirmed automatic USB admission after
the package restart, normal UI START, first-entry cloud in the existing custom
viewer, camera preview, and UI STOP returning to ready. It received 2,541
cloud frames / 10,020,892 points with zero decoder errors. The final acquisition
was completed and the preview peer list empty. The checkpoint was ceased,
although its projection retained a `cease-failed` diagnostic reason; that
diagnostic inconsistency remains to be investigated separately.
The browser reload test is **not accepted**: the device session and camera
returned, the isolated Rerun realm loaded, but this browser received no cloud
batches during the bounded observation. Do not conflate working USB ingress
with reliable Node → Control Station delivery. Delivery/re-entry, stale-view
ownership and preview latency remain an explicit follow-up, as requested by
the owner. The point-cloud first-entry bootstrap now loads the bundled runtime
document into the same isolated iframe; it does not alter the stream budget,
point accumulation, colour settings or the recorder.
Idle USB unplug/replug was qualified on 0.1.33. The operator disconnected the
cable at 15:41:30 UTC and reattached it at 15:41:48 UTC. Linux enumerated a new
USB device number (5 → 6), and the existing Verify pipeline opened a fresh
device session at 15:41:54.916 UTC. The stable USB identity was preserved; the
interface obtained its lease again and the peer route still used USB. The UI
showed Connected and the normal new-project controls without a manual Verify,
Wi-Fi enrollment or START. The final state was idle, `can_start: true`,
`can_stop: false`, `prepare-safe: true`, with no preview peers. This proves
idle attachment recovery, not recovery of a scan interrupted mid-acquisition.
## Preview recovery follow-up, 2026-11-02
The failed 0.1.33 reload was traced to detached RRD subscribers counting toward
the two-active-view limit. A reload creates a new view UUID; a five-minute resume
reservation could therefore reject the new page as `Close another live viewer`.
The bound is now two active plus two detached resumable views. Oldest detached
reservations may expire, but an active view is never evicted. A missing resume
cursor fails explicitly instead of silently restarting its native recording.
The 0.1.34 test returned cloud to the same acquisition after reload, but showed
datagrams expiring in the shared budget queue. Version 0.1.35 paces cloud data
in 1 KiB fragments before SCTP, using the existing producer allocation and
framing headroom. It does not increase cloud demand, change the shared admission
deadline, or reduce primary camera/control priority. Pacing alone did not fully
stabilize preview latency in the presence of a retained legacy viewer.
Version 0.1.36 rejects the legacy raw-fMP4 `camera` data channel on a cloud peer.
That channel had been admitted under the cloud budget alongside reliable RRD,
despite the current camera UI already using its separate RTP/video offer. Only
the obsolete channel is closed: its RRD subscription remains usable. Modern
camera offers and the acquisition recorder are unchanged. An old page must be
refreshed to obtain the separate camera viewer. Preview health exposes admitted
channel labels so this boundary can be inspected without packet contents.
Repeated state reduction after STOP also previously reported `cease-failed`
after local cleanup released its operation/evidence owners. The reducer now
recognizes the trusted ceased checkpoint of the same completed acquisition,
checking the original START whenever its local owner is still present. It
does not cease an active checkpoint without evidence, accept another
acquisition/START, alter journal bytes or grant recovery authority. The 0.1.35
hardware run confirmed completed/ceased, no reason, no peers and prepare-safe
after UI STOP; 115 checkpoint/USB tests and 32 preview/media tests pass.
The 0.1.36 hardware delivery/re-entry acceptance is recorded in the task's
`outputs/k1-usb-preview-recovery-20261102/result.json`. Do not treat unit tests
or the earlier 0.1.35 first-entry latency sample as final delivery acceptance.
## Adaptive full-density preview, 2026-11-02
Node 0.8.53-104 with K1 0.1.38 was installed through the versioned installer.
Cloud demand now follows observed native frame size/cadence; complete selected
frames retain all points instead of spatially decimating them to fit a fixed
small demand. Input frames may coalesce while delivery waits; raw acquisition
recording remains independent. Only the selected primary video receives the
video priority share. Cloud framing follows its allocation and feedback credit
follows the existing adaptive budget instead of a fixed 128 KiB ceiling.
Node 104 also fixes a recovery deadlock: a quiet primary camera could reserve
most of a reduced feedback window while waiting cloud packets could not fill
half that window to qualify for growth. Recent denied real packets can now
qualify useful demand for growth under healthy feedback; idle declarations
alone cannot. Command-pressure and feedback-silence guards remain unchanged.
The USB J run delivered 3943–4025 points per observed frame to the custom
viewer, versus approximately 247 before the change. Over an 81.98-second
interval including a delivery pause, this browser received 47.97 kB/s of RRD,
0.646 batches/s. Received-frame age samples were 0.39–2.17 seconds; these are
not a continuous latency distribution and do not hide the observed pause.
After the last of three feedback-silence events, optional credit recovered
above 30 Mbit/s in 10.6 seconds without a reconnect. This is an allocation,
not a measured physical link capacity.
Leaving and re-entering the Observatory restored cloud and camera under the
same acquisition without another START. However, visible scene recovery took
up to 32.17 seconds in the sampled run; signalling and native first-scene
presentation remain unresolved. Short inbound tunnel gaps were independently
observed while Core transmission continued. Continuous low-latency delivery,
full available-bandwidth use and real driving with VESC are not accepted by
this test. J ended with UI STOP, fresh READY, a ceased checkpoint and
prepare-safe true. Evidence is in the task's `outputs/k1-traffic-20261102/REPORT.md`.
## Vendor command reference
The XGRIDS Lixel OpenAPI protocol documentation and the v1.1.0 protobuf schema
are references for wire semantics only. The schema includes USB_MASS,
USB_ETHER, POWER_OFF and SYSTEM_REBOOT, among other actions. An enum in a newer
schema does not qualify that action on this firmware. The initial USB transport
change did not expose these maintenance actions.
The separate 2026-11-03 management increment adds an idle-only mailbox to the
existing application MQTT worker. DeviceInfo and ProjectList were read through
the current USB Ethernet control channel: 18 real projects, with the scanner
still in USB Ethernet mode. No mass-storage switch or filesystem mount was
needed. Project deletion has its own vendor command on that same control
channel. With explicit owner permission for all test projects, acceptance
deleted one (18→17 projects; 81.6→80.7% used), then three selected projects
(17→14; 70.8% used), then formatted the remaining test storage (0 projects;
0% used as rounded by the device). Every result used a fresh device catalog
and storage report, not optimistic removal from the UI.
K1 0.1.43 executes selected deletion as sequential singular-ID vendor requests
inside the existing fenced worker, with one reply per request and no retry.
The tested firmware rejected the newer repeated-ID request; partial failure
stops the group and retains the confirmed deleted IDs. The common operation
deadline remains bounded. A control interruption overlapped the storage test
and an owner-reported USB cable replacement; formatting is not an established
cause. Existing USB recovery restored confirmed standby and a fresh catalog.
No USB-mode change or second format command was sent.
Final qualified installation: Node 0.8.53-109 / K1 0.1.43, with all four
Node/K1/VESC/USB-CAN services active and prepare-safe true after acceptance.
Power-off/reboot and USB mode commands use explicit confirmation and
generation/revision fencing. A subsequent owner-authorized UI reboot test
confirmed USB disappearance and reappearance, then fresh DeviceInfo in USB
Ethernet mode and a fresh empty project catalog. The board remained online.
Power-off and a USB-mode round-trip remain physically unqualified.
USB mass-storage removes the current Ethernet control path. Both the UI and
the worker reject USB_MASS unless the connection binding is Bridge, so a
USB-only operator cannot strand the scanner behind a non-existent return
channel. A Bridge mode round-trip still needs physical qualification. The UI
calls the modes “Канал управления (USB Ethernet)” and “USB-накопитель”. DeviceInfo,
not a command acknowledgement or cached project catalog, supplies actual mode.
Reset and firmware upload remain outside this change. No Lixel Studio runtime
or alternate OpenAPI authentication/session owner is added.
References:
- <https://docs.xgrids.com/en-us/07-plugin-sdk/04-lixel-openapi/v1.1.0/02-connection.html>
- <https://github.com/xgrids/Lixel_OpenAPI/tree/a60a73773b0c2da3e582607ff71b32baa1238d4e>