This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Nonblocking serial ports


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

HTH,


Yaakov

#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>

#define DEVICE "/dev/ttyS2"

int main(void) {
	int fd;
	fd = open(DEVICE, O_RDWR | O_NOCTTY | O_NONBLOCK);
	if (fd < 0) {
        fprintf(stderr, "first open(%s) failed: %s\n", DEVICE, strerror(errno));
		return 1;
	}
	fd = open(DEVICE, O_RDWR);
	if (fd < 0)
        fprintf(stderr, "second open(%s) failed: %s\n", DEVICE, strerror(errno));
		return 2;
	close(fd);
	return 0;
}

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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]