简体   繁体   English

如何使用USB访问数字I / O

[英]How to access Digital I/O using USB

如何使用C或C ++或Vb.net或C#.net使用USB访问数字I / O?

Easiest solution is possibly a USB-to-RS232 convertor. 最简单的解决方案可能是USB到RS232转换器。 They're cheap commodity products, supported on most OS'es, and trivial to access as SerialPort objects. 它们是廉价的商品产品,在大多数OS上都受支持,并且可以作为SerialPort对象轻松访问。 The physical side is a simple 5V, low-speed, low pincount interface suitable for both input and output. 物理端是一个简单的5V,低速,低引脚数接口,适用于输入和输出。

您可以在这里找到更多信息: http : //www.beyondlogic.org/

I use the Velleman K8055 USB EXPERIMENT INTERFACE BOARD 我使用的是Velleman K8055 USB实验接口板

It is simple to program for, and has several inputs and outputs 它易于编程,并具有多个输入和输出

I got one from Maplin for less than £30 我从Maplin买了一个不到30英镑的东西

If you want to write/read directly to/from USB device, in Windows you can easily use function CreateFile with param lpFileName as special device name. 如果要直接从USB设备写入数据/从USB设备读取数据,则可以在Windows中轻松使用函数CreateFile并将参数lpFileName作为特殊设备名称。 Example: 例:

HANDLE hFile = CreateFile(
"\\\\.\\X:", //X - is your USB device letter
GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ, //for example READ
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
NULL
);

Next you can work with your device as with normal file. 接下来,您可以像使用普通文件一样使用设备。 More information here 更多信息在这里

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM