Skip to content

Commit 831c25e

Browse files
committed
Merge remote-tracking branch 'origin/CON-656' into ASM-2341
Conflicts: ShimmerDriver/src/main/java/com/shimmerresearch/verisense/UtilVerisenseDriver.java
2 parents 3848f90 + a2f5d1b commit 831c25e

3 files changed

Lines changed: 76 additions & 32 deletions

File tree

ShimmerDriver/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Rev0.2
1313
*/
1414

1515
//This version should match the git release tag
16-
version = '0.9.144alpha'
16+
version = '0.9.146alpha'
1717

1818
sourceCompatibility = 1.7
1919
targetCompatibility = 1.7

ShimmerDriver/src/main/java/com/shimmerresearch/verisense/UtilVerisenseDriver.java

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -553,10 +553,23 @@ public static File[] filterFileArrayForAllAndRemoveDuplicates(File[] fileArray,
553553
* @param fileArray -> input file array to filter
554554
* @param nameContains -> substrings of files names to keep. If NULL, this parameter is not used.
555555
* @param pathContains -> substrings of paths to keep. If NULL, this parameter is not used.
556-
* @param fileNameSuffix[] -> suffixes (including file extension) of files to keep. If NULL, this parameter is not used.
557-
* @return a new fileArray[] containing matches with nameContains, pathContains and fileSuffice
556+
* @param fileNameSuffixes[] -> suffixes (including file extension) of files to keep. If NULL, this parameter is not used.
557+
* @return a new fileArray[] containing matches with nameContains, pathContains and fileNameSuffixes
558558
*/
559559
public static File[] filterFileArrayForAllAndRemoveDuplicates(File[] fileArray, String[][] nameContains, String[][] pathContains, String[] fileNameSuffixes) {
560+
return filterFileArrayForAllAndRemoveDuplicates(fileArray, nameContains, pathContains, fileNameSuffixes, null);
561+
}
562+
563+
/** This method is particularly used when searching for a matching strings in a set. All strings within any of the 1D arrays must be contained within the name or path.
564+
*
565+
* @param fileArray -> input file array to filter
566+
* @param nameContains -> substrings of files names to keep. If NULL, this parameter is not used.
567+
* @param pathContains -> substrings of paths to keep. If NULL, this parameter is not used.
568+
* @param fileNameSuffixes[] -> suffixes (including file extension) of files to keep. If NULL, this parameter is not used.
569+
* @param String[] fileNamePrefixes -> prefixes of filenames to keep. If NULL, this parameter is not used.
570+
* @return a new fileArray[] containing matches with nameContains, pathContains, fileNameSuffixes and fileNamePrefixes
571+
*/
572+
public static File[] filterFileArrayForAllAndRemoveDuplicates(File[] fileArray, String[][] nameContains, String[][] pathContains, String[] fileNameSuffixes, String[] fileNamePrefixes) {
560573
List<File> listOfFiles = new ArrayList<File>();
561574
fileLoop:
562575
for(File file:fileArray) {
@@ -588,6 +601,19 @@ public static File[] filterFileArrayForAllAndRemoveDuplicates(File[] fileArray,
588601
}
589602
}
590603

604+
if(fileNamePrefixes != null) {
605+
for(int i=0; i<fileNamePrefixes.length; i++) {
606+
if(fileName.startsWith(fileNamePrefixes[i])) {
607+
break;
608+
}
609+
610+
// If last entry and still no match, continue to next file
611+
if(i==fileNamePrefixes.length-1) {
612+
continue fileLoop;
613+
}
614+
}
615+
}
616+
591617
listOfFiles.add(file);
592618
}
593619

ShimmerDriver/src/main/java/com/shimmerresearch/verisense/communication/payloads/StatusPayload.java

Lines changed: 47 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ public class StatusPayload extends AbstractPayload {
3939
public boolean adaptiveSchedulerEnabled;
4040
public boolean dfuServiceOn;
4141
public boolean statusFlagFirstBoot;
42+
public boolean secondaryStatusMsg;
4243

4344
public int syncType = -1;
4445

@@ -91,7 +92,7 @@ public class STATUS_FLAGS {
9192
public static final int BIT_MASK_ADAPTIVE_SCHEDULER_ON = (1 << 4);
9293
public static final int BIT_MASK_DFU_SERVICE_ON = (1 << 5);
9394
public static final int BIT_MASK_FIRST_BOOT = (1 << 6);
94-
// public static final int BIT_MASK_UNUSED = (1 << 7);
95+
public static final int BIT_MASK_SECONDARY_STATUS = (1 << 7);
9596

9697
public static final int BIT_SHIFT_FLASH_WRITE_RETRY_COUNTER_SHORT_TRY_LSB = (8 * 1);
9798
public static final int BIT_SHIFT_FLASH_WRITE_RETRY_COUNTER_SHORT_TRY_MSB = (8 * 2);
@@ -174,29 +175,7 @@ public boolean parsePayloadContents(byte[] payloadContents) {
174175
// reverse so the value of 9 00001001 will be 10010000 which is easier to read
175176
// via index/table provided in the document ASM-DES04
176177

177-
usbPowered = ((statusFlags & STATUS_FLAGS.BIT_MASK_USB_PLUGGED_IN) > 0) ? true : false;
178-
recordingPaused = ((statusFlags & STATUS_FLAGS.BIT_MASK_RECORDING_PAUSED) > 0) ? true : false;
179-
flashIsFull = ((statusFlags & STATUS_FLAGS.BIT_MASK_FLASH_IS_FULL) > 0) ? true : false;
180-
powerIsGood = ((statusFlags & STATUS_FLAGS.BIT_MASK_POWER_IS_GOOD) > 0) ? true : false;
181-
adaptiveSchedulerEnabled = ((statusFlags & STATUS_FLAGS.BIT_MASK_ADAPTIVE_SCHEDULER_ON) > 0) ? true : false;
182-
dfuServiceOn = ((statusFlags & STATUS_FLAGS.BIT_MASK_DFU_SERVICE_ON) > 0) ? true : false;
183-
statusFlagFirstBoot = ((statusFlags & STATUS_FLAGS.BIT_MASK_FIRST_BOOT) > 0) ? true : false;
184-
185-
// For a number of previous FW versions, the timestamp in ticks was stored in
186-
// byte 5, 6 and 7. A better approach is to know what version of FW it is so it
187-
// can be parsed correctly but that information isn't available at this point in
188-
// the code.
189-
if(isStatusFlagValid()) {
190-
// FW v1.02.123 onwards
191-
flashWriteRetryCounterShortTry = (int) parseByteArrayAtIndex(payloadContents, 27, CHANNEL_DATA_TYPE.UINT16);
192-
flashWriteRetryCounterLongTry = (int) parseByteArrayAtIndex(payloadContents, 29, CHANNEL_DATA_TYPE.UINT16);
193-
194-
// FW v1.02.084 onwards
195-
flashWriteFailCounter = (int) parseByteArrayAtIndex(payloadContents, 31, CHANNEL_DATA_TYPE.UINT16);
196-
197-
// FW v1.02.063 onwards
198-
failedBleConnectionAttemptCount = (int) parseByteArrayAtIndex(payloadContents, 33, CHANNEL_DATA_TYPE.UINT8);
199-
}
178+
parseStatusFlagBytes(statusFlags);
200179
}
201180

202181
if (payloadContents.length > 34) { // supported fw for ASM-1329
@@ -221,6 +200,36 @@ public boolean parsePayloadContents(byte[] payloadContents) {
221200
return isSuccess;
222201
}
223202

203+
public void parseStatusFlagBytes(long statusFlags) {
204+
if(isStatusFlagValid()) {
205+
usbPowered = ((statusFlags & STATUS_FLAGS.BIT_MASK_USB_PLUGGED_IN) > 0) ? true : false;
206+
recordingPaused = ((statusFlags & STATUS_FLAGS.BIT_MASK_RECORDING_PAUSED) > 0) ? true : false;
207+
flashIsFull = ((statusFlags & STATUS_FLAGS.BIT_MASK_FLASH_IS_FULL) > 0) ? true : false;
208+
powerIsGood = ((statusFlags & STATUS_FLAGS.BIT_MASK_POWER_IS_GOOD) > 0) ? true : false;
209+
adaptiveSchedulerEnabled = ((statusFlags & STATUS_FLAGS.BIT_MASK_ADAPTIVE_SCHEDULER_ON) > 0) ? true : false;
210+
dfuServiceOn = ((statusFlags & STATUS_FLAGS.BIT_MASK_DFU_SERVICE_ON) > 0) ? true : false;
211+
statusFlagFirstBoot = ((statusFlags & STATUS_FLAGS.BIT_MASK_FIRST_BOOT) > 0) ? true : false;
212+
213+
// FW v1.02.124 & FW v1.04.000 onwards (not the versions in between)
214+
secondaryStatusMsg = ((statusFlags & STATUS_FLAGS.BIT_MASK_SECONDARY_STATUS) > 0) ? true : false;
215+
216+
// For a number of previous FW versions, the timestamp in ticks was stored in
217+
// byte 5, 6 and 7. A better approach is to know what version of FW it is so it
218+
// can be parsed correctly but that information isn't available at this point in
219+
// the code.
220+
221+
// FW v1.02.123 onwards
222+
flashWriteRetryCounterShortTry = (int) ((statusFlags >> STATUS_FLAGS.BIT_SHIFT_FLASH_WRITE_RETRY_COUNTER_SHORT_TRY_LSB) & 0xFFFF);
223+
flashWriteRetryCounterLongTry = (int) ((statusFlags >> STATUS_FLAGS.BIT_SHIFT_FLASH_WRITE_RETRY_COUNTER_LONG_TRY_LSB) & 0xFFFF);
224+
225+
// FW v1.02.084 onwards
226+
flashWriteFailCounter = (int) ((statusFlags >> STATUS_FLAGS.BIT_SHIFT_FAIL_COUNT_FLASH_WRITE_LSB) & 0xFFFF);
227+
228+
// FW v1.02.063 onwards
229+
failedBleConnectionAttemptCount = (int) ((statusFlags >> STATUS_FLAGS.BIT_SHIFT_FAIL_COUNT_BLE_SYNC) & 0xFF);
230+
}
231+
}
232+
224233
public void parseBatteryChargerStatusValue() {
225234
if(hwVerMajor!=-1 && VerisenseDevice.isChargerLm3658dPresent(hwVerMajor, hwVerMinor, hwVerInternal)) {
226235
batteryChargerStatus = VerisenseDevice.CHARGER_STATUS_LM3658D.values()[batteryChargerStatusValue];
@@ -271,11 +280,15 @@ public boolean isStatusFlagValid() {
271280
}
272281

273282
public boolean isStatusFlagRecordingPaused() {
274-
return (isStatusFlagValid() && (statusFlags&STATUS_FLAGS.BIT_MASK_RECORDING_PAUSED)>0);
283+
return recordingPaused;
275284
}
276285

277286
public boolean isStatusFlagFirstBoot() {
278-
return (isStatusFlagValid() && (statusFlags&STATUS_FLAGS.BIT_MASK_FIRST_BOOT)>0);
287+
return statusFlagFirstBoot;
288+
}
289+
290+
public boolean isStatusFlagSecondaryStatusMsg() {
291+
return secondaryStatusMsg;
279292
}
280293

281294
@Override
@@ -314,19 +327,24 @@ public String generateDebugString() {
314327
if (payloadContents.length >= 34) {
315328
sb.append("\tStatus Message Flags:\n");
316329

317-
// First byte - Bits 0-7
330+
// Byte 0 - Status flags
318331
sb.append("\t\tUSB_PLUGGED_IN:\t\t\t" + usbPowered + "\n");
319332
sb.append("\t\tRECORDING_PAUSED:\t\t" + recordingPaused + "\n");
320333
sb.append("\t\tFLASH_IS_FULL:\t\t\t" + flashIsFull + "\n");
321334
sb.append("\t\tPOWER_IS_GOOD:\t\t\t" + powerIsGood + "\n");
322335
sb.append("\t\tADAPTIVE_SCHEDULER_ON:\t\t" + adaptiveSchedulerEnabled + "\n");
323336
sb.append("\t\tDFU_SERVICE_ON:\t\t\t" + dfuServiceOn + "\n");
324337
sb.append("\t\tFIRST BOOT ON:\t\t\t" + statusFlagFirstBoot + "\n");
338+
sb.append("\t\tSecondary Status:\t\t" + secondaryStatusMsg + "\n");
339+
340+
// Bytes 1-4 - Pause counters
341+
sb.append("\t\tLTF WRITE - Short Retry Counter (2 minutes gap, 10 retries):\t" + flashWriteRetryCounterShortTry + "\n");
342+
sb.append("\t\tLTF WRITE - Long Retry Counter (4hrs gap, 1 retry):\t\t" + flashWriteRetryCounterLongTry + "\n");
325343

326-
// 7th byte - Bits 0-7
344+
// Bytes 5-6 - LTF write fail counter
327345
sb.append("\t\tLTF WRITE FAIL COUNTER:\t\t" + failedBleConnectionAttemptCount + "\n");
328346

329-
// Last byte - Bits 0-7
347+
// Byte 7 - Sync fail counter
330348
sb.append("\t\tFAIL SYNC COUNTER:\t\t" + flashWriteFailCounter + "\n");
331349
}
332350

0 commit comments

Comments
 (0)