如何使用c#在USB端口上进行读写? [英] How I can Read/Write on USB port with c#?

查看:182
本文介绍了如何使用c#在USB端口上进行读写?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好.
我想在C#应用程序中将数据写入USB端口并从中读取数据.
USB端口已连接到打印机.
我看到了在串行端口上读写的源代码,但没有USB.我想要此源代码或库.请帮助我.
非常感谢.

Hello.
i want in c# application write data on usb port and read from it data.
usb port connected to printer.
i see source code write and read on serial port but not usb.i want source code or library for this.please help me.
Thanks a lot.

推荐答案

您不这样做.您正在尝试将USB端口与串行或并行端口相同.你不能那样做.

USB是BUS,而不是端口.您可以与连接到USB的设备进行通讯,而无需与端口本身进行通讯.

该如何操作取决于您要与之交谈的设备及其通常通过某些设备驱动程序公开的接口.
You don''t do this. You''re trying to treat the USB port the same as a serial or parallel port. You can''t do that.

USB is a BUS, not a port. You talk to the devices that are attached to USB, no to the port itself.

How you do that depends on the device you want to talk to and the interfaces it exposes, normally through some device driver.


这不像串行通信那么简单.

阅读这些文章以了解一个想法:
http://www.developerfusion.com/article/84338/making-usb-c-friendly / [ ^ ],
http://www.developerfusion.com/article/84302/usb-interface/ [ ^ ],
用于C#的USB HID组件 [ http://sushantkumar.wordpress.com/tech/c-code-4-usb/ [< ^ ].

查看此库: http://www.icsharpcode.net/OpenSource/SharpUSBLib/default.aspx [ ^ ].

—SA
This is not as trivial as serial communications.

Read these articles to get an idea:
http://www.developerfusion.com/article/84338/making-usb-c-friendly/[^],
http://www.developerfusion.com/article/84302/usb-interfacing/[^],
A USB HID Component for C#[^],
http://sushantkumar.wordpress.com/tech/c-code-4-usb/[^].

Look at this library: http://www.icsharpcode.net/OpenSource/SharpUSBLib/default.aspx[^].

—SA


这篇关于如何使用c#在USB端口上进行读写?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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