Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Non-canonical mode on OS X?




On Aug 29, 2005, at 10:42 , Gregory Weston wrote:

I'm trying to read a Mac's built-in modem in raw mode (after some help from this lists months ago, then a long period of downtime) and I'm running into something annoying. When data shows up, it comes through as a small burst (100 characters or so) followed by a brief pause (.02 seconds, say) and then another small burst (32 characters).

The difficulty I'm having is that the read() I eventually issue returns before the second burst shows up. Here's the setup routine.

static int set_local_mode(int inFileDescriptor)
{
  int theResult = 0;
  struct termios theOptions = {};

if(tcgetattr(inFileDescriptor, &theOptions) == -1) {theResult = errno;}
cfmakeraw(&theOptions);
//theOptions.c_lflag &= ~(ICANON | ECHO); /* Clear ICANON and ECHO. */
theOptions.c_cc[VMIN] = 1;
theOptions.c_cc[VTIME] = 5;
theOptions.c_cflag |= (CS8 | CLOCAL);
if(tcsetattr(inFileDescriptor, TCSANOW, &theOptions) == -1) {theResult = errno;}
return theResult;
}


My understanding is that if this completes successfully, the read() should return after once there has been a half-second interval since the last character received. The buffer passed to read() is much larger than the returned data, and the commented line doesn't have any impact (c_lflag is already zero by the time we get there). Any advice?

Your code asks for one character, so the VMIN requirement will be satisfied before the VTIME requirement starts (VTIME is the number of time periods to wait after the last character is received; until the first character is received, there is no time requirement). I think that is why you get the return before the second burst.


Also, if at the time of the call, there are bytes queued up, they will be copied and if the VMIN requirement is thereby satisfied, return is immediate.

Regards,

Justin

--
Justin C. Walker, Curmudgeon-At-Large
Institute for General Semantics
--------
Some people have a mental horizon of radius zero, and
call it their point of view.
  -- David Hilbert
--------


_______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-dev/email@hidden

This email sent to email@hidden
References: 
 >Non-canonical mode on OS X? (From: Gregory Weston <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.