diff --git a/src/rsc/rsc.c b/src/rsc/rsc.c index 366292b7..f94b36d4 100644 --- a/src/rsc/rsc.c +++ b/src/rsc/rsc.c @@ -161,7 +161,9 @@ upm_result_t rsc_eeprom_read(rsc_context dev, uint16_t address, uint8_t* buf, in upm_result_t rsc_get_sensor_name(rsc_context dev, uint8_t* sensor_name) { rsc_set_access_type(dev, EEPROM); - rsc_eeprom_read(dev, RSC_CATALOG_LISTING_MSB, sensor_name, RSC_SENSOR_NAME_LEN, RSC_EEPROM_STANDARD_ARGUMENT_LENGTH); + if(rsc_eeprom_read(dev, RSC_CATALOG_LISTING_MSB, sensor_name, RSC_SENSOR_NAME_LEN, RSC_EEPROM_STANDARD_ARGUMENT_LENGTH) != UPM_SUCCESS) { + return UPM_ERROR_OPERATION_FAILED; + } sensor_name[RSC_SENSOR_NAME_LEN-1]='\0'; @@ -170,7 +172,9 @@ upm_result_t rsc_get_sensor_name(rsc_context dev, uint8_t* sensor_name) { upm_result_t rsc_get_sensor_serial_number(rsc_context dev, uint8_t* rsc_number) { rsc_set_access_type(dev, EEPROM); - rsc_eeprom_read(dev, RSC_SERIAL_NO_YYYY_MSB, rsc_number, RSC_SENSOR_NUMBER_LEN, RSC_EEPROM_STANDARD_ARGUMENT_LENGTH); + if(rsc_eeprom_read(dev, RSC_SERIAL_NO_YYYY_MSB, rsc_number, RSC_SENSOR_NUMBER_LEN, RSC_EEPROM_STANDARD_ARGUMENT_LENGTH) != UPM_SUCCESS) { + return UPM_ERROR_OPERATION_FAILED; + } rsc_number[RSC_SENSOR_NUMBER_LEN-1]='\0'; @@ -283,7 +287,9 @@ upm_result_t rsc_retrieve_coefficients(rsc_context dev) { // of the address spaces of all the 3 coefficient groups // refer the datasheet for more info base_address = RSC_OFFSET_COEFFICIENT_0_LSB + i*80; - rsc_eeprom_read(dev, base_address, l_coeffs, (RSC_COEFF_ADDRESS_SPACE_SIZE), RSC_EEPROM_STANDARD_ARGUMENT_LENGTH); + if(rsc_eeprom_read(dev, base_address, l_coeffs, (RSC_COEFF_ADDRESS_SPACE_SIZE), RSC_EEPROM_STANDARD_ARGUMENT_LENGTH) != UPM_SUCCESS) { + return UPM_ERROR_OPERATION_FAILED; + } // storing all the coefficients for(j=0; j3) + if(reg >3) return UPM_ERROR_UNSPECIFIED; uint8_t tx[num_bytes+1]; diff --git a/src/rsc/rsc.cxx b/src/rsc/rsc.cxx index f36902cb..06285961 100644 --- a/src/rsc/rsc.cxx +++ b/src/rsc/rsc.cxx @@ -137,10 +137,7 @@ string RSC::getPressureType() uint8_t *RSC::getInitialADCState() { uint8_t initialState[4]={0,0,0,0}; - if(rsc_get_initial_adc_values(m_rsc, initialState) != UPM_SUCCESS) { - throw std::runtime_error(std::string(__FUNCTION__) + - ": Unable to read the ADC state from the eeprom"); - } + rsc_get_initial_adc_values(m_rsc, initialState); int cnt = 0; for (cnt = 0; cnt<4; cnt++) m_adc_coeff[cnt]=initialState[cnt]; @@ -176,16 +173,10 @@ float RSC::getPressure() void RSC::setMode(RSC_MODE mode) { - if(rsc_set_mode(m_rsc, mode) != UPM_SUCCESS){ - throw std::runtime_error(std::string(__FUNCTION__) + - ": Unable to set the ADC mode"); - } + rsc_set_mode(m_rsc, mode); } void RSC::setDataRate(RSC_DATA_RATE dr) { - if(rsc_set_data_rate(m_rsc, dr) != UPM_SUCCESS) { - throw std::runtime_error(std::string(__FUNCTION__) + - ": Unable to set the ADC data rate"); - } + rsc_set_data_rate(m_rsc, dr); } diff --git a/src/rsc/rsc.hpp b/src/rsc/rsc.hpp index ff731c8f..b3f650c1 100644 --- a/src/rsc/rsc.hpp +++ b/src/rsc/rsc.hpp @@ -242,6 +242,7 @@ namespace upm { private: rsc_context m_rsc; + RSC(const RSC& src) { /* do not create copied */} uint8_t m_adc_coeff[4]; }; }