cancel
Showing results for 
Search instead for 
Did you mean: 

Porting C++ application to STM32, problem with cin special character input from UART

RAltm
Senior

Hi,

I'm porting a C++ application to a STM32, using CubeIDE. The application uses cin/cout, for which I implemented the __io_getchar() and __io_putchar() functions used by _read()/_write() from syscalls.c, redirecting the input/output to UART. This works in general, but I've some issues with special characters. I want to know where I have to do the changes to make it run smoothly.

Note: I'm aware of that using <iostream> will increase the code size. I'll modify it later to use scanf/printf to reduce code size, that's not the current issue.

The original application is a command line application and works as an interpreter for commands. For the embedded device, the "console" will be a terminal software like TeraTerm or similar. So, the goal is that the input/output via UART works similar to the console I/O on a PC.

For the output, it seems that this is already working. However, for input, I've some issues with special characters like backspace. Other special characters like tabulator are processed as whitespaces by the interpreter.

Now, the question is where do I have to handle the backspace? Both cin/scanf are using _read() function from syscalls.c file. So, I assume I've to check the characters within _read() function and modify the pointer accordingly, right?

So, in fact I've to check all possible inputs from a given terminal application (for example, some terminals will send specials characters for using the arrow keys) and handle them in the _read() function.

Regards

0 REPLIES 0