2024-09-18 05:23 AM - last edited on 2024-09-19 04:38 AM by Andrew Neil
(originally a reply to https://community.st.com/t5/stm32cubeide-mcus/retarget-printf-on-stm32g070rbxx-cortex-m0/td-p/720883)
Hi @Andrew Neil,
For the scanf do we need to make any other change?
My read function is-
int _read(int fd, char *ptr, int len){
(void)fd;
int i;
for(i=0;i<len;i++){
*ptr++ = uart_read();
}
return len;
}
In the terminal window it is not taking any keypress.
Solved! Go to Solution.
2024-09-19 04:50 AM - edited 2024-09-19 05:02 AM
2024-09-18 05:52 AM
I've not tried it.
I guess you would still need to do the extern "C" and anything else specific to C++ ...
2024-09-18 11:07 AM
This I'm trying on C. The cursor doesn't take input on keypress.
2024-09-18 03:18 PM
@AVerm.4 wrote:the cursor doesn't take input on keypress.
What do you mean by that?
Do you mean the keypress doesn't appear on your terminal?
If you want that, it's called echo - it can be either local or remote:
Again, beware of the line buffering.
If you put a breakpoint in your _read function, is it hit ?
2024-09-19 03:45 AM - edited 2024-09-19 03:47 AM
Both the local and remote echo is working fine. now, i have to handle CR so that on pressing Enter key the code should return to main function.
Also it is hitting my read function correctly.!
2024-09-19 04:50 AM - edited 2024-09-19 05:02 AM
setbuf(stdin, NULL);
2024-09-19 05:00 AM
@AVerm.4 wrote:Both the local and remote echo is working fine.
So what did you mean by, "The cursor doesn't take input on keypress", then ?
2024-09-19 07:16 AM
It was not visible on my terminal. So enabled it in settings.
2024-09-19 07:38 AM
Right - so it was an echo setting, then?
2024-09-19 11:24 PM
Exactly !