LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 07-11-2014, 05:23 AM   #1
Pavan Kumar Reddy
LQ Newbie
 
Registered: Jun 2014
Location: India
Distribution: Linux
Posts: 6

Rep: Reputation: Disabled
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 !!!!!!!!!!!

Last edited by Pavan Kumar Reddy; 07-11-2014 at 06:48 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
stty ixon flow control - not working caylan Linux - General 4 05-30-2012 05:59 PM
flow control rehan999 Linux - Networking 3 05-05-2008 02:58 AM
Serial flow control in 2.6.8 kidzmom3 Linux - General 1 12-08-2004 08:47 AM
EXT3-control flow? shrey_j Programming 0 10-18-2004 12:42 AM
what should be my flow control values? HW? SF? or NONE? kublador Linux - Networking 0 06-07-2003 11:03 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 03:02 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration