-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
72 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
// Copyright (c) 2022, Olaf Kober <[email protected]> | ||
// Copyright (c) 2024, Olaf Kober <[email protected]> | ||
|
||
using System; | ||
using Amarok.Contracts; | ||
using Amarok.Shared; | ||
|
||
|
||
namespace InlayTester.Shared; | ||
namespace InlayTester.Drivers.Feig; | ||
|
||
|
||
/// <summary> | ||
|
@@ -97,8 +97,8 @@ public Int32 Calculate(in BufferSpan data) | |
|
||
private void _Setup() | ||
{ | ||
mCrcMask = ( ( ( (UInt64)1 << ( mOrder - 1 ) ) - 1 ) << 1 ) | 1; | ||
mCrcHighBit = (UInt64)1 << ( mOrder - 1 ); | ||
mCrcMask = ((((UInt64)1 << (mOrder - 1)) - 1) << 1) | 1; | ||
mCrcHighBit = (UInt64)1 << (mOrder - 1); | ||
|
||
_BuildTable(); | ||
_Prepare(); | ||
|
@@ -192,9 +192,9 @@ private static UInt64 _Reflect(UInt64 crc, Int32 bitnum) | |
UInt64 j = 1; | ||
UInt64 crcout = 0; | ||
|
||
for (var i = (UInt64)1 << ( bitnum - 1 ); i != 0; i >>= 1) | ||
for (var i = (UInt64)1 << (bitnum - 1); i != 0; i >>= 1) | ||
{ | ||
if (( crc & i ) != 0) | ||
if ((crc & i) != 0) | ||
{ | ||
crcout |= j; | ||
} | ||
|
@@ -218,7 +218,7 @@ private UInt64 _Calculate(Byte[] buffer, Int32 offset, Int32 count) | |
{ | ||
for (var i = offset; i < offset + count; i++) | ||
{ | ||
crc = ( crc << 8 ) ^ mCrcTable[( ( crc >> ( mOrder - 8 ) ) & 0xff ) ^ buffer[i]]; | ||
crc = (crc << 8) ^ mCrcTable[((crc >> (mOrder - 8)) & 0xff) ^ buffer[i]]; | ||
} | ||
} | ||
else | ||
|
@@ -227,7 +227,7 @@ private UInt64 _Calculate(Byte[] buffer, Int32 offset, Int32 count) | |
|
||
for (var i = offset; i < offset + count; i++) | ||
{ | ||
crc = ( crc >> 8 ) ^ mCrcTable[( crc & 0xff ) ^ buffer[i]]; | ||
crc = (crc >> 8) ^ mCrcTable[(crc & 0xff) ^ buffer[i]]; | ||
} | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
// Copyright (c) 2022, Olaf Kober <[email protected]> | ||
// Copyright (c) 2024, Olaf Kober <[email protected]> | ||
|
||
using System; | ||
using System.IO; | ||
|
@@ -203,7 +203,7 @@ public Task<FeigTransferResult> Transfer( | |
|
||
/// <summary> | ||
/// Executes the supplied command by sending a request to the reader/module and then waits for a | ||
/// corresponding response from the reader/module or for timeout, whatever comes first. This | ||
/// corresponding response from the reader/module or for timeout, whatever comes first. These | ||
/// methods throws appropriate exceptions for timeout, cancellation or failed operations. | ||
/// </summary> | ||
/// | ||
|
@@ -252,7 +252,7 @@ public async Task<FeigResponse> Execute( | |
|
||
if (result.Status == FeigTransferStatus.Success) | ||
{ | ||
if (result!.Response!.Status is FeigStatus.OK or FeigStatus.NoTransponder or FeigStatus.MoreData) | ||
if (result.Response!.Status is FeigStatus.OK or FeigStatus.NoTransponder or FeigStatus.MoreData) | ||
{ | ||
return result.Response; // success | ||
} | ||
|
@@ -303,7 +303,7 @@ public async Task<FeigResponse> Execute( | |
|
||
/// <summary> | ||
/// Executes the supplied command by sending a request to the reader/module and then waits for a | ||
/// corresponding response from the reader/module or for timeout, whatever comes first. This | ||
/// corresponding response from the reader/module or for timeout, whatever comes first. These | ||
/// methods throws appropriate exceptions for timeout, cancellation or failed operations. | ||
/// </summary> | ||
/// | ||
|
@@ -486,7 +486,7 @@ public async Task ResetCPU(TimeSpan? timeout = null, CancellationToken cancellat | |
|
||
/// <summary> | ||
/// The RF-field of the Reader antenna is switched off for approx. 6 ms. Thus, all transponders | ||
/// which are within the antenna field of the reader will be reset to their base setting. After a | ||
/// which are within the antenna field of the reader will be reset to their base setting. After an | ||
/// RF Reset a transponder which is located within the field has to be re-selected. | ||
/// </summary> | ||
/// | ||
|
@@ -551,7 +551,7 @@ public async Task ResetRF(TimeSpan? timeout = null, CancellationToken cancellati | |
/// </summary> | ||
/// | ||
/// <param name="flag"> | ||
/// A value indicating which RF field should switched on or off. Specify 0x00 to switch off all | ||
/// A value indicating which RF field should switch on or off. Specify 0x00 to switch off all | ||
/// antennas and 0x01 to switch on the first antenna. Look up more information in the reader's | ||
/// manual. | ||
/// </param> | ||
|
@@ -674,7 +674,7 @@ public async Task<FeigSoftwareInfo> GetSoftwareInfo( | |
FirmwareVersion = new Version(response.Data[0], response.Data[1], response.Data[2]), | ||
HardwareType = response.Data[3], | ||
ReaderType = (FeigReaderType)response.Data[4], | ||
SupportedTransponders = ( response.Data[5] << 8 ) | response.Data[6], | ||
SupportedTransponders = (response.Data[5] << 8) | response.Data[6], | ||
}; | ||
|
||
#region (logging) | ||
|
@@ -764,7 +764,7 @@ public async Task<BufferSpan> ReadConfiguration( | |
|
||
var addr = (Byte)0x00; | ||
addr |= (Byte)location; | ||
addr |= (Byte)( block & 0x3F ); | ||
addr |= (Byte)(block & 0x3F); | ||
|
||
mRequestBuffer[0] = addr; | ||
var data = BufferSpan.From(mRequestBuffer, 0, 1); | ||
|
@@ -873,15 +873,15 @@ async Task writeConfiguration() | |
|
||
var addr = (Byte)0x00; | ||
addr |= (Byte)location; | ||
addr |= (Byte)( block & 0x3F ); | ||
addr |= (Byte)(block & 0x3F); | ||
|
||
mRequestBuffer[0] = addr; | ||
|
||
Buffer.BlockCopy(data.Buffer, data.Offset, mRequestBuffer, 1, data.Count); | ||
|
||
var cfgdata = BufferSpan.From(mRequestBuffer, 0, 1 + data.Count); | ||
var cfgData = BufferSpan.From(mRequestBuffer, 0, 1 + data.Count); | ||
|
||
var response = await Execute(FeigCommand.WriteConfiguration, cfgdata, timeout, cancellationToken) | ||
var response = await Execute(FeigCommand.WriteConfiguration, cfgData, timeout, cancellationToken) | ||
.ConfigureAwait(false); | ||
|
||
#region (logging) | ||
|
@@ -1022,7 +1022,7 @@ public async Task SaveConfiguration( | |
|
||
#endregion | ||
|
||
mRequestBuffer[0] = (Byte)( block & 0x3F ); | ||
mRequestBuffer[0] = (Byte)(block & 0x3F); | ||
|
||
var data = BufferSpan.From(mRequestBuffer, 0, 1); | ||
|
||
|
@@ -1188,7 +1188,7 @@ public async Task ResetConfiguration( | |
|
||
var addr = (Byte)0x00; | ||
addr |= (Byte)location; | ||
addr |= (Byte)( block & 0x3F ); | ||
addr |= (Byte)(block & 0x3F); | ||
|
||
mRequestBuffer[0] = addr; | ||
|
||
|
@@ -1271,9 +1271,7 @@ public async Task ResetConfiguration( | |
|
||
var rspDat = response.Data; | ||
|
||
var result = response.Status == FeigStatus.NoTransponder | ||
? Array.Empty<FeigTransponder>() | ||
: Inventory_Parse(ref rspDat); | ||
var result = response.Status == FeigStatus.NoTransponder ? [] : Inventory_Parse(ref rspDat); | ||
|
||
#region (logging) | ||
|
||
|
@@ -1289,7 +1287,7 @@ public async Task ResetConfiguration( | |
|
||
#endregion | ||
|
||
return ( result, response ); | ||
return (result, response); | ||
} | ||
|
||
internal static FeigTransponder[] Inventory_Parse(ref BufferSpan data) | ||
|
@@ -1335,7 +1333,7 @@ private static FeigTransponder _Inventory_ParseSingle(ref BufferSpan data) | |
internal static FeigTransponder Inventory_Parse_ISO14443A(ref BufferSpan data) | ||
{ | ||
var info = data[0]; | ||
var length = ( info & 0x04 ) != 0 ? 10 : 7; | ||
var length = (info & 0x04) != 0 ? 10 : 7; | ||
var identifier = data.Slice(2, length); | ||
|
||
data = data.Discard(2 + length); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
// Copyright (c) 2022, Olaf Kober <[email protected]> | ||
// Copyright (c) 2024, Olaf Kober <[email protected]> | ||
|
||
using System; | ||
using System.Threading; | ||
|
@@ -111,7 +111,7 @@ CancellationToken cancellationToken | |
|
||
#endregion | ||
|
||
( (TaskCompletionSource<FeigTransferResult>)completionSource! ).TrySetResult( | ||
((TaskCompletionSource<FeigTransferResult>)completionSource!).TrySetResult( | ||
FeigTransferResult.Canceled(mRequest) | ||
); | ||
}, | ||
|
@@ -137,7 +137,7 @@ CancellationToken cancellationToken | |
|
||
#endregion | ||
|
||
( (TaskCompletionSource<FeigTransferResult>)completionSource! ).TrySetResult( | ||
((TaskCompletionSource<FeigTransferResult>)completionSource!).TrySetResult( | ||
FeigTransferResult.Timeout(mRequest) | ||
); | ||
}, | ||
|
@@ -193,7 +193,7 @@ private void _HandleReceived(BufferSpan data) | |
{ | ||
_CompleteWithError(result); | ||
} | ||
else if (result!.Response!.Command != mRequest!.Command) | ||
else if (result.Response!.Command != mRequest!.Command) | ||
{ | ||
_CompleteWithUnexpectedResponse(result); | ||
} | ||
|
4 changes: 3 additions & 1 deletion
4
src/InlayTester.Drivers.FeigReader/Drivers.Feig/FeigBlockLocation.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
// Copyright (c) 2022, Olaf Kober <[email protected]> | ||
// Copyright (c) 2024, Olaf Kober <[email protected]> | ||
|
||
// ReSharper disable InconsistentNaming | ||
|
||
using System; | ||
|
||
|
3 changes: 1 addition & 2 deletions
3
src/InlayTester.Drivers.FeigReader/Drivers.Feig/FeigChecksum.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,7 @@ | ||
// Copyright (c) 2022, Olaf Kober <[email protected]> | ||
// Copyright (c) 2024, Olaf Kober <[email protected]> | ||
|
||
using System; | ||
using Amarok.Shared; | ||
using InlayTester.Shared; | ||
|
||
|
||
namespace InlayTester.Drivers.Feig; | ||
|
4 changes: 3 additions & 1 deletion
4
src/InlayTester.Drivers.FeigReader/Drivers.Feig/FeigCommand.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
// Copyright (c) 2022, Olaf Kober <[email protected]> | ||
// Copyright (c) 2024, Olaf Kober <[email protected]> | ||
|
||
// ReSharper disable InconsistentNaming | ||
|
||
using System; | ||
|
||
|
4 changes: 3 additions & 1 deletion
4
src/InlayTester.Drivers.FeigReader/Drivers.Feig/FeigISOStandardCommand.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
// Copyright (c) 2022, Olaf Kober <[email protected]> | ||
// Copyright (c) 2024, Olaf Kober <[email protected]> | ||
|
||
// ReSharper disable InconsistentNaming | ||
|
||
using System; | ||
|
||
|
4 changes: 3 additions & 1 deletion
4
src/InlayTester.Drivers.FeigReader/Drivers.Feig/FeigReaderType.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
// Copyright (c) 2022, Olaf Kober <[email protected]> | ||
// Copyright (c) 2024, Olaf Kober <[email protected]> | ||
|
||
// ReSharper disable InconsistentNaming | ||
|
||
using System; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
// Copyright (c) 2022, Olaf Kober <[email protected]> | ||
// Copyright (c) 2024, Olaf Kober <[email protected]> | ||
|
||
using System; | ||
using System.Text; | ||
|
@@ -89,8 +89,8 @@ private BufferSpan _ToStandardProtocolFrame() | |
|
||
var crc = FeigChecksum.Calculate(BufferSpan.From(frame, 0, frameLength - 2)); | ||
|
||
frame[frameLength - 2] = (Byte)( crc & 0xff ); | ||
frame[frameLength - 1] = (Byte)( crc >> 8 ); | ||
frame[frameLength - 2] = (Byte)(crc & 0xff); | ||
frame[frameLength - 1] = (Byte)(crc >> 8); | ||
|
||
return BufferSpan.From(frame, frameLength); | ||
} | ||
|
@@ -101,17 +101,17 @@ private BufferSpan _ToAdvancedProtocolFrame() | |
var frame = new Byte[frameLength]; | ||
|
||
frame[0] = 0x02; | ||
frame[1] = (Byte)( frameLength >> 8 ); | ||
frame[2] = (Byte)( frameLength & 0xff ); | ||
frame[1] = (Byte)(frameLength >> 8); | ||
frame[2] = (Byte)(frameLength & 0xff); | ||
frame[3] = Address; | ||
frame[4] = (Byte)Command; | ||
|
||
Buffer.BlockCopy(Data.Buffer, Data.Offset, frame, 5, Data.Count); | ||
|
||
var crc = FeigChecksum.Calculate(BufferSpan.From(frame, 0, frameLength - 2)); | ||
|
||
frame[frameLength - 2] = (Byte)( crc & 0xff ); | ||
frame[frameLength - 1] = (Byte)( crc >> 8 ); | ||
frame[frameLength - 2] = (Byte)(crc & 0xff); | ||
frame[frameLength - 1] = (Byte)(crc >> 8); | ||
|
||
return BufferSpan.From(frame, frameLength); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
// Copyright (c) 2022, Olaf Kober <[email protected]> | ||
// Copyright (c) 2024, Olaf Kober <[email protected]> | ||
|
||
using System; | ||
using System.Text; | ||
|
@@ -105,7 +105,7 @@ private static FeigParseResult _TryParseAdvancedProtocolFrame(in BufferSpan span | |
|
||
var lenHigh = span[1]; | ||
var lenLow = span[2]; | ||
var frameLength = ( lenHigh << 8 ) | lenLow; | ||
var frameLength = (lenHigh << 8) | lenLow; | ||
|
||
if (span.Count < frameLength) | ||
{ | ||
|
@@ -118,7 +118,7 @@ private static FeigParseResult _TryParseAdvancedProtocolFrame(in BufferSpan span | |
|
||
var crcLow = span[frameLength - 2]; | ||
var crcHigh = span[frameLength - 1]; | ||
var crc = ( crcHigh << 8 ) | crcLow; | ||
var crc = (crcHigh << 8) | crcLow; | ||
|
||
var calcCrc = FeigChecksum.Calculate(BufferSpan.From(span.Buffer, span.Offset, frameLength - 2)); | ||
|
||
|
@@ -166,7 +166,7 @@ private static FeigParseResult _TryParseStandardProtocolFrame(in BufferSpan span | |
|
||
var crcLow = span[frameLength - 2]; | ||
var crcHigh = span[frameLength - 1]; | ||
var crc = ( crcHigh << 8 ) | crcLow; | ||
var crc = (crcHigh << 8) | crcLow; | ||
|
||
var calcCrc = FeigChecksum.Calculate(BufferSpan.From(span.Buffer, span.Offset, frameLength - 2)); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
// Copyright (c) 2022, Olaf Kober <[email protected]> | ||
// Copyright (c) 2024, Olaf Kober <[email protected]> | ||
|
||
// ReSharper disable InconsistentNaming | ||
|
||
using System; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
// Copyright (c) 2022, Olaf Kober <[email protected]> | ||
// Copyright (c) 2024, Olaf Kober <[email protected]> | ||
|
||
using System; | ||
using System.Text; | ||
|
@@ -67,7 +67,7 @@ public override String ToString() | |
|
||
|
||
/// <summary> | ||
/// Returns a result indicating a successfully transfer operation. | ||
/// Returns a result indicating a successful transfer operation. | ||
/// </summary> | ||
/// | ||
/// <exception cref="ArgumentNullException"> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
// Copyright (c) 2022, Olaf Kober <[email protected]> | ||
// Copyright (c) 2024, Olaf Kober <[email protected]> | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
|
@@ -10,7 +10,7 @@ namespace InlayTester.Drivers.Feig; | |
|
||
|
||
/// <summary> | ||
/// This type represents a RFID transponder consisting of type and identifier. | ||
/// This type represents an RFID transponder consisting of type and identifier. | ||
/// </summary> | ||
public sealed class FeigTransponder | ||
{ | ||
|
@@ -53,7 +53,7 @@ public override String ToString() | |
/// <summary> | ||
/// Returns a string representation for the given transponders. | ||
/// </summary> | ||
public static String ToString(IEnumerable<FeigTransponder> transponders) | ||
public static String ToString(IEnumerable<FeigTransponder>? transponders) | ||
{ | ||
if (transponders == null) | ||
{ | ||
|
4 changes: 3 additions & 1 deletion
4
src/InlayTester.Drivers.FeigReader/Drivers.Feig/FeigTransponderType.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
// Copyright (c) 2022, Olaf Kober <[email protected]> | ||
// Copyright (c) 2024, Olaf Kober <[email protected]> | ||
|
||
// ReSharper disable InconsistentNaming | ||
|
||
using System; | ||
|
||
|
Oops, something went wrong.