----------------------------------------------------------------------------- Handle receiving data -----------------------------------------------------------------------------
| 203 | // Handle receiving data |
| 204 | //----------------------------------------------------------------------------- |
| 205 | void HidController::ThreadProc |
| 206 | ( |
| 207 | Event* _exitEvent |
| 208 | ) |
| 209 | { |
| 210 | uint32 attempts = 0; |
| 211 | while( true ) |
| 212 | { |
| 213 | // Init must have been called successfully during Open, so we |
| 214 | // don't do it again until the end of the loop |
| 215 | if( m_hHidController ) |
| 216 | { |
| 217 | // Enter read loop. Call will only return if |
| 218 | // an exit is requested or an error occurs |
| 219 | Read(); |
| 220 | |
| 221 | // Reset the attempts, so we get a rapid retry for temporary errors |
| 222 | attempts = 0; |
| 223 | } |
| 224 | |
| 225 | if( attempts < 25 ) |
| 226 | { |
| 227 | // Retry every 5 seconds for the first two minutes... |
| 228 | if( Wait::Single( _exitEvent, 5000 ) >= 0 ) |
| 229 | { |
| 230 | // Exit signalled. |
| 231 | break; |
| 232 | } |
| 233 | } |
| 234 | else |
| 235 | { |
| 236 | // ...retry every 30 seconds after that |
| 237 | if( Wait::Single( _exitEvent, 30000 ) >= 0 ) |
| 238 | { |
| 239 | // Exit signalled. |
| 240 | break; |
| 241 | } |
| 242 | } |
| 243 | |
| 244 | Init( ++attempts ); |
| 245 | } |
| 246 | } |
| 247 | |
| 248 | //----------------------------------------------------------------------------- |
| 249 | // <HidController::Init> |
no test coverage detected