Hardware Reference
In-Depth Information
The following example shows the program immediately suspending output:
int rc;
rc = tcflow(fd,TCOOFF);
if ( rc < 0 ) {
perror("tcflow (3)");
cfmakeraw(3)
The cfmakeraw(3) function is a convenience routine to establish raw mode, where
no special data conversions or mappings occur. The caller should first call upon
tcgetattr(3) to define the initial termios structure settings. Then cfmakeraw(3) can be
used to adjust those settings for raw mode:
void cfmakeraw(struct termios *termios_p);
where
termios_p is a pointer to a struct populated with the serial device's current settings,
to be altered.
Note that no file descriptor is provided since this function doesn't actually change
anything beyond the data structure that was passed to it. After calling cfmakeraw(3) , the
user will need to use cfsetattr(3) to inform the driver of the changes.
struct termios term;
int rc;
rc = cfgetattr(fd,&term); /* Get settings */
cfmakeraw(&term); /* Alter settings for raw mode */
rc = tcsetattr(fd,TCSADRAIN,&term); /* Apply the settings */
Calling cfmakeraw(3) is equivalent to manually applying the following changes:
struct termios term;
...
term.c_iflag &= ~(IGNBRK | BRKINT | PARMRK | ISTRIP
| INLCR | IGNCR | ICRNL | IXON);
term.c_oflag &= ~OPOST;
term.c_lflag &= ~(ECHO | ECHONL | ICANON | ISIG | IEXTEN);
term.c_cflag &= ~(CSIZE | PARENB);
term.c_cflag |=CS8;
This is a good place to pause and discuss what raw mode is. There are two forms of
serial I/O supported by Linux (and Unix generally):
Cooked mode : The input, output, and echoing functions are modified/performed by
the kernel.
Raw mode : The input/output data is sent to/from the application unchanged by the
kernel.
 
Search WWH ::




Custom Search