Sfoglia il codice sorgente

Zephyr port: strip report ID from control SET_REPORT (fixes command channel)

Hardware capture (Steam pairing) showed every puck feature command parsed
off-by-one: the command parser expects b[0]=command, but Zephyr's control
SET_REPORT path delivered the buffer with the report ID still at b[0] (TinyUSB
strips it; our interrupt-OUT path already stripped it, so they were
inconsistent). Result: 0xA3 read-bond seen as 0x02, 0xAD pairing-arm never
recognized -> Steam talks to the puck but pairing never starts.

Strip the leading report-ID byte in op_set_report when id != 0. Verified on
hardware: commands now parse (cmd=87/A3), bond writes persist, and the RF poll
loop runs at 250 Hz.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Jari 4 mesi fa
parent
commit
5b17ea076a

+ 5 - 1
OpenPuckZephyr/src/compat/serial_cdc_glue.cpp

@@ -41,7 +41,11 @@ extern "C" int opk_serial_read(void)
 
 extern "C" int opk_serial_avail_write(void)
 {
-	return 64;
+	// The firmware gates its diagnostic prints on availableForWrite() > 80/90.
+	// Report a generous CDC TX budget so those logs are not suppressed (the
+	// underlying uart_poll_out drops bytes when the host isn't draining, so
+	// over-reporting can't wedge the loop).
+	return 256;
 }
 
 extern "C" size_t opk_serial_write(uint8_t b)

+ 11 - 1
OpenPuckZephyr/src/compat/usb_glue.cpp

@@ -112,7 +112,17 @@ static int op_set_report(const struct device *dev, const uint8_t type,
 	int i = pool_index(dev);
 	if (i < 0 || !s_hid_owner[i] || !s_hid_owner[i]->_set_cb)
 		return -ENOTSUP;
-	s_hid_owner[i]->_set_cb(id, type, buf, len);
+	// TinyUSB delivers the SET_REPORT payload WITHOUT the report ID; the
+	// macOS/Zephyr control path leaves the ID as buf[0]. Strip it so the puck
+	// command parser sees b[0]=command (else every command is off-by-one and
+	// Steam's pairing/bond commands are misparsed).
+	const uint8_t *payload = buf;
+	uint16_t plen = len;
+	if (id != 0 && plen >= 1 && buf[0] == id) {
+		payload++;
+		plen--;
+	}
+	s_hid_owner[i]->_set_cb(id, type, payload, plen);
 	return 0;
 }