• 0

scanf timeout on ARTY


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


Share this post

Link to post
Share on other sites

1 answer to this question

Recommended Posts

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Answer this question...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.