Windows IoT - USB打印机

时间:2016-01-28 08:27:09

标签: printing raspberry-pi2 zebra-printers windows-10-iot-core

问题类似于此帖子Windows IoT - Zebra Bluetooth Printer中的问题。

我有一台Zebra GX420d打印机。唯一的区别是,它不通过蓝牙连接,而是通过USB连接。我似乎无法将它与我的树莓派2配对。我需要打印一些东西(例如" Hello world")。请帮忙。

更新: 所以,我为打印机安装了usb驱动程序,现在Raspberry可以看到它,但我仍然无法向打印机写任何东西。现在我得到"尝试读取或写入受保护的内存"例外。 我的代码:

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 个答案:

答案 0 :(得分:1)

您可能还需要允许USB功能。方法如下:

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

详细信息: https://msdn.microsoft.com/en-us/library/windows/apps/dn263092.aspx 和这里: https://msdn.microsoft.com/en-us/library/windows/hardware/dn303351(v=vs.85).aspx