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

📄 gprs_sms_linux.txt

📁 GPRS SMS sample source code
💻 TXT
字号:
int main(void)
{
	int fd;
	int nread,nwrite,i;
	char buff[32];
	char reply[128];
	char gsmMessage[20] = "Hello!";
	
	if((fd=open_port(fd,2))<0){
		perror("open_port error");
		return -1;
	}
	if((i=set_opt(fd,115200,8,'N',1))<0){
		perror("set_opt error");
		return -1;
	}
	printf("fd=%d\n",fd);
	memset(buff,0,sizeof(buff));
	buff[0] = 'A'; 
	buff[1] = 'T'; 
	buff[2] = '\r'; 
	nwrite = write(fd,buff,3);
	printf("nwrite=%d,%s\n",nwrite,buff);
	memset(reply,0,sizeof(reply));
	nread = read(fd,reply,sizeof(reply));
	printf("nread=%d,%s\n",nread,reply);
	memset(buff,0,sizeof(buff));
	strcpy(buff,"AT+CMGF=1");
	strcat(buff,"\r");
	nwrite = write(fd,buff,10);
	printf("nwrite=%d,%s\n",nwrite,buff);
	memset(reply,0,sizeof(reply));
	nread = read(fd,reply,sizeof(reply));
	printf("nread=%d,%s\n",nread,reply);
	memset(buff,0,sizeof(buff));
	strcpy(buff,"AT+CMGS=");
	strcat(buff,"136");
	strcat(buff,"\r");
	nwrite = write(fd,buff,strlen(buff));
	printf("nwrite=%d,%s\n",nwrite,buff);
	memset(reply,0,sizeof(reply));
	nread = read(fd,reply,sizeof(reply));
	printf("nread=%d,%s\n",nread,reply);
	strcat(gsmMessage, "\x1a");     
	nwrite = write(fd,gsmMessage,7);
	printf("nwrite=%d,%s\n",nwrite,gsmMessage);
	memset(reply,0,sizeof(reply));
	nread = read(fd,reply,sizeof(reply));
	printf("nread=%d,%s\n",nread,reply);
	close(fd);
	return 0;
} 

⌨️ 快捷键说明

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