2017-09-13 09:41 AM
I'm looking for a way to input data on stdin, but with a non-blocking function. Everything I've tried in stdio.h blocks program execution while waiting for a keypress. I want to input a keypress if one has occurred, but continue program execution if one has not.
I understand the function kbhit() is usually in conio.h, but that library isn't present in my AC6 install. Is it available?
Is there another way?
2017-09-13 10:09 AM
It is going to depend on how you've implemented __io_getchar()
http://www.openstm32.org/tiki-view_forum_thread.php?comments_parentId=1065&display=print_all
You'd have to implement you're own equivalent to kbhit() based on your input source.
ie
if (USART2->SR & USART_SR_RXNE) return(1); else return(0);
2017-09-13 12:18 PM
Please pardon my not communicating that I'm using semihosting to redirect the stdio to the AC6 console through the debugger. So there is no physical USART to query.
I'm using the ST-Link debugger integrated on the NucleoF4 board.
2017-09-13 03:37 PM
Something you'd want to probe with your tool vendor.
Presuming it is using the SWV channel rather than the VCP/USART, you could perhaps looks at the ITM registers, or look at the __io_getchar() or equivalent.