Skip to content

Commit

Permalink
add: reader select
Browse files Browse the repository at this point in the history
  • Loading branch information
NAVAL committed Dec 18, 2023
1 parent 045a28d commit 5784e92
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 3 deletions.
30 changes: 28 additions & 2 deletions src/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,33 @@ private static void Main(string[] args)
readerNames = context.GetReaders();
}

string readerName = readerNames[0];
string? readerName = null;

if (readerNames.Length > 1)
{
for (int i = 0; i < readerNames.Length; i++)
{
Console.WriteLine($"{i}: {readerNames[i]}");
}
while (readerName == null)
{
Console.Write("Select a reader -> ");
string? reader = Console.ReadLine();

if (int.TryParse(reader, out int index))
{
if (index < readerNames.Length)
{
readerName = readerNames[index];
}
}
}
}
else
{
readerName = readerNames[0];
}

using SCardReader rfidReader = new(context);

while (true)
Expand Down Expand Up @@ -90,7 +116,6 @@ private static void Main(string[] args)
{
Console.WriteLine("ERROR: Incorrect PIN.\n");
}
rfidReader.Disconnect(SCardReaderDisposition.Eject);
}
else
{
Expand All @@ -101,6 +126,7 @@ private static void Main(string[] args)
{
Console.WriteLine("ERROR Cannot select EF ICCID file.\n");
}
rfidReader.Disconnect(SCardReaderDisposition.Eject);
}
}
catch (Exception ex)
Expand Down
2 changes: 1 addition & 1 deletion src/aprt.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<Nullable>enable</Nullable>
<ApplicationIcon>Assets\sim.ico</ApplicationIcon>
<AssemblyName>$(MSBuildProjectName)</AssemblyName>
<AssemblyVersion>0.1</AssemblyVersion>
<AssemblyVersion>0.2</AssemblyVersion>
<FileVersion>$(AssemblyVersion)</FileVersion>
<Version>$(AssemblyVersion)</Version>
<AssemblyName>APRT</AssemblyName>
Expand Down
25 changes: 25 additions & 0 deletions src/aprt.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.4.33213.308
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "aprt", "aprt.csproj", "{8295542C-DF90-44D6-B986-341F5AB53F15}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{8295542C-DF90-44D6-B986-341F5AB53F15}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8295542C-DF90-44D6-B986-341F5AB53F15}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8295542C-DF90-44D6-B986-341F5AB53F15}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8295542C-DF90-44D6-B986-341F5AB53F15}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {7B20011A-286F-4720-9288-03C5053CFE84}
EndGlobalSection
EndGlobal

0 comments on commit 5784e92

Please sign in to comment.