mirror of
https://github.com/eclipse/upm.git
synced 2025-03-24 01:10:22 +03:00
mq303a: throw exception(s) on fatal errors
Signed-off-by: Jon Trulson <jtrulson@ics.com> Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
This commit is contained in:
parent
b00e81dfce
commit
7866e54e8d
@ -23,6 +23,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <string>
|
||||||
|
#include <stdexcept>
|
||||||
|
|
||||||
#include "mq303a.h"
|
#include "mq303a.h"
|
||||||
|
|
||||||
@ -30,9 +32,19 @@ using namespace upm;
|
|||||||
|
|
||||||
MQ303A::MQ303A(int pin, int heaterPin)
|
MQ303A::MQ303A(int pin, int heaterPin)
|
||||||
{
|
{
|
||||||
m_aio = mraa_aio_init(pin);
|
if ( !(m_aio = mraa_aio_init(pin)) )
|
||||||
|
{
|
||||||
|
throw std::invalid_argument(std::string(__FUNCTION__) +
|
||||||
|
": mraa_aio_init() failed, invalid pin?");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
m_gpio = mraa_gpio_init(heaterPin);
|
if ( !(m_gpio = mraa_gpio_init(heaterPin)) )
|
||||||
|
{
|
||||||
|
throw std::invalid_argument(std::string(__FUNCTION__) +
|
||||||
|
": mraa_gpio_init() failed, invalid pin?");
|
||||||
|
return;
|
||||||
|
}
|
||||||
mraa_gpio_dir(m_gpio, MRAA_GPIO_OUT);
|
mraa_gpio_dir(m_gpio, MRAA_GPIO_OUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user