mirror of
https://github.com/eclipse/upm.git
synced 2025-07-26 21:51:16 +03:00
Make static allocation for mraaIo variable
Signed-off-by: Adelin Dobre <adelin.dobre@rinftech.com> Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
This commit is contained in:

committed by
Mihai Tudor Panu

parent
90167f6ac1
commit
9869b31a3e
@ -30,6 +30,11 @@
|
||||
using namespace std;
|
||||
using namespace upm;
|
||||
|
||||
static bool operator!(mraa::MraaIo &mraaIo)
|
||||
{
|
||||
return mraaIo.getMraaDescriptors() == NULL;
|
||||
}
|
||||
|
||||
ADXRS610::ADXRS610(int dPin, int tPin, float aref) :
|
||||
m_aioData(new mraa::Aio(dPin)), m_aioTemp(new mraa::Aio(tPin))
|
||||
{
|
||||
@ -43,17 +48,12 @@ ADXRS610::ADXRS610(int dPin, int tPin, float aref) :
|
||||
m_centerVolts = aref / 2.0;
|
||||
}
|
||||
|
||||
ADXRS610::ADXRS610(std::string initStr) : mraaIo(new mraa::MraaIo(initStr))
|
||||
ADXRS610::ADXRS610(std::string initStr) : mraaIo(initStr)
|
||||
{
|
||||
if(mraaIo == NULL)
|
||||
if(!mraaIo.aios.empty())
|
||||
{
|
||||
throw std::invalid_argument(std::string(__FUNCTION__) +
|
||||
": Failed to allocate memory for internal member");
|
||||
}
|
||||
if(!mraaIo->aios.empty())
|
||||
{
|
||||
m_aioData = &mraaIo->aios[0];
|
||||
m_aioTemp = &mraaIo->aios[1];
|
||||
m_aioData = &mraaIo.aios[0];
|
||||
m_aioTemp = &mraaIo.aios[1];
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -63,8 +63,8 @@ ADXRS610::ADXRS610(std::string initStr) : mraaIo(new mraa::MraaIo(initStr))
|
||||
|
||||
std::vector<std::string> upmTokens;
|
||||
|
||||
if (!mraaIo->getLeftoverStr().empty()) {
|
||||
upmTokens = UpmStringParser::parse(mraaIo->getLeftoverStr());
|
||||
if (!mraaIo.getLeftoverStr().empty()) {
|
||||
upmTokens = UpmStringParser::parse(mraaIo.getLeftoverStr());
|
||||
}
|
||||
|
||||
// ADC resolution of data and temp should be the same...
|
||||
@ -84,9 +84,7 @@ ADXRS610::ADXRS610(std::string initStr) : mraaIo(new mraa::MraaIo(initStr))
|
||||
|
||||
ADXRS610::~ADXRS610()
|
||||
{
|
||||
if(mraaIo != NULL)
|
||||
delete mraaIo;
|
||||
else
|
||||
if(!mraaIo)
|
||||
{
|
||||
delete m_aioData;
|
||||
delete m_aioTemp;
|
||||
|
@ -177,7 +177,7 @@ namespace upm {
|
||||
protected:
|
||||
mraa::Aio* m_aioData = NULL;
|
||||
mraa::Aio* m_aioTemp = NULL;
|
||||
mraa::MraaIo* mraaIo = NULL;
|
||||
mraa::MraaIo mraaIo;
|
||||
|
||||
private:
|
||||
float m_aref;
|
||||
|
Reference in New Issue
Block a user