LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-23-2011, 04:03 AM   #1
SJank
LQ Newbie
 
Registered: Jun 2011
Posts: 2

Rep: Reputation: Disabled
tcsetattr timing issues


Hello LQ,

i'm trying to access a piece of hardware over rs232. According to the protocol
of the hardware, i have to send an address byte using mark parity and several command bytes using space parity.

When setting the parity modes using tcsetattr with optional_actions set to TCSADRAIN or TSCAFLUSH, it needs about 15 ms to switch parity modes and send the address byte, which is not acceptable. When using the parameter TCSANOW performance is just fine, but i'm getting protocol errors.

My guess about the 15 ms when using TSCADRAIN is that i'm running into a context switch, as i get the same timing results when using TCSANOW with usleep.

At the moment, i'm slowing my application down using a delay-loop
Is there a way, waiting until the new portstate is set (like TSCADRAIN does) without running into a context switch?

Thanks,
Stefan
 
Old 06-23-2011, 11:27 AM   #2
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
If your application can run with root access, you could potentially do direct access to the UART, setting the appropriate bit(s) in the UART registers. You would probably want to use the /dev/port (x86) or /dev/mem (other memory mapped IO architecture) facility to do this. This would of course be very host-specific.
--- rod.
 
  


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
timeout for standard input using tcsetattr not working VGM Programming 3 01-05-2010 12:21 PM
timing issues important for a kernel(RTOS) krap Linux - Kernel 1 08-07-2008 03:00 AM
how to start timing and print the timing result on portions of java codes ?? alred Programming 2 05-15-2006 10:00 AM
Timing issues eagle683 Programming 4 06-01-2005 01:35 PM
tcsetattr() TCSANOW vs. TCSETA GarroteYou Programming 1 05-16-2005 09:45 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:52 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
Open Source Consulting | Domain Registration