I am trying to send AT commands to a Telit modem from C. Simply interfacing with the modem through system() calls works fine, but there are some issues that arise when I try to transfer a python script with AT#WSCRIPT. The ">>>" portion also gets transferred into the chip, corrupting the script.
Anyway, so I am now trying to do it within C using termios library. The problem is, I can only send the chip one "AT" command, it responds with an OK and every attempt to send another AT commands results in an ERROR response. Further, after runnning my C code, I can't interface with the chip even through the terminal. I suspect something is off about the termios configuration, which is listed below.
Any ideas? Thanks
char command[] = "AT\r\n";
fd = open(serialport, O_RDWR | O_NOCTTY | O_NDELAY);
termios_config.c_cflag &= ~PARENB;
termios_config.c_cflag &= ~CSTOPB;
termios_config.c_cflag &= ~CSIZE;
termios_config.c_cflag |= CS8;
termios_config.c_cflag &= ~CRTSCTS;
termios_config.c_cflag |= CREAD | CLOCAL;
termios_config.c_cflag &= ~(IXON | IXOFF | IXANY);
termios_config.c_cflag &= ~(ICANON | ECHO | ECHOE | ISIG);
termios_config.c_cflag &= ~OPOST;
tcsetattr(fd, TCANOW, &termios_config);
write(fd, send_str, strlen(send_str));