为什么.NET框架不包含USB工具

发布于 2024-08-20 16:04:24 字数 181 浏览 4 评论 0原文

我想知道为什么 .NET 框架不提供任何使用 USB 驱动程序的托管方法。从我读到的所有内容来看,您仍然必须调用 Windows API 并使用编组和 PInvoke 以及我们 .NET 程序员都不想做的所有废话。为什么.NET提供了与串行端口通信的方法而不是USB端口?现在USB已经比串行端口使用得更广泛了,现在不正是他们将其纳入框架的时候吗?

I am wondering why the .NET framework does not provide any managed methods for working with USB drivers. From everything I have read you still have to call into Windows API's and use marshalling and PInvoke and all that crap that none of us .NET programmers want to have to do. Why does .NET provide methods for communicating with serial ports but not USB ports? USB has become much more widely used that serial ports now, isn't it time they incorporated it into the Framework?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

沦落红尘 2024-08-27 16:04:24

与 .Net 框架中的所有其他功能一样,它归结为成本与回报。随着 .Net 的每次发布,所有者都必须对功能做出非常痛苦的削减决定。有太多的要求/想要满足他们所有人。所选择的企业需要以合理的成本提供明确的价值。

我的猜测是,串行端口虽然可能不如 USB 流行,但更容易在托管代码中实现。因此,尽管使用率可能不那么高,但实施起来相对容易,使它们处于领先地位。

Like all other features in the .Net framework it comes down to cost vs. reward. With every release of .Net the owners have to make very painful cut decisions for features. There are simply too many requests / wants to satsify them all. The ones that are chosen need to provide clear value at a reasonable cost.

My guess is that Serial Ports, while probably less popular than USB, are simply easier to implement in managed code. Hence even though the use may not be as high, the relative easy of implementing them put them over the top.

冷情 2024-08-27 16:04:24

USB只是一种总线。与设备通信的方式取决于总线另一端的芯片。没有一种与所有设备通信的标准化方法。

如果 USB 设备提供商希望以标准方式公开设备(他们中的大多数确实符合标准,以节省开发、记录和向客户介绍其 API 的成本),他们的驱动程序程序员可以编写驱动程序,使设备可用于各种Windows API(海量存储、WIA、DirectShow、虚拟串口、蓝牙、人机接口设备等)。同样,由于标准化驱动程序已经暴露给 Windows API,因此 .Net 不需要直接与硬件对话。

USB is just a bus. The way you communicate to the device depends on the chip at the other side of bus. There isn't a standardized way to talk to all devices.

If a USB device provider want to expose the device to a standard way (most of them do conform to standards to save costs on develop, document, and educate clients about their APIs), their driver programmers can write drivers that make the device available to various Windows APIs (massive storage, WIA, DirectShow, virtual serial port, bluetooth, Human Interface Device, etc). Again, since standardized drivers are already exposed to Windows API, there is no need for .Net to talk to hardware directly.

迷离° 2024-08-27 16:04:24

If you're looking to interface with an HID compatible USB device you might take a look at CC.USBHID. It's old and nasty but might get you going in the right direction. There might be more mature projects available.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文