Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,17 @@ interface Condition {
volatile String connectFailure;
/** jssc's message when Windows refuses to open a COM port that another program already has open. */
private static final Pattern PORT_BUSY = Pattern.compile("Port busy");
/**
* Per connect: whether the driver has sent NOTIFICATION_SHIMMER_FULLY_INITIALIZED (the end of
* its connect sequence), and whether the first CONNECTED state is still to come.
*/
private volatile boolean fullyInitialisedSinceConnect;
private volatile boolean awaitingFirstConnected;
/**
* Connects whose first CONNECTED came before the end of the connect sequence: the app was told
* the unit was ready while the sequence was still queued (DEV-1275).
*/
volatile int connectedBeforeReady;

HilSession(String port, String mac, String type) {
this.port = port;
Expand Down Expand Up @@ -102,7 +113,18 @@ protected void processMsgFromCallback(ShimmerMsg msg) {
lastState = state;
stateChanges++;
event("state " + state);
if (state == BT_STATE.CONNECTED && awaitingFirstConnected) {
awaitingFirstConnected = false;
if (!fullyInitialisedSinceConnect) {
connectedBeforeReady++;
event("CONNECTED reported before the connect sequence ended (no FULLY_INITIALIZED yet; DEV-1275)");
}
}
}
} else if (msg.mIdentifier == HilShimmerPC.MSG_IDENTIFIER_NOTIFICATION_MESSAGE && msg.mB instanceof CallbackObject
&& ((CallbackObject) msg.mB).mIndicator == HilShimmerPC.NOTIFICATION_SHIMMER_FULLY_INITIALIZED) {
fullyInitialisedSinceConnect = true;
event("fully initialised");
} else if (msg.mIdentifier == HilShimmerPC.MSG_IDENTIFIER_DATA_PACKET && msg.mB instanceof ObjectCluster) {
if (recording) {
recordPacket((ObjectCluster) msg.mB);
Expand Down Expand Up @@ -186,6 +208,8 @@ boolean call(String what, long timeoutMs, Call call) {
boolean connect(long timeoutMs) throws InterruptedException {
connects++;
connectFailure = null;
fullyInitialisedSinceConnect = false;
awaitingFirstConnected = true;
int mark = stateChanges;
int logMark = device.logSize();
Condition failed = () -> stateChanges > mark && device.getBluetoothRadioState() == BT_STATE.CONNECTION_FAILED;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ public void end() {
}

private void finish() {
report.check(session.connectedBeforeReady == 0, session.connectedBeforeReady + " of " + session.connects
+ " connects reported CONNECTED before the connect sequence ended (DEV-1275)");
if (session.hung != null) {
report.put("hungCall", session.hung);
report.check(false, session.hung + " never returned: the API call blocked (thread dump in the report's events)");
Expand All @@ -116,6 +118,7 @@ private void finish() {
/** What the driver did in this session: replies by type, decodes, timer requests, connects. */
private void putDriverCounts() {
report.put("connects", session.connects);
report.put("connectedBeforeReady", session.connectedBeforeReady);
report.put("inStreamReplies", device.inStreamReplies());
report.put("statusesDecoded", device.statusesDecoded());
report.put("batteryReadings", device.batteryReadings());
Expand Down
2 changes: 2 additions & 0 deletions tools/hil/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ A connect is never retried. If the COM port can't be opened, the scenario fails
- **CONNECTION_FAILED** for any other reason: the unit is off, out of range, or connected to
another host such as a phone.

Every connect, in every scenario, is also checked for DEV-1275: the first CONNECTED must come only after the driver's NOTIFICATION_SHIMMER_FULLY_INITIALIZED, which marks the end of its connect sequence. `connectedBeforeReady` counts the connects that broke this, and any one fails the scenario.

Each report counts what the session covered: connects, in-stream replies by type, statuses and
battery readings decoded, the status timer's requests, and command timeouts. Its events also say
which driver timers were running after connect, after configure and while streaming.
Expand Down
Loading