Jump to content
  • 0

scanf timeout on ARTY


emfries

Question

I've set up my ARTY board to read and write strings via a UART connection to a computer. The computer makes a serial connection with ARTY. In the SKD, I use scanf to read an input to the UART line and save it as a string on ARTY. This works, but scanf will hang forever until input is provided.

Is there a way to make scanf timeout? If not, is there a way (using scanf or some other feature) to check for input to the UART line and not hang if there isn't input, and then if there is input read it? For example, I'd want the loop in the following pseudocode to run at ~1s per loop, instead of hanging if there is no input to the UART line:

while True:
	sleep one second
	if there is input to the UART line:
		read the input from the UART line and save to a string
		do something

Thanks!

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...