Windows IoT - USB Printer

♀尐吖头ヾ 提交于 2019-12-11 10:20:04

问题


The question is similar to question in this thread Windows IoT - Zebra Bluetooth Printer .

I have a Zebra GX420d printer. The only difference is, it is not connected via Bluetooth but via USB. I can't seem to get it paired with my raspberry pi 2. I need to print something out (like "Hello world"). Please help.

Update: So, i installed the usb driver for the printer, now the Raspberry can see it, but i still can't write anything to the printer. Now i get the "Attempted to read or write protected memory" Exception. My code:

private async void getObject()
        {
            var devices = await DeviceInformation.FindAllAsync();
            UInt32 vid = 0x0A5F;
            UInt32 pid = 0x0084;
            //Guid winusbInterfaceGuid = new Guid("532C0D5D-1122-4378-96D3-1BCDF8FB31A2");

            string aqs = UsbDevice.GetDeviceSelector(vid, pid);

            var myDevices = await Windows.Devices.Enumeration.DeviceInformation.FindAllAsync(aqs, null);

            if (myDevices.Count == 0)
            {
                return;
            }
            String str = "ABCDEFGH";
            IBuffer buffUTF8 = CryptographicBuffer.ConvertStringToBinary(str, BinaryStringEncoding.Utf8);

            UsbDevice device = await UsbDevice.FromIdAsync(myDevices[0].Id);
            var send = await device.SendControlOutTransferAsync(new UsbSetupPacket(buffUTF8));

回答1:


You likely need to also allow the USB capability. Here's how:

<DeviceCapability Name="usb">
    <Device Id="vidpid:xxxx xxxx">
      <Function Type="classId:xx xx xx"/>
      <Function Type="name:xxxxx"/>
      <Function Type="winUsbId:xxxxx"/>
    </Device>
</DeviceCapability>

Details here: https://msdn.microsoft.com/en-us/library/windows/apps/dn263092.aspx and here: https://msdn.microsoft.com/en-us/library/windows/hardware/dn303351(v=vs.85).aspx



来源:https://stackoverflow.com/questions/35056276/windows-iot-usb-printer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!