3

&"warning: GDB: Failed to set controlling terminal: Inappropriate ioctl for device\n"

   bool rs485::rs485ConfigPort()
    {
        termios portSettings;

        memset(&portSettings, 0, sizeof(portSettings));

        portSettings.c_cflag |= (CLOCAL | CREAD);

        cfsetispeed(&portSettings, B57600);

        portSettings.c_cflag &= ~PARENB;

        portSettings.c_cflag |= CS8;

        portSettings.c_cflag &= ~CSIZE;

        portSettings.c_cflag &= ~CSTOPB; //stop bit = 1

        //cfmakeraw(&portSettings);

        if (tcsetattr(fd, TCSANOW, &portSettings))
        {
            emit logMessage("Can not adjust port settings");

            close(fd);
            return false;
        }

        tcflush(fd, TCIFLUSH);
        return true;
    }

I found the problem, this is because tcsetattr() gives back Input/Output Error. the device is open with write permissions. and... when I do dmesg | grep ttyS0 or S1-3, I do not receive anything! it also follows sometimes with the error "No such device".

anybody can help solve this problem?

Sam
  • 813
  • 2
  • 16
  • 30
  • 1
    You might want to start off by calling `tcgetattr()` to get the initial settings. I'd also note that I don't see what the GDB error has to do with it. – Hasturkun Mar 03 '13 at 12:59
  • how is fd set? Is it possible the file didn't actually exist before you tried tcsetattr? – john.pavan Mar 03 '13 at 13:21
  • I solved the problem. I was trying to open port COM4, that is /dev/ttyS3. I changed it to /dev/tty3 and it worked fine!!! what is the difference? isn't /dev/tty3 a console port? i think the right device is what I tried first ttyS3. but that device does not exist! how should i solve this? I also checked ttyS3 in /dev, it exists, but dmesg gives me nothing about ttyS0-3 ! – Sam Mar 03 '13 at 18:56
  • 1
    i am still not cleared about my problem, anyone could give me an explanation? – Sam Mar 04 '13 at 06:40

0 Answers0