MCPcopy Create free account
hub / github.com/OpenZWave/open-zwave / ReadThreadProc

Method ReadThreadProc

cpp/src/platform/windows/SerialControllerImpl.cpp:129–169  ·  view source on GitHub ↗

----------------------------------------------------------------------------- Handle receiving data -----------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

127// Handle receiving data
128//-----------------------------------------------------------------------------
129void SerialControllerImpl::ReadThreadProc
130(
131)
132{
133 uint32 attempts = 0;
134 while( true )
135 {
136 // Init must have been called successfully during Open, so we
137 // don't do it again until the end of the loop
138 if( INVALID_HANDLE_VALUE != m_hSerialController )
139 {
140 // Enter read loop. Call will only return if
141 // an exit is requested or an error occurs
142 Read();
143
144 // Reset the attempts, so we get a rapid retry for temporary errors
145 attempts = 0;
146 }
147
148 if( attempts < 25 )
149 {
150 // Retry every 5 seconds for the first two minutes...
151 if( WAIT_OBJECT_0 == ::WaitForSingleObject( m_hExit, 5000 ) )
152 {
153 // Exit signalled.
154 break;
155 }
156 }
157 else
158 {
159 // ...retry every 30 seconds after that
160 if( WAIT_OBJECT_0 == ::WaitForSingleObject( m_hExit, 30000 ) )
161 {
162 // Exit signalled.
163 break;
164 }
165 }
166
167 Init( ++attempts );
168 }
169}
170
171//-----------------------------------------------------------------------------
172// <SerialControllerImpl::Init>

Callers 1

Calls 1

ReadFunction · 0.85

Tested by

no test coverage detected