Re: Correction: Serial port arbitration
site_archiver@lists.apple.com Delivered-To: darwin-dev@lists.apple.com Cheers Godfrey On 04/09/2005, at 5:35 AM, Gregory Weston wrote: On Apr 9, 2005, at 4:21 AM, Dan Bernstein wrote: I had a similar problem with the code. Solved it by turning on the CLOCAL bit in the termios struct's c_cflag field and turning off CCTLS_FLOW and CRTS_IFLOW. Here's my setup code: struct termios options; if ( tcgetattr( fd, &options )==-1 ) { /* throw an exception */ } cfmakeraw(&options); options.c_cc[VMIN] = 1; // characters options.c_cc[VTIME] = 10; // tenths of a second _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-dev mailing list (Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-dev/site_archiver%40lists.appl... CLOCAL is the key to programming the modem when using the tty.* serial line. The idea is that tty.* will block until the carrier detect rises. By definition you can not have a carrier yet, thus you must tell the port not to wait for it, that is what CLOCAL does. Assert CLOCAL before clearing the O_NONBLOCK flag with the fcntl. if ( cfsetspeed( &options, B57600 )==-1 ) // Set 57600 baud { /* throw an exception */ } options.c_cflag |= ( CS8 | CLOCAL ); // Use 8 bit words, ignore status lines if ( tcsetattr( [modemFileHandle fileDescriptor], TCSANOW, &options )==-1 ) { /* throw an exception */ } That looks like a success in my testbed app. I'll try it in the real project later. Thanks very much. This email sent to site_archiver@lists.apple.com
participants (1)
-
Godfrey van der Linden