----------------------------------------------------------------------------- Handle receiving data -----------------------------------------------------------------------------
| 134 | // Handle receiving data |
| 135 | //----------------------------------------------------------------------------- |
| 136 | void SerialControllerImpl::ReadThreadProc |
| 137 | ( |
| 138 | Event* _exitEvent |
| 139 | ) |
| 140 | { |
| 141 | uint32 attempts = 0; |
| 142 | while( !_exitEvent->IsSignalled() ) |
| 143 | { |
| 144 | // Init must have been called successfully during Open, so we |
| 145 | // don't do it again until the end of the loop |
| 146 | if( -1 != m_hSerialController ) |
| 147 | { |
| 148 | // Enter read loop. Call will only return if |
| 149 | // an exit is requested or an error occurs |
| 150 | Read(_exitEvent); |
| 151 | |
| 152 | // Reset the attempts, so we get a rapid retry for temporary errors |
| 153 | attempts = 0; |
| 154 | } |
| 155 | |
| 156 | if( attempts < 25 ) |
| 157 | { |
| 158 | // Retry every 5 seconds for the first two minutes... |
| 159 | if( Wait::Single( _exitEvent, 5000 ) >= 0 ) |
| 160 | { |
| 161 | // Exit signalled. |
| 162 | break; |
| 163 | } |
| 164 | } |
| 165 | else |
| 166 | { |
| 167 | // ...retry every 30 seconds after that |
| 168 | if( Wait::Single( _exitEvent, 30000 ) >= 0 ) |
| 169 | { |
| 170 | // Exit signalled. |
| 171 | break; |
| 172 | } |
| 173 | } |
| 174 | |
| 175 | Init( ++attempts ); |
| 176 | } |
| 177 | } |
| 178 | |
| 179 | //----------------------------------------------------------------------------- |
| 180 | // <SerialControllerImpl::Init> |
no test coverage detected