Class FingerprintReader
The main class representing the Sparkfun fingerprint reader module GT521Fxx. Reference: https://cdn.sparkfun.com/assets/learn_tutorials/7/2/3/GT-521F52_Programming_guide_V10_20161001.pdf WIKI: https://learn.sparkfun.com/tutorials/fingerprint-scanner-gt-521fxx-hookup-guide.
Inheritance
Implements
Inherited Members
Namespace: Unosquare.Sparkfun.FingerprintModule
Syntax
public class FingerprintReader : IDisposable
Constructors
FingerprintReader(FingerprintReaderModel)
Initializes a new instance of the FingerprintReader class.
Declaration
public FingerprintReader(FingerprintReaderModel model)
Parameters
| Type | Name | Description |
|---|---|---|
| FingerprintReaderModel | model | The fingerprint reader model. |
Remarks
The model determines the device capacity.
Properties
FingerprintCapacity
Gets the fingerprint capacity.
Declaration
public int FingerprintCapacity { get; }
Property Value
| Type | Description |
|---|---|
| System.Int32 |
FirmwareVersion
Gets the device firmware version.
Declaration
public string FirmwareVersion { get; }
Property Value
| Type | Description |
|---|---|
| System.String |
IsoAreaMaxSize
Gets the maximum size of the iso area.
Declaration
public int IsoAreaMaxSize { get; }
Property Value
| Type | Description |
|---|---|
| System.Int32 |
MaxValidId
Gets the maximum valid identifier.
Declaration
public int MaxValidId { get; }
Property Value
| Type | Description |
|---|---|
| System.Int32 | The maximum valid identifier. |
SerialNumber
Gets the device serial number.
Declaration
public string SerialNumber { get; }
Property Value
| Type | Description |
|---|---|
| System.String |
Methods
CheckEnrollmentStatusAsync(Int32, CancellationToken)
Checks the enrollment status asynchronous.
Declaration
public Task<CheckEnrollmentResponse> CheckEnrollmentStatusAsync(int userId, CancellationToken ct = default(CancellationToken))
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | userId | The user identifier to check. |
| System.Threading.CancellationToken | ct | An instance of System.Threading.CancellationToken. |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task<CheckEnrollmentResponse> | A task that represents the asynchronous check enrolled status operation. The result of the task contains an instance of CheckEnrollmentResponse. |
CheckFingerPressingStatusAsync(CancellationToken)
Checks the finger pressing status asynchronous.
Declaration
public Task<CheckFingerPressingResponse> CheckFingerPressingStatusAsync(CancellationToken ct = default(CancellationToken))
Parameters
| Type | Name | Description |
|---|---|---|
| System.Threading.CancellationToken | ct | An instance of System.Threading.CancellationToken. |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task<CheckFingerPressingResponse> | A task that represents the asynchronous check finger pressing status operation. The result of the task contains an instance of CheckFingerPressingResponse. |
CloseAsync(CancellationToken)
Closes the fingerprint device if open.
Declaration
public Task CloseAsync(CancellationToken ct = default(CancellationToken))
Parameters
| Type | Name | Description |
|---|---|---|
| System.Threading.CancellationToken | ct | An instance of System.Threading.CancellationToken. |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task | A task that represents the asynchronous close operation. |
CountEnrolledFingerprintAsync(CancellationToken)
Counts the enrolled fingerprint asynchronous.
Declaration
public Task<CountEnrolledFingerprintResponse> CountEnrolledFingerprintAsync(CancellationToken ct = default(CancellationToken))
Parameters
| Type | Name | Description |
|---|---|---|
| System.Threading.CancellationToken | ct | An instance of System.Threading.CancellationToken. |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task<CountEnrolledFingerprintResponse> | A task that represents the asynchronous count enrolled fingerprint operation. The result of the task contains an instance of CountEnrolledFingerprintResponse. |
DeleteAllUsersAsync(CancellationToken)
Deletes all users from device's database asynchronous.
Declaration
public Task<BasicResponse> DeleteAllUsersAsync(CancellationToken ct = default(CancellationToken))
Parameters
| Type | Name | Description |
|---|---|---|
| System.Threading.CancellationToken | ct | An instance of System.Threading.CancellationToken. |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task<BasicResponse> | A task that represents the asynchronous delete all users operation. The result of the task contains an instance of BasicResponse. |
DeleteUserAsync(Int32, CancellationToken)
Deletes a specific user asynchronous.
Declaration
public Task<BasicResponse> DeleteUserAsync(int userId, CancellationToken ct = default(CancellationToken))
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | userId | The user identifier. |
| System.Threading.CancellationToken | ct | An instance of System.Threading.CancellationToken. |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task<BasicResponse> | A task that represents the asynchronous delete user operation. The result of the task contains an instance of BasicResponse. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentOutOfRangeException | userId. |
Dispose()
Declaration
public void Dispose()
Dispose(Boolean)
Releases unmanaged and - optionally - managed resources.
Declaration
protected virtual void Dispose(bool disposing)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Boolean | disposing |
|
EnrollUserAsync(Int32, Int32, CancellationToken)
Enrolls a new user asynchronous.
Declaration
public Task<EnrollmentResponse> EnrollUserAsync(int iteration, int userId, CancellationToken ct = default(CancellationToken))
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | iteration | The iteration. |
| System.Int32 | userId | The user identifier. |
| System.Threading.CancellationToken | ct | An instance of System.Threading.CancellationToken. |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task<EnrollmentResponse> | A task that represents the asynchronous enroll user operation. The result of the task contains an instance of EnrollmentResponse. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentOutOfRangeException | iteration or userId. |
EnterStandByMode(CancellationToken)
Sets device to stand by mode (low power mode).
Declaration
public Task<BasicResponse> EnterStandByMode(CancellationToken ct = default(CancellationToken))
Parameters
| Type | Name | Description |
|---|---|---|
| System.Threading.CancellationToken | ct | An instance of System.Threading.CancellationToken. |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task<BasicResponse> | A task that represents the asynchronous enter standby operation. The result of the task contains an instance of BasicResponse. |
FastDeviceSearching(CancellationToken)
Fasts device searching asynchronous.
Declaration
public Task<FastSearchingResponse> FastDeviceSearching(CancellationToken ct = default(CancellationToken))
Parameters
| Type | Name | Description |
|---|---|---|
| System.Threading.CancellationToken | ct | An instance of System.Threading.CancellationToken. |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task<FastSearchingResponse> | A task that represents the asynchronous set fast device searching operation. The result of the task contains an instance of FastSearchingResponse. |
Remarks
The device operates as removable CD drive. If another removable CD drive exists in the system, connection time maybe will be long. To prevent this, FastDeviceSearching(CancellationToken) command is used for fast searching of the device.
GetImageAsync(CancellationToken)
Gets a fingerprint image asynchronous.
Declaration
public Task<GetFingerprintImageResponse> GetImageAsync(CancellationToken ct = default(CancellationToken))
Parameters
| Type | Name | Description |
|---|---|---|
| System.Threading.CancellationToken | ct | An instance of System.Threading.CancellationToken. |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task<GetFingerprintImageResponse> | A task that represents the asynchronous get image operation. The result of the task contains an instance of GetFingerprintImageResponse. |
GetPortNames()
Gets an array of serial port names for the current computer.
This method is just a shortcut for Microsoft and RJCP libraries, you may use your SerialPort library to enumerate the available ports.
Declaration
public static string[] GetPortNames()
Returns
| Type | Description |
|---|---|
| System.String[] | An array of serial port names for the current computer. |
GetRawImageAsync(CancellationToken)
Gets a raw image from the device asynchronous.
Declaration
public Task<GetRawImageResponse> GetRawImageAsync(CancellationToken ct = default(CancellationToken))
Parameters
| Type | Name | Description |
|---|---|---|
| System.Threading.CancellationToken | ct | An instance of System.Threading.CancellationToken. |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task<GetRawImageResponse> | A task that represents the asynchronous get raw image operation. The result of the task contains an instance of GetRawImageResponse. |
GetSecurityLevelAsync(CancellationToken)
Gets the device's security level asynchronous. 1 is the lowest security level, 5 is the highest security level.
Declaration
public Task<GetSecurityLevelResponse> GetSecurityLevelAsync(CancellationToken ct = default(CancellationToken))
Parameters
| Type | Name | Description |
|---|---|---|
| System.Threading.CancellationToken | ct | An instance of System.Threading.CancellationToken. |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task<GetSecurityLevelResponse> | A task that represents the asynchronous get security level operation. The result of the task contains an instance of GetSecurityLevelResponse. |
GetTemplateAsync(Int32, CancellationToken)
Gets a fingerprint template asynchronous.
Declaration
public Task<TemplateResponse> GetTemplateAsync(int userId, CancellationToken ct = default(CancellationToken))
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | userId | The user identifier. |
| System.Threading.CancellationToken | ct | An instance of System.Threading.CancellationToken. |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task<TemplateResponse> | A task that represents the asynchronous get template operation. The result of the task contains an instance of TemplateResponse. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentOutOfRangeException | userId. |
MakeTemplateAsync(CancellationToken)
Makes a fingerprint template asynchronous. This template must be used only for transmission and not for user enrollment.
Declaration
public Task<TemplateResponse> MakeTemplateAsync(CancellationToken ct = default(CancellationToken))
Parameters
| Type | Name | Description |
|---|---|---|
| System.Threading.CancellationToken | ct | An instance of System.Threading.CancellationToken. |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task<TemplateResponse> | A task that represents the asynchronous make template operation. The result of the task contains an instance of TemplateResponse. |
MatchOneToN(Byte[], CancellationToken)
Match 1:N asynchronous. Identifies the user id whom a provided fingerprint template belongs to.
Declaration
public Task<MatchOneToNResponse> MatchOneToN(byte[] template, CancellationToken ct = default(CancellationToken))
Parameters
| Type | Name | Description |
|---|---|---|
| System.Byte[] | template | The fingerprint template. |
| System.Threading.CancellationToken | ct | An instance of System.Threading.CancellationToken. |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task<MatchOneToNResponse> | A task that represents the asynchronous match one to n operation. The result of the task contains an instance of MatchOneToNResponse. |
MatchOneToN(CancellationToken)
Match 1:N asynchronous. Acquires an image from the device and identifies the user id it belongs to.
Declaration
public Task<MatchOneToNResponse> MatchOneToN(CancellationToken ct = default(CancellationToken))
Parameters
| Type | Name | Description |
|---|---|---|
| System.Threading.CancellationToken | ct | An instance of System.Threading.CancellationToken. |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task<MatchOneToNResponse> | A task that represents the asynchronous match one to n operation. The result of the task contains an instance of MatchOneToNResponse. |
MatchOneToN2(Byte[], CancellationToken)
Match 1:N asynchronous. Identifies the user id whom a provided fingerprint template belongs to.
Declaration
public Task<MatchOneToNResponse> MatchOneToN2(byte[] template, CancellationToken ct = default(CancellationToken))
Parameters
| Type | Name | Description |
|---|---|---|
| System.Byte[] | template | The special fingerprint template. |
| System.Threading.CancellationToken | ct | An instance of System.Threading.CancellationToken. |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task<MatchOneToNResponse> | A task that represents the asynchronous match one to n operation. The result of the task contains an instance of MatchOneToNResponse. |
Remarks
MatchOneToN2(Byte[], CancellationToken) uses a special fingerprint template with 2 extra bytes at the beginning of the byte array.
MatchOneToOneAsync(Int32, Byte[], CancellationToken)
Match 1:1 asynchronous. Verify if a provided fingerprint template matches the supplied user id.
Declaration
public Task<BasicResponse> MatchOneToOneAsync(int userId, byte[] template, CancellationToken ct = default(CancellationToken))
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | userId | The user identifier. |
| System.Byte[] | template | The fingerprint template. |
| System.Threading.CancellationToken | ct | An instance of System.Threading.CancellationToken. |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task<BasicResponse> | A task that represents the asynchronous match one to one operation. The result of the task contains an instance of BasicResponse. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentOutOfRangeException | userId. |
MatchOneToOneAsync(Int32, CancellationToken)
Match 1:1 asynchronous. Acquires an image from the device and verify if it matches the supplied user id.
Declaration
public Task<BasicResponse> MatchOneToOneAsync(int userId, CancellationToken ct = default(CancellationToken))
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | userId | The user identifier. |
| System.Threading.CancellationToken | ct | An instance of System.Threading.CancellationToken. |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task<BasicResponse> | A task that represents the asynchronous match one to one operation. The result of the task contains an instance of BasicResponse. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentOutOfRangeException | userId. |
OpenAsync(String, CancellationToken)
Opens and initialize the fingerprint device at the specified port name.
Declaration
public Task OpenAsync(string portName, CancellationToken ct = default(CancellationToken))
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | portName | Name of the port. |
| System.Threading.CancellationToken | ct | An instance of System.Threading.CancellationToken. |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task | A task that represents the asynchronous open operation. |
Exceptions
| Type | Condition |
|---|---|
| System.InvalidOperationException | Device is already open. Call the close method first. |
OpenAsync(ISerialPort, CancellationToken)
Opens and initialize the fingerprint device at the specified port name.
Declaration
public Task OpenAsync(ISerialPort serialPort, CancellationToken ct = default(CancellationToken))
Parameters
| Type | Name | Description |
|---|---|---|
| ISerialPort | serialPort | The serial port. |
| System.Threading.CancellationToken | ct | An instance of System.Threading.CancellationToken. |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task | A task that represents the asynchronous open operation. |
Exceptions
| Type | Condition |
|---|---|
| System.InvalidOperationException | Device is already open. Call the close method first. |
SetLetStatusAsync(LedStatus, CancellationToken)
Sets the let status asynchronous.
Declaration
public Task<BasicResponse> SetLetStatusAsync(LedStatus status, CancellationToken ct = default(CancellationToken))
Parameters
| Type | Name | Description |
|---|---|---|
| LedStatus | status | The status. |
| System.Threading.CancellationToken | ct | An instance of System.Threading.CancellationToken. |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task<BasicResponse> | A task that represents the asynchronous set led status operation. The result of the task contains an instance of BasicResponse. |
SetSecurityLevelAsync(Int32, CancellationToken)
Sets the device's security level asynchronous. 1 is the lowest security level, 5 is the highest security level.
Declaration
public Task<BasicResponse> SetSecurityLevelAsync(int level, CancellationToken ct = default(CancellationToken))
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | level | The security level. |
| System.Threading.CancellationToken | ct | An instance of System.Threading.CancellationToken. |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task<BasicResponse> | A task that represents the asynchronous set security level operation. The result of the task contains an instance of BasicResponse. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentOutOfRangeException | level. |
SetTemplateAsync(Int32, Byte[], CancellationToken)
Sets a fingerprint template asynchronous.
Declaration
public Task<BasicResponse> SetTemplateAsync(int userId, byte[] template, CancellationToken ct = default(CancellationToken))
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | userId | The user identifier. |
| System.Byte[] | template | The fingerprint template. |
| System.Threading.CancellationToken | ct | An instance of System.Threading.CancellationToken. |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task<BasicResponse> | A task that represents the asynchronous set template operation. The result of the task contains an instance of BasicResponse. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentOutOfRangeException | userId. |
TurnLedOffAsync(CancellationToken)
Turns the led off asynchronous.
Declaration
public Task<BasicResponse> TurnLedOffAsync(CancellationToken ct = default(CancellationToken))
Parameters
| Type | Name | Description |
|---|---|---|
| System.Threading.CancellationToken | ct | An instance of System.Threading.CancellationToken. |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task<BasicResponse> | A task that represents the asynchronous turn led off operation. The result of the task contains an instance of BasicResponse. |
TurnLedOnAsync(CancellationToken)
Turns the led on asynchronous.
Declaration
public Task<BasicResponse> TurnLedOnAsync(CancellationToken ct = default(CancellationToken))
Parameters
| Type | Name | Description |
|---|---|---|
| System.Threading.CancellationToken | ct | An instance of System.Threading.CancellationToken. |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task<BasicResponse> | A task that represents the asynchronous turn led on operation. The result of the task contains an instance of BasicResponse. |
WaitFingerActionAsync(FingerAction, CancellationToken)
Waits a finger action asynchronous.
Declaration
public Task<bool> WaitFingerActionAsync(FingerAction action, CancellationToken ct = default(CancellationToken))
Parameters
| Type | Name | Description |
|---|---|---|
| FingerAction | action | The action to wait for. |
| System.Threading.CancellationToken | ct | An instance of System.Threading.CancellationToken. |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task<System.Boolean> | A task that represents the asynchronous wait finger action operation.
The result of the task contains a System.Boolean indicating if the action was performed.
|
WaitFingerActionAsync(FingerAction, TimeSpan, CancellationToken)
Waits a finger action for a specified time period asynchronous.
Declaration
public Task<bool> WaitFingerActionAsync(FingerAction action, TimeSpan timeout, CancellationToken ct = default(CancellationToken))
Parameters
| Type | Name | Description |
|---|---|---|
| FingerAction | action | The action to wait for. |
| System.TimeSpan | timeout | The timeout. |
| System.Threading.CancellationToken | ct | An instance of System.Threading.CancellationToken. |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task<System.Boolean> | A task that represents the asynchronous wait finger action operation.
The result of the task contains a System.Boolean indicating if the action was performed.
|