mirror of
https://github.com/eclipse/upm.git
synced 2025-06-09 14:50:24 +03:00
hmtrp: Added functions that throw exceptions when failing to read from sensors, and added java exception handling.
Signed-off-by: Stefan Andritoiu <stefan.andritoiu@intel.com> Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
This commit is contained in:
parent
9bfda4219d
commit
4de9734f0a
@ -452,6 +452,15 @@ bool HMTRP::getRFSignalStrength(uint8_t *strength)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint8_t HMTRP::getRFSignalStrength()
|
||||||
|
{
|
||||||
|
uint8_t strength = 0;
|
||||||
|
if (!getRFSignalStrength(&strength))
|
||||||
|
throw std::runtime_error(std::string(__PRETTY_FUNCTION__) +
|
||||||
|
": readData() failed");
|
||||||
|
return strength;
|
||||||
|
}
|
||||||
|
|
||||||
bool HMTRP::getModSignalStrength(uint8_t *strength)
|
bool HMTRP::getModSignalStrength(uint8_t *strength)
|
||||||
{
|
{
|
||||||
if (!strength)
|
if (!strength)
|
||||||
@ -484,3 +493,12 @@ bool HMTRP::getModSignalStrength(uint8_t *strength)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint8_t HMTRP::getModSignalStrength()
|
||||||
|
{
|
||||||
|
uint8_t strength = 0;
|
||||||
|
if (!getModSignalStrength(&strength))
|
||||||
|
throw std::runtime_error(std::string(__PRETTY_FUNCTION__) +
|
||||||
|
": readData() failed");
|
||||||
|
return strength;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -235,6 +235,14 @@ namespace upm {
|
|||||||
*/
|
*/
|
||||||
bool getRFSignalStrength(uint8_t *strength);
|
bool getRFSignalStrength(uint8_t *strength);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the RF signal strength
|
||||||
|
*
|
||||||
|
* @return Signal strength
|
||||||
|
* @throws std::runtime_error if reading from the sensor failed
|
||||||
|
*/
|
||||||
|
uint8_t getRFSignalStrength();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the modulation signal strength.
|
* Gets the modulation signal strength.
|
||||||
*
|
*
|
||||||
@ -243,6 +251,14 @@ namespace upm {
|
|||||||
*/
|
*/
|
||||||
bool getModSignalStrength(uint8_t *strength);
|
bool getModSignalStrength(uint8_t *strength);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the modulation signal strength.
|
||||||
|
*
|
||||||
|
* @return Signal strength
|
||||||
|
* @throws std::runtime_error if reading from the sensor failed
|
||||||
|
*/
|
||||||
|
uint8_t getModSignalStrength();
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
mraa_uart_context m_uart;
|
mraa_uart_context m_uart;
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
%include "stdint.i"
|
%include "stdint.i"
|
||||||
%include "typemaps.i"
|
%include "typemaps.i"
|
||||||
%include "../java_buffer.i"
|
%include "../java_buffer.i"
|
||||||
|
%include "../java_exceptions.i"
|
||||||
|
|
||||||
%apply uint32_t *OUTPUT { uint32_t *freq, uint32_t *dataRate };
|
%apply uint32_t *OUTPUT { uint32_t *freq, uint32_t *dataRate };
|
||||||
%apply uint16_t *OUTPUT { uint16_t *rxBandwidth };
|
%apply uint16_t *OUTPUT { uint16_t *rxBandwidth };
|
||||||
@ -15,6 +16,12 @@
|
|||||||
speed_t int_B9600 = B9600;
|
speed_t int_B9600 = B9600;
|
||||||
%}
|
%}
|
||||||
|
|
||||||
|
%ignore getRFSignalStrength(uint8_t *strength);
|
||||||
|
READDATA_EXCEPTION(getRFSignalStrength())
|
||||||
|
|
||||||
|
%ignore getModSignalStrength(uint8_t *strength);
|
||||||
|
READDATA_EXCEPTION(getModSignalStrength())
|
||||||
|
|
||||||
%include "hmtrp.h"
|
%include "hmtrp.h"
|
||||||
speed_t int_B9600 = B9600;
|
speed_t int_B9600 = B9600;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user