
          // set the current CTD Time, Temp, Salinity, Depth values
          if( (srchptr=strstr(cbuf, "CTD,")) != NULL ){

            if(strchr(srchptr, '?') != NULL){
              printf("ACK,CTD?,%lu,%.4f,%.4f,%.2f\n", CTD_Time, CTD_Temp, CTD_Salinity, CTD_Depth);
              SCIRxFlush();
              continue;
              }

            i = gotVal = 0;
            srchptr = strtok(srchptr, ",");
            while( (srchptr = strtok(NULL, ",")) != NULL ){
              ++i;
              if(i == 1){
                if(strchr(srchptr, '-') != NULL){
                  printf("NAK,CTD,ESignErr: %s\n", srchptr);
                  i = ERROR;
                  break;
                  }
                CTD_Time = strtoul(srchptr, NULL, 10);
                //printf("\n srchptr = %p endptr = %p\n", srchptr, endptr);
                if( errno == ERANGE ){
                  printf("NAK,CTD,EOverflowErr: %s\n", srchptr);
                  i = ERROR;
                  break;
                  }
                else if( CTD_Time == 0 ){
                  printf("NAK,CTD,EConvertErr: %s\n", srchptr);
                  i = ERROR;
                  break;
                  }
                else
                  ++gotVal;
                }
              else if(i == 2){
                CTD_Temp = (float)strtod(srchptr, &endptr);
                if( errno == ERANGE ){
                  printf("NAK,CTD,TOverflowErr: %s\n", srchptr);
                  i = ERROR;
                  break;
                  }
                else if( (CTD_Temp == 0.0) && (endptr == srchptr) ){
                  printf("NAK,CTD,TConvertErr: %s\n", srchptr);
                  i = ERROR;
                  break;
                  }
                else if( (CTD_Temp < -10.0) || (CTD_Temp > 35.0) ){
                  printf("NAK,CTD,TRangeErr [-10,35.0]: %s\n", srchptr);
                  i = ERROR;
                  break;
                  }
                else
                  ++gotVal;
                }
              else if(i == 3){
                CTD_Salinity = (float)strtod(srchptr, &endptr);
                if( errno == ERANGE ){
                  printf("NAK,CTD,SOverflowErr: %s\n", srchptr);
                  i = ERROR;
                  break;
                  }
                else if( (CTD_Salinity == 0.0) && (endptr == srchptr) ){
                  printf("NAK,CTD,SConvertErr: %s\n", srchptr);
                  i = ERROR;
                  break;
                  }
                else if( (CTD_Salinity < -0.25) || (CTD_Salinity > 40.0) ){
                  printf("NAK,CTD,SRangeErr [-0.25,40.0]: %s\n", srchptr);
                  i = ERROR;
                  break;
                  }
                else
                  ++gotVal;
                }
              else if(i == 4){
                CTD_Depth = (float)strtod(srchptr, &endptr);
                if( errno == ERANGE ){
                  printf("NAK,CTD,POverflowErr: %s\n", srchptr);
                  i = ERROR;
                  break;
                  }
                else if( (CTD_Depth == 0.0) && (endptr == srchptr) ){
                  printf("NAK,CTD,PConvertErr: %s\n", srchptr);
                  i = ERROR;
                  break;
                  }
                else if( (CTD_Depth < -200.0) || (CTD_Depth > 5000.0) ){
                  printf("NAK,CTD,PRangeErr [-200.0,5000.0]: %s\n", srchptr);
                  i = ERROR;
                  break;
                  }
                else
                  ++gotVal;
                }
              } //end strtok while

            if( (gotVal == 4) && (i != ERROR) ){
              printf("ACK,CTD,%lu,%.4f,%.4f,%.2f\n", CTD_Time, CTD_Temp, CTD_Salinity, CTD_Depth);

              SCIRxFlush();
              if( SerGetsTmout(abuf, sizeof(abuf), GET_ACK_TIMEOUT) > 0 ){
                //printf("CTD ABUF = %s\n", abuf);
                if( MatchACK(abuf) == ACK ){
                  SCIRxFlush();
                  continue;
                  }
                }

              CTD_Time = 0;                             //no ACK no keepy vals
              CTD_Temp = CTD_Salinity = CTD_Depth = -1.0;

              sprintf(ebuf, "CTD Command ACK Failure");
              LogErrorMsg(ebuf, (int)COMMAND_ACK_FAILURE, sys_message_enable);

              SCIRxFlush();
              continue;
              } // end gotVal4 if
            else{
              if(i != ERROR)
                printf("NAK,CTD,FormatErr\n");

              CTD_Time = 0;
              CTD_Temp = CTD_Salinity = CTD_Depth = -1.0;

              SCIRxFlush();
              continue;
              }

            } // end get CTD Time,Temp,Sal,Depth if
