C# SerialDevice no port information (Raspberry Pi 3)

113 views Asked by At

I have two USB receivers for bar-code scanners connected to a raspberry pi3 (Windows IOT Core).

I can connect to them and list the USB Virtual COM devices and connect to them and receive data. But I can't differentiate between the two, the IDs are identical and the system is not providing Port numbers.

When I call Current.portnumber.ToString() the string is empty.

I am hoping to assign each device to a person and have them scan a bar-code for their username and would like to display which scanner is associated with which person (Such as Com5 = Bill Com6 = Dave) but just can't find a unique identifier for each virtual com

private async void ListAvailablePorts()
        {
            try
            {
                string aqs = SerialDevice.GetDeviceSelector();
                var infos = await DeviceInformation.FindAllAsync(aqs);

                foreach (var info in infos)
                {
                    var serialDevice = await SerialDevice.FromIdAsync(info.Id);
                    DeviceInformation Current = info as DeviceInformation;
                    if (serialDevice != null && Current.Name == "USB Virtual COM")
                    {
                        listOfDevices.Add(Current);
                        ComList.Items.Add(Current.Name.ToString());
                    }
                }

                DeviceList.ItemsSource = listOfDevices;

                ComList.SelectedIndex = -1;
                DeviceList.SelectedIndex = -1;
            }
            catch (Exception ex)
            {
                txtUser.Text = ex.Message;
            }
        }
1

There are 1 answers

1
Rich Burgess On

After additional scrutiny I found that the ID fields are different on a single digit within an 86 character string.

\\?\USB#VID_0416&PID_5011#5&3753427a&0&5#{86e0d1e0-8089-11d0-9ce4-08003e301f73}

VS

\\?\USB#VID_0416&PID_5011#5&3753427a&0&2#{86e0d1e0-8089-11d0-9ce4-08003e301f73}

Thanks