@@ -1385,7 +1385,7 @@ else if(responseCommand==SAMPLING_RATE_RESPONSE) {
13851385 }
13861386 }
13871387 }
1388- else if (getHardwareVersion ()==HW_ID .SHIMMER_3 ) {
1388+ else if (getHardwareVersion ()==HW_ID .SHIMMER_3 || getHardwareVersion ()== HW_ID . SHIMMER_3R ) {
13891389 byte [] bufferSR = readBytes (2 , responseCommand ); //read the sampling rate
13901390 if (bufferSR !=null ){
13911391 setSamplingRateShimmer (convertSamplingRateBytesToFreq (bufferSR [0 ], bufferSR [1 ], getSamplingClockFreq ()));
@@ -1430,11 +1430,14 @@ else if(responseCommand==FW_VERSION_RESPONSE){
14301430 }
14311431
14321432 else if (responseCommand ==ALL_CALIBRATION_RESPONSE ) {
1433- if (getHardwareVersion ()==HW_ID .SHIMMER_3 ) {
1433+ if (getHardwareVersion ()==HW_ID .SHIMMER_3 || getHardwareVersion ()== HW_ID . SHIMMER_3R ) {
14341434 processAccelCalReadBytes ();
14351435 processGyroCalReadBytes ();
14361436 processMagCalReadBytes ();
14371437 processLsm303dlhcAccelCalReadBytes ();
1438+ if (getHardwareVersion () == HW_ID .SHIMMER_3R ) {
1439+ //TODO added support for Shimmer3R alt accel and alt mag if needed but this has been replaced by calib dump
1440+ }
14381441 }
14391442 else { //Shimmer2R etc.
14401443 processAccelCalReadBytes ();
@@ -2585,129 +2588,15 @@ private void initializeShimmer2R(){
25852588 }
25862589
25872590 private void initializeShimmer3R (){
2588-
2589- setHardwareVersionAndCreateSensorMaps (HW_ID .SHIMMER_3R );
2590- // initialise(HW_ID.SHIMMER_3);
2591-
2592- setHaveAttemptedToReadConfig (true );
2593-
2594- if (mSendProgressReport ){
2595- operationPrepare ();
2596- setBluetoothRadioState (BT_STATE .CONNECTING );
2597- }
2598-
2599- //readExpansionBoardID();
2600-
2601- if (isBtCrcModeSupported ()) {
2602- writeBtCommsCrcMode (DEFAULT_BT_CRC_MODE_IF_SUPPORTED );
2603- }
2604-
2605- if (isSetupDeviceWhileConnecting ()){
2606- if (mFixedShimmerConfigMode !=null && mFixedShimmerConfigMode !=FIXED_SHIMMER_CONFIG_MODE .NONE ){
2607- boolean triggerConfig = setFixedConfigWhenConnecting ();
2608- if (triggerConfig ){
2609- writeConfigBytes (false );
2610- }
2611- }
2612- else {
2613- if (this .mUseInfoMemConfigMethod && getFirmwareVersionCode ()>=6 ){
2614- writeConfigBytes (false );
2615- }
2616- else {
2617- if (isThisVerCompatibleWith (HW_ID .SHIMMER_3 , FW_ID .LOGANDSTREAM , 0 , 5 , 2 )){
2618- writeShimmerUserAssignedName (getShimmerUserAssignedName ());
2619- }
2620- if (mSetupEXG ){
2621- writeEXGConfiguration ();
2622- mSetupEXG = false ;
2623- }
2624- writeGSRRange (getGSRRange ());
2625- writeAccelRange (getAccelRange ());
2626- writeGyroRange (getGyroRange ());
2627- writeMagRange (getMagRange ());
2628- writeShimmerAndSensorsSamplingRate (getSamplingRateShimmer ());
2629- writeInternalExpPower (1 );
2630- // setContinuousSync(mContinousSync);
2631- }
2632- }
2633- }
2634-
2635- if (this .mUseInfoMemConfigMethod && getFirmwareVersionCode ()>=6 ){
2636- readConfigBytes ();
2637- readPressureCalibrationCoefficients ();
2638- }
2639- else {
2640- readSamplingRate ();
2641- readMagRange ();
2642- readAccelRange ();
2643- readGyroRange ();
2644- readAccelSamplingRate ();
2645- readCalibrationParameters ("All" );
2646- readPressureCalibrationCoefficients ();
2647- readEXGConfigurations ();
2648- //enableLowPowerMag(mLowPowerMag);
2649-
2650- readDerivedChannelBytes ();
2651-
2652- if (isThisVerCompatibleWith (HW_ID .SHIMMER_3 , FW_ID .LOGANDSTREAM , 0 , 5 , 2 )){
2653- readTrial ();
2654- readConfigTime ();
2655- readShimmerName ();
2656- readExperimentName ();
2657- }
2658- }
2659-
2660- readLEDCommand ();
2661-
2662- if (isThisVerCompatibleWith (HW_ID .SHIMMER_3 , FW_ID .LOGANDSTREAM , 0 , 5 , 2 ) ||
2663- isThisVerCompatibleWith (HW_ID .SHIMMER_3 , FW_ID .BTSTREAM , 0 , 8 , 1 )){
2664- readStatusLogAndStream ();
2665- }
2666-
2667- if (isThisVerCompatibleWith (HW_ID .SHIMMER_3 , FW_ID .LOGANDSTREAM , 0 , 5 , 9 ) ||
2668- isThisVerCompatibleWith (HW_ID .SHIMMER_3 , FW_ID .BTSTREAM , 0 , 8 , 1 )){
2669- readBattery ();
2670- }
2671-
2672- if (getShimmerVerObject ().isSupportedBtFwVerRequest ()) {
2673- readBtFwVersion ();
2674- }
2675-
2676- // Only read calibration dump over bluetooth if the Shimmer is not
2677- // docked as the Shimmer won't have access to the SD card
2678- if (!isDocked ()){
2679- readCalibrationDump ();
2680- }
2681-
2682- if (isSetupDeviceWhileConnecting ()){
2683- if (mFixedShimmerConfigMode !=null && mFixedShimmerConfigMode !=FIXED_SHIMMER_CONFIG_MODE .NONE ){
2684- writeEnabledSensors (mEnabledSensors ); //this should always be the last command
2685- } else {
2686- //writeAccelRange(mDigitalAccelRange);
2687- writeEnabledSensors (mSetEnabledSensors ); //this should always be the last command
2688- }
2689- }
2690- else {
2691- inquiry ();
2692- }
2693-
2694- if (mSendProgressReport ){
2695- // Just unlock instruction stack and leave logAndStream timer as
2696- // this is handled in the next step, i.e., no need for
2697- // operationStart() here
2698- startOperation (BT_STATE .CONNECTING , getListofInstructions ().size ());
2699-
2700- setInstructionStackLock (false );
2701- }
2702-
2703- startTimerReadStatus (); // if shimmer is using LogAndStream FW, read its status periodically
2704- startTimerReadBattStatus (); // if shimmer is using LogAndStream FW, read its status periodically
2705-
2706-
2591+ initializeShimmer3or3R (HW_ID .SHIMMER_3R );
27072592 }
27082593
27092594 private void initializeShimmer3 (){
2710- setHardwareVersionAndCreateSensorMaps (HW_ID .SHIMMER_3 );
2595+ initializeShimmer3or3R (HW_ID .SHIMMER_3 );
2596+ }
2597+
2598+ private void initializeShimmer3or3R (int hardwareVersion ){
2599+ setHardwareVersionAndCreateSensorMaps (hardwareVersion );
27112600// initialise(HW_ID.SHIMMER_3);
27122601
27132602 setHaveAttemptedToReadConfig (true );
@@ -2780,23 +2669,22 @@ private void initializeShimmer3(){
27802669
27812670 readLEDCommand ();
27822671
2783- if (isThisVerCompatibleWith (HW_ID .SHIMMER_3 , FW_ID .LOGANDSTREAM , 0 , 5 , 2 ) ||
2784- isThisVerCompatibleWith (HW_ID .SHIMMER_3 , FW_ID .BTSTREAM , 0 , 8 , 1 )){
2672+ if (getShimmerVerObject ().isSupportedBtStatusRequest ()) {
27852673 readStatusLogAndStream ();
27862674 }
2787-
2788- if (isThisVerCompatibleWith (HW_ID .SHIMMER_3 , FW_ID .LOGANDSTREAM , 0 , 5 , 9 ) ||
2789- isThisVerCompatibleWith (HW_ID .SHIMMER_3 , FW_ID .BTSTREAM , 0 , 8 , 1 )){
2675+
2676+ if (getShimmerVerObject ().isSupportedBtBatteryRequest ()) {
27902677 readBattery ();
27912678 }
27922679
27932680 if (getShimmerVerObject ().isSupportedBtFwVerRequest ()) {
27942681 readBtFwVersion ();
27952682 }
27962683
2797- // Only read calibration dump over bluetooth if the Shimmer is not
2798- // docked as the Shimmer won't have access to the SD card
2799- if (!isDocked ()){
2684+ //TODO this could actually be causing a lot of misunderstanding and a disconnect between what the user thinks is set and what is actually set.
2685+ // Only read calibration dump over bluetooth if the Shimmer3 is not
2686+ // docked as the Shimmer3 won't have access to the SD card. The Shimmer3R does.
2687+ if (hardwareVersion ==HW_ID .SHIMMER_3R || !isDocked ()){
28002688 readCalibrationDump ();
28012689 }
28022690
@@ -2823,7 +2711,6 @@ private void initializeShimmer3(){
28232711
28242712 startTimerReadStatus (); // if shimmer is using LogAndStream FW, read its status periodically
28252713 startTimerReadBattStatus (); // if shimmer is using LogAndStream FW, read its status periodically
2826-
28272714 }
28282715
28292716 @ Override
@@ -3628,11 +3515,9 @@ public void writeMagSamplingRate(int rate) {
36283515 * Used to retrieve the data rate of the Accelerometer on Shimmer 3
36293516 */
36303517 public void readAccelSamplingRate () {
3631- if (getHardwareVersion ()!=HW_ID .SHIMMER_3 ){
3632- }
3633- else {
3518+ if (getHardwareVersion ()==HW_ID .SHIMMER_3 || getHardwareVersion ()==HW_ID .SHIMMER_3R ){
36343519 writeInstruction (GET_ACCEL_SAMPLING_RATE_COMMAND );
3635- }
3520+ }
36363521 }
36373522
36383523 /**
@@ -5184,7 +5069,7 @@ else if((sensorToCheck & SENSOR_BATT) >0){
51845069 }
51855070 }
51865071
5187- else if (getHardwareVersion ()==HW_ID .SHIMMER_3 ){
5072+ else if (getHardwareVersion ()==HW_ID .SHIMMER_3 || getHardwareVersion ()== HW_ID . SHIMMER_3R ){
51885073
51895074 if ((sensorToCheck & SENSOR_GSR ) >0 ){
51905075 enabledSensors = disableBit (enabledSensors ,SENSOR_INT_ADC_A1 );
@@ -5262,7 +5147,7 @@ else if((sensorToCheck & SENSOR_INT_ADC_A14) >0){
52625147 //TODO: MN -> replace with sensormap conflict checks? unfinished for Shimmer2R
52635148 public boolean sensorConflictCheck (long enabledSensors ){
52645149 boolean pass =true ;
5265- if (getHardwareVersion ()!=HW_ID .SHIMMER_3 ){
5150+ if (getHardwareVersion ()!=HW_ID .SHIMMER_3 && getHardwareVersion ()!= HW_ID . SHIMMER_3R ){
52665151 if (((enabledSensors & 0xFF )& SENSOR_GYRO ) > 0 ){
52675152 if (((enabledSensors & 0xFF )& SENSOR_EMG ) > 0 ){
52685153 pass =false ;
@@ -5616,7 +5501,7 @@ private long generateSensorBitmapForHardwareControl(long enabledSensors){
56165501 }
56175502 hardwareSensorBitmap = enabledSensors ;
56185503 }
5619- else if (getHardwareVersion ()==HW_ID .SHIMMER_3 ){
5504+ else if (getHardwareVersion ()==HW_ID .SHIMMER_3 || getHardwareVersion ()== HW_ID . SHIMMER_3R ){
56205505 if (((enabledSensors & 0xFF )& SENSOR_ACCEL ) > 0 ){
56215506 hardwareSensorBitmap = hardwareSensorBitmap |Configuration .Shimmer3 .SensorBitmap .SENSOR_A_ACCEL ;
56225507 }
0 commit comments