RE: Serial Port (RS-232)
Glynn Clements <[email protected]>
| Newsgroups | org.kernel.vger.linux-c-programming |
|---|---|
| Message-ID | <[email protected]> |
Jaime Garcia wrote: > What I want to do is to read from another device that transmit a string of > chars through serial connector, what do you recommend? I would like to know > your approach for this. Thank you in advance for your help. First, open() the device. Then configure the line settings with e.g.: struct termios t; tcgetattr(fd, &t); t.c_lflag &= ~ICANON; tcsetattr(fd, TCSANOW, &t); The ICANON flag controls the use of "canonical mode" (line buffering, processing of control codes, etc). For a device other than a terminal, you would normally disable this flag. Exactly how the line is configured depends upon the device; see the termios(3) manpage for a list of settings. Finally, just read() data. -- Glynn Clements <[email protected]>