This is the mail archive of the ecos-patches@sourceware.org mailing list for the eCos 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]

[Bug 1001466] /dev/null serial driver


Please do not reply to this email. Use the web interface provided at:
http://bugs.ecos.sourceware.org/show_bug.cgi?id=1001466

--- Comment #6 from Bernard Fouchà <bernard.fouche@kuantic.com> 2012-02-16 14:20:30 GMT ---
My issue is to keep in the app on the field things like
fprintf(DebugStream,...) and be able to activate/deactivate the debug messages
without modifying the app, and without adding things like 'if(DebugOpened)'
before each use of DebugStream.

This way I can use a serial port for the app and when debug is needed, I
disconnect the connected device on the serial port, connect instead a terminal
emulator, activate debug, check the debug messages and then go back to full app
mode afterwards.

If I use:

if(DebugOpened)
  fprintf(DebugStream,...)

Then I also need

if(!DebugOpened)
  fprintf(NotADebugStream,...)

While with this driver I can do:

#if DEBUG
fprintf(DebugStream,...)
#endif
fprintf(NotADebugStream,...)

When I need to deactivate the messages, I fclose(DebugStream) and do
DebugStream=fopen("/dev/null").

When I need the debug messages back I do the same fclose() but fopen() to some
/dev/serX. In my mind it's like sending stderr to /dev/null or sending it to
some output device, that's why I named this fake driver '/dev/null'.

Performance isn't an issue here, it's convenience first during app tests (that
can last for months) on a target that uses all serial ports.

I can't add enable/disable config keys to serial.c since this would completely
switch on or off the uart: I always need the uart but I need to select what
stream is feeding it.

Maybe the proper solution is in the stdio lib? Or rename the driver
/dev/ser_void to avoid semantics confusion with /dev/null?

-- 
Configure bugmail: http://bugs.ecos.sourceware.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


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