X-Recipient: archive-cygwin AT delorie DOT com X-SWARE-Spam-Status: No, hits=-2.1 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Message-ID: <4960ED6A.7030303@xs4all.nl> Date: Sun, 04 Jan 2009 18:10:02 +0100 From: Bob van Loosen User-Agent: Thunderbird 2.0.0.18 (X11/20081125) MIME-Version: 1.0 To: cygwin AT cygwin DOT com Subject: Re: printf goes to serial port? Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: 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 Hi, I was pointed to this discussion at the archives: http://www.cygwin.com/ml/cygwin/2008-12/msg00489.html I have a similar problem with my app, all printf statements go out the serial port. The problem is, I'm using the -mwindows flag to get a sort of "real" windows app, so no console output. Because of this, the app doesn't get the standard file descriptors for stdin, stdout and stderr, also when you open a file the file descriptors start at 0. So what happens is, my app opens a config file, which then becomes stdin, then it opens a serial port, which becomes stdout, causing all printf statements to go out the serial port. The solution is quite simple, just disable all printf statements for a cygwin build. I have no idea how to get console output when using the -mwindows flag, but I don't really need it. I didn't notice this at first because my homemade rs232 hardware expects 0xFF and then 12 bytes (for 12 pwm channels) which is sent to it every 16 ms or so, so any garbage sent to it basically gets ignored because the hardware waits for the 0xFF prefix. However, some people use hardware that doesn't expect a prefix, so if it expects 9 bytes at a time for 9 pwm channels, and the data from the printf statements is sent out the serial port, the hardware gets out of sync. This is a really bad design for a protocol, but there's a howto for the hardware on the net somewhere so a lot of people use it. Bob. -- 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/