Example #1
0
        private static UsbIo Open()
        {
            var serialNumbers = UsbIo.GetDevices();

            var serialNumberToOpen = _serialNumber;

            if (serialNumberToOpen == null)
            {
                if (serialNumbers.Length == 0)
                {
                    Console.WriteLine("No device found");
                    Environment.Exit(1);
                }

                serialNumberToOpen = serialNumbers[0];

                if (serialNumbers.Length > 1)
                {
                    Console.WriteLine($"Warning: multiple devices found, picked first: {serialNumberToOpen}");
                }
            }

            var device = new UsbIo(serialNumberToOpen);

            return(device);
        }
Example #2
0
        private static void ListDevices()
        {
            var serialNumbers = UsbIo.GetDevices();

            foreach (var serialNumber in serialNumbers)
            {
                Console.WriteLine("Device: " + serialNumber);
            }
        }