locked
Windows 8.1 USB serial port

    Question

  • Hi,

    is it possible access to custom device (EEPROM RFID reader) by USB serial port? I'm trying to use UsbDevice, which was added to windows 8.1, but access is denied by system. Is other way to do it?

    Here is my sample code:

    string aqs = "System.Devices.InterfaceClassGuid:=\"{Guid}\"";
    var myDevices = await Windows.Devices.Enumeration.DeviceInformation.FindAllAsync(aqs);
    UsbDevice device = await UsbDevice.FromIdAsync(myDevices[0].Id);
     
    if(device == null)
    {
      var deviceAccessStatus = DeviceAccessInformation.CreateFromId(myDevices[0].Id).CurrentStatus;
    }

    and manifest:

    <m2:DeviceCapability Name="usb">
          <m2:Device Id="vidpid:0403 6001">
            <m2:Function Type="classId:ff * *"/>
          </m2:Device>
    </m2:DeviceCapability>

    Thanks 


    Wednesday, December 11, 2013 6:07 PM

Answers

  • Hi FlowSvk,

    I'd like to know if have fulfill the requirements below:

    Before getting a reference to the UsbDevice object, you must have one of these identifiers:

    • The vendor and product identifiers for the physical device. Those identifiers are part of the hardware ID string. You can obtain that string from the Models section in the INF file. Alternatively, if WinUSB was loaded based on the compatible ID specified in the device descriptor, you can derive the identifiers from the Hardware Ids property in  Device Manager. For example, if Hardware Id is "USB\VID_045E&PID_078E", vendor ID is "0x045E"  and product Id is "0x078E".
    • The device interface GUID. You can obtain that GUID from the DeviceInterfaceGuids registry entry under this key:

      HKEY_LOCAL_MACHINE\System\CurrentControlSet\Enum\USB\<Device Identifier>\<Instance Identifier>\Device Parameters

    • The device's class, subclass, and protocol codes. You can obtain that information from the CompatibleIds registry entry, found under the Device Parameters key.

    To get the UsbDevice object:

    1. Get the Advanced Query Syntax (AQS) string that contains search criteria for finding the device in the enumerated device collection. If you want to search by the vendor ID/product ID or the device interface GUID, call GetDeviceSelector. If you want to search by the device class, call GetDeviceClassSelector. Both calls retrieve formatted AQS strings.
    2. Pass the retrieved string to FindAllAsync. The call retrieves a DeviceInformationCollection object.
    3. Loop through the collection. Each iteration gets a DeviceInformation object.
    4. Get the DeviceInformation.Id property value. The string value is the device instance path. For example, "\\\\?\\USB#VID_045E&PID_078F#6&1b8ff026&0&5#{dee824ef-729b-4a0e-9c14-b7117d33a817}".
    5. Call FromIdAsync by passing the device instance string and get the UsbDevice object.

    And make sure that you have declared the "USB" capability in app manifest.

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.


    Friday, January 3, 2014 5:24 AM
    Moderator

All replies

  • Hi FlowSvk,

    I’m afraid that it is not the correct forum about this issue, since this forum is to discuss Visual C#. I am moving your question to the moderator forum ("Where is the forum for..?"). The owner of the forum will direct you to a right forum. Thanks for your understanding.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, December 12, 2013 6:22 AM
  • I'd probably ask them over here.

    http://social.msdn.microsoft.com/Forums/windowsdesktop/en-US/home?forum=wdk%2Cwhck&filter=alltypes&sort=lastpostdesc

     

     

     


    Regards, Dave Patrick ....
    Microsoft Certified Professional
    Microsoft MVP [Windows]

    Disclaimer: This posting is provided "AS IS" with no warranties or guarantees , and confers no rights.

    • Proposed as answer by Just Karl Friday, December 13, 2013 3:45 PM
    Friday, December 13, 2013 1:27 AM
  • Hi FlowSvk,

    I'd like to know if have fulfill the requirements below:

    Before getting a reference to the UsbDevice object, you must have one of these identifiers:

    • The vendor and product identifiers for the physical device. Those identifiers are part of the hardware ID string. You can obtain that string from the Models section in the INF file. Alternatively, if WinUSB was loaded based on the compatible ID specified in the device descriptor, you can derive the identifiers from the Hardware Ids property in  Device Manager. For example, if Hardware Id is "USB\VID_045E&PID_078E", vendor ID is "0x045E"  and product Id is "0x078E".
    • The device interface GUID. You can obtain that GUID from the DeviceInterfaceGuids registry entry under this key:

      HKEY_LOCAL_MACHINE\System\CurrentControlSet\Enum\USB\<Device Identifier>\<Instance Identifier>\Device Parameters

    • The device's class, subclass, and protocol codes. You can obtain that information from the CompatibleIds registry entry, found under the Device Parameters key.

    To get the UsbDevice object:

    1. Get the Advanced Query Syntax (AQS) string that contains search criteria for finding the device in the enumerated device collection. If you want to search by the vendor ID/product ID or the device interface GUID, call GetDeviceSelector. If you want to search by the device class, call GetDeviceClassSelector. Both calls retrieve formatted AQS strings.
    2. Pass the retrieved string to FindAllAsync. The call retrieves a DeviceInformationCollection object.
    3. Loop through the collection. Each iteration gets a DeviceInformation object.
    4. Get the DeviceInformation.Id property value. The string value is the device instance path. For example, "\\\\?\\USB#VID_045E&PID_078F#6&1b8ff026&0&5#{dee824ef-729b-4a0e-9c14-b7117d33a817}".
    5. Call FromIdAsync by passing the device instance string and get the UsbDevice object.

    And make sure that you have declared the "USB" capability in app manifest.

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.


    Friday, January 3, 2014 5:24 AM
    Moderator
  • Hello,

    I am having the exact same problem with my USB device (GPS USB device), it is "denied by system". Here is my full post on my issue:

    http://social.msdn.microsoft.com/Forums/en-US/90b4804a-dfbd-4381-943e-19a70343ac18/cant-access-a-usb-device-usb-gps-via-the-winjs-apis?forum=winappswithhtml5

    Did you get to find the problem?

    Thanks a lot!

    Fabien

    Sunday, September 21, 2014 9:51 AM