diff --git a/SickRfid/ConnectedSickRfidController.cs b/SickRfid/ConnectedSickRfidController.cs index cdf712d..f1c8eaa 100644 --- a/SickRfid/ConnectedSickRfidController.cs +++ b/SickRfid/ConnectedSickRfidController.cs @@ -100,7 +100,7 @@ public async Task ReadAsync(CancellationToken cancellationToken = defaul var message = Encoding.ASCII.GetString(buffer, 0, result); if (string.IsNullOrEmpty(message) || - message.Contains(Acknowledgements.ACK_START, StringComparison.Ordinal) || + message.Equals(Acknowledgements.ACK_START, StringComparison.Ordinal) || message.Contains(Acknowledgements.ACK_STOP, StringComparison.Ordinal)) continue; return message; diff --git a/SickRfid/DisconnectedSickRfidController.cs b/SickRfid/DisconnectedSickRfidController.cs index cb3977c..be185b9 100644 --- a/SickRfid/DisconnectedSickRfidController.cs +++ b/SickRfid/DisconnectedSickRfidController.cs @@ -18,10 +18,10 @@ internal DisconnectedSickRfidController(IPAddress ipAddress, int port) _port = port; } - public async Task ConnectAsync() + public async Task ConnectAsync(CancellationToken cancellationToken = default) { var socket = new Socket(SocketType.Stream, ProtocolType.Tcp); - await socket.ConnectAsync(_ipAddress, _port).ConfigureAwait(true); + await socket.ConnectAsync(_ipAddress, _port, cancellationToken).ConfigureAwait(true); return new ConnectedSickRfidController().SetSocket(socket); } } \ No newline at end of file