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

📄 speech.h

📁 it is about embeded system
💻 H
字号:
#include <termios.h>#include <stdio.h>#include <unistd.h>#include <fcntl.h>#include <stdlib.h>#include<string.h>#include <sys/types.h>#include <sys/stat.h>#include <error.h>// 第一组命令#define CALL               1	                //打电话#define MESSAGE           2			//短信				#define EXPLORER          3			//盲人浏览器#define ROAD_DOG         4			//探路狗#define OTHER             5			//其他//第二组命令#define BAUDRATE B9600#define COM1 "/dev/tts/1"extern char speech(char num){    	struct termios oldtio,newtio,oldstdtio,newstdtio;    //define some variable    	int i,j,fd;	char get_data;	            				fd=open(COM1,O_RDWR | O_NOCTTY);	//open ttyS1	if(fd==-1)		perror("can not open the ttyS1\n");	else                 printf("good ,it is open!\n ");		tcgetattr(0,&oldstdtio);		//save the old tty set   	tcgetattr(fd,&oldtio);   	tcgetattr(fd,&newstdtio); 			newtio.c_cflag = BAUDRATE | CRTSCTS | CS8 | CLOCAL | CREAD; //set the new tty 	newtio.c_iflag = IGNPAR; 		/*input flag*/	newtio.c_oflag = 0;		/*output flag*/	newtio.c_lflag = 0;	newtio.c_cc[VMIN]=1;	newtio.c_cc[VTIME]=0; 	tcflush(fd, TCIFLUSH);	tcsetattr(fd,TCSANOW,&newtio);	/*set attrib	  */			printf("write: 0x%x \n",num);		write(fd,&num,1);	 	read(fd,&get_data,1);//	printf("read: 0x%x\n",get_data);		tcsetattr(fd,TCSANOW,&oldtio);   /* restore old modem setings */  	tcsetattr(0,TCSANOW,&oldstdtio); /* restore old tty setings */	close(fd);	return get_data;}

⌨️ 快捷键说明

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