⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tryttys1.c

📁 这是一个MINITGUI2。0的应用程序
💻 C
字号:
#include     <stdio.h>      /*标准输入输出定义*/#include     <stdlib.h>     /*标准函数库定义*/#include     <unistd.h>     /*Unix 标准函数定义*/#include     <sys/types.h>  #include     <sys/stat.h>   #include     <fcntl.h>      /*文件控制定义*/#include     <termios.h>    /*PPSIX 终端控制定义*/#include     <errno.h>      /*错误号定义*/#include     <fcntl.h>#include     <sys/signal.h>#define FALSE 0#define TRUE 1extern int readttyS1(int fd,char *buf);extern int initttyS1(void);//void signal_handler_IO (int status);   /* definition of signal handler */int wait_flag=TRUE;                    /* TRUE while no signal received */volatile int STOP=FALSE;  int initttyS1(void){	static int fd;	struct  termios Opt;	//fd = open( "/dev/ttyS1", O_RDWR|O_NONBLOCK|O_NOCTTY);	fd = open( "/dev/tts/1", O_RDWR|O_NONBLOCK|O_NOCTTY);	if (-1 == fd){ 	/* 不能打开串口一*/ 		printf("can't open /dev/ttys1\n");		exit(0);	}	/*------------------------------------*/	//串口参数设置,波特率19200,8n1	tcgetattr(fd, &Opt);	cfsetispeed(&Opt,B9600);     /*设置为19200Bps*/	cfsetospeed(&Opt,B9600);	tcsetattr(fd,TCSANOW,&Opt);	printf("btl is 9600\n");       	Opt.c_lflag &= ~(ICANON|ECHO|ECHOE|ISIG);	Opt.c_oflag &= ~OPOST;	tcsetattr(fd,TCSANOW,&Opt);	printf("8n1\n");	/*-------------------------------------*/		return fd;}       int readttyS1(int fd,char *buf){	//static int i;   /*以读写方式打开串口*/		//fd_set rds;	//int ret;	int res;		//char buf[4];	//char relbuf[13]; //真正要传出的数据,	res = read(fd,buf,5);	buf[res] = 0;        printf ("res = %d\n",res);	printf(":%s\n", buf);	return res;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -