LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Flow control none is not working as expected after we change flow control software (https://www.linuxquestions.org/questions/linux-software-2/flow-control-none-is-not-working-as-expected-after-we-change-flow-control-software-4175510772/)

Pavan Kumar Reddy 07-11-2014 05:23 AM

Flow control none is not working as expected after we change flow control software
 
Hi all,

As i am facing problem with flow control, when i change the flow control from software to none, still is stuck in xoff char ,here is my code
void SerialConfigureHardwareParameters(SERIALPort *pSerial)
{
int port = pSerial->port;
struct termios oldtio, newtio;
char buf [50];
#if defined(USE_ATMEL_SERIAL) || defined(USE_8250_SERIAL)
bool custom_baud = false;
#endif

if (pSerial->ttyFd == -1)
{
return;
}

/* Setup the UART mode based on current configuration. */
{
/* setup baud rate, data size, parity and stop bit */
if (tcgetattr(pSerial->ttyFd, &oldtio) == -1)
{
SYSCALL_ERROR_LOG("tcgetattr() error: %s", strerror_r(errno, buf, sizeof(buf)));
return;
}
memset (&newtio, 0, sizeof(newtio));

/* input modes : check framing errors and parity errors, check BREAK condition */
/* output modes : raw outout */
/* control modes : ignore modem status line to indicate that the port is ready, enable receiver */
/* local modes : raw input (noncanonical) mode, no echo, don't send signalings to calling programs*/

newtio.c_iflag |= (BRKINT);
newtio.c_oflag = 0;
newtio.c_cflag |= (CLOCAL | CREAD);
newtio.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG);

/* VMIN = 0; VTIME = 0 : If data is available, read() returns immediately, with */
/* the lesser of the number of bytes available, or the number of bytes requested */
/* if no data is available read() return 0 */
newtio.c_cc[VMIN] = 0;
newtio.c_cc[VTIME] = 0;

/* set default XON/XOFF control character */
/* start char DC1 when enable XON XOFF flow control on output */
/* stop char DC3 when enable XON XOFF flow control on output */
newtio.c_cc[VSTOP] = 0x13;
newtio.c_cc[VSTART] = 0x11;

/* set baud rate */
switch (pSerial->currentSettings.baud_rate)
{
case 300: newtio.c_cflag |= B300; break;
case 600: newtio.c_cflag |= B600; break;
case 1200: newtio.c_cflag |= B1200; break;
case 2400: newtio.c_cflag |= B2400; break;
case 4800: newtio.c_cflag |= B4800; break;
case 9600: newtio.c_cflag |= B9600; break;
case 19200: newtio.c_cflag |= B19200; break;
case 38400: newtio.c_cflag |= B38400; break;
case 57600: newtio.c_cflag |= B57600; break;
case 115200:newtio.c_cflag |= B115200; break;
case 230400:newtio.c_cflag |= B230400; break;
case 460800:newtio.c_cflag |= B460800; break;
case 921600:newtio.c_cflag |= B921600; break;
default:
newtio.c_cflag |= B9600;
#if defined(USE_ATMEL_SERIAL) || defined(USE_8250_SERIAL)
custom_baud = true; /* need custom baud */
#endif
}
/* set parity */
switch (pSerial->currentSettings.parity)
{
case VARDEF_ENUM_LINE__DEVICE_PARITY_ODD: newtio.c_cflag |= PARENB | PARODD; break;
case VARDEF_ENUM_LINE__DEVICE_PARITY_EVEN: newtio.c_cflag |= PARENB; break;
case VARDEF_ENUM_LINE__DEVICE_PARITY_NONE:
default: newtio.c_cflag &= ~(PARENB | PARODD);break;
}
/* set stop bit */
switch ( pSerial->currentSettings.stop_bits)
{
case VARDEF_ENUM_LINE__DEVICE_STOP_BITS_2: newtio.c_cflag |= CSTOPB; break;
case VARDEF_ENUM_LINE__DEVICE_STOP_BITS_1:
default: newtio.c_cflag &= ~CSTOPB;break;
}
/* set data bit */
switch (pSerial->currentSettings.data_bits)
{
case VARDEF_ENUM_LINE__DEVICE_DATA_BITS_7: newtio.c_cflag |= CS7; break;
case VARDEF_ENUM_LINE__DEVICE_DATA_BITS_8:
default: newtio.c_cflag |= CS8; break;
}
/* set flow control */
switch (pSerial->currentSettings.flow_control)
{
case VARDEF_ENUM_LINE__DEVICE_FLOW_CONTROL_HARDWARE:
newtio.c_cflag |= CRTSCTS; break;
case VARDEF_ENUM_LINE__DEVICE_FLOW_CONTROL_SOFTWARE:
newtio.c_iflag |= IXON | IXOFF ;
/* Set XON/XOFF control character */
newtio.c_cc[VSTART] = pSerial->currentSettings.xon_char;
newtio.c_cc[VSTOP] = pSerial->currentSettings.xoff_char;
break;
case VARDEF_ENUM_LINE__DEVICE_FLOW_CONTROL_NONE:
default:
newtio.c_cflag |= (CLOCAL | CREAD);
newtio.c_iflag &= ~(IXON | IXOFF);
newtio.c_cflag &= ~CRTSCTS; break;
}

/* clean the line and activate the setting for the port */
if (tcflush(pSerial->ttyFd, TCIFLUSH) == -1)
{
SYSCALL_ERROR_LOG("tcflush(TCIFLUSH) port: %d fd: %d error: %s",
port, pSerial->ttyFd, strerror_r(errno, buf, sizeof(buf)));
}
if (tcsetattr(pSerial->ttyFd,TCSANOW, &newtio) == -1)
{
SYSCALL_ERROR_LOG("tcsetattr(TCSANOW) port: %d fd: %d error: %s",
port, pSerial->ttyFd, strerror_r(errno, buf, sizeof(buf)));
}

/* configure the vendor chip specific features */


Please can any one can tell me what is happening !!!!!!!!!!!


All times are GMT -5. The time now is 11:42 AM.