Saturday, January 16, 2016
SMS platform under Linux via serial port to receive GSM reply message, not a serial data read-out buffer is how so?
Projects related to the serial port to send information through the GSM module, the appropriate treatment program data received through the serial port, but the question now is, this should be read once the serial port can receive data, you need to read the serial port can be read many times complete piece of data. I do not know how else?
Here is part of my code, please look at the help. Thank you.
int fd;
struct termios term_attr;
int len;
char rdbuf [300];
do {
fd = open (PortName, O_RDWR | O_NOCTTY);
} While (fd & lt; 0) ;;;;
memset (& amp; term_attr, 0, sizeof (struct termios));
tcgetattr (fd, & amp; term_attr);
// 9600bps, 8bit, no parity check, 1 stopbit
term_attr.c_iflag & amp; = ~ (IXON | IXOFF | IXANY | INLCR | IGNCR | ICRNL | ISTRIP);
term_attr.c_lflag & amp; = ~ (ISIG | ECHO | ECHOE | ICANON | NOFLSH);
term_attr.c_cflag | = (CLOCAL | CREAD);
// Baud 9600
term_attr.c_cflag & amp; = ~ CBAUD;
term_attr.c_cflag | = B9600;
// (8N1)
term_attr.c_cflag & amp; = ~ PARENB;
term_attr.c_cflag & amp; = ~ CSTOPB;
term_attr.c_cflag & amp; = ~ CSIZE;
term_attr.c_cflag | = CS8;
term_attr.c_oflag & amp; = ~ (OPOST | ONLCR | OCRNL);
tcflush (fd, TCIOFLUSH);
tcsetattr (fd, TCSANOW, & amp; term_attr);
return 0;
len = read (fd, rdbuf, 300) ;;
I do not know is not due to the serial port settings problem?
Reply:
Reply:
AT commands you to receive short messages it
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment