www.delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2006/09/28/09:46:40

X-Spam-Check-By: sourceware.org
From: "Dave Korn" <dave DOT korn AT artimi DOT com>
To: <cygwin AT cygwin DOT com>
Subject: RE: tcgetattr problem
Date: Thu, 28 Sep 2006 14:46:27 +0100
Message-ID: <01bd01c6e304$7f278ab0$a501a8c0@CAM.ARTIMI.COM>
MIME-Version: 1.0
X-Mailer: Microsoft Office Outlook 11
In-Reply-To: <20060928021335.GD31675@trixie.casa.cgf.cx>
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
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

On 28 September 2006 03:14, Christopher Faylor wrote:

[ ... just to add a few more of the implementation details ... ]

> On Thu, Sep 28, 2006 at 12:10:18AM +0100, ahnkle wrote:
>> On 18:36 Wed 27 Sep     , Igor Peshansky wrote:
>>> 
>>> #define PORT "com1"
>>> ...
>>>   fd = open(PORT, O_RDWR | O_NOCTTY );
>>> 
>>> There's your problem.  When you open a port as "com1", it looks like a
>>> file to Cygwin, since it doesn't recognize it as a valid device name.
>>> Thus any attempt to manipulate that fd as a device will fail.
>>> 
>>> Use the Cygwin device (e.g., "/dev/ttyS0").
>> 
>> Strangely, com1 *does* work in the call to open. Having tried "/dev/ttyS0",
>> tcgetattr() works ok.
> 
> "It looks like a file to Cygwin"

.. which passes it through to the underlying windows api, which knows that it
isn't just a file - but cygwin doesn't.
 
>> I also note that read() and write() work ok too using "com1", but
>> tcsetattr() also fails.
> 
> "It looks like a file to Cygwin"

.. which passes it through to the underlying windows api, which knows that it
isn't just a file - but cygwin doesn't.
 
>> BTW, I obtained the CVS source, but couldn't find the _ioctl() call
>> anywhere in my (brief) grepping. Is there any documentation about internal
>> structure, and whats going on under the hood?
> 
> The name of the function is "ioctl", not "ioctl".

  And the specific implementation is in fhandler_serial.cpp.  But because you
opened something that just looked like a file rather than a special device
(because all cygwin can go by is the filename, and since it doesn't begin
'/dev/' cygwin "knows" it's not a special device file), cygwin opened a
fhandler_disk_file for it.  See

int fhandler_serial::ioctl (unsigned int cmd, void *buffer)

and

int fhandler_base::ioctl (unsigned int cmd, void *buf)

(since fhandler_disk_file doesn't override the virtual method, it inherits the
base class' version).


    cheers,
      DaveK
-- 
Can't think of a witty .sigline today....


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