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

📄 ttys.h

📁 足球机器人自动程序
💻 H
字号:
#ifndef TTYS_H#define TTYS_H#include <stdio.h>#include <string.h>#include <sys/types.h>#include <sys/stat.h>#include <fcntl.h>#include <termios.h>#include <unistd.h>inline int ttys_init(int id) {		char dev[11];	sprintf(dev, "/dev/ttyS%d", id);	int fd;        if ((fd = open(dev, O_RDWR | O_NOCTTY)) < 0) {		perror(dev);		return -1;	}        	struct termios tio;        memset(&tio, 0, sizeof(tio));        tio.c_cflag = B4800 | CS8 | CLOCAL | CREAD | PARENB;	tio.c_iflag = INPCK;        tio.c_cc[VMIN] = 1;                 if (tcsetattr(fd, TCSANOW, &tio) < 0) {		perror("tcsetattr");		return -1;	}	return fd;}#endif

⌨️ 快捷键说明

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