Compare commits

...

6 Commits

Author SHA1 Message Date
23c6036924 Add doc comments 2020-12-01 16:17:25 +01:00
5a061d7600 Fix TryQueryPermission 2020-12-01 16:13:16 +01:00
e295afd899 Fix TryComparison1N
Should sleep more
2020-12-01 16:07:21 +01:00
6f5ff3ce00 Fix ReadData
Stupid serial
2020-12-01 15:53:13 +01:00
80e67f3afc Add ArrayDisplay Utils method 2020-12-01 15:33:43 +01:00
7b5716b8f3 Fix ComputeChecksumData 2020-12-01 15:33:08 +01:00
2 changed files with 14 additions and 4 deletions

View File

@@ -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)

View File

@@ -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)} ]";
}
}