LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices



Reply
 
Search this Thread
Old 05-22-2008, 02:35 PM   #1
Peatmoss
Member
 
Registered: Nov 2007
Location: Vancouver
Distribution: Ubuntu 7.10
Posts: 43

Rep: Reputation: 15
Assistance With Termios Settings Please


Hello,

I've got a problem with an unwanted character manipulation on a TTY. I'm using a usb_serial driver which maps my modem's serial paths to TTYs. My software is exchanging proprietary binary data with the modem. I happened to send the modem a packet with a 0x0D character included and the driver has added a 0x0A immediately following it.

I think I need to turn off Canonical processing so that the driver does not modify my data in any way. But I've only been able to find references to ICANON when I google "termios". Since my specific problem is output related, how do I suppress Linux Data Manipulation on the Output direction?

Actually, I'll need to stop it in both directions.

Thanks,


Peatmoss
 
Old 05-23-2008, 10:54 PM   #2
eggixyz
Member
 
Registered: Apr 2008
Posts: 310

Rep: Reputation: 30
Hey There,

You should be able to do this on a raw socket by setting the lflag:

Quote:
YOURPROG.c_lflag &= ~(ECHO|ECHONL|ICANON|ISIG|IEXTEN);
Hopefully that helps

, Mike
 
Old 06-01-2008, 08:38 PM   #3
Peatmoss
Member
 
Registered: Nov 2007
Location: Vancouver
Distribution: Ubuntu 7.10
Posts: 43

Original Poster
Rep: Reputation: 15
Hi Mike,

Thank you for your response. Sorry for the belated response, I was off architecting other areas of the machine until now. I've added your suggested changes to the code and so far so good. The trouble is, I added some code to force a 0x0d into the data stream and the problem I had before did not recurr. Just for kicks, I added another test, this time with a 0x0A in the data stream and same thing. No problems.

I'm wondering if I maybe ran another program in between which changed the termios settings so they were causing this problem. If so, I haven't reproduced it so far.

Anyhow, thanks for taking the time to send a reply.

Regards

peatmoss
 
Old 06-01-2008, 10:54 PM   #4
pinniped
Senior Member
 
Registered: May 2008
Location: planet earth
Distribution: Debian
Posts: 1,732

Rep: Reputation: 50
Perhaps 'stty' is being run on reboot and you've somehow influenced its settings.
You can check out the scripts and ensure that the particular port you want to work with has the settings you want; in particular the 'raw' mode should be used (switches off character translation and XON/XOFF).

Of course it's best if you do all that within your own code because that way you don't have to rely on someone configuring your port correctly beforehand (and no one interfering with it before you open it):

'tcgetattr()' to fetch the termios for your open terminal
'cfmakeraw()' to set the attributes for 'raw' mode
If you actually want XON/XOFF, make sure the XON/XOFF characters are correctly defined and switch on XON/XOFF translation.
set the bit rate you want (cfsetispeed()/cfsetospeed())
possibly 'tcflush()' to get rid of things
'tcsetattr()' to set everything
and off you go
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
managing termios for ser ports DavidHB Linux - Software 2 09-21-2006 08:37 AM
problem with serial port in loopback mode .. (termios) mta Programming 1 06-06-2006 12:56 PM
Mandrake 10.0 Gnome/KDE Taskbar icon settings...are there settings? LiquidRezin Linux - Newbie 2 03-22-2004 10:27 AM
Figuring out a 'c_oflag'(man termios) that will help in stdout supression. Tarts Programming 13 08-11-2003 10:04 AM
Changing US keyboard settings to Spain (SP) settings or Mexico. zLinuxz Linux - General 4 12-01-2002 01:49 AM


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

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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration