diff --git a/ShimmerDriver/src/main/java/com/shimmerresearch/driverUtilities/HwDriverShimmerDeviceDetails.java b/ShimmerDriver/src/main/java/com/shimmerresearch/driverUtilities/HwDriverShimmerDeviceDetails.java index 164b1eedc..82f3f9d78 100644 --- a/ShimmerDriver/src/main/java/com/shimmerresearch/driverUtilities/HwDriverShimmerDeviceDetails.java +++ b/ShimmerDriver/src/main/java/com/shimmerresearch/driverUtilities/HwDriverShimmerDeviceDetails.java @@ -57,10 +57,17 @@ public enum SPAN_VERSION{ UNKNOWN, SPAN_SR1_3_1, // 115200 baud SPAN_SR1_3_0, // 230400 baud - VIRTUAL; + VIRTUAL, + /** nRF52840 with native USB (verisense-firmware SR9_SPAN_NRF52840): one CDC port, no FTDI bridge and no BSL */ + SPAN_NRF52840; public boolean isSupported(){ - return this==SPAN_VERSION.SPAN_SR1_3_1; + return this==SPAN_VERSION.SPAN_SR1_3_1 || this==SPAN_VERSION.SPAN_NRF52840; + } + + /** Whether the Span is an MSP430 that is reset and programmed through the BSL on its FTDI's first port */ + public boolean isMspBslSupported(){ + return this==SPAN_VERSION.SPAN_SR1_3_0 || this==SPAN_VERSION.SPAN_SR1_3_1; } } @@ -107,6 +114,15 @@ public static final class SH_SEARCH { "SHIMMER SPAN SR1-3.1", }; + /** USB product string of the nRF52840 Span (verisense-firmware + * SR9_SPAN_NRF52840/pca10056/blank/config/app_config.h). It is matched with + * {@link SERIAL_PORT#NORDIC_VEND_ID} and any PID: its PID, 0x5210, is + * provisional and unallocated under Nordic's VID, and matching on it would need a + * host release whenever it changes. See {@link HwDriverShimmerDeviceDetails#isSpanNrf52840}. */ + public static final String[] SPAN_NRF52840 = new String[] { + "NeuroLynQ Span", + }; + public static final String[] DISK_DRIVE = new String[] { "Shimmer", "Generic" // Some docks went out unprogrammed? @@ -195,6 +211,9 @@ public static final class SERIAL_PORT { public static final String FTDI_FT2232H_PROD_ID = "6010"; public static final String FTDI_FT4232H_PROD_ID = "6011"; + /** Nordic Semiconductor: the vendor ID of the Verisense and of the nRF52840 Span */ + public static final String NORDIC_VEND_ID = "1915"; + public static final String VIRTUAL_PORT = "COM0COM"; public static final String[] SHIMMER_3R = new String[] { @@ -321,6 +340,18 @@ else if(this.deviceType == DEVICE_TYPE.BASE6) { } } + /** Whether a USB device is an nRF52840 Span: Nordic's vendor ID with the Span's + * product string, whatever its product ID. Every platform's detection calls this so + * that they all apply the same rule. + * @param usbVendorId the vendor ID as four hex digits, e.g. "1915" + * @param usbProductString the USB product string (iProduct) + */ + public static boolean isSpanNrf52840(String usbVendorId, String usbProductString) { + return SH_SEARCH.SERIAL_PORT.NORDIC_VEND_ID.equalsIgnoreCase(usbVendorId) + && usbProductString!=null + && UtilShimmer.stringContainsItemFromListUpperCaseCheck(usbProductString, SH_SEARCH.SPAN_NRF52840); + } + public static DEVICE_TYPE getDeviceTypeFromLabel(String label){ for (DEVICE_TYPE deviceType:DEVICE_TYPE.values()) { if(deviceType.getLabel().equals(label)){ diff --git a/ShimmerDriver/src/test/java/com/shimmerresearch/driverUtilities/API_00012_SpanNrf52840IdentityTest.java b/ShimmerDriver/src/test/java/com/shimmerresearch/driverUtilities/API_00012_SpanNrf52840IdentityTest.java new file mode 100644 index 000000000..5224d9433 --- /dev/null +++ b/ShimmerDriver/src/test/java/com/shimmerresearch/driverUtilities/API_00012_SpanNrf52840IdentityTest.java @@ -0,0 +1,78 @@ +package com.shimmerresearch.driverUtilities; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; + +import com.shimmerresearch.driverUtilities.HwDriverShimmerDeviceDetails.SPAN_VERSION; + +/** + * How the host recognises the nRF52840 Span, and what it assumes about one once found + * (DEV-1047). + *
+ * The Span is matched on Nordic's vendor ID and its USB product string, not on its + * PID: 0x5210 is provisional and unallocated, and a PID match would need a host release + * whenever it changes. The strings below are the ones Windows reported for the bench + * devices on 2026-09-24. + */ +public class API_00012_SpanNrf52840IdentityTest { + + /** iProduct of the nRF52840 Span, verisense-firmware SR9_SPAN_NRF52840 */ + private static final String SPAN_NRF52840_PRODUCT = "NeuroLynQ Span"; + /** A Verisense in NeuroLynQ mode, on the same VID. It is a node, not a Span. */ + private static final String VERISENSE_NEUROLYNQ_PRODUCT = "Verisense-NeuroLynQ-01-2511210195BC"; + private static final String VERISENSE_PRODUCT = "Verisense-01-2511210195BC"; + private static final String SR9_SPAN_PRODUCT = "SHIMMER SPAN SR1-3.1"; + + @Test + public void matchesNordicVendorAndSpanProductString() { + assertTrue(HwDriverShimmerDeviceDetails.isSpanNrf52840("1915", SPAN_NRF52840_PRODUCT)); + } + + @Test + public void productStringMatchIgnoresCase() { + assertTrue(HwDriverShimmerDeviceDetails.isSpanNrf52840("1915", SPAN_NRF52840_PRODUCT.toUpperCase())); + } + + @Test + public void rejectsTheProductStringUnderAnotherVendor() { + assertFalse(HwDriverShimmerDeviceDetails.isSpanNrf52840( + HwDriverShimmerDeviceDetails.SH_SEARCH.SERIAL_PORT.FTDI_VEND_ID, SPAN_NRF52840_PRODUCT)); + } + + @Test + public void rejectsOtherNordicDevices() { + assertFalse(HwDriverShimmerDeviceDetails.isSpanNrf52840("1915", VERISENSE_NEUROLYNQ_PRODUCT)); + assertFalse(HwDriverShimmerDeviceDetails.isSpanNrf52840("1915", VERISENSE_PRODUCT)); + } + + @Test + public void rejectsTheSr9() { + assertFalse(HwDriverShimmerDeviceDetails.isSpanNrf52840( + HwDriverShimmerDeviceDetails.SH_SEARCH.SERIAL_PORT.FTDI_VEND_ID, SR9_SPAN_PRODUCT)); + } + + @Test + public void rejectsMissingValues() { + assertFalse(HwDriverShimmerDeviceDetails.isSpanNrf52840(null, SPAN_NRF52840_PRODUCT)); + assertFalse(HwDriverShimmerDeviceDetails.isSpanNrf52840("1915", null)); + assertFalse(HwDriverShimmerDeviceDetails.isSpanNrf52840("", "")); + } + + @Test + public void nrf52840SpanIsSupportedButHasNoBsl() { + assertTrue(SPAN_VERSION.SPAN_NRF52840.isSupported()); + assertFalse(SPAN_VERSION.SPAN_NRF52840.isMspBslSupported()); + } + + @Test + public void msp430SpansKeepTheirBsl() { + assertTrue(SPAN_VERSION.SPAN_SR1_3_1.isSupported()); + assertTrue(SPAN_VERSION.SPAN_SR1_3_1.isMspBslSupported()); + assertFalse(SPAN_VERSION.SPAN_SR1_3_0.isSupported()); + assertTrue(SPAN_VERSION.SPAN_SR1_3_0.isMspBslSupported()); + assertFalse(SPAN_VERSION.VIRTUAL.isMspBslSupported()); + assertFalse(SPAN_VERSION.UNKNOWN.isMspBslSupported()); + } +}