static async Task RunBlink() { while (true) { Console.Write("Waiting for board..."); // Get a reference to the first TreehopperUsb board connected. This will await indefinitely until a board is connected. Board = await ConnectionService.Instance.GetFirstDeviceAsync(); Console.WriteLine("Found board: " + Board); Console.WriteLine("Version: " + Board.VersionString); // You must explicitly connect to a board before communicating with it await Board.ConnectAsync(); Console.WriteLine("Start blinking. Press any key to stop."); while (Board.IsConnected && !Console.KeyAvailable) { // toggle the LED. Board.Led = !Board.Led; await Task.Delay(100); } Board.Disconnect(); } }
static void Main(string[] args) { RunApp(); Console.Read(); board.Disconnect(); Environment.Exit(0); }
static async Task App() { Console.Write("Waiting for board..."); // Get a reference to the first TreehopperUsb board connected. This will await indefinitely until a board is connected. TreehopperUsb Board = await ConnectionService.Instance.GetFirstDeviceAsync(); Console.WriteLine("Found board: " + Board); // You must explicitly open a board before communicating with it await Board.ConnectAsync(); Board.Uart.Mode = UartMode.OneWire; Board.Uart.Enabled = true; List <UInt64> addresses = await Board.Uart.OneWireSearchAsync(); Console.WriteLine("Found addresses: "); foreach (var address in addresses) { Console.WriteLine(address); } Board.Disconnect(); }
static void Main(string[] args) { App().Wait(); board.Disconnect(); Console.WriteLine("Board disconnected"); }