C++ 错误:杂散'\302和x27;程序内代码块
我写了这段代码(使用代码块),其中我想向我的手机发送GSM消息。它包括一些AT命令。问题是我在printf中有这个错误,at+cmgf=1。我认为我的代码是正确的。UTF或ASCII有什么问题吗C++ 错误:杂散'\302和x27;程序内代码块,c++,codeblocks,at-command,C++,Codeblocks,At Command,我写了这段代码(使用代码块),其中我想向我的手机发送GSM消息。它包括一些AT命令。问题是我在printf中有这个错误,at+cmgf=1。我认为我的代码是正确的。UTF或ASCII有什么问题吗 #include <stdio.h> // standard input / output functions #include <string.h> // string function definitions #include <unistd.h> // UNIX
#include <stdio.h> // standard input / output functions
#include <string.h> // string function definitions
#include <unistd.h> // UNIX standard function definitions
#include <fcntl.h> // File control definitions
#include <errno.h> // Error number definitions
#include <termios.h> // POSIX terminal control definitions
int open_port(void)
{
int fd; // file description for the serial port
fd = open("/dev/ttyAMA0", O_RDWR | O_NOCTTY | O_NDELAY);
if(fd == -1) // if open is unsucessful
{
printf("open_port: Unable to open /dev/ttyAMA0. \n");
}
else
{
fcntl(fd, F_SETFL, 0);
printf("port is open.\n");
}
return(fd);
} //open_port
int configure_port(int fd) // configure the port
{
struct termios port_settings; // structure to store the port settings in
cfsetispeed(&port_settings, B9600); // set baud rates
cfsetospeed(&port_settings, B9600);
port_settings.c_cflag &= ~PARENB; // set no parity, stop bits, data bits
port_settings.c_cflag &= ~CSTOPB;
port_settings.c_cflag &= ~CSIZE;
port_settings.c_cflag |= CS8;
tcsetattr(fd, TCSANOW, &port_settings); // apply the settings to the port
return(fd);
}
void init_gsm()
{
printf("at+cmgf=1\r\n");
printf("at+cmgs=\"60*****\"\r\n");
printf("Hello\r\n%c",26);
}
int main(void)
{
int fd = open_port();
configure_port(fd);
//query_modem(fd);
init_gsm();
return(0);
} //main
#包括//标准输入/输出函数
#包含//字符串函数定义
#包含//UNIX标准函数定义
#包含//文件控制定义
#包括//错误号定义
#包括//POSIX终端控制定义
int open_端口(无效)
{
int fd;//串行端口的文件说明
fd=开放(“/dev/ttyam0”,O|RDWR | O|NOCTTY | O|NDELAY);
if(fd=-1)//如果打开不成功
{
printf(“打开端口:无法打开/dev/ttyam0。\n”);
}
其他的
{
fcntl(fd,F_SETFL,0);
printf(“端口已打开。\n”);
}
返回(fd);
}//打开\u端口
int configure_port(int fd)//配置端口
{
struct termios port_settings;//存储端口设置的结构
cfsetispeed(&port_settings,B9600);//设置波特率
cfsetospeed(端口设置和B9600);
port_settings.c_cflag&=~PARENB;//设置无奇偶校验、停止位、数据位
端口设置.c\u cflag&=~CSTOPB;
端口设置.c\u cflag&=~CSIZE;
端口_settings.c_cflag |=CS8;
tcsetattr(fd、TCSANOW和port_设置);//将设置应用于端口
返回(fd);
}
void init_gsm()
{
printf(“at+cmgf=1\r\n”);
printf(“at+cmgs=\”60******\“\r\n”);
printf(“你好\r\n%c”,26);
}
内部主(空)
{
int fd=打开_端口();
配置_端口(fd);
//查询调制解调器(fd);
init_gsm();
返回(0);
}//主要
问题在于,代码的某个地方包含非中断空间,而不是正常空间
然而,解决了这个问题,我看到了另外两个问题 发布的代码没有那个错误,您能从编辑器发布准确的代码吗?