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
9 changes: 6 additions & 3 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,12 @@ That runs both the debug and release variants. CI runs the debug variant (`testD

Some tests pin down what the driver queues, not only what `Shimmer.java` does, so a driver pin bump
can fail them with nothing wrong here: adapt them to the driver's new behaviour in the bump PR. The
first case is DEV-1337 (Shimmer-Java-Android-API#339), which stops the driver writing the clock to
a streaming Shimmer3R, while AAPI_00002, 00003 and 00005 expect `startSDLogging()` on one to queue
`SET_RWC_COMMAND`. #339 adapts the driver's own tests the same way.
first case was driver 0.11.12_beta and DEV-1337 (Shimmer-Java-Android-API#339): the driver no longer
writes the clock to a streaming Shimmer3R, so `startSDLogging()` on one queues only
`START_LOGGING_ONLY_COMMAND`. The 0.11.12_beta bump adapted AAPI_00002, 00003 and 00005 to that, as
#339 did the driver's own tests. Where a test needs a command queued behind the one in flight, it
uses `readDirectoryName()`: while streaming, `readBattery()` here writes straight to the socket
rather than queueing.

## CI

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,30 +253,25 @@ private static void assertNoResync(QueueShimmer device) {
}

/**
* startSDLogging() while streaming sends SET_RWC_COMMAND and then
* START_LOGGING_ONLY_COMMAND, and the firmware answers each with a bare ACK
* startSDLogging() while a Shimmer3R streams sends START_LOGGING_ONLY_COMMAND,
* with no clock write before it (DEV-1337), and the firmware answers with a
* bare ACK
*/
private void startSdLoggingWhileStreaming(BT_CRC_MODE crcMode, int readSize) {
QueueShimmer device = streamingShimmer3r(crcMode);
device.startSDLogging();

sendNextInstruction(device);
assertEquals(ShimmerObject.SET_RWC_COMMAND, device.mCurrentCommand);
receive(device, readSize, dataPacket(payload(1), crcMode), bareAck(crcMode),
dataPacket(payload(2), crcMode), dataPacket(payload(3), crcMode));
assertAckProcessed(device);
assertEquals("START_LOGGING_ONLY_COMMAND is still queued", 1, device.getListofInstructions().size());
assertEquals("only START_LOGGING_ONLY_COMMAND is queued", 1, device.getListofInstructions().size());

sendNextInstruction(device);
assertEquals(ShimmerObject.START_LOGGING_ONLY_COMMAND, device.mCurrentCommand);
receive(device, readSize, dataPacket(payload(4), crcMode), bareAck(crcMode),
dataPacket(payload(5), crcMode), new byte[] {ShimmerObject.DATA_PACKET});
receive(device, readSize, dataPacket(payload(1), crcMode), bareAck(crcMode),
dataPacket(payload(2), crcMode), dataPacket(payload(3), crcMode), new byte[] {ShimmerObject.DATA_PACKET});
assertAckProcessed(device);
assertTrue(device.getListofInstructions().isEmpty());
assertTrue(device.isSDLogging());
assertEquals(BT_STATE.STREAMING_AND_SDLOGGING, device.getBluetoothRadioState());

assertParsed(device, payload(1), payload(2), payload(3), payload(4), payload(5));
assertParsed(device, payload(1), payload(2), payload(3));
assertBuffered(device, ShimmerObject.DATA_PACKET);
assertNoResync(device);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -357,13 +357,13 @@ public void replyToTheQueuedCommandInFlightCompletesItOnce() throws Exception {
receive(device, readSize, dataPacket(payload(1), crcMode), statusPush(STATUS_STREAMING, crcMode),
dataPacket(payload(2), crcMode));
assertAwaitingReply(device, ShimmerObject.GET_DIR_COMMAND);
assertQueued(device, ShimmerObject.GET_DIR_COMMAND, ShimmerObject.SET_RWC_COMMAND, ShimmerObject.START_LOGGING_ONLY_COMMAND);
assertQueued(device, ShimmerObject.GET_DIR_COMMAND, ShimmerObject.START_LOGGING_ONLY_COMMAND);

receive(device, readSize, dataPacket(payload(3), crcMode), dirReply(crcMode),
dataPacket(payload(4), crcMode), new byte[] {ShimmerObject.DATA_PACKET});
assertEquals(DIRECTORY_NAME, device.getDirectoryName());
assertAnswered(device);
assertQueued(device, ShimmerObject.SET_RWC_COMMAND, ShimmerObject.START_LOGGING_ONLY_COMMAND);
assertQueued(device, ShimmerObject.START_LOGGING_ONLY_COMMAND);

assertParsed(device, payload(1), payload(2), payload(3), payload(4));
assertBuffered(device, ShimmerObject.DATA_PACKET);
Expand All @@ -372,36 +372,40 @@ public void replyToTheQueuedCommandInFlightCompletesItOnce() throws Exception {
}

/**
* startSDLogging() while streaming queues SET_RWC_COMMAND, then
* START_LOGGING_ONLY_COMMAND. In-stream responses that answer neither leave
* startSDLogging() while a Shimmer3R streams queues START_LOGGING_ONLY_COMMAND
* with no clock write before it (DEV-1337), and readDirectoryName() queues
* GET_DIR_COMMAND behind it. In-stream responses that answer neither leave
* both alone: the battery timer's reading, which readBattery() wrote straight
* out, while the first awaits its ACK, and a status push while the second
* waits its turn. The first used to take SET_RWC_COMMAND off the queue, so
* its ACK was processed against START_LOGGING_ONLY_COMMAND's instruction.
* waits its turn. The first used to take the SET command in flight off the
* queue, so its ACK was processed against the next instruction.
*/
@Test
public void responsesThatAnswerNoQueuedCommandLeaveTheQueueAlone() throws Exception {
forEveryCrcModeAndReadSize((crcMode, readSize) -> {
QueueShimmer device = streamingShimmer3r(crcMode);
device.startSDLogging();
device.readDirectoryName();
sendNextInstruction(device);
device.readBattery();

receive(device, readSize, dataPacket(payload(1), crcMode), vbattReply(crcMode), dataPacket(payload(2), crcMode));
assertEquals(VBATT_ADC, device.getBattStatusDetails().getBattAdcValue(), 0);
assertAwaitingReply(device, ShimmerObject.SET_RWC_COMMAND);
assertQueued(device, ShimmerObject.SET_RWC_COMMAND, ShimmerObject.START_LOGGING_ONLY_COMMAND);
assertAwaitingReply(device, ShimmerObject.START_LOGGING_ONLY_COMMAND);
assertQueued(device, ShimmerObject.START_LOGGING_ONLY_COMMAND, ShimmerObject.GET_DIR_COMMAND);

receive(device, readSize, dataPacket(payload(3), crcMode), bareAck(crcMode), dataPacket(payload(4), crcMode));
assertAnswered(device);
assertQueued(device, ShimmerObject.START_LOGGING_ONLY_COMMAND);
assertQueued(device, ShimmerObject.GET_DIR_COMMAND);
assertTrue(device.isSDLogging());

receive(device, readSize, dataPacket(payload(5), crcMode), statusPush(STATUS_STREAMING, crcMode), dataPacket(payload(6), crcMode));
assertQueued(device, ShimmerObject.START_LOGGING_ONLY_COMMAND);
receive(device, readSize, dataPacket(payload(5), crcMode), statusPush(STATUS_STREAMING_AND_LOGGING, crcMode), dataPacket(payload(6), crcMode));
assertQueued(device, ShimmerObject.GET_DIR_COMMAND);

sendNextInstruction(device);
receive(device, readSize, dataPacket(payload(7), crcMode), bareAck(crcMode),
receive(device, readSize, dataPacket(payload(7), crcMode), dirReply(crcMode),
dataPacket(payload(8), crcMode), new byte[] {ShimmerObject.DATA_PACKET});
assertEquals(DIRECTORY_NAME, device.getDirectoryName());
assertAnswered(device);
assertQueued(device);
assertTrue(device.isSDLogging());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -385,15 +385,16 @@ public void bareAckInThePause() throws Exception {
forEachCrcModeAndReadSize(CRC_ON, (crcMode, readSize) -> {
QueueShimmer device = streamingShimmer3r(crcMode);
device.stopSDLogging();
device.startSDLogging();
assertQueued(device, ShimmerObject.STOP_LOGGING_ONLY_COMMAND, ShimmerObject.SET_RWC_COMMAND, ShimmerObject.START_LOGGING_ONLY_COMMAND);
device.startSDLogging(); // START_LOGGING_ONLY_COMMAND: no clock write to a streaming Shimmer3R (DEV-1337)
device.readDirectoryName();
assertQueued(device, ShimmerObject.STOP_LOGGING_ONLY_COMMAND, ShimmerObject.START_LOGGING_ONLY_COMMAND, ShimmerObject.GET_DIR_COMMAND);
stopLoggingAndReceiveItsAck(device, crcMode, readSize);

sendNextInstruction(device);
assertEquals(ShimmerObject.SET_RWC_COMMAND, device.mCurrentCommand);
assertEquals(ShimmerObject.START_LOGGING_ONLY_COMMAND, device.mCurrentCommand);
receive(device, readSize, bareAck(crcMode), dataPacket(payload(2), crcMode), new byte[] {ShimmerObject.DATA_PACKET});
assertAnswered(device);
assertQueued(device, ShimmerObject.START_LOGGING_ONLY_COMMAND);
assertQueued(device, ShimmerObject.GET_DIR_COMMAND);

assertParsed(device, payload(1), payload(2));
assertBuffered(device, ShimmerObject.DATA_PACKET);
Expand Down
2 changes: 1 addition & 1 deletion ShimmerAndroidInstrumentDriver/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ apply plugin: 'maven-publish'
// The shimmerdriver / shimmerbluetoothmanager version (Shimmer-Java-Android-API) that the library and
// every example build against. The default is what master builds with; the Release Android API
// workflow passes -PdriverVersion, by default the newest Java API release.
def shimmerDriverVersion = findProperty('driverVersion') ?: '0.11.11_beta'
def shimmerDriverVersion = findProperty('driverVersion') ?: '0.11.12_beta'

allprojects {
repositories {
Expand Down
Loading