Thread: Problem with Termios and a tty

  1. #1
    Registered User
    Join Date
    Aug 2007
    Posts
    1

    Problem with Termios and a tty

    I am tring to speak to a modem attached as tty via AT commands. i wrote a tool to issue the commands. The tool works with any modem tty, just the one I need replys the correct number of char but nearly all of them are 0xFF which is obviously not correct.

    example OK -> 0xFFFF

    Anyone met such behaviour before?

    Talking to the tty with Minicom does work for some reason, repsonse is normal. Minicom uses same baud, parity, flowcontrol, no init string.

    Any ideas?

    cfsetspeed(&term, 115200);
    cfmakeraw(&term);
    term.c_cc[VMIN] = 0;
    term.c_cc[VTIME] = 5;
    term.c_cc[VEOL] = '\r';

    term.c_iflag = (term.c_iflag & 0xFFFFF0CD) | 5;
    term.c_oflag = term.c_oflag & 0xFFFFFFFE;
    term.c_cflag = (term.c_cflag & 0xFFFC6CFF) | 0x3CB00;
    term.c_lflag = term.c_lflag & 0xFFFFFA77;

    term.c_cflag = (term.c_cflag & ~CSIZE) | CS8;
    term.c_cflag &= ~PARENB;
    term.c_lflag |= ICANON;
    term.c_lflag &= ~ECHO;

    tcsetattr(fd, TCSANOW, &term);

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    > term.c_iflag = (term.c_iflag & 0xFFFFF0CD) | 5;
    How about looking up the meaningful symbolic constants which define what all the bits mean?

    I mean, you use PARENB and ICANON later on, use the relevant constants here.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed