1

I am using Eclipse variant called Atollic TrueSTUDIO version 9.2.0 for the STM32 platform.

When I do printf("Hello World\n"); from the microcontroller, is it possible to configure the Eclipse terminal to treat the \n as a newline? Without the carriage return, Eclipse does not return the cursor to the start of the line.

Is it possible to do this? I tried the following: Window->Preferences->General->Workspace, and on this window selected "New text file line delimiter: Unix", but this did not work for me.

Below image illustrates the problem. Eclipse not treating \n as line feed carriage return

Maxim Blinov
  • 886
  • 9
  • 33

2 Answers2

0

two options:

  1. printf("Hello World\r\n");
  2. Use another program for example realterm which allow you to append \r to every \n
  3. #define myprintf(fmt, ...) {printf(fmt, ___VA_ARG__); printf("\r");}

But I do not really understand

0___________
  • 60,014
  • 4
  • 34
  • 74
0

I'd really like to use the internal terminal to display stuff, but this is still a problem. osstreams terminated with std::endl; lead to this weird indentation. No fix to this yet? I have not found a way to have implicit carriaghe return with line feed in the eclipse settings for the terminal

Spacefish
  • 305
  • 4
  • 11
  • I'm assuming that you've defined the `__io_putchar` method in order to direct `printf` (or `std::cout`) to the UART - in which case, you could add a condition in `__io_putchar` that if we're called with `\n`, then also call `__io_putchar('\r')`. something like `extern "C" int __io_putchar(int ch)` `{` ` HAL_UART_Transmit(&huart1, (uint8_t *)&ch, 1, 0xFFFF);` `` ` if (ch = '\n')` ` __io_putchar('\r');` `` ` return ch;` `}` (untested) – Maxim Blinov Apr 10 '20 at 18:46
  • It does indeed print to a Serial interface. I solved the problem for now by modifying our stream buffer sync function (which was overriden to add a preamble to custom osstreams) to have an option to add an optional "\r" at the beginning. Problem is that when I run this in a regular program which does print to std::cout directly, it will recognize \r\n as two line breaks. – Spacefish Apr 13 '20 at 11:16