如何“猫”文件以特定的波特率?

发布于 2024-09-10 01:48:41 字数 417 浏览 0 评论 0原文

我正在使用 uCsim 对 SDCC 项目进行单元测试。

来模拟串行线路流量。

s51 -s /dev/tty PROGRAM.ihx

在uCsim/S51中,可以通过或

s51 -S in=testdata.in,out=testdata.out PROGRAM.ihx

在后一种形式中,数据立即发送到模拟器,这会导致大量帧丢失。因此,不要在纯文件中给出测试数据,而是使用管道:

s51 -S in=<(cat testdata.in),out=testdata.out PROGRAM.ihx

现在,我如何控制“cat”实用程序的输出波特率?或者是否有其他实用程序可以用来以特定速率输出位?

I'm using uCsim to do unit test on SDCC projects.

In uCsim/S51, you can simulate serial line traffic by

s51 -s /dev/tty PROGRAM.ihx

or

s51 -S in=testdata.in,out=testdata.out PROGRAM.ihx

In the latter form, the data is immediately sent to the simulator which causes a lot of frames are lost. So instead of given the test data in plain file, using pipe instead:

s51 -S in=<(cat testdata.in),out=testdata.out PROGRAM.ihx

Now, how can I control the output baud from the `cat' utility? Or is there another utility I can use to output bits in a specific rate?

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

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

发布评论

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

评论(2

美人骨 2024-09-17 01:48:41

您输入 in= 文件的速率并不是速率的设置方式。模拟器无法知道您的应用程序何时初始化串行端口并准备好读取。您可能会丢失数据,因为模拟器在执行串行初始化代码之前向模拟串行端口提供数据。

您需要做的是使用 mkfifo 设置一个 fifo 文件(请参阅手册页),然后将其用作 in= 参数。然后在模拟应用程序启动并运行后,向该 fifo 文件提供数据。

The rate you feed the in= file is not how the rate is set. The simulator has no way of knowing when your application has initialized the serial port and is ready to read. You are probably missing data because the simulator feeds the simulated serial port before your serial initialization code has executed.

What you need to do is set up a fifo file with mkfifo (see the man page) then use that as your in= parameter. Then feed that fifo file with data after your simulated application is up and running.

笑红尘 2024-09-17 01:48:41

答案1不正确。没有人将文件的内容“馈送到”串行线路。 uCsim 在需要时从文件中读取。波特率由定时器和UART 的SFR 控制。当模拟必要的刻度数时,将从文件中读取一个字节。

Answer 1 is incorrect. Nobody "feeds" file's content to serial line. uCsim reads fromthe file when it is necessary. Baud rate is controlled by SFRs of timer and uart. When necessary count of ticks are simulated, one byte will be read from the file.

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