Я написал этот код (используя кодовые блоки), в котором я хочу отправить сообщение для 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 standard function definitions
#include <fcntl.h> // File control definitions
#include <errno.h> // Error number definitions
#include <termios.h> // POSIX terminal control definitionsint 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
Проблема с заблудившийся ‘\ 302’ в том, что код содержит где-то неразрывный пробел вместо обычного пробела.
Однако исправляя это, я вижу две дополнительные проблемы, которые я решаю Вот.
Других решений пока нет …