[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

bug? serial port raw input mode dependent on processing flags?



To Debian Users,

I currently am using the 2.6 verions kernel on sarge.(all standard software packages) I am not sure this is debian related, gnu related, or i just dont understand things very well.
	I was having a rather odd serial port data problem.
	The code was written in C with the gnuC compiler.

At the heart of the problem, i was setting up a serial port for raw input mode(as opposed to canonical).
	My understanding of raw mode as:
"Raw input is unprocessed. Input characters are passed through exactly as they are received, when they are received. "
	as according to http://www.easysw.com/~mike/serial/serial.html
	which is a very useful reference regarding serial ports.

Anyway 0x0d carriage returns were being processed and replaced with 0x0a line feeds.
	while, the following line with ICRNL turned off fixes my problem
	options.c_iflag &= ~(IXON | IXOFF | IXANY | ICRNL);	

I am thinking i should not have had to add the ICRNL flag bit turned off due to my original setting of "raw input mode".
	The whole configuration i used was is at the bottom of the page.
	
Anyway, if this is just a misunderstanding on my part regarding the raw input mode type, i apologize for wasting your time.

thanks
Dennis



/*void serialConfigure*/
void serialConfigure(int fileDescriptor)
{	struct termios options;
	fcntl(fileDescriptor,F_SETFL,FNDELAY);//force immediate return of read.
	//configure the port some more.
	tcgetattr(fileDescriptor,&options);	//get the current options
	
	cfsetispeed(&options,B38400);		//set the baud rates
	cfsetospeed(&options,B38400);
	options.c_cflag |= (CLOCAL | CREAD);
	options.c_cflag &= ~PARENB;			//no parity,8bits,1stop
	options.c_cflag &= ~CSTOPB;
	options.c_cflag &= ~CSIZE;
	options.c_cflag |= CS8;
	options.c_cflag &= ~CRTSCTS;			//dis hw flow
	
	//options.c_iflag &= ~(IXON | IXOFF | IXANY | ICRNL);
	//see that one on the end ICRNL
//that one sucked a day of my life away.(i thought these options were only for canonical mode
	//which i am not using....but you cant argue with results..!
	
	options.c_iflag &= ~(IXON | IXOFF | IXANY | ICRNL);	//
	//options.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG);
	options.c_lflag &= ~(ICANON | ISIG | ECHO | ECHONL | ECHOE | ECHOK);
	options.c_oflag &= ~OPOST;
tcsetattr(fileDescriptor, TCSANOW, &options); //Set the new options for the port...
	return;
}

		
	




Reply to: