Reading from USB device and sending queries to it, in C#

12,464

I don't think that WMI code would be relevant for you, I think that's just able to get out basic information about the device. If you want to actually read and send data to it you'll have to use different APIs.
When I've done any USB develoment it's been mostly using HID which is fairly straightforward, but I don't think you can transfer audio streams using HID, you'll need to use the Audio class driver. Though you might need to use HID to find out information about the soundcard.

Some useful links to get you started are:

Jan Axelson's website (author of USB Complete) - http://janaxelson.com/usbc.htm

A USB HID Component for C# - http://www.codeproject.com/KB/cs/USB_HID.aspx?msg=2004501

A USB library for .Net - http://www.icsharpcode.net/OpenSource/SharpUSBLib/

A Java sample for a webcam app - http://www.mutong.com/fischer/java/usbcam/

Share:
12,464
KdgDev
Author by

KdgDev

Updated on June 19, 2022

Comments

  • KdgDev
    KdgDev almost 2 years

    I've read this: https://stackoverflow.com/questions/1176053/, which was an insightful article.

    However, I have no great background in WMI, and I found the large amount of documentation to be overwhelming. I can't find what I'm looking for.

    The situation is that I have a device that will send data over the USB port, to the soundcard of the PC in question.

    Consider camera-software. You connect your camera, start the program, and you can control the program with the camera, and vica versa. For instance, you can press a button on the camera and it'll start transmitting to the program. Or you can click a button in the program and it will start querying for data.

    I need to find a way to query and catch this data, safely and correct. It's probably a Stream of bytes, but searching for that doesn't produce any results.

    I'm thinking I first need to somehow connect. Then send the query. Then receive.

    However, connecting and querying both is something that I can't find in the example code, or the System.Management documentation on MSDN.