X-Recipient: archive-cygwin AT delorie DOT com X-Spam-Check-By: sourceware.org Date: Thu, 1 May 2008 17:53:54 -0700 From: Gary Johnson To: cygwin AT cygwin DOT com Subject: Re: Looking for basic documentation on Cygwin and Serial Ports Message-ID: <20080502005354.GB4342@suncomp1.spk.agilent.com> Mail-Followup-To: cygwin AT cygwin DOT com References: <16827997 DOT post AT talk DOT nabble DOT com> <480F02EA DOT AF265921 AT dessent DOT net> <16853883 DOT post AT talk DOT nabble DOT com> <28D25EB5A34E89408B73B6793C742171CAB6B4 AT nutmeg DOT CAM DOT ARTIMI DOT COM> <16897467 DOT post AT talk DOT nabble DOT com> <16995311 DOT post AT talk DOT nabble DOT com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <16995311.post@talk.nabble.com> X-Operating-System: SunOS suncomp1 5.8 sparc User-Agent: Mutt/1.5.17 (2007-11-01) X-IsSubscribed: yes Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com On 2008-05-01, Nefastor wrote: > Nefastor wrote: > > > > Thanks for all the info, everyone :-D. I'm gonna try a few things and get > > back to you. > > > > So I've tried a few things, and obviously all hell broke loose, sort of. > I've written a very simple "Hello World" program, which I'll paste at the > end of this message. The program is based 90% on code copy-pasted directed > from the serial programming HOWTO. Here's what it does : > > - Open COM3 > - Get its attribute > - Modify them to my desired baudrate and such > - Send out the string "Hello World" > - Close COM3 > > Opening and closing COM3 works. The rest exhibits faulty but consistent > behavior : > > - The baudrate never changes and I can't seem to figure out what it is, but > the terminal I plugged on COM3 always gets the same garbled characters > instead of "Hello World". Also, the terminal flags me a buffer overrun. This > suggested that tcsetattr() didn't work. I ported a program using a serial port from HP-UX to Cygwin a while ago and ran into similar problems: everything seemed to work OK except for the speed settings. I don't remember the issues exactly, but I finally got it to work by setting the speeds using cfsetispeed() and cfsetospeed() instead of setting the speed bits of c_cflag directly. Applying this to your program, > tcgetattr (tty,¶ms); // get the current port settings > params.c_cflag = B19200 | CRTSCTS | CS8 | CLOCAL | CREAD; > params.c_iflag = IGNPAR; > params.c_oflag = 0; > params.c_lflag = ICANON; > tcflush (tty, TCIFLUSH); > tcsetattr (tty,TCSANOW,¶ms); would become this: tcgetattr (tty,¶ms); // get the current port settings params.c_cflag = CRTSCTS | CS8 | CLOCAL | CREAD; params.c_iflag = IGNPAR; params.c_oflag = 0; params.c_lflag = ICANON; cfsetispeed(¶ms, B19200); cfsetospeed(¶ms, B19200); tcflush (tty, TCIFLUSH); tcsetattr (tty,TCSANOW,¶ms); HTH, Gary -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/