Пример #1
0
int
setRawTermios(void)
{
    struct termios tio;
    int rc;

    if (!saved_tio_valid)
	saveTermios();
    rc = tcgetattr(0, &tio);
    if (rc < 0)
	return rc;
    tio.c_lflag &= (unsigned) ~(ECHO | ICANON | IEXTEN | ISIG);
    tio.c_iflag &= (unsigned) ~(ICRNL | IXOFF | IXON | ISTRIP);
#ifdef ONLCR
    tio.c_oflag &= (unsigned) ~ONLCR;
#endif
#ifdef OCRNL
    tio.c_oflag &= (unsigned) ~OCRNL;
#endif
#ifdef ONOCR
    tio.c_oflag &= (unsigned) ~ONOCR;
#endif

#ifdef VMIN
    tio.c_cc[VMIN] = 0;
    tio.c_cc[VTIME] = 0;
#endif
    rc = tcsetattr(0, TCSAFLUSH, &tio);
    if (rc < 0)
	return rc;
    return 0;
}
Пример #2
0
TermiosHelper::TermiosHelper(int fileDescriptor)
    : fileDescriptor_(fileDescriptor), originalAttrs_(NULL), currentAttrs_(NULL)
{
    Q_ASSERT(fileDescriptor_ > 0);

    originalAttrs_ = new termios();
    currentAttrs_ = new termios();

    // save the current serial port attributes
    // see restoreTermios()

    saveTermios();

    // clone the original attributes

    *currentAttrs_ = *originalAttrs_;

    // initialize port attributes for serial port communication

    initTermios();
}