• 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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now