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
2 changes: 1 addition & 1 deletion .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
gradle-version: '8.10.2'
- name: Build with Gradle 8.10.2
run: |
cd ShimmerDriver
cd ShimmerDriverPC
gradle build -i
- name: Publish Test Report
uses: mikepenz/action-junit-report@v4
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1274,6 +1274,8 @@ public static class CompatibilityInfoForMaps{

public static final ShimmerVerObject svoShimmer3RLogAndStream = new ShimmerVerObject(HW_ID.SHIMMER_3R,FW_ID.LOGANDSTREAM,ShimmerVerDetails.ANY_VERSION,ShimmerVerDetails.ANY_VERSION,ShimmerVerDetails.ANY_VERSION,ShimmerVerDetails.ANY_VERSION);
public static final ShimmerVerObject svoShimmer3RSDLog = new ShimmerVerObject(HW_ID.SHIMMER_3R,FW_ID.SDLOG,ShimmerVerDetails.ANY_VERSION,ShimmerVerDetails.ANY_VERSION,ShimmerVerDetails.ANY_VERSION,ShimmerVerDetails.ANY_VERSION);
public static final ShimmerVerObject svoShimmer3LogAndStreamWithSDLogSyncSupport = new ShimmerVerObject(HW_ID.SHIMMER_3,FW_ID.LOGANDSTREAM,0,16,11,ShimmerVerDetails.ANY_VERSION);


private static final ShimmerVerObject svoShimmerGq802154Lr = new ShimmerVerObject(HW_ID.SHIMMER_GQ_802154_LR,ShimmerVerDetails.ANY_VERSION,ShimmerVerDetails.ANY_VERSION,ShimmerVerDetails.ANY_VERSION,ShimmerVerDetails.ANY_VERSION,ShimmerVerDetails.ANY_VERSION);
private static final ShimmerVerObject svoShimmerGq802154Nr = new ShimmerVerObject(HW_ID.SHIMMER_GQ_802154_NR,ShimmerVerDetails.ANY_VERSION,ShimmerVerDetails.ANY_VERSION,ShimmerVerDetails.ANY_VERSION,ShimmerVerDetails.ANY_VERSION,ShimmerVerDetails.ANY_VERSION);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2049,7 +2049,8 @@ public boolean isSupportedSrProgViaDock() {

public boolean isSupportedSdLogSync() {
if(getFirmwareIdentifier()==ShimmerVerDetails.FW_ID.SDLOG
|| getFirmwareIdentifier()==ShimmerVerDetails.FW_ID.LOGANDSTREAM
|| (UtilShimmer.compareVersions(getShimmerVerObject(),Configuration.Shimmer3.CompatibilityInfoForMaps.svoShimmer3RLogAndStream))
|| (UtilShimmer.compareVersions(getShimmerVerObject(),Configuration.Shimmer3.CompatibilityInfoForMaps.svoShimmer3LogAndStreamWithSDLogSyncSupport))
|| getFirmwareIdentifier()==ShimmerVerDetails.FW_ID.STROKARE){
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5973,7 +5973,7 @@ public void setButtonStart(int state) {
this.mButtonStart = state;
}

public void setDisableBluetooth(int state) {
protected void setDisableBluetooth(int state) {
this.mDisableBluetooth = state;
}

Expand Down Expand Up @@ -8854,8 +8854,8 @@ public Object setConfigValueUsingConfigLabel(String identifier, String configLab
setButtonStart((boolean)valueToSet);
break;
case(Configuration.Shimmer3.GuiLabelConfig.SD_BT_STREAM_WHEN_RECORDING):
setDisableBluetooth((boolean)valueToSet);
setSyncWhenLogging((boolean)valueToSet);
setDisableBluetooth(!(boolean)valueToSet);
setSyncWhenLogging(!(boolean)valueToSet);
break;
case(Configuration.Shimmer3.GuiLabelConfig.SD_STREAM_WHEN_RECORDING):
setDisableBluetooth((boolean)valueToSet);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ public static void generateMultipleShimmerConfig(List<ShimmerDevice> listOfShimm
if(shimmerDevice instanceof ShimmerBluetooth) {
// shimmerDevice = (ShimmerBluetooth) shimmerDevice;
if(((ShimmerBluetooth)shimmerDevice).isMasterShimmer()) {
syncNodesList.add(0, shimmerDevice.getMacIdFromUart());
syncNodesList.add(0, shimmerDevice.getMacId());
}
else {
syncNodesList.add(shimmerDevice.getMacIdFromUart());
syncNodesList.add(shimmerDevice.getMacId());
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ public static final class HW_ID {
aMap.put(HW_ID.SHIMMER_2, "Shimmer2");
aMap.put(HW_ID.SHIMMER_2R, "Shimmer2r");
aMap.put(HW_ID.SHIMMER_3, "Shimmer3");
aMap.put(HW_ID.SHIMMER_3R, "Shimmer3r");
aMap.put(HW_ID.SHIMMER_SR30, "Shimmer_SR30");
aMap.put(HW_ID.SHIMMER_GQ_BLE, "ShimmerGQBle");
aMap.put(HW_ID.SWEATCH, "SwEatch");
Expand Down
4 changes: 3 additions & 1 deletion ShimmerDriverPC/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@
import com.shimmerresearch.sensors.SensorGSR;
import com.shimmerresearch.sensors.lsm303.SensorLSM303;
import com.shimmerresearch.sensors.mpu9x50.SensorMPU9X50;
import com.shimmerresearch.shimmer3.communication.ByteCommunication;
import com.shimmerresearch.shimmer3.communication.ByteCommunicationJSSC;
import com.shimmerresearch.shimmerConfig.FixedShimmerConfigs.FIXED_SHIMMER_CONFIG_MODE;
import com.shimmerresearch.driver.CallbackObject;
import com.shimmerresearch.driver.ObjectCluster;
Expand All @@ -92,11 +94,13 @@

public class ShimmerPC extends ShimmerBluetooth implements Serializable{

private boolean mTesting = false;
/** * */
private static final long serialVersionUID = -5927054314345918072L;

// Used by the constructor when the user intends to write new settings to the Shimmer device after connection
protected transient SerialPort mSerialPort=null;
//protected transient SerialPort mSerialPort=null;
protected transient ByteCommunication mByteCommunication;
ObjectCluster objectClusterTemp = null;

// double mLastSavedCalibratedTimeStamp = -1;
Expand All @@ -115,6 +119,11 @@ public ShimmerPC() {
super();
}

public void setTestRadio(ByteCommunication radio) {
mTesting = true;
mByteCommunication = radio;
}

/**
* Constructor. Prepares a new Bluetooth session. Upon Connection the configuration of the device is read back and used. No device setup is done. To setup device see other Constructors.
* This constructor was created as a simple constructor for use with MATLAB.
Expand Down Expand Up @@ -343,22 +352,30 @@ public void run(){
setIamAlive(false);
getListofInstructions().clear();

if (mSerialPort==null){
if (mByteCommunication==null || mTesting){
setComPort(address);
mSerialPort = new SerialPort(address);
if (!mTesting) {
mByteCommunication = new ByteCommunicationJSSC(address);
} else { // do nothingit should already be set

}

try {
/*
consolePrintLn("Connecting to Shimmer on " + address);
consolePrintLn("Port open: " + mSerialPort.openPort());
consolePrintLn("Params set: " + mSerialPort.setParams(115200, 8, 1, 0));
consolePrintLn("Port Status : " + Boolean.toString(mSerialPort.isOpened()));

*/
consolePrintLn("Connecting to Shimmer on " + address);
mByteCommunication.openPort();
consolePrintLn("Port Status : " + Boolean.toString(mByteCommunication.isOpened()));
if (mIOThread != null) {
mIOThread = null;
mPThread = null;
}

if (mSerialPort.isOpened() && mBluetoothRadioState!=BT_STATE.DISCONNECTED){
if (mByteCommunication.isOpened() && mBluetoothRadioState!=BT_STATE.DISCONNECTED){
// if (mSerialPort.isOpened() && mState!=BT_STATE.NONE && mState!=BT_STATE.DISCONNECTED){
// setState(BT_STATE.CONNECTED);
setIsConnected(true);
Expand Down Expand Up @@ -409,8 +426,8 @@ public void run(){
@Override
public boolean bytesAvailableToBeRead() {
try {
if(mSerialPort != null){
if (mSerialPort.getInputBufferBytesCount()!=0){
if(mByteCommunication != null){
if (mByteCommunication.getInputBufferBytesCount()!=0){
return true;
}
}
Expand All @@ -425,8 +442,8 @@ public boolean bytesAvailableToBeRead() {

public int availableBytes(){
try {
if(mSerialPort != null){
return mSerialPort.getInputBufferBytesCount();
if(mByteCommunication != null){
return mByteCommunication.getInputBufferBytesCount();
}
else{
return 0;
Expand All @@ -441,11 +458,11 @@ public int availableBytes(){
@Override
public void writeBytes(byte[] data) {
try {
if(mSerialPort != null){
if(mByteCommunication != null){
if(CONSOLE_PRINT_TX_RX_BYTES) {
consolePrintLn("TX: " + UtilShimmer.bytesToHexStringWithSpacesFormatted(data));
}
mSerialPort.writeBytes(data);
mByteCommunication.writeBytes(data);
}
} catch (SerialPortException | NullPointerException ex) {
consolePrintLn("Tried to writeBytes but port is closed");
Expand All @@ -462,9 +479,9 @@ protected byte[] readBytes(int numberOfBytes) {
}

try {
if(mSerialPort != null){
if (mSerialPort.isOpened()){
byte[] data = mSerialPort.readBytes(numberOfBytes, AbstractSerialPortHal.SERIAL_PORT_TIMEOUT_2000);
if(mByteCommunication != null){
if (mByteCommunication.isOpened()){
byte[] data = mByteCommunication.readBytes(numberOfBytes, AbstractSerialPortHal.SERIAL_PORT_TIMEOUT_2000);
if(CONSOLE_PRINT_TX_RX_BYTES) {
consolePrintLn("RX: " + UtilShimmer.bytesToHexStringWithSpacesFormatted(data));
}
Expand Down Expand Up @@ -605,38 +622,44 @@ private void closeConnection(){
mIsInitialised = false;

setBluetoothRadioState(BT_STATE.DISCONNECTED);
if (mSerialPort != null) {
if (mSerialPort.isOpened()) {
mSerialPort.purgePort(1);
mSerialPort.purgePort(2);
mSerialPort.closePort();
if (mByteCommunication != null) {
if (mByteCommunication.isOpened()) {
mByteCommunication.purgePort(1);
mByteCommunication.purgePort(2);
mByteCommunication.closePort();
}
}
mSerialPort = null;
mByteCommunication = null;
} catch (Exception ex) {
consolePrintException(ex.getMessage(), ex.getStackTrace());
setBluetoothRadioState(BT_STATE.DISCONNECTED);
}
}

public void setSerialPort(SerialPort sp){
mSerialPort = sp;
getSamplingRateShimmer();
if (mSerialPort.isOpened()){
setBluetoothRadioState(BT_STATE.CONNECTING);
if (mByteCommunication == null) {
mByteCommunication = new ByteCommunicationJSSC(sp);
}
if (mSerialPort.isOpened() && mBluetoothRadioState!=BT_STATE.DISCONNECTED){
// if (mSerialPort.isOpened() && mState!=BT_STATE.NONE && mState!=BT_STATE.DISCONNECTED){
// setState(BT_STATE.CONNECTED);
setIsConnected(true);

mIOThread = new IOThread();
mIOThread.start();
if(mUseProcessingThread){
mPThread = new ProcessingThread();
mPThread.start();
if(mByteCommunication instanceof ByteCommunicationJSSC) {
((ByteCommunicationJSSC)mByteCommunication).setSerialPort(sp);
getSamplingRateShimmer();

if (mByteCommunication.isOpened()){
setBluetoothRadioState(BT_STATE.CONNECTING);
}
if (mByteCommunication.isOpened() && mBluetoothRadioState!=BT_STATE.DISCONNECTED){
// if (mSerialPort.isOpened() && mState!=BT_STATE.NONE && mState!=BT_STATE.DISCONNECTED){
// setState(BT_STATE.CONNECTED);
setIsConnected(true);

mIOThread = new IOThread();
mIOThread.start();
if(mUseProcessingThread){
mPThread = new ProcessingThread();
mPThread.start();
}
initialize();
}
initialize();
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package com.shimmerresearch.shimmer3.communication;

import com.shimmerresearch.verisense.communication.ByteCommunicationListener;

import jssc.SerialPortException;
import jssc.SerialPortTimeoutException;

public interface ByteCommunication{

// Returns the number of bytes available in the input buffer.
int getInputBufferBytesCount() throws SerialPortException;

// Checks if the communication port is open.
boolean isOpened();

// Closes the communication port.
boolean closePort() throws SerialPortException;

// Opens the communication port.
boolean openPort() throws SerialPortException;

// Reads 'byteCount' bytes from the communication port with a timeout.
byte[] readBytes(int byteCount, int timeout) throws SerialPortTimeoutException, SerialPortException;

// Writes the specified byte buffer to the communication port.
boolean writeBytes(byte[] buffer) throws SerialPortException;

boolean setParams(int i, int j, int k, int l) throws SerialPortException;

boolean purgePort(int i) throws SerialPortException;

public void setByteCommunicationListener(ByteCommunicationListener byteCommListener);

public void removeRadioListenerList();

}
Loading