使用C#从USB设备读取并向其发送查询 [英] Reading from USB device and sending queries to it, in C#

查看:73
本文介绍了使用C#从USB设备读取并向其发送查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已阅读以下内容: https://stackoverflow.com/questions/1176053/,这是一篇很有见地的文章.

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

但是,我在WMI方面没有很丰富的背景,并且我发现大量文档不胜枚举.我找不到我想要的东西.

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.

这种情况是,我有一台可以通过USB端口将数据发送到相关PC的声卡的设备.

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.

但是,连接和查询都是我在示例代码或MSDN上的System.Management文档中找不到的.

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

推荐答案

我认为WMI代码与您无关,我认为这只是能够获得有关该设备的基本信息.如果您想实际读取数据并向其发送数据,则必须使用其他API.
当我完成任何USB开发工作后,大部分时间都在使用HID,这非常简单,但是我认为您不能使用HID传输音频流,您需要使用Audio类驱动程序.尽管您可能需要使用HID来查找有关声卡的信息.

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的网站(USB Complete的作者)- http://janaxelson.com/usbc.htm

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

用于C#的USB HID组件- http://www.codeproject.com/KB/cs/USB_HID.aspx?msg=2004501

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

.NET的USB库- http://www.icsharpcode.net/OpenSource/SharpUSBLib/

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

用于网络摄像头应用程序的Java示例- http://www.mutong.com/fischer/java/usbcam/

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

这篇关于使用C#从USB设备读取并向其发送查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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