使用/dev/tty* 进行 9 位 uart 仿真 [英] 9 bits uart emulation with /dev/tty*

查看:54
本文介绍了使用/dev/tty* 进行 9 位 uart 仿真的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个不常见的协议,它需要 9600 波特、9 位和一个停止位.我找不到任何可以实现此发送/接收的驱动程序.

I have a uncommon protocol, which requires 9600 baud, 9 bits and one stop bit. I can't find any driver, which can implement this sending/receiving.

我可以向 /dev/tty* 发送一些东西来模拟这些查询吗?我应该送什么?如何模拟 9600 波特率?

Can I send something to /dev/tty* for emulating these queries? What should I send? How can I emulate a 9600 baud rate?

推荐答案

您可以使用粘性奇偶校验,也称为 MARK 和 SPACE 奇偶校验.termios.h 支持这一点.但是,您需要在相应地发送地址或数据字节之前更改奇偶校验设置,并且取决于硬件,这可能会在两种类型的字节之间引入不希望的延迟.我使用 FT232RL & 经历了 0.4 毫秒到 10 毫秒的延迟.FT232BL USB 转串口转换器.我不确定,但我怀疑它也受到主板和您使用的 USB 端口(USB2 或 USB3)的影响.此外,在尝试更改奇偶校验模式之前,您需要确保发送缓冲区为空,因为它还会影响已放置在发送缓冲区中的字节的奇偶校验设置.

You can use sticky parity, which is also called MARK and SPACE parity. termios.h supports this. However, you need to change the parity settings before sending address or data bytes accordingly and depending on the hardware, this may introduce undesired delays between two types of bytes. I have experienced delays from 0.4 ms to 10 ms with FT232RL & FT232BL USB to serial converters. I'm not sure but I suspect that it's also affected by the motherboard and the USB port you use (USB2 or USB3). Also, you need to be sure that the transmit buffer is empty before attempting a parity mode change because it also affects the parity settings of the bytes that are already placed in the transmit buffer.

这篇关于使用/dev/tty* 进行 9 位 uart 仿真的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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