1

该问题与此线程中的问题类似Windows IoT - Zebra Bluetooth PrinterWindows物联网 - USB打印机

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

更新: 所以,我安装了打印机的USB驱动程序,现在树莓可以看到它,但我仍然不能写任何东西到打印机。现在我得到“尝试读取或写入受保护的内存”异常。 我的代码:

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

回答