mirror of
https://github.com/eclipse/upm.git
synced 2025-06-10 23:30:27 +03:00
pulsesensor: 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
5e9d9f4e66
commit
60a3f6cd7e
@ -22,6 +22,8 @@
|
|||||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <stdexcept>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include "pulsensor.h"
|
#include "pulsensor.h"
|
||||||
@ -29,7 +31,12 @@
|
|||||||
void init_pulsensor (pulsensor_context * ctx, callback_handler handler) {
|
void init_pulsensor (pulsensor_context * ctx, callback_handler handler) {
|
||||||
ctx->callback = handler;
|
ctx->callback = handler;
|
||||||
|
|
||||||
ctx->pin_ctx = mraa_aio_init(0);
|
if ( !(ctx->pin_ctx = mraa_aio_init(0)) )
|
||||||
|
{
|
||||||
|
throw std::invalid_argument(std::string(__FUNCTION__) +
|
||||||
|
": mraa_aio_init() failed, invalid pin?");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
ctx->sample_counter = 0;
|
ctx->sample_counter = 0;
|
||||||
ctx->last_beat_time = 0;
|
ctx->last_beat_time = 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user