Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > IOKit Serial Port Madness

IOKit Serial Port Madness
Thread Tools
Professional Poster
Join Date: Apr 2001
Location: Long Beach, CA
Status: Offline
Reply With Quote
Sep 30, 2005, 07:06 PM
 
I'm hoping some Unix GURU can give me a quick one-liner to help me fix this problem...


I have serial input and output working fine through the IOKit (yes, the termios stuff). I have it configured not to block on reads, but I do want it to block on writes.

The problem I'm having is that in one situation, the port gets closed shortly after it's written to, and the last several bytes get chopped off. I've tried using O_FSYNC, and tcdrain, but it still gets chopped off. If I block the thread for about 200ms, none of the data is lost, but I'm running in a time-critical environment, so losing 200ms is a big deal. BTW, I do have the thread running in real-time priority, so if I don't block, external threads don't run ( it's really funny to hear iTunes just stop and see the mouse freeze when the thread starts doing heavy computation w/o blocking ).

Anyway, I'm basically looking for a way to ensure that all data has been written from the serial output buffer before the function moves on. All the documentation I've found on the internet says tcdrain is what I need, but Apple's website says that tcdrain only passes the command on to the serial driver. BTW, the issue occurs with both a Keyspan and an FTDI adapter, so it's not likely to be a driver issue.


Thanks for any input you can offer.

ACSA 10.4/10.3, ACTC 10.3, ACHDS 10.3
     
   
Thread Tools
Forum Links
Forum 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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 07:38 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2