X-Spam-Check-By: sourceware.org Message-ID: <25e2d6fe0701170637t73d09f1es7db8fe1695fa5c38@mail.gmail.com> Date: Wed, 17 Jan 2007 15:37:35 +0100 From: "Florent Morin" To: cygwin AT cygwin DOT com Subject: Re: cygwin 1.5.23-2 : CREAD termios option don't work In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <25e2d6fe0701110753k506a1d21l382cca911bca3bca AT mail DOT gmail DOT com> <20070112102814 DOT GB8311 AT calimero DOT vinschen DOT de> X-IsSubscribed: yes Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Hello, Like you say, CREAD isn't the real problem. I use select() to read/write socket and read/write serial. But, after writing the content of socket on serial port, I can't read serial port (access denied). This is an extract of my source code : ---------------- CODE --------------------- int serial_fd; int max_fd; unsigned char buffer[MAX_CANON]; int size; int converted_size; unsigned char buffer2[MAX_CANON]; int size2; fd_set read_set; fd_set write_set; nice(15); /* opening serial port read/write, non-block */ serial_fd = open ( port_settings->device, O_NONBLOCK | O_RDWR | O_NOCTTY); max_fd = socket_fd < serial_fd ? serial_fd : socket_fd; alarm(ALARM_TIMEOUT); while (1) { FD_ZERO(&read_set); FD_SET(socket_fd, &read_set); FD_SET(serial_fd, &read_set); FD_ZERO(&write_set); FD_SET(socket_fd, &write_set); FD_SET(serial_fd, &write_set); if ( select(max_fd + 1, &read_set, &write_set, NULL, NULL) < 0) perror("select"); if (FD_ISSET(socket_fd, &read_set) && !FD_ISSET(serial_fd, &read_set) && FD_ISSET(serial_fd, &write_set)) { alarm(0); memset(&buffer, 0, MAX_CANON); size = read(socket_fd, buffer, MAX_CANON - 1); converted_size = convert_telnet(&buffer, size); while (write(serial_fd, buffer, converted_size) < 0) { if (errno == EAGAIN) { error("write", 0); sleep(1); } else error("write", 1); } alarm(ALARM_TIMEOUT); } if (FD_ISSET(serial_fd, &read_set) && FD_ISSET(socket_fd, &write_set)) { alarm(0); memset(&buffer2, 0, MAX_CANON); printf("read serial"); size2 = read(serial_fd, buffer2, MAX_CANON - 1); if (size2 > 0) { while (write(socket_fd, buffer2, size2) < 0) { if (errno == EAGAIN) { error("write", 0); sleep(1); } else error("write", 1); } } alarm(ALARM_TIMEOUT); } sleep(1); } close(serial_fd); ---------------- /CODE --------------------- I have tested it on Linux. It works fine. When I send data throw telnet protocol, the data are received by the peripheral connected to serial and vice-versa. Perhaps I don't use the functions very well. So, if you can help me, thanks. Florent Morin. 2007/1/12, Brian Ford : > On Fri, 12 Jan 2007, Corinna Vinschen wrote: > > On Jan 11 16:53, Florent Morin wrote: > > > For testing, I have tried with a working program : stty. It works fine > > > with all options, but not with CREAD. > > > > > > $ stty cread < /dev/ttyS0 > > > stty: /dev/ttyS0: unable to perform all requested operations > > > > > > Can someone explain this ? > > > > Please consider to debug this yourself. Cygwin has no volunteer which > > is fluent with serial I/O right now. > > This is not a regression from 1.5.18, which I know worked fine with serial > I/O. I will try to test 1.5.23 when I get a chance, but I have no reason > to suspect it is broken. > > CREAD appears to always be enabled but not indicated by tcgetattr or > controllable via tcsetattr right now. So, the test case above is not > indicative of the original problem. > > To the OP, posting your code might be informative. > > -- > Brian Ford > Lead Realtime Software Engineer > VITAL - Visual Simulation Systems > FlightSafety International > the best safety device in any aircraft is a well-trained crew... > > > > -- > 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/