mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-10-14 19:27:09 -04:00
Glasses: drop USB frames with a bad checksum
This commit is contained in:
1 parent
bdf876d47c
commit
da72c85352
3 files changed
+4
-5
No files matched your search
@@ -542,9 +542,9 @@ object Glasses {
|
||||
private fun linkListener(generation: Long) = object : VitureLink.Listener {
|
||||
override fun onFrame(frame: VitureProtocol.Frame) = post {
|
||||
if (generation != linkGeneration) return@post
|
||||
val line = "%s 0x%04X %s%s".format(
|
||||
val line = "%s 0x%04X %s".format(
|
||||
when (frame.magic) { VitureProtocol.MAGIC_REPORT -> "FD"; VitureProtocol.MAGIC_COMMAND -> "FE"; else -> "FC" },
|
||||
frame.msgId, frame.payload.joinToString("") { "%02X".format(it) }, if (frame.crcOk) "" else " crc!",
|
||||
frame.msgId, frame.payload.joinToString("") { "%02X".format(it) },
|
||||
)
|
||||
synchronized(frames) {
|
||||
frames.addLast(line)
|
||||
|
||||
@@ -32,10 +32,10 @@ internal class VitureLink private constructor(
|
||||
val hasImu: Boolean get() = imuIn != null
|
||||
|
||||
private fun startReaders() {
|
||||
mcuIn?.let { ep -> readers += reader("viture-mcu", ep) { buf, n -> VitureProtocol.parse(buf, n)?.let(listener::onFrame) } }
|
||||
mcuIn?.let { ep -> readers += reader("viture-mcu", ep) { buf, n -> VitureProtocol.parse(buf, n)?.takeIf { it.crcOk }?.let(listener::onFrame) } }
|
||||
imuIn?.let { ep ->
|
||||
readers += reader("viture-imu", ep) { buf, n ->
|
||||
val frame = VitureProtocol.parse(buf, n) ?: return@reader
|
||||
val frame = VitureProtocol.parse(buf, n)?.takeIf { it.crcOk } ?: return@reader
|
||||
if (frame.magic == VitureProtocol.MAGIC_IMU) listener.onImu(frame.payload, SystemClock.elapsedRealtimeNanos())
|
||||
else listener.onFrame(frame)
|
||||
}
|
||||
|
||||
@@ -132,7 +132,6 @@ tools/droiddeckctl glasses raw 0x0007
|
||||
Glasses status reports `deviceMode` from the MCU separately from `sbs`, which
|
||||
requires a physical stereo display mode. `switching3d` marks the bounded
|
||||
confirmation window. A successful mode-command reply alone does not confirm 3D.
|
||||
In `frames`, a report whose checksum does not match ends in `crc!`.
|
||||
|
||||
A sleeping device suspends the session and hides the app's windows from `ui dump`; `wake` first.
|
||||
|
||||
|
||||
Reference in new issue
Block a user