mirror of
https://github.com/eclipse/upm.git
synced 2025-07-02 01:41:12 +03:00
This is a combination of 2 commits.
aio: mraa_aio_read (v1.0.0) can now return -1, treat that in sensors using it Adds alot of exceptions if the aio read goes wrong Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com> Signed-off-by: Noel Eck <noel.eck@intel.com>
This commit is contained in:

committed by
Noel Eck

parent
f6816797bb
commit
e51c5f3018
@ -82,18 +82,22 @@ uint32_t TA12200::getMillis()
|
||||
}
|
||||
|
||||
|
||||
unsigned int TA12200::highestValue()
|
||||
int TA12200::highestValue()
|
||||
{
|
||||
unsigned int hiVal = 0;
|
||||
unsigned int val;
|
||||
int hiVal = 0;
|
||||
int val;
|
||||
uint32_t start = getMillis();
|
||||
|
||||
// 1 second
|
||||
while (getMillis() < (start + 1000))
|
||||
{
|
||||
val = mraa_aio_read(m_aio);
|
||||
if (val > hiVal)
|
||||
if (val == -1) {
|
||||
return -1;
|
||||
}
|
||||
if (val > hiVal) {
|
||||
hiVal = val;
|
||||
}
|
||||
}
|
||||
|
||||
return hiVal;
|
||||
|
@ -89,9 +89,9 @@ namespace upm {
|
||||
/**
|
||||
* Gets the conversion value from the sensor
|
||||
*
|
||||
* @return Highest value obtained over 1 second of measuring
|
||||
* @return Highest value obtained over 1 second of measuring or -1 if error
|
||||
*/
|
||||
unsigned int highestValue();
|
||||
int highestValue();
|
||||
|
||||
/**
|
||||
* Computes the measured voltage
|
||||
|
Reference in New Issue
Block a user