public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* Re: printf goes to serial port?
@ 2009-01-04 19:22 Bob van Loosen
  2009-01-04 21:30 ` Dave Korn
  0 siblings, 1 reply; 12+ messages in thread
From: Bob van Loosen @ 2009-01-04 19:22 UTC (permalink / raw)
  To: cygwin

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/

^ permalink raw reply	[flat|nested] 12+ messages in thread
* printf goes to serial port?
@ 2008-12-19 18:02 Alex Martin
  2008-12-19 19:31 ` Gary R. Van Sickle
  0 siblings, 1 reply; 12+ messages in thread
From: Alex Martin @ 2008-12-19 18:02 UTC (permalink / raw)
  To: cygwin

Hello,

I have a cygwin environment, running some software I am writing to talk 
to some serial devices.

Somehow, trying to debug why I could not see printf output to console, I 
ran a serial port sniffer and voila all of my printf commands are 
writing on the serial port.

Any idea how to fix this?

Thanks,
Alex Martin

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

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2009-01-04 20:34 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-01-04 19:22 printf goes to serial port? Bob van Loosen
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)

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