From: Bob van Loosen <loosen@xs4all.nl>
To: cygwin@cygwin.com
Subject: Re: printf goes to serial port?
Date: Sun, 04 Jan 2009 19:22:00 -0000 [thread overview]
Message-ID: <4960ED6A.7030303@xs4all.nl> (raw)
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/
next reply other threads:[~2009-01-04 17:10 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-01-04 19:22 Bob van Loosen [this message]
2009-01-04 21:30 ` Dave Korn
2009-01-04 21:45 ` Bob van Loosen
-- strict thread matches above, loose matches on Subject: below --
2008-12-19 18:02 Alex Martin
2008-12-19 19:31 ` Gary R. Van Sickle
2008-12-19 19:35 ` Matt Wozniski
2008-12-19 20:35 ` Alex Martin
2008-12-19 20:19 ` Alex Martin
2008-12-19 20:38 ` Gary R. Van Sickle
2008-12-19 21:01 ` Alex Martin
2008-12-19 21:23 ` Gary R. Van Sickle
2008-12-19 21:32 ` Larry Hall (Cygwin)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4960ED6A.7030303@xs4all.nl \
--to=loosen@xs4all.nl \
--cc=cygwin@cygwin.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).