Beispiel #1
0
bool MySensorsTCP::StopHardware()
{
	m_stoprequested = true;
	StopSendQueue();
	if (isConnected())
	{
		try {
			disconnect();
		}
		catch (...)
		{
			//Don't throw from a Stop command
		}
	}
	try {
		if (m_thread)
		{
			m_thread->join();
		}
	}
	catch (...)
	{
		//Don't throw from a Stop command
	}

	m_bIsStarted=false;
	return true;
}
Beispiel #2
0
bool MySensorsSerial::StopHardware()
{
    StopSendQueue();
    m_stoprequested = true;
    if (m_thread != NULL)
        m_thread->join();
    // Wait a while. The read thread might be reading. Adding this prevents a pointer error in the async serial class.
    sleep_milliseconds(10);
    if (isOpen())
    {
        try {
            clearReadCallback();
            close();
            doClose();
            setErrorStatus(true);
        }
        catch (...)
        {
            //Don't throw from a Stop command
        }
    }
    m_bIsStarted = false;
    return true;
}