Skip to content

Commit 4c57fed

Browse files
Copilotjyong15
andcommitted
Significantly increase all MacOS timing delays for device communication
Co-authored-by: jyong15 <[email protected]>
1 parent d29109f commit 4c57fed

2 files changed

Lines changed: 10 additions & 6 deletions

File tree

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ protected int readHardwareVersion() throws ShimmerException, InterruptedExceptio
5757

5858
serialCommPort.txBytes(instruction);
5959
if(mUseLegacyDelayToDelayForResponse) {
60-
System.out.println("ShimmerRadioInitializer: Applying command-response delay (200ms)");
61-
Thread.sleep(200);
60+
System.out.println("ShimmerRadioInitializer: Applying command-response delay (500ms)");
61+
Thread.sleep(500); // Increased from 200ms to 500ms for MacOS
6262
} else {
6363
System.out.println("ShimmerRadioInitializer: No command-response delay (flag is false)");
6464
}
@@ -78,7 +78,7 @@ protected byte[] readFirmwareVersion() throws ShimmerException, InterruptedExcep
7878
serialCommPort.txBytes(instruction);
7979
byte[] bufferInquiry = new byte[6];
8080
if(mUseLegacyDelayToDelayForResponse)
81-
Thread.sleep(200);
81+
Thread.sleep(500); // Increased from 200ms to 500ms for MacOS
8282
serialCommPort.rxBytes(1);
8383
serialCommPort.rxBytes(1);
8484
bufferInquiry = serialCommPort.rxBytes(6);
@@ -106,7 +106,7 @@ public ExpansionBoardDetails readExpansionBoardID() {
106106

107107
serialCommPort.txBytes(instruction);
108108
if(mUseLegacyDelayToDelayForResponse)
109-
Thread.sleep(200);
109+
Thread.sleep(500); // Increased from 200ms to 500ms for MacOS
110110
byte[] response = serialCommPort.rxBytes(3+1);
111111

112112
if(response!=null){

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public class SerialPortCommJssc extends AbstractSerialPortHal implements SerialP
3333
private boolean setDtrOnConnect = false;
3434

3535
/** MacOS serial ports require initialization time after opening */
36-
private static final int MACOS_PORT_INIT_DELAY_MS = 100;
36+
private static final int MACOS_PORT_INIT_DELAY_MS = 500; // Increased from 100ms to 500ms
3737

3838
private transient ShimmerUartListener mShimmerUartListener;
3939
private boolean mIsSerialPortReaderStarted = false;
@@ -119,12 +119,16 @@ public void connect() throws ShimmerException {
119119
mSerialPort.setRTS(true);
120120
mSerialPort.setDTR(true);
121121
consolePrintLn("MacOS: Explicitly set RTS=true and DTR=true");
122+
// Give signals time to stabilize before continuing
123+
Thread.sleep(50);
122124
} catch (SerialPortException e) {
123125
consolePrintLn("MacOS: Warning - failed to set DTR/RTS: " + e.getMessage());
126+
} catch (InterruptedException e) {
127+
Thread.currentThread().interrupt();
124128
}
125129
}
126130

127-
// On MacOS, serial ports need a brief settling time after opening
131+
// On MacOS, serial ports need a longer settling time after opening
128132
if(UtilShimmer.isOsMac()) {
129133
try {
130134
Thread.sleep(MACOS_PORT_INIT_DELAY_MS);

0 commit comments

Comments
 (0)