mirror of
https://github.com/eclipse/upm.git
synced 2025-03-24 01:10:22 +03:00
bmpx8x: 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
b8af35a797
commit
3d837284fd
@ -23,6 +23,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <string>
|
||||||
|
#include <stdexcept>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
@ -31,19 +33,19 @@
|
|||||||
using namespace upm;
|
using namespace upm;
|
||||||
|
|
||||||
BMPX8X::BMPX8X (int bus, int devAddr, uint8_t mode) : m_i2ControlCtx(bus) {
|
BMPX8X::BMPX8X (int bus, int devAddr, uint8_t mode) : m_i2ControlCtx(bus) {
|
||||||
|
|
||||||
m_name = "BMPX8X";
|
m_name = "BMPX8X";
|
||||||
|
|
||||||
m_controlAddr = devAddr;
|
mraa::Result ret = m_i2ControlCtx.address(devAddr);
|
||||||
m_bus = bus;
|
|
||||||
|
|
||||||
mraa::Result ret = m_i2ControlCtx.address(m_controlAddr);
|
|
||||||
if (ret != mraa::SUCCESS) {
|
if (ret != mraa::SUCCESS) {
|
||||||
fprintf(stderr, "Messed up i2c bus\n");
|
throw std::invalid_argument(std::string(__FUNCTION__) +
|
||||||
exit(-1);
|
": mraa_i2c_address() failed");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i2cReadReg_8 (0xD0) != 0x55) {
|
if (i2cReadReg_8 (0xD0) != 0x55) {
|
||||||
std::cout << "Error :: Cannot continue" << std::endl;
|
throw std::runtime_error(std::string(__FUNCTION__) +
|
||||||
|
": Invalid chip ID");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user