mirror of
https://github.com/eclipse/upm.git
synced 2025-06-08 14:20:38 +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;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
if (!strength)
|
||||
@ -484,3 +493,12 @@ bool HMTRP::getModSignalStrength(uint8_t *strength)
|
||||
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);
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
@ -243,6 +251,14 @@ namespace upm {
|
||||
*/
|
||||
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:
|
||||
mraa_uart_context m_uart;
|
||||
|
@ -3,6 +3,7 @@
|
||||
%include "stdint.i"
|
||||
%include "typemaps.i"
|
||||
%include "../java_buffer.i"
|
||||
%include "../java_exceptions.i"
|
||||
|
||||
%apply uint32_t *OUTPUT { uint32_t *freq, uint32_t *dataRate };
|
||||
%apply uint16_t *OUTPUT { uint16_t *rxBandwidth };
|
||||
@ -15,6 +16,12 @@
|
||||
speed_t int_B9600 = B9600;
|
||||
%}
|
||||
|
||||
%ignore getRFSignalStrength(uint8_t *strength);
|
||||
READDATA_EXCEPTION(getRFSignalStrength())
|
||||
|
||||
%ignore getModSignalStrength(uint8_t *strength);
|
||||
READDATA_EXCEPTION(getModSignalStrength())
|
||||
|
||||
%include "hmtrp.h"
|
||||
speed_t int_B9600 = B9600;
|
||||
|
||||
@ -27,4 +34,4 @@ speed_t int_B9600 = B9600;
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
%}
|
||||
%}
|
||||
|
@ -349,7 +349,7 @@ namespace upm {
|
||||
* @throws std::runtime_error if reading from the sensor failed
|
||||
*/
|
||||
uint16_t getCurrentFile();
|
||||
|
||||
|
||||
/**
|
||||
* Gets the device date
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user