delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2004/02/12/01:13:29

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/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
Message-ID: <024201c3f12f$2a803cb0$6601a8c0@MYKEPCGW>
From: "Myke Predko" <myke AT passport DOT ca>
To: <cygwin AT cygwin DOT com>, "Arik BenDov" <arikbd AT hotmail DOT com>
References: <loom DOT 20040209T105919-70 AT post DOT gmane DOT org> <Pine DOT GSO DOT 4 DOT 58 DOT 0402091428010 DOT 25734 AT thing1-200>
Subject: Re: Problem with serial port init
Date: Thu, 12 Feb 2004 01:12:11 -0500
MIME-Version: 1.0
X-Authentication-Info: Submitted using SMTP AUTH LOGIN at fep01-mail.bloor.is.net.cable.rogers.com from [24.156.204.171] using ID <mpredk2559 AT rogers DOT com> at Thu, 12 Feb 2004 01:12:07 -0500
X-IsSubscribed: yes

Hey Brian,

I don't know if anybody else replied, but here is some code that I have used
to run a port at 115,200 bps (you should see how to change the various
parameters for different speeds/operation).

         hComm = CreateFile(COMList[i], GENERIC_READ | GENERIC_WRITE,
                0,
                0,
                OPEN_EXISTING,
                FILE_FLAG_OVERLAPPED,
                0);
            if (hComm == INVALID_HANDLE_VALUE)
            {
//  Error, Can't Open Port (usually because its not there)
            } else {                   //  Open OK, Specify Parameters via
DCB
                ZeroMemory(&dcbSer, sizeof(dcbSer));
                if (!GetCommState(hComm, &dcbSer))
                {                      //  Can't Set Baudrate and other
Parameters
//  Error, Can't Read DCB for Serial Port
                } else {               //  Set Serial Port Parameters
                    dcbSer.BaudRate    = CBR_115200;
                    dcbSer.ByteSize    = 8;
                    dcbSer.Parity      = NOPARITY;
                    dcbSer.StopBits    = ONESTOPBIT;
                    dcbSer.fDtrControl = DTR_CONTROL_DISABLE;
                    if (!SetCommState(hComm, &dcbSer))
                    {                  //  Can't Set Baudrate and other
Parameters
//  Error, Can't Set DCB Parameters
                    } else {           //  Set Serial Port Parameters
//  You're ready to Rock
                    }  //  fi
                }  //  fi
            }  //  fi

For other parameters/defines, you can find them at
http://msdn.microsoft.com.

Good luck!

myke

----- Original Message ----- 
From: "Brian Ford" <ford AT vss DOT fsi DOT com>
To: "Arik BenDov" <arikbd AT hotmail DOT com>
Cc: <cygwin AT cygwin DOT com>
Sent: Monday, February 09, 2004 3:32 PM
Subject: Re: Problem with serial port init


> On Mon, 9 Feb 2004, Arik BenDov wrote:
>
> > Hi,
> >
> > I have a strang proglem any help will be appriciated
> >
> > I have s program sending data VIA serial port between 2 machines. The
program
> > works fine when both are Linux.
> > I use cygwin to port the program to windows (I run the program under Dos
shell
> > not Cygwin) and I have problem with the port setup part, the program
cannot
> > set the serial port parameters (speed, data bits etc).
> >
> > When I disable the port setup part and use mode to set the port
parameters the
> > program works fine.
> >
> > Does any one has code example (in C, C++) that does the work? I'm using
> > termios tcsetattr.
> >
> WFM.
>
> Please see:
> > Problem reports:       http://cygwin.com/problems.html
> >
>
> for how to submit a more well formed report.  Please pay special
> attention to the part that requests uncompressed cygcheck output as an
> attachment.  Also, please give more details about the specific values
> passed to tcsetattr and its return code.  Thanks.
>
> -- 
> Brian Ford
> Senior Realtime Software Engineer
> VITAL - Visual Simulation Systems
> FlightSafety International
> Phone: 314-551-8460
> Fax:   314-551-8444
>
> --
> 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/
>
>
>



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