-2

I have this code in my C# program:

UsbRegistry reg = null;
if (productId == 0)
    reg = UsbDevice.AllDevices.FirstOrDefault(d => d.Vid.Equals(vendorId));
else
    reg = UsbDevice.AllDevices.FirstOrDefault(d => d.Vid.Equals(vendorId) 
          && d.Pid.Equals(productId));

if (reg != null)
    reg.Open(out _device);

UsbDevice.AllDevices property only list a USB fingerprint device, even when I have a USB printer also connected to a USB connector.

Printer is firmly connected and turned on, and in fact, if I print using Winspool driver, it works.

I need to bypass Winspool driver but printing directly sending bytes to USB port where the printer is attached.

What may be happening here?

This has been cross-posted to this Github issue

jstuardo
  • 3,901
  • 14
  • 61
  • 136
  • Please see https://meta.stackoverflow.com/questions/266053/is-it-ok-to-cross-post-a-question-between-non-stack-exchange-and-stack-exchange. You cross-posted this with https://github.com/LibUsbDotNet/LibUsbDotNet/issues/80. This is generally discouraged. –  Jan 08 '19 at 18:56
  • I don't think so. Github is the site were the developer publishes his work. It has an issue tab where one can post problems (bugs), however, for a lot of problems, never get a reply, for several reasons. Developer has abandoned the project or he is very busy to pay attention on issues or posted issue is not really a bug. StackOverflow is a complete different network where more people collaborate so it is more likely to have an answer here. It is also likely other has faced the same problem that already solved by himself or by somebody else's help. – jstuardo Jan 08 '19 at 20:30
  • 1
    You're *still* cross-posting. Having a good reason to post on multiple sites doesn't change the fact that you are posting on multiple sites. Just cite your opened issue here and there isn't a problem anymore. It's just good etiquette. Also, I know what Stack Overflow and Github issues are. I don't know why you are explaining what the sites are. –  Jan 08 '19 at 20:31
  • The point to this is rather simple. If someone answers on Github, we will know that, here on SO, and won't waste time answering an already answered question. And vice versa. It doesn't matter that you are posting on different kinds of sites. That is completely irrelevant, the problem is the same. Save us all some trouble and use good etiquette,. –  Jan 08 '19 at 20:38
  • I don't think so. By posting in 2 different sites, probabilities of getting an answer increases. Not all people in SO read GitHub issues, or vice versa. And even, sometimes I also post the same question in MSDN... that was not the case at this time, but if I don't get an answer in GitHub nor in SO, I will. You are talking about wasting time. Isn't it a waste of time sending all these comments not related to the answer of the question? Furthermore, what's wrong to have more than one answer? in GitHub and in SO? If you think better, even SO allows posting more than 1 answer. – jstuardo Jan 08 '19 at 23:05
  • 2
    You're missing the point. You can post in both places, but you should tell people. Once the question is answered in one place, people at the other place will know, and won't waste their time answering an already answered question. Please read the first link I pasted in my first comment. This has been good etiquette for 30+ years online. What you are insisting on doing is considered inappropriate, and some sites ban it outright. –  Jan 08 '19 at 23:36
  • 1
    Cross-posting [is banned between Stack Exchange sites](https://meta.stackexchange.com/questions/64068/is-cross-posting-a-question-on-multiple-stack-exchange-sites-permitted-if-the-qu). [Cross-posting etiquette](https://meta.stackexchange.com/questions/95615/cross-posting-etiquette). [Is cross-posting wrong?](https://meta.stackexchange.com/questions/141823/is-cross-posting-wrong-to-an-external-site) –  Jan 08 '19 at 23:44
  • 1
    "a lot of problems never get a reply for several reasons.... **posted issue is not really a bug**". Exactly. – Ben Voigt Jan 09 '19 at 00:40

1 Answers1

1

On Windows, libusb only supports a few drivers, please read https://github.com/libusb/libusb/wiki/FAQ#How_to_use_libusb_under_Windows

Your fingerprint device is found because it uses the HID driver (probably). Your printer is not HID, nor WinUSB.sys, nor LibusbK.sys It doesn't use "winspool driver" either (as your question wrongly claims). Winspool is a service not a device driver.

Use the printer API to find the device path, then open it with CreateFile and write to it. See the question you should have asked.

Ben Voigt
  • 277,958
  • 43
  • 419
  • 720