Why the .NET framework does not include USB tools

I am wondering why the .NET framework does not provide any controlled methods for working with USB drivers. Of all that I read, you still have to call the Windows API and use marshalling and PInvoke and all that shit that none of us want .NET programmers to do. Why does .NET provide methods for communicating with serial ports, but not with USB ports? USB has become much more widely used, now serial ports, is it time to turn it on in the Framework?

+4
source share
3 answers

Like all other features in the .Net infrastructure, it comes down to cost and reward. With each release of .Net, owners must make very painful decisions to solve problems. Just too many requests / wants to satatize them. Those selected should provide clear value at a reasonable price.

I assume that Serial Ports, although less popular than USB, is easier to implement in managed code. Therefore, although the use may not be so high, the relative ease of their implementation puts them on top.

+10
source

USB is just a bus. The way you communicate with the device depends on the chip on the other side of the bus. There is no standardized way to communicate with all devices.

If the USB device vendor wants to expose the device in a standard way (most of them are compliant with the standards to save the cost of developing, documenting and training customers regarding their APIs), their driver programmers can write drivers that make the device available for different Windows APIs (massive storage, WIA, DirectShow, virtual serial port, Bluetooth, user interface device, etc.). Again, since standardized drivers are already open for the Windows API, there is no need for .Net to speak directly to the hardware.

+3
source

If you want to interact with a HID-compatible USB device, you can take a look at CC.USBHID . It's old and nasty, but it can make you go in the right direction. More mature designs are available.

0
source

Source: https://habr.com/ru/post/1300510/


All Articles