Stop double opens and closes on the UMP when used for Nextion and control lines.
This commit is contained in:
parent
fcfe171365
commit
4581a7c9fd
1 changed files with 11 additions and 0 deletions
11
UMP.cpp
11
UMP.cpp
|
@ -41,6 +41,7 @@ const unsigned int BUFFER_LENGTH = 255U;
|
||||||
|
|
||||||
CUMP::CUMP(const std::string& port) :
|
CUMP::CUMP(const std::string& port) :
|
||||||
m_serial(port, SERIAL_115200),
|
m_serial(port, SERIAL_115200),
|
||||||
|
m_open(false),
|
||||||
m_buffer(NULL),
|
m_buffer(NULL),
|
||||||
m_length(0U),
|
m_length(0U),
|
||||||
m_offset(0U),
|
m_offset(0U),
|
||||||
|
@ -58,6 +59,9 @@ CUMP::~CUMP()
|
||||||
|
|
||||||
bool CUMP::open()
|
bool CUMP::open()
|
||||||
{
|
{
|
||||||
|
if (m_open)
|
||||||
|
return true;
|
||||||
|
|
||||||
bool ret = m_serial.open();
|
bool ret = m_serial.open();
|
||||||
if (!ret)
|
if (!ret)
|
||||||
return false;
|
return false;
|
||||||
|
@ -74,6 +78,8 @@ bool CUMP::open()
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_open = true;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -235,5 +241,10 @@ void CUMP::clock(unsigned int ms)
|
||||||
|
|
||||||
void CUMP::close()
|
void CUMP::close()
|
||||||
{
|
{
|
||||||
|
if (!m_open)
|
||||||
|
return;
|
||||||
|
|
||||||
m_serial.close();
|
m_serial.close();
|
||||||
|
|
||||||
|
m_open = false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue