diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2019-04-24 14:01:40 +0300 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2019-04-24 14:01:40 +0300 |
| commit | afca405892ace809c498c010a2d4484bec5adf11 (patch) | |
| tree | e3a1640a7ff89ecc0d246287a4281efe616f5715 /Software/Visual_Studio/Tango.Transport | |
| parent | 636ad730569dfef1a4ee04c8d716d510bcc47ee1 (diff) | |
| download | Tango-afca405892ace809c498c010a2d4484bec5adf11.tar.gz Tango-afca405892ace809c498c010a2d4484bec5adf11.zip | |
Implemented USB adapter finalizer.
Added exception logging for USB adapter disconnection error.
Added Volume color space icon to PPC.
Implemented KeepAlive suppression on StorageAPI.
Suppressed KeepAlive when uploading job.
Implemented keep alive skipping when arrived responses queue is busy.
Diffstat (limited to 'Software/Visual_Studio/Tango.Transport')
| -rw-r--r-- | Software/Visual_Studio/Tango.Transport/Adapters/UsbTransportAdapter.cs | 28 | ||||
| -rw-r--r-- | Software/Visual_Studio/Tango.Transport/TransporterBase.cs | 9 |
2 files changed, 32 insertions, 5 deletions
diff --git a/Software/Visual_Studio/Tango.Transport/Adapters/UsbTransportAdapter.cs b/Software/Visual_Studio/Tango.Transport/Adapters/UsbTransportAdapter.cs index f00347c8d..1c21723c8 100644 --- a/Software/Visual_Studio/Tango.Transport/Adapters/UsbTransportAdapter.cs +++ b/Software/Visual_Studio/Tango.Transport/Adapters/UsbTransportAdapter.cs @@ -153,7 +153,10 @@ namespace Tango.Transport.Adapters State = TransportComponentState.Disconnected; LogManager.Log("USB adapter disconnected."); } - catch { } + catch (Exception ex) + { + LogManager.Log(ex, "Could not close serial port on " + Address + "."); + } } catch (Exception ex) @@ -167,7 +170,7 @@ namespace Tango.Transport.Adapters } }); - TimeoutTask.StartNew(() => + TimeoutTask.StartNew(() => { if (!source.Task.IsCompleted) @@ -202,7 +205,7 @@ namespace Tango.Transport.Adapters } catch (Exception ex) { - OnFailed(LogManager.Log(ex)); + OnFailed(LogManager.Log(ex, "Error writing to the serial port.")); } } @@ -244,7 +247,24 @@ namespace Tango.Transport.Adapters } catch (Exception ex) { - LogManager.Log(ex, "Error occurred while trying to read from serial port."); + LogManager.Log(ex, "Error occurred while trying to read from the serial port."); + } + } + + /// <summary> + /// Finalizes an instance of the <see cref="UsbTransportAdapter"/> class. + /// </summary> + ~UsbTransportAdapter() + { + if (_serialPort != null) + { + try + { + LogManager.Log("Finalizing USB transport adapter."); + _serialPort.Close(); + _serialPort.Dispose(); + } + catch { } } } } diff --git a/Software/Visual_Studio/Tango.Transport/TransporterBase.cs b/Software/Visual_Studio/Tango.Transport/TransporterBase.cs index c1a13ce26..008c0759a 100644 --- a/Software/Visual_Studio/Tango.Transport/TransporterBase.cs +++ b/Software/Visual_Studio/Tango.Transport/TransporterBase.cs @@ -1093,7 +1093,14 @@ namespace Tango.Transport if (UseKeepAlive) { - var response = SendRequest<KeepAliveRequest, KeepAliveResponse>(new KeepAliveRequest(), TimeSpan.FromSeconds(2)).Result; + if (_arrivedResponses.Count == 0) + { + var response = SendRequest<KeepAliveRequest, KeepAliveResponse>(new KeepAliveRequest(), TimeSpan.FromSeconds(2)).Result; + } + else + { + LogManager.Log("Keep alive request was skipped due to busy response queue.", LogCategory.Debug); + } } } catch (Exception ex) when (ex is TimeoutException || ex is AggregateException) |
