BeagleBone Black UART软件FIFO的大小是多少? [英] BeagleBone Black UART software FIFO size?

查看:236
本文介绍了BeagleBone Black UART软件FIFO的大小是多少?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在BeagleBone Black上开发一个自定义应用程序,该应用程序必须通过BBB上运行的Debian Linux使用设备的UART功能,以读取大块数据.为了从UART读取,我使用open() 从此端口读取功能:

I'm developing a custom application on the BeagleBone Black that has to use the UART capabilities of the device via the Debian Linux that runs on the BBB, for reading big chunks of data. For reading from the UART I'm opening one of the /dev/ttyO0, /dev/ttyO1, etc. devices with the open() function in nonblocking mode. And then I'm trying to read from this port with the read(2) function:

ssize_t read(int fd, void *buf, size_t count);

我想知道参数count的最大合理数字是多少,它与UART的FIFO缓冲区有何关系?

I would like to know what is the biggest reasonable number for the parameter count and how is it related to the UART's FIFO buffer?

在AM335x技术参考手册(TI文档spruh73p,第4328页,第19.3.6节)中,我可以看到HW缓冲区的长度为64个字节.但是,正如我怀疑使用read()函数那样,我的程序没有直接与硬件fifo缓冲区通信,而是从Linux的串行驱动程序的软件缓冲区(如果有)中读取数据.这是真的?如果是,fifo软件的大小是多少?有人可以帮我启发一下这个领域吗?

In the AM335x technical reference manual (TI document spruh73p, page 4328, section 19.3.6) I can see that the HW buffer is 64 bytes long. But, as I suspect by using the read() function my program is not communicating directly with the hardware fifo buffer but it is reading from Linux' serial driver's software buffer (if there is such). Is this true? If yes, what is the size of the software fifo? Could somebody please enlighten this field for me?

推荐答案

然后我尝试使用read(2)函数从该端口读取

And then I'm trying to read from this port with the read(2) function

实际上,您是从硬件设备中删除了几层,而不是从端口" 中读取了串行终端的系统缓冲区.

Rather than the "port", you are actually several layers removed from the hardware device, and reading from the system buffer of the serial terminal.

我想知道参数计数的最大合理数字是多少,它与UART的FIFO缓冲区有何关系?

I would like to know what is the biggest reasonable number for the parameter count and how is it related to the UART's FIFO buffer?

首先,count不得大于提供的用户缓冲区.
对于阻塞的 read(),您可以将此count设置为与您可以分配的任何缓冲区一样大.
对于无阻塞的 read(),比终端接收缓冲区大的count毫无意义.
请注意,count仅仅是一个请求, read()系统调用返回的字节数可以少于请求的字节数.

First of all the count must be no larger than the user buffer provided.
For a blocking read(), you could probably make this count as large as any buffer you could allocate.
For a nonblocking read(), a count larger than the terminal receive buffer makes little sense.
Note that count is merely a request, and the read() syscall can return with less than the requested number of bytes.

UART FIFO和串行端口驱动程序缓冲区的大小与用户空间中的任何 read()请求无关.
请参见 Linux串行驱动程序.

The sizes of the UART FIFO and serial port driver buffers are irrelevant to any read() requests from userspace.
See Linux serial drivers.

...正在从Linux的串行驱动程序的软件缓冲区中读取(如果有的话).这是真的?

... it is reading from Linux' serial driver's software buffer (if there is such). Is this true?

差不多.
用户空间中的 read()系统调用从终端缓冲区中获取数据.
终端驱动程序是比串行端口驱动程序更高级别的驱动程序.

Almost.
The read() syscall from userspace fetches data from the terminal buffer.
The terminal driver is a higher-level driver than the serial port driver.

终端缓冲区与UART FIFO没有直接连接.
如果使用DMA,则数据将从UART FIFO传输到DMA缓冲区.
如果使用PIO,则数据将从UART FIFO传输到驱动器缓冲区.
无论哪种情况,串行端口驱动程序最终都会将数据传输到tty翻转缓冲区.
在非中断模式下,来自tty翻转缓冲区的数据将传输到终端/线路规则缓冲区.
再次参考 Linux串行驱动程序.

The terminal buffer has no direct connection to the UART FIFO.
If DMA is employed, then data is transferred from the UART FIFO to a DMA buffer.
If PIO is employed, then data is transferred from the UART FIFO to a driver buffer.
In either case the serial port driver eventually transfers the data to a tty flip buffer.
In non-interrupt mode, data from the tty flip buffer is transferred to the terminal/line-discipline buffer.
Again refer to Linux serial drivers.

如果是,fifo软件的大小是多少?

If yes, what is the size of the software fifo?

终端接收缓冲区通常为4096字节,尽管您可以编写自己的具有不同大小的线路规则,或者重新定义宏.
来自 include/linux/tty.h 在Linux内核源代码中:

The terminal receive buffer is typically 4096 bytes, although you could write your own line discipline with a different size, or redefine the macro.
From include/linux/tty.h in Linux kernel source:

#define N_TTY_BUF_SIZE 4096

终端驱动程序是Linux支持的所有体系结构所共有的,因此您的BBB应该具有4096字节的终端缓冲区.

The terminal driver is common to all architectures supported by Linux, so your BBB should have a terminal buffer of 4096 bytes.

这篇关于BeagleBone Black UART软件FIFO的大小是多少?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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