Class SerialBarCodeScanner
- Namespace
- Acuit.Pinpoint.BarCodeScanning
- Assembly
- Acuit.Pinpoint.BarCodeScanning.dll
A serial port bar code scanner.
public class SerialBarCodeScanner : StreamingBarCodeScanner, IConnectedDevice, IHealthCheck, IDisposable, IAsyncDisposable, IBarCodeScanner, IBarCodeScannerRaw
- Inheritance
-
SerialBarCodeScanner
- Implements
- Inherited Members
Remarks
Incoming data is assumed to be encoded as ASCII.
Constructors
SerialBarCodeScanner(IErrorHandler, ILogger<SerialBarCodeScanner>, ITimeService)
Initializes a new instance of the SerialBarCodeScanner class.
public SerialBarCodeScanner(IErrorHandler errorHandler, ILogger<SerialBarCodeScanner> logger, ITimeService timeService)
Parameters
errorHandler
IErrorHandlerThe error handler to use for unexpected background errors.
logger
ILogger<SerialBarCodeScanner>An optional logger. If this is null, no logging will occur.
timeService
ITimeServiceThe time service.
Exceptions
- ArgumentNullException
errorHandler
is null.- ArgumentNullException
timeService
is null.
Properties
SerialPort
Gets the serial port settings used for communication with the bar code scanner.
public SerialPortSettings SerialPort { get; }
Property Value
Methods
Dispose(bool)
Closes and releases all resources used by the object.
protected override void Dispose(bool disposing)
Parameters
Remarks
Derived classes should override this when they have any resources that should be disposed.
When Dispose() is called on the object, Dispose(bool) will be called with true for the parameter value.
When DisposeAsync() is called on the object, DisposeAsyncCore() will be called, and then Dispose(bool) will be called with false for the parameter value.
DisposeAsyncCore()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources asynchronously.
protected override ValueTask DisposeAsyncCore()
Returns
- ValueTask
A task that represents the asynchronous operation.
Remarks
Derived classes should override this when they have any resources that should be disposed.
When Dispose() is called on the object, Dispose(bool) will be called with true for the parameter value.
When DisposeAsync() is called on the object, DisposeAsyncCore() will be called, and then Dispose(bool) will be called with false for the parameter value.
DoConnectAndGetStreamAsync(CancellationToken)
Connects to the device and gets the Stream to use to communication with the bar code scanner.
protected override Task<Stream> DoConnectAndGetStreamAsync(CancellationToken cancellationToken)
Parameters
cancellationToken
CancellationTokenThe cancellation token, which indicates that the connection attempt should be aborted.
Returns
- Task<Stream>
A task that represents the asynchronous operation. The value of its Result property contains the stream.
Remarks
This might be called from any thread, but it and DoDisconnectAsync(CancellationToken) will never be called concurrently.
Exceptions
- Exception
The connection could not be established.
DoDisconnectAsync(CancellationToken)
Disconnects from the device.
protected override Task DoDisconnectAsync(CancellationToken cancellationToken)
Parameters
cancellationToken
CancellationTokenA CancellationToken that can request that the disconnection process no longer be graceful.
Returns
- Task
A task that represents the asynchronous operation.
Remarks
When cancellationToken
is signaled, it indicates that the disconnection should still occur, but not gracefully.
The implementation should complete its disconnection process as directly as possible, but the returned Task should
still reflect a RanToCompletion status (not Canceled).
This might be called from any thread, but it and DoConnectAsync(CancellationToken) will never be called concurrently.