简体   繁体   English

Linux串行端口编程c_cc字符配置

[英]Linux serial port programming c_cc character configurations

By referencing the source in the following link : Serial_Port_Programming_How_To 通过在以下链接中引用源: Serial_Port_Programming_How_To

I found out that there are c_cc character configurations there. 我发现那里有c_cc字符配置。 After searching around the affections, I did not find the exact answer to this. 在寻找感情之后,我没有找到确切的答案。 I try to comment out each line of these c_cc configurations and found out the following line does affect the output. 我尝试注释掉这些c_cc配置的每一行,发现以下行确实会影响输出。

newtio.c_cc[VEOF]     = 4;

Can anyone explain the meaning of this and possibly for the rest of these? 谁能解释这个的含义,并可能为其余这些解释?

Thanks 谢谢

As suggested, the manual page for termios is a starting point: 根据建议, termios的手册页是一个起点:

VEOF 天窗

(004, EOT, Ctrl-D) End-of-file character (EOF). (004,EOT,Ctrl-D)文件结尾字符(EOF)。 More precisely: this character causes the pending tty buffer to be sent to the waiting user program without waiting for end-of-line. 更准确地说:此字符使待处理的tty缓冲区被发送到正在等待的用户程序,而无需等待行尾。 If it is the first character of the line, the read(2) in the user program returns 0, which signifies end-of-file. 如果它是该行的第一个字符,则用户程序中的read(2)返回0,表示文件结束。 Recognized when ICANON is set, and then not passed as input. 设置ICANON后识别,然后不作为输入传递。

In the context of the given link, 3.1. 在给定链接的上下文中, 3.1。 Canonical Input Processing , the OP has observed that commenting out an assignment 规范输入处理 ,OP观察到注释出一个作业

newtio.c_cc[VEOF]     = 4;

prevents ^D from working as expected. 阻止^D正常工作。 That, and similar assignments correspond to the settings one might use for a shell script with stty . 这样的分配和类似的分配对应于可能用于具有stty的shell脚本的设置。 Internally (using termios ) those are set to an undefined value when assigned 0xff , but a default 0x00 is almost as good. 在内部(使用termios ),当它们分配为0xff ,它们被设置为未定义的值,但是默认的0x00几乎一样。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM