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
@ -59,6 +59,8 @@ ECS1030::getCurrency_A () {
|
||||
|
||||
for (int i = 0; i < NUMBER_OF_SAMPLES; i++) {
|
||||
sensorValue = mraa_aio_read (m_dataPinCtx);
|
||||
if (sensorValue == -1) throw std::runtime_error(std::string(__FUNCTION__) +
|
||||
": Failed to do an aio read.");
|
||||
volt = (VOLT_M * sensorValue) - 2.5;
|
||||
volt = volt * volt;
|
||||
rms = rms + volt;
|
||||
@ -77,6 +79,8 @@ ECS1030::getCurrency_B () {
|
||||
for (int i = 0; i < NUMBER_OF_SAMPLES; i++) {
|
||||
m_lastSample = m_sample;
|
||||
m_sample = mraa_aio_read (m_dataPinCtx);
|
||||
if (m_sample == -1) throw std::runtime_error(std::string(__FUNCTION__) +
|
||||
": Failed to do an aio read.");
|
||||
m_lastFilter = m_filteredSample;
|
||||
m_filteredSample = 0.996 * (m_lastFilter + m_sample - m_lastSample);
|
||||
sumCurrency += (m_filteredSample * m_filteredSample);
|
||||
|
Reference in New Issue
Block a user