diff --git a/common/HamegWidget.cc b/common/HamegWidget.cc index e69081e9b..ac84da733 100644 --- a/common/HamegWidget.cc +++ b/common/HamegWidget.cc @@ -153,14 +153,14 @@ void HamegChannelWidget::updateInfo() } } - char dummy[10]; + char dummy[30]; if (!voltageSpinner_->hasFocus()) { float setVoltage = model_->getVoltageParameter(channel_).getValue(); voltageSpinner_->setValue(setVoltage); } float voltage = model_->getVoltage(channel_); - sprintf(dummy, "%.02f", voltage); + snprintf(dummy, sizeof(dummy), "%.02f", voltage); voltageDisplay_->display(dummy); if (!currentSpinner_->hasFocus()) { @@ -168,7 +168,7 @@ void HamegChannelWidget::updateInfo() currentSpinner_->setValue(setCurrent); } float current = model_->getCurrent(channel_); - sprintf(dummy, "%.03f", current); + snprintf(dummy, sizeof(dummy), "%.03f", current); currentDisplay_->display(dummy); } diff --git a/devices/Huber/HuberPetiteFleur.cpp b/devices/Huber/HuberPetiteFleur.cpp index 6989a932e..b5059227f 100644 --- a/devices/Huber/HuberPetiteFleur.cpp +++ b/devices/Huber/HuberPetiteFleur.cpp @@ -10,6 +10,8 @@ // // ///////////////////////////////////////////////////////////////////////////////// +//http://www.huber-online.com/download/manuals/archive/Manual_DataCommunication_EN.pdf + #include #include @@ -58,23 +60,27 @@ bool HuberPetiteFleur::SetWorkingTemperature( const float workingTemp ) const { sprintf(buffer, "%+06d", iTemp); std::stringstream theCommand; - theCommand << "SP! " << buffer; + theCommand << "SP@ " << buffer; comHandler_->SendCommand( theCommand.str().c_str() ); usleep( uDelay_ ); - comHandler_->SendCommand( "SP?" ); - usleep( uDelay_ ); - + memset( buffer, 0, sizeof( buffer ) ); comHandler_->ReceiveString( buffer ); usleep( uDelay_ ); StripBuffer( buffer ); + + int oTemp = ToInteger( buffer ); - if( std::fabs( iTemp - ToInteger(buffer) ) > 1 ) { + if( iTemp != oTemp ) { std::cerr << " [HuberPetiteFleur::SetWorkingTemp] ** ERROR: check failed." << std::endl; - std::cerr << " > Expected: T=" << workingTemp << " but received (string):" - << buffer << "." << std::endl; + if ( strlen( buffer ) == 0 ) + std::cerr << " > Got no reply. (timeout?)" << std::endl; + else + std::cerr << " > Expected: T=" << workingTemp + << " but received T=" << oTemp / 100 << std::endl; + return false; }