This is the mail archive of the
cygwin
mailing list for the Cygwin project.
Re: Nonblocking serial ports
- From: Corinna Vinschen <corinna-cygwin at cygwin dot com>
- To: cygwin at cygwin dot com
- Date: Mon, 14 Jun 2010 12:26:31 +0200
- Subject: Re: Nonblocking serial ports
- References: <1276495179.5780.13.camel@YAAKOV04>
- Reply-to: cygwin at cygwin dot com
On Jun 14 00:59, Yaakov S wrote:
> I came across this while working on getting my Palm to hook up to
> gnome-pilot over Bluetooth. COM3 is an incoming COM Port created within
> Bluetooth Settings, although the STC has the same results on COM1 (a
> standard serial port).
>
> Unlike pilot-link's tools and jpilot (all three use pilot-link's
> libpisock under the hood), gnome-pilot open()s a serial port with
> O_NONBLOCK when first started in order to initialize a GIOChannel, then
> later pi_bind()s a different fd pointing to the same port. Works great
> on Linux, but on Cygwin the latter call fails, as the serial port is
> already blocked by the first open() call. FWIW, both pilot-xfer and
> friends and jpilot work fine over the Bluetooth serial port, and all
> three work over the network.
>
> Attached is a STC. On Linux, this succeeds, but on Cygwin (both 1.7.5
> and latest snapshot), it fails:
>
> second open(/dev/ttyS2) failed: Permission denied
That's apparently a Windows restriction. Communication devices like
serial or parallel ports can only be opened exclusively on the API
level. It does not matter what sharing flags have been set when opening
the file for the first time. Actually MSDN requies to set the sharing
flags to 0 when opening comm devices, but Cygwi opens them with all
sharing flags set, to no avail.
Allowing to open a comm device more than once at a time would require
some redesign in Cygwin, along the lines of what's done to propagate
the pipe handles used for ttys to other processes. That would be a
nice case of http://cygwin.com/acronyms/#PTC ...
Corinna
--
Corinna Vinschen Please, send mails regarding Cygwin to
Cygwin Project Co-Leader cygwin AT cygwin DOT com
Red Hat
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple