读取设备数据流中缺少流控制数据

读取设备数据流中缺少流控制数据

本文介绍了读取设备数据流中缺少流控制数据(0x13)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经写了一个Linux应用来阅读&通过模拟串行端口的USB端口将二进制数据写入远程设备.

I have written a Linux app to read & write binary data to a remote device over a USB port that is emulating a serial port.

当我从设备读取数据时,我有一个USB嗅探器,它显示了这样的二进制数据流(0x01,0x0A ...... 0x13),但是当我的程序读取字节时,0x13不在字节流-这是XOFF字符,但我没有使用XON/XOFF流控制(我认为).

When I read data from the device, I have a USB sniffer that shows a binary data stream like this (0x01, 0x0A......0x13), but when my program reads the bytes, the 0x13 is not in the byte stream - this is the XOFF char, but I am not using XON/XOFF flow control (I think).

尝试以二进制方式打开读取和写入,以及fopen fread和fwrite,结果相同.有什么想法吗?

Tried both open read and write, as well as fopen fread and fwrite in binary mode, same result. Any ideas?

推荐答案

感谢任何答复,例如网站.原来显示的姿势:

Thanks for any responses, like the website. Turns out stty showed:

# stty -F /dev/ttyUSB0

speed 115200 baud;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>;
eol2 = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W;
lnext = ^V; flush = ^O; min = 0; time = 10;
-brkint -imaxbel
-opost
-isig -icanon -echo -echoe

即使似乎流量控制已关闭,解决方案是使用cfmakeraw设置查看所有字符并且什么都不忽略.

Even though it looked like flow control was off,The solution was to use cfmakeraw settings to see ALL characters and ignore nothing.

cfmakeraw()将终端设置为类似于旧版本7终端驱动程序的原始"模式:逐字符可用输入,禁用回显,并且禁用终端输入和输出字符的所有特殊处理.终端属性设置如下:

cfmakeraw() sets the terminal to something like the "raw" mode of the old Version 7 terminal driver: input is available character by character, echoing is disabled, and all special processing of terminal input and output characters is disabled. The terminal attributes are set as follows:

termios_p->c_iflag &= ~(IGNBRK | BRKINT | PARMRK | ISTRIP
            | INLCR | IGNCR | ICRNL | IXON);
termios_p->c_oflag &= ~OPOST;
termios_p->c_lflag &= ~(ECHO | ECHONL | ICANON | ISIG | IEXTEN);
termios_p->c_cflag &= ~(CSIZE | PARENB);
termios_p->c_cflag |= CS8;

现在可以查看我的所有数据:)

Can see all my data now :)

这篇关于读取设备数据流中缺少流控制数据(0x13)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 08:31