delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2008/05/01/19:05:20

X-Recipient: archive-cygwin AT delorie DOT com
X-Spam-Check-By: sourceware.org
Message-ID: <16995311.post@talk.nabble.com>
Date: Thu, 1 May 2008 16:04:37 -0700 (PDT)
From: Nefastor <nefastor AT hotmail DOT com>
To: cygwin AT cygwin DOT com
Subject: RE: Looking for basic documentation on Cygwin and Serial Ports
In-Reply-To: <16897467.post@talk.nabble.com>
MIME-Version: 1.0
X-Nabble-From: nefastor AT hotmail 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>
X-IsSubscribed: yes
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com


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.

- So I tested tcsetattr() by omitting the CRTSCTS flag in my parameters.
With it, the program would not send data until the terminal was ready to
receive, without it, the program would send the data no matter what. So
tcsetattr() appears to work.

My terminal is an ultra-reliable PSION Series 3A I've been using for almost
a decade. I've tested it again with Windows' Hyperterminal and COM3 to
verify that it wasn't a hardware problem.

My conclusion would be that either the FTDI drivers are broken or Cygwin has
trouble interfacing with them. Dave, since you're an FTDI user too, does any
of this sound familiar ?

Here's the program I've written :

#include <stdlib.h>
#include <stdio.h>
#include <termios.h>
#include <unistd.h>
#include <fcntl.h>

int main (int argc, char* argv[])
{
  struct termios params;  
  int tty;               

  tty = open ("/dev/ttyS2", O_RDWR | O_NOCTTY | O_NONBLOCK);
  
  if (tty < 0)
   {
      printf ("Unable to open /dev/ttyS2\n");
      exit (1);
   } 
   
  tcgetattr (tty,&params);    // 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,&params);
   
  write (tty,"Hello World",11); 
  
  close (tty);

  return 0;
}


-- 
View this message in context: http://www.nabble.com/Looking-for-basic-documentation-on-Cygwin-and-Serial-Ports-tp16827997p16995311.html
Sent from the Cygwin list mailing list archive at Nabble.com.


--
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/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019