Compare commits
6 Commits
f93a821a2b
...
23c6036924
| Author | SHA1 | Date | |
|---|---|---|---|
| 23c6036924 | |||
| 5a061d7600 | |||
| e295afd899 | |||
| 6f5ff3ce00 | |||
| 80e67f3afc | |||
| 7b5716b8f3 |
@@ -79,7 +79,7 @@ namespace WaveshareUARTFingerprintSensor
|
||||
{
|
||||
byte checksum = 0;
|
||||
|
||||
for (int i = 1; i < length + 1; i++)
|
||||
for (int i = 1; i < length; i++)
|
||||
{
|
||||
checksum ^= data[i];
|
||||
}
|
||||
@@ -166,6 +166,9 @@ namespace WaveshareUARTFingerprintSensor
|
||||
|
||||
private byte[] ReadData(int length)
|
||||
{
|
||||
// Needed to work
|
||||
Thread.Sleep(150);
|
||||
|
||||
byte first = (byte)_serialPort.ReadByte();
|
||||
|
||||
if (first != PacketSeparator)
|
||||
@@ -344,7 +347,7 @@ namespace WaveshareUARTFingerprintSensor
|
||||
/// <returns></returns>
|
||||
public bool TryComparison1N(out (ushort userID, UserPermission permission) userInfo)
|
||||
{
|
||||
if (TrySendAndReceive(CommandType.Comparison11, 0, 0, 0, out var response, 1000))
|
||||
if (TrySendAndReceive(CommandType.Comparison1N, 0, 0, 0, out var response, 1000))
|
||||
{
|
||||
if (response.responseType != ResponseType.NoUser && response.responseType != ResponseType.Timeout)
|
||||
{
|
||||
@@ -369,13 +372,13 @@ namespace WaveshareUARTFingerprintSensor
|
||||
{
|
||||
userPermission = (UserPermission)reponse.responseType;
|
||||
|
||||
return true;
|
||||
return userPermission != 0;
|
||||
}
|
||||
}
|
||||
|
||||
userPermission = default;
|
||||
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool TryGetComparisonLevel(out byte comparisonLevel)
|
||||
@@ -395,6 +398,11 @@ namespace WaveshareUARTFingerprintSensor
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set comparison level used to compare fingerprints
|
||||
/// </summary>
|
||||
/// <param name="comparisonLevel">A value in 0..9 range, 9 is the strictest, default is 5</param>
|
||||
/// <returns></returns>
|
||||
public bool TrySetComparisonLevel(byte comparisonLevel)
|
||||
{
|
||||
if (comparisonLevel < 0 || comparisonLevel > 9)
|
||||
|
||||
@@ -13,5 +13,7 @@ namespace WaveshareUARTFingerprintSensor
|
||||
|
||||
public static (byte high, byte low) Split(ushort value) => ((byte)(value >> 8), (byte)(value & 0xFF));
|
||||
public static (byte first, byte second, byte third) Split(uint value) => ((byte)(value >> 16 & 0xFF), (byte)(value >> 8 & 0xFF), (byte)(value & 0xFF));
|
||||
|
||||
public static string ArrayDisplay<T>(T[] arr) => $"[ {string.Join(", ", arr)} ]";
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user