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]

Re: printf goes to serial port?


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/


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