User guide
August 2001 35
Sending and Receiving Digits
Flushing the Digit Buffer
Before detecting new digits from an incoming call, flush the
digit buffer using RHT_FLUSH_DIGIT. In a well designed
application there should never be digits remaining in the buffer
after a call, since the digits are deleted after the application
reads them. However, if the application does not run properly,
then extra digits might remain in the buffer even after you
terminate the application, remove any bugs, and run it again.
Flushing the digit buffer is particularly important in handling
R2 digits. If digits remain in the digit buffer from a previous
call, the application inappropriately responds to the digits
although no digits have been sent on the line. The resulting
protocol violation causes the carrier to drop the call.
The best time to flush digits is after going on-hook but before
monitoring for a new call using RHT_WAIT_LINE_ON. If you
flush digits after calling RHT_WAIT_LINE_ON, your thread
could get pre-empted. If that happens, the function might not
execute until after the application has started receiving digits
from a new call. When the application eventually flushes the
digit buffer, it clears digits that are already stored so the
application doesn’t receive the entire digit string. In R2
signaling, the application waits for a new digit rather than
acknowledging any of the deleted received digits. However, the
other end doesn’t send a new digit until it receives an
acknowledgment. The function eventually times out when
neither end receives the expected signal.
The timing of when to flush digits is less important if the
application is sending the call. However, it is best to flush digits
before beginning the call. This way, if you ever reuse the code as
the receiving end, the application will not flush digits at the
wrong time.