使用DMA访问高速串口 [英] Using DMA to access High Speed Serial Port

查看:54
本文介绍了使用DMA访问高速串口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 c# 中使用了串行端口组件,它运行良好!但问题是如何才能更快地处理高速(例如 2 Mbps)数据传输.

I use serialport component in c# and it works well! But the question is how can it be faster to handle high speed (e.g. 2 Mbps) data transfers.

由于我对此进行了研究,我发现可以直接访问内存(使用像 此链接 ).谁能告诉我如何在我的应用程序中定义和使用它?

As I have researched about this, I have found that memory can be accessed directly (using DMA like this link ). Can anybody tell me how can I define and use it in my application?

推荐答案

不,[c#] 标签使这变得遥不可及.该网页上的代码片段不是真实的,它只是一个模式".它可以完成在 C# 中无法完成的事情,例如处理中断、获取缓冲区的物理内存地址、直接对设备寄存器进行编程.在可以执行 C# 代码的机器上,不包括 Micro Framework,这只能由设备驱动程序来完成.

No, the [c#] tag puts this a million miles out of reach. The code snippet on that web page is not real, it is just a "pattern". It does things you cannot do in C#, like handling interrupts, obtaining the physical memory address of buffers, directly programming the device registers. On the kind of machines that can execute C# code, not counting the Micro Framework, this can only be done by device drivers.

这将是一种可以在微控制器上运行的代码,一种不与保护模式操作系统一起运行的处理器.即便如此,它仍然是拉伸,它通过未声明的魔法调用 DMA,例如,从不实际开始传输时的传输.也没有 DMA 控制器的迹象,需要仲裁设备之间的总线访问.这是假代码.

It would be the kind of code that could run on a micro-controller, the kind of processor that doesn't run with a protected-mode operating system. Even then it is stretch, it invokes DMA by unstated magic, never actually starting the transfer on a transmit for example. No sign of a DMA controller either, required to arbitrate bus access between devices. It is fake code.

当你使用真正的硬件时,你总是会得到一个设备驱动程序,它负责与设备通信.如果设备实际上支持 DMA,非常不寻常,那么设备驱动程序程序员不会避免使用它.您在 C# 程序中使用的 SerialPort 类使用操作系统 API,该 API 对任何类型的串行端口设备都是通用的.它将您的 I/O 请求传递给设备驱动程序以完成工作.

When you use real hardware you always get a device driver with it that takes care of talking to the device. If the device actually supports DMA, very unusual, then the device driver programmer would not avoid using it. The SerialPort class you use in a C# program uses the operating system api, one that's universal for any kind of serial port device. It passes your I/O requests to the device driver to get the job done.

操作系统 api 和设备驱动程序之间的接口由 IOCTL 覆盖.此 MSDN 页面 记录了 Windows 的页面.IOCTL 和 api 之间的匹配非常接近,api 层非常薄.当您仔细观察时,很明显它们都与 DMA 无关.他们不能,这是严格的驱动程序实现细节.

The interface between the operating system api and the device driver is covered by IOCTLs. This MSDN page documents the ones for Windows. There's a pretty close match between the IOCTLs and the api, the api layer is pretty thin. When you take a closer look, it will be obvious that none of them have anything to do with DMA. They can't, it is strictly a driver implementation detail.

这篇关于使用DMA访问高速串口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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