문제

Are there any USB developers out there who use .NET?

I know one way of communicating with USB HID device is creating wrappers to the Windows API's like CreateFile, WriteFile and ReadFile. But I am wondering does anyone know if you can use any of the .NET classes to do the same thing. I am certain that I will still have to use some of the API's for operations like detecting which devices are on the bus and requesting the dectriptors but I am looking for a .NET method of sending/receiving reports? I am thinking, for example, that I could use the Stream Class or StreamWriter and StreamReader but I don't know.

도움이 되었습니까?

해결책

The System.IO.FileStream class is a highly suitable replacement. Its constructor calls CreateFile(), its Read method calls ReadFile(), its Write method calls WriteFile(). You should have little trouble matching the FileAcces, FileMode and FileShare enums to the corresponding CreateFile() arguments. You will however have to P/Invoke the SetupAPI functions.

다른 팁

Probably have more luck using a library that wraps all the P/Invoke calls for you. One I've looked at is HidLibrary.

FileStream is working well enough for me, though mine is a very simple USB implementation.

I use CreateFile to initially set up the device,but then do all the reading and writing to the device through the FileStream object.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top