mirror of
https://github.com/eclipse/upm.git
synced 2025-03-15 04:57:30 +03:00
RSC: Fixing static analysis issues
Signed-off-by: Abhishek Malik <abhishek.malik@intel.com>
This commit is contained in:
parent
dc7c012c24
commit
356f0348ed
@ -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) {
|
upm_result_t rsc_get_sensor_name(rsc_context dev, uint8_t* sensor_name) {
|
||||||
rsc_set_access_type(dev, EEPROM);
|
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';
|
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) {
|
upm_result_t rsc_get_sensor_serial_number(rsc_context dev, uint8_t* rsc_number) {
|
||||||
rsc_set_access_type(dev, EEPROM);
|
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';
|
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
|
// of the address spaces of all the 3 coefficient groups
|
||||||
// refer the datasheet for more info
|
// refer the datasheet for more info
|
||||||
base_address = RSC_OFFSET_COEFFICIENT_0_LSB + i*80;
|
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
|
// storing all the coefficients
|
||||||
for(j=0; j<RSC_COEFF_T_COL_NO; j++) {
|
for(j=0; j<RSC_COEFF_T_COL_NO; j++) {
|
||||||
@ -304,7 +310,7 @@ upm_result_t rsc_adc_write(rsc_context dev, uint8_t reg, uint8_t num_bytes, uint
|
|||||||
return UPM_ERROR_UNSPECIFIED;
|
return UPM_ERROR_UNSPECIFIED;
|
||||||
|
|
||||||
// the ADC registers are 0,1,2,3
|
// the ADC registers are 0,1,2,3
|
||||||
if(reg < 0 || reg >3)
|
if(reg >3)
|
||||||
return UPM_ERROR_UNSPECIFIED;
|
return UPM_ERROR_UNSPECIFIED;
|
||||||
|
|
||||||
uint8_t tx[num_bytes+1];
|
uint8_t tx[num_bytes+1];
|
||||||
|
@ -137,10 +137,7 @@ string RSC::getPressureType()
|
|||||||
uint8_t *RSC::getInitialADCState()
|
uint8_t *RSC::getInitialADCState()
|
||||||
{
|
{
|
||||||
uint8_t initialState[4]={0,0,0,0};
|
uint8_t initialState[4]={0,0,0,0};
|
||||||
if(rsc_get_initial_adc_values(m_rsc, initialState) != UPM_SUCCESS) {
|
rsc_get_initial_adc_values(m_rsc, initialState);
|
||||||
throw std::runtime_error(std::string(__FUNCTION__) +
|
|
||||||
": Unable to read the ADC state from the eeprom");
|
|
||||||
}
|
|
||||||
int cnt = 0;
|
int cnt = 0;
|
||||||
for (cnt = 0; cnt<4; cnt++)
|
for (cnt = 0; cnt<4; cnt++)
|
||||||
m_adc_coeff[cnt]=initialState[cnt];
|
m_adc_coeff[cnt]=initialState[cnt];
|
||||||
@ -176,16 +173,10 @@ float RSC::getPressure()
|
|||||||
|
|
||||||
void RSC::setMode(RSC_MODE mode)
|
void RSC::setMode(RSC_MODE mode)
|
||||||
{
|
{
|
||||||
if(rsc_set_mode(m_rsc, mode) != UPM_SUCCESS){
|
rsc_set_mode(m_rsc, mode);
|
||||||
throw std::runtime_error(std::string(__FUNCTION__) +
|
|
||||||
": Unable to set the ADC mode");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RSC::setDataRate(RSC_DATA_RATE dr)
|
void RSC::setDataRate(RSC_DATA_RATE dr)
|
||||||
{
|
{
|
||||||
if(rsc_set_data_rate(m_rsc, dr) != UPM_SUCCESS) {
|
rsc_set_data_rate(m_rsc, dr);
|
||||||
throw std::runtime_error(std::string(__FUNCTION__) +
|
|
||||||
": Unable to set the ADC data rate");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -242,6 +242,7 @@ namespace upm {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
rsc_context m_rsc;
|
rsc_context m_rsc;
|
||||||
|
RSC(const RSC& src) { /* do not create copied */}
|
||||||
uint8_t m_adc_coeff[4];
|
uint8_t m_adc_coeff[4];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user