Hi,
There is no need to know when the response will end as the loop will stop automatically when all the response is received. ie The 'OK' is received.
I put the timeout in just as a backstop incase there is something wrong, a way out for the loop.
In reality the response time is more immediate on the modems I am using.
I think my final code had this at one minute, 10 seconds [u]might</u> be plenty.
Also, it would be an advantage to put a few second thread sleep in between loops as this code puts the CPU in a bit of a spin if there is a problem and you have to wait for the timeout.
The five/one minute fallback should never be reached if all is going well, and the loop/process will stop as soon as the OK is received.
I am not aware of a definative way to tell in advance what response time the modem will give, and I would imagine that it will vary form modem to modem and depending on how many messages there are.
I suggest logging the datetime when you send the command and again when you receive the OK a few times to work out the most appropriate time for you.
Also, my final code had the timeout value set from the config file so it can be improved if needed.
If you improve on this code please post on the original thread as it gets a lot of hits.
Hope this helps
Rod
======================================
"They say, best men are molded out of faults,
And, for the most, become much more the better
For being a little bad."
--Shakespeare
======================================
|