Provide weak default implementation for printChar function #565

Closed
opened 2022-02-23 10:56:31 +01:00 by muellerr · 2 comments
Owner

I think it might be a good idea to provide a weak default implementation for the printChar function. Most of the time, compiler specific extensions are necessary to do this, but all compilers I saw provide this feature and in practice, the FSFW is mostly compiled with GCC anyway. In most cases, a default implementation using putc is okay. Even on bare metal systems, syscall overrides make sure that standard IO function are rerouted through an interface like UART.

This would make it easier to simply use fsfw as a utility library (I'm looking at arrayprinter, DleEncoder etc. and all code sections which are usually just copy and pasted)

I think it might be a good idea to provide a weak default implementation for the printChar function. Most of the time, compiler specific extensions are necessary to do this, but all compilers I saw provide this feature and in practice, the FSFW is mostly compiled with GCC anyway. In most cases, a default implementation using `putc` is okay. Even on bare metal systems, syscall overrides make sure that standard IO function are rerouted through an interface like UART. This would make it easier to simply use `fsfw` as a utility library (I'm looking at arrayprinter, DleEncoder etc. and all code sections which are usually just copy and pasted)
Author
Owner

One possible default implementation:

void printChar(const char* character, bool errStream) {
  if (errStream) {
    putc(*character, stderr);
    return;
  }
  putc(*character, stdout);
}
One possible default implementation: ```c void printChar(const char* character, bool errStream) { if (errStream) { putc(*character, stderr); return; } putc(*character, stdout); } ```
Author
Owner

Fixed by #674

Fixed by https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/674
Sign in to join this conversation.
No Milestone
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: fsfw/fsfw#565
No description provided.