Skip to content

Commit

Permalink
Merge pull request #131 from jrueb/master
Browse files Browse the repository at this point in the history
Two small fixes
  • Loading branch information
Negusbuk authored Jul 18, 2018
2 parents ee5fc65 + 79790d2 commit a1f469d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
6 changes: 3 additions & 3 deletions common/HamegWidget.cc
Original file line number Diff line number Diff line change
Expand Up @@ -153,22 +153,22 @@ 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()) {
float setCurrent = model_->getCurrentParameter(channel_).getValue();
currentSpinner_->setValue(setCurrent);
}
float current = model_->getCurrent(channel_);
sprintf(dummy, "%.03f", current);
snprintf(dummy, sizeof(dummy), "%.03f", current);
currentDisplay_->display(dummy);
}

Expand Down
20 changes: 13 additions & 7 deletions devices/Huber/HuberPetiteFleur.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
// //
/////////////////////////////////////////////////////////////////////////////////

//http://www.huber-online.com/download/manuals/archive/Manual_DataCommunication_EN.pdf

#include <string.h>

#include <cstdlib>
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit a1f469d

Please sign in to comment.