Last active
June 24, 2024 14:10
-
-
Save akechi-haruka/57ef36ba37fdbfbffffd95d26a8c0736 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| using AMDaemon; | |
| using System; | |
| using System.Threading; | |
| using System.IO; | |
| namespace aimereadtest { | |
| internal class Program { | |
| const string LOG = "aimereadtest.log"; | |
| static void Main(string[] args) { | |
| Run(); | |
| } | |
| static void Run() { | |
| if (File.Exists(LOG)) { | |
| File.Delete(LOG); | |
| } | |
| Log("Waiting for amdaemon..."); | |
| while (!Core.IsReady) { | |
| Core.Execute(); | |
| Thread.Sleep(100); | |
| } | |
| if (Aime.UnitCount <= 0) { | |
| Log("Invalid amdaemon config!"); | |
| Environment.Exit(1); | |
| return; | |
| } | |
| Log("Waiting for reader to be ready..."); | |
| var aime = Aime.Units[0]; | |
| while (!aime.CanStart) { | |
| Core.Execute(); | |
| Thread.Sleep(100); | |
| } | |
| Log(" --- Press any key to exit --- "); | |
| while (!Console.KeyAvailable) { | |
| Log("Waiting for card reader..."); | |
| while (aime.IsBusy) { | |
| Core.Execute(); | |
| if (Console.KeyAvailable) { | |
| Environment.Exit(0); | |
| return; | |
| } | |
| Thread.Sleep(100); | |
| } | |
| Log("Please scan a card"); | |
| aime.Start(AimeCommand.Scan); | |
| while (aime.IsBusy) { | |
| Core.Execute(); | |
| if (Console.KeyAvailable) { | |
| aime.Cancel(); | |
| Environment.Exit(0); | |
| return; | |
| } | |
| Thread.Sleep(100); | |
| } | |
| if (!aime.HasResult) { | |
| Log("No Result! (Aime reader disconnected?)"); | |
| continue; | |
| } | |
| if (aime.HasError) { | |
| Log("Error: " + aime.ErrorInfo.Number + ", " + aime.ErrorInfo.Category + ", " + aime.ErrorInfo.Message); | |
| } | |
| Log("Accesscode: " + aime.Result.AccessCode); | |
| Log("Authkey: " + aime.Result.SegaIdAuthKey); | |
| Log("Aime DB ID: " + aime.Result.AimeId); | |
| } | |
| Environment.Exit(0); | |
| } | |
| static void Log(String str) { | |
| File.AppendAllText(LOG, str); | |
| Console.WriteLine(str); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment