Skip to content

Commit bf34400

Browse files
Copilotjyong15
andcommitted
Add debug logging and increase MacOS serial port timeout to 2000ms
Co-authored-by: jyong15 <26561407+jyong15@users.noreply.github.com>
1 parent 0f43660 commit bf34400

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

ShimmerDriver/src/main/java/com/shimmerresearch/bluetooth/ShimmerRadioInitializer.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ public ShimmerRadioInitializer(AbstractSerialPortHal serialCommPort){
2727
}
2828

2929
public ShimmerRadioInitializer(AbstractSerialPortHal serialCommPort, boolean useLegacyDelayBeforeBtRead){
30+
System.out.println("ShimmerRadioInitializer: Constructor called with delay flag = " + useLegacyDelayBeforeBtRead);
3031
mUseLegacyDelayToDelayForResponse = useLegacyDelayBeforeBtRead;
3132
this.serialCommPort = serialCommPort;
3233
}
@@ -55,8 +56,12 @@ protected int readHardwareVersion() throws ShimmerException, InterruptedExceptio
5556
byte[] instruction = {InstructionsGet.GET_SHIMMER_VERSION_COMMAND_VALUE};
5657

5758
serialCommPort.txBytes(instruction);
58-
if(mUseLegacyDelayToDelayForResponse)
59+
if(mUseLegacyDelayToDelayForResponse) {
60+
System.out.println("ShimmerRadioInitializer: Applying command-response delay (200ms)");
5961
Thread.sleep(200);
62+
} else {
63+
System.out.println("ShimmerRadioInitializer: No command-response delay (flag is false)");
64+
}
6065
byte[] response = serialCommPort.rxBytes(3);
6166
if (response==null){
6267
serialCommPort.disconnect();

ShimmerDriverPC/src/main/java/com/shimmerresearch/pcSerialPort/SerialPortCommJssc.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,12 @@ public SerialPortCommJssc(String comPort, String uniqueId, int baudToUse) {
5858
mBaudToUse = baudToUse;
5959
mSerialPort = new SerialPort(mComPort);
6060
jsscByteWriter = new JsscByteWriter(mSerialPort);
61+
62+
// On MacOS, increase timeout to accommodate command-response delay
63+
if(UtilShimmer.isOsMac()) {
64+
setTimeout(SERIAL_PORT_TIMEOUT_2000);
65+
consolePrintLn("MacOS: Using extended serial port timeout (2000ms)");
66+
}
6167
}
6268

6369
public SerialPortCommJssc(String comPort, String uniqueId, int baudToUse, SerialPortListener shimmerSerialEventCallback) {

0 commit comments

Comments
 (0)