see the comments in the code for explanation of the use of the different input modes. i hope that the code is understandable. the example for canonical input is commented best, the other examples are commented only where they differ from the example for canonical input to emphasize the differences. 【程序编程相关:内容管理系统的设计和选型 】
all examples have been derived from miniterm.c. the type ahead buffer is limited to 255 characters, just like the maximum string length for canonical input processing (<linux/limits.h> or <posix1_lim.h>). 【推荐阅读:世界上发现首例PHP病毒】
don´t forget to give the appropriate serial ports the right permissions (e. g.: chmod a+rw /dev/ttys1)! 【扩展信息:也谈绑定dropdownlist(3)】
the descriptions are not complete, but you are encouraged to experiment with the examples to derive the best solution for your application.
所有的示例来自于 miniterm.c. the type ahead 缓存器限制在 255 字节的大小, 这与标准输入(canonical input)进程的字符串最大长度相同 (<linux/limits.h> 或 <posix1_lim.h>).
代码中的注释解释了不同输入模式的使用以希望这些代码能够易于理解.标准输入程序的示例做了最详细的注解, 其它的示例则只是在不同于标准输入示例的地方做了强调.
叙述不是很完整, 但可以激励你对这范例做实验, 以延生出合于你所需应用程序的最佳解.
不要忘记赋予串口正确的权限 (也就是: chmod a+rw /dev/ttys1)!
3.1. canonical input processing 标准输入模式#include <sys/types.h>
#include <sys/stat.h>#include <fcntl.h>#include <termios.h>#include <stdio.h>/* baudrate settings are defined in <asm/termbits.h>, which is included by <termios.h> */
// 波特率的设置定义在 <asm/termbits.h>. 包含在 <termios.h> 里#define baudrate b38400/* change this definition for the correct port */
// 定义您所需要的串口号#define modemdevice "/dev/ttys1"#define _posix_source 1 /*posix compliant source posix系统兼容*/
#define false 0
#define true 1volatile int stop=false;
... 下一页