We are using a ADUC848 Microcontroller that has an 8051 based core.
We are using Keil uVision 3.
What we need to do is send a #TST# string out from the Microcontroller, which we are accomplishing using a printf("!&#TST#&\n"); command.
The Microcontroller is connected to a PC via USB, but a PC isn't always used, so the embedded software will run with or without it.
If the computer sees the #TST# string it will send a signal to the Microcontroller, telling it to start running a test.
If the Microcontroller does not see the signal from the computer, it will send the #TST# string a couple more times.
If it still doesn't see it, the Microcontroller will begin running the test.
We want to do this in about 5 seconds.
The embedded C software has already been written and it works fine, but i'm trying to add this functionality, because when they are using a PC, we want to make sure that they see each other properly.
My problem:
I've been trying to use the Getkey command to get the character from the computer. It works, but the problem is the getkey command halts execution and won't start again until it gets a key
Basically, what i'm asking is, is there anyway we can have the getkey run for 5 seconds, if it doesn't find anything, then it will just continue.
unfortunaltely I don't know that special API. On such systems you usually have an interrupt for events like that.
The easiest way to solve that is: set bool to false, [ In your interrupt function: if the serial event occurs set the bool to true ] sleep 5 seconds, check whether that bool is true or not.
My problem with understanding your issue is that logically it reduces to Micorcontroler run this test, because regardless of the response from the computer it will eventually run the test evert 5 seconds.