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
@ -51,7 +51,10 @@ ENC03R::~ENC03R()
|
||||
|
||||
unsigned int ENC03R::value()
|
||||
{
|
||||
return mraa_aio_read(m_aio);
|
||||
int x = mraa_aio_read(m_aio);
|
||||
if (x == -1) throw std::out_of_range(std::string(__FUNCTION__) +
|
||||
": Failed to do an aio read.");
|
||||
return (unsigned int) x;
|
||||
}
|
||||
|
||||
void ENC03R::calibrate(unsigned int samples)
|
||||
@ -62,6 +65,8 @@ void ENC03R::calibrate(unsigned int samples)
|
||||
for (int i=0; i<samples; i++)
|
||||
{
|
||||
val = mraa_aio_read(m_aio);
|
||||
if (val == -1) throw std::out_of_range(std::string(__FUNCTION__) +
|
||||
": Failed to do an aio read.");
|
||||
total += (float)val;
|
||||
usleep(2000);
|
||||
}
|
||||
|
Reference in New Issue
Block a user