List All UART Ports


	string AqsFilter = SerialDevice.GetDeviceSelector();
	var dis = await DeviceInformation.FindAllAsync(AqsFilter);
	for (Count = 0; Count < dis.Count; Count++)
		System.Diagnostics.Debug.WriteLine("UART Port: " + dis[Count].Name + ", " + dis[Count].Id);

Connect To A specific UART Port


	string AqsFilter = SerialDevice.GetDeviceSelector();
	var dis = await DeviceInformation.FindAllAsync(AqsFilter);
	for (Count = 0; Count < dis.Count; Count++)
	{
		if (dis[Count].Id.Contains("FTDI"))			//We are looking for a FDTI USB to serial USB device
			break;
	}
	if (Count < dis.Count)
	{
		//----- SERIAL PORT FOUND -----
		ConfigAppPort = await SerialDevice.FromIdAsync(dis[0].Id);

		//Configure serial settings
		ConfigAppPort.WriteTimeout = TimeSpan.FromMilliseconds(1000);    //mS before a time-out occurs when a write operation does not finish (default=InfiniteTimeout).
		ConfigAppPort.ReadTimeout = TimeSpan.FromMilliseconds(1000);     //mS before a time-out occurs when a read operation does not finish (default=InfiniteTimeout).
		ConfigAppPort.BaudRate = 9600;
		ConfigAppPort.Parity = SerialParity.None;
		ConfigAppPort.StopBits = SerialStopBitCount.One;
		ConfigAppPort.DataBits = 8;

 

Feel free to comment if you can add help to this page or point out issues and solutions you have found. I do not provide support on this site, if you need help with a problem head over to stack overflow.

Comments

Your email address will not be published. Required fields are marked *