Windows IoT

编程入门 行业动态 更新时间:2024-10-28 21:23:11
本文介绍了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>

详情请见:msdn.microsoft/en-us/library/windows/apps/dn263092.aspx和这里:msdn.microsoft/en-us/library/windows/hardware/dn303351(v=vs.85).aspx

更多推荐

Windows IoT

本文发布于:2023-10-29 20:13:21,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1540642.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Windows   IoT

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!