Windows IoT - USB 打印机 [英] Windows IoT - USB Printer

查看:60
本文介绍了Windows IoT - USB 打印机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题类似于此线程中的问题Windows IoT - Zebra 蓝牙打印机.

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

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

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.

更新:所以,我为打印机安装了USB驱动程序,现在树莓可以看到它,但我仍然无法向打印机写入任何内容.现在我得到试图读取或写入受保护的内存"异常.我的代码:

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));

推荐答案

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

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>

详情请见: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

这篇关于Windows IoT - USB 打印机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆