Repository navigation
DEV-1291 DEV-1275: Android HIL inStream and connectReady scenarios - #134
Merged
Merged
Conversation
inStream (DEV-1291): while streaming, start SD logging, stop it, and read the battery and the status every 40 ms for 400 ms. Android writes those reads straight out, so some land in the ~100 ms the unit pauses its data packets while it closes its SD file, and their replies come with no data packet before them. Then stop and start logging back to back, so the queued start goes out in the pause. It fails when: - a battery read goes unanswered, or fewer status replies than reads are decoded; - logging doesn't stop or restart; - a command times out; - there's a parser error. Loss near the reads is reported, not failed: a Shimmer3 skips a sample there now and then on its own. connectReady (DEV-1275): connect to the unit idle, then again while it logs. It fails when the unit is reported ready (a CONNECTED or SDLOGGING state message, or that state in the API) more than 250 ms before NOTIFICATION_SHIMMER_FULLY_INITIALIZED, which ends the connect sequence. The HIL's own connect waits for isInitialised(), which on Classic comes only at the end, so the existing scenarios never saw the early report. The runner runs both by default, and the README lists them. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…s lock The IO thread takes the queue's lock and then the device's (DEV-1198). Polling the queue through the synchronized getListofInstructions() made the IO thread wait on the device's lock while it held the queue's, which widened that deadlock's window. Read the field directly instead. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…stalled connect connectReady's second connect, to the unit while it logs, can fail. The unit was then left logging, and every later run failed to connect to it as idle. It now connects again to stop logging, and resetUnit does the same by hand. A connect that doesn't finish now dumps every thread, as a hung call does. The connect call itself returns at once, so nothing showed a stalled connect sequence, such as the DEV-1198 lock-order deadlock. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…at an SD start are the unit's The phone's log buffer is small, and with the Bluetooth snoop log on it rolled past inStream's start marker within a run. Every count then read 0, so 15 decoded battery replies were reported as none. inStream now places a marker per round and counts right after it. If a marker is gone anyway, it fails saying the lines could not be counted, rather than counting none. A timestamp jump within 3 s after an SD logging start or stop is now reported rather than failed, just as the loss there is. The captured bytes show a Shimmer3 doing this itself. After a 1.5 s pause while it opened its file, it sent two packets it had held, and a millisecond later the next one it sampled, 385 periods on. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The driver guards its instruction queue with two locks, the device and the queue. Up to 0.11.10_beta its IO thread took them queue first when it fetched the next instruction, and every call that queues one takes them device first, so the two could deadlock and every later call hung. On Android it hung 5 of 12 inStream runs on driver 0.11.7_beta, but inStream needs SD logging and catches it only by chance. queueStress makes the window wide on purpose, as the Java HIL's scenario of the same name does. With the unit connected and idle, timers on, four threads queue battery and status reads in tight loops for 60 s, keeping the queue under 8. Idle, because while streaming Android writes these reads straight out, unqueued, and they never take the queue's lock. It needs no SD card, so it also runs on a docked or charging unit. It fails when a read doesn't return within 10 s or no read returns for 10 s, with every thread's stack in the events; when a read throws; or when the queue doesn't drain within 15 s. The runner runs it by default and the README lists it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This was referenced Oct 23, 2026
Up to driver 0.11.10_beta, a configuration written straight after stopStreaming() could lose its first chunk, the one holding the sampling rate: operationPrepare() cleared the instruction list while the STOP was still in flight, and the stop's reply then retired the next instruction in its place. The unit kept its old rate. The Java HIL's samplingRates found it on a Shimmer3 and a Shimmer3R. Android configures through the same driver code over both transports, and had no scenario for it. samplingRates, as in the Java and shimmer-logandstream HILs, writes 51.2, 256 and 512 Hz in turn and streams 5 s at each, then writes the unit's own rate back; every configure but the first comes straight after a stop. Unlike the Java HIL's configure, the Android one can finish on the manager's SUCCESS without looking at the rate, so the scenario checks that the rate read back is the one written. No SD card is needed. The runner runs it by default and the README lists it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…pling_rates DEV-1306: Android HIL samplingRates, configuring straight after a stop
…ue_stress DEV-1266: Android HIL queueStress, to reproduce the lock-order deadlock
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two Android HIL scenarios for the DEV-1291 and DEV-1275 ports, plus HIL fixes they needed. Stacked on #128 (the Android HIL); merge #128 first.
New scenarios
inStream(DEV-1291): while streaming, start SD logging, stop it, and read the battery and the status every 40 ms for 400 ms. Android writes those reads straight out, so some land in the ~100 ms the unit pauses its data packets while it closes its SD file. Then stop and start logging back to back, so the queued start goes out in the pause. It fails when a battery read goes unanswered, fewer status replies than reads are decoded, logging doesn't stop or restart, a command times out, or there's a parser error. Loss near the reads is reported, not failed: a Shimmer3 skips a sample there now and then on its own (DEV-1297).connectReady(DEV-1275): connect to the unit idle, then again while it logs. It fails when the unit is reported ready (a CONNECTED or SDLOGGING state, in a message or the API) more than 250 ms beforeNOTIFICATION_SHIMMER_FULLY_INITIALIZED. The HIL's own connect waits forisInitialised(), so the existing scenarios never saw the early report.resetUnit, manual only: stops logging on a unit a failed run left logging.The runner runs
inStreamandconnectReadyby default, and the README lists them.HIL fixes
connectReady's connect to a logging unit fails, the HIL connects again to stop logging. Before, every later run failed to connect to it as idle.inStreamplaces a log marker per round and counts right after it. The phone's log buffer, with the Bluetooth snoop log on, rolled past a single start marker within a run and made 15 decoded replies read as 0. If a marker is gone anyway it fails saying so, rather than counting none.Tested
On a Shimmer3 (3E36, Classic, from a phone): both scenarios fail on a build without the ports and pass with them. Results are in the DEV-1275 and DEV-1291 port PRs.
🤖 Generated with Claude Code