コード例 #1
0
ファイル: MainPage.xaml.cs プロジェクト: Ellerbach/BrickPi
        /// <summary>
        /// This functions initimlaize a serial port and pass it to the brick
        /// </summary>
        /// <returns></returns>
        private async Task InitSerial()
        {
            string aqs = SerialDevice.GetDeviceSelector();
            var dis = await DeviceInformation.FindAllAsync(aqs);

            for (int i = 0; i < dis.Count; i++)
            {
                Debug.WriteLine(string.Format("Serial device found: {0}", dis[i].Id));
                if (dis[i].Id.IndexOf("UART0") != -1)
                {
                    serialPort = await SerialDevice.FromIdAsync(dis[i].Id);
                }
            }
            if (serialPort != null)
            {
                Debug.WriteLine("Serial port initialiazed");
                brick = new Brick(serialPort);
                Debug.WriteLine("Brick initialiazed");
            }

        }