上一个讲了打电话发短信的c代码。。这里给出接电话的c代码
没做过收短信的c代码。。以为我的可能是我设置不对还是什么原因。。我的接短信一直没显示。。就没做。。不过大概思路和接电话应该一样。。就是循环检测串口输出看看有没有想要的符合的字符串
#include<termios.h>
#include<stdio.h>
#include<stdlib.h>
#include<unistd.h>
#include<fcntl.h>
#include<string.h>
#include<sys/types.h>
#include<sys/stat.h>
void serial_init(int fd)
{
struct termios options;
tcgetattr(fd, &options);
options.c_cflag |= (CLOCAL | CREAD);
options.c_cflag &= ~CSIZE;
options.c_cflag &= ~CRTSCTS;
options.c_cflag |= CS8;
options.c_cflag &= ~CSTOPB;
options.c_iflag |= IGNPAR;
options.c_oflag = 0;
options.c_lflag = 0;
cfsetispeed(&options, B115200);
cfsetospeed(&options, B115200);
tcsetattr(fd, TCSANOW, &am