| 147 | } |
| 148 | |
| 149 | void CanDevice::startSimulation() |
| 150 | { |
| 151 | Q_D(CanDevice); |
| 152 | |
| 153 | d->_simStarted = true; |
| 154 | |
| 155 | if (!d->_initialized) { |
| 156 | cds_info("CanDevice not initialized"); |
| 157 | return; |
| 158 | } |
| 159 | |
| 160 | if (!d->_canDevice.connectDevice()) { |
| 161 | cds_error("Failed to connect device. Trying to init the device again..."); |
| 162 | |
| 163 | // Cannelloni plugin fails to reconnect after initial disconnection. |
| 164 | // This workaround reinit the device before reconnection |
| 165 | // TODO: Findout why cannelloni plugin fails. |
| 166 | if (init()) { |
| 167 | cds_info("Re-init successful"); |
| 168 | |
| 169 | if (!d->_canDevice.connectDevice()) { |
| 170 | cds_error("Failed to re-connect device"); |
| 171 | } else { |
| 172 | cds_info("Re-connection successful"); |
| 173 | } |
| 174 | } |
| 175 | } |
| 176 | |
| 177 | d->_sendQueue.clear(); |
| 178 | } |
| 179 | |
| 180 | void CanDevice::stopSimulation() |
| 181 | { |
no test coverage detected