[Home]

Summary:ASTERISK-10538: Add fractional timeouts and default timeout variable values to Read
Reporter:Michael FIG (michael-fig)Labels:
Date Opened:2007-10-15 20:47:25Date Closed:2007-11-06 11:59:15.000-0600
Priority:MajorRegression?No
Status:Closed/CompleteComponents:Applications/app_read
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:( 0) asterisk-1.4.13-read-float-timeouts-with-defaults.diff
( 1) asterisk-1.4.13-really-read-float-timeouts-with-defaults.diff
( 2) asterisk-85883-read-float-timeouts-with-defaults.diff
( 3) asterisk-read-float-timeouts-with-defaults.diff
Description:The Read application currently has no way to distinguish between when the user pressed '#' (the variable is set to a zero-length string), or if the Read application times out.

The attached patch adds a new option 'd' to Read that allows the dial plan to set the variable, and leave its value unchanged on timeout.

The fractional read timeout is used to allow playing a single message while polling for a key, then immediately advancing to a second message.  This is useful when the messages are built out of fragments instead of one big message that can be provided as the second argument to Read.

****** ADDITIONAL INFORMATION ******

Here is an idiom of where these features would be useful:

exten => 100,1,Set(VAR=N) ; No read key yet.
exten => 100,n,Read(VAR|my-message|1|d||0.001)
exten => 100,n,ExecIf($["${VAR}" = "N"]|Read|VAR|my-message2|1|d||0.001)
exten => 100,n,ExecIf($["${VAR}" = "N"]|Read|VAR|my-message3|1|||86400)
exten => 100,n,GotoIf($["${VAR}" = ""]?PoundKeyPressed)
exten => 100,n,GotoIf($["${VAR}" = "N"]?AWholeDayExpired)
exten => 100,n,GotoIf($["${VAR}" = "1"]?OnePressed)
...

This allows for interruptible menus built out of any kind of logic.
Comments:By: Michael FIG (michael-fig) 2007-10-15 21:25:28

When reviewing the patch, I noticed a few errors.  The first is that a too-small timeout (less than 1ms) will result in the default being used.

Second, a defaultvalue variable that's larger than the tmp array will not be properly zero-terminated.

The attached patch fixes these problems, and while I was at it, updates the patch for asterisk-1.4.13.

By: Jared Smith (jsmith) 2007-10-16 09:17:37

Let me throw out an idea here... why not simply have the application set a channel variable named READSTATUS, as many of the other applications already save their status to a channel variable.  This gives the user greater flexibility, and doesn't require another option to the application.

Thoughts?

By: Michael FIG (michael-fig) 2007-10-16 13:02:13

I just tried to make the most minimal change possible.

Can you propose exactly what you want to add, with sample code?  With such a specification, I can implement it if you like, if that would mean my change would be accepted (I really need one of these two features for a dial plan I'm working on).

By: Tilghman Lesher (tilghman) 2007-10-16 13:07:00

While this is nice, 1.4 is feature-frozen.  Please create any patches that implement feature adds to trunk.  If you also found bugs, though, those patches can go into 1.4.

By: Tilghman Lesher (tilghman) 2007-10-16 13:11:12

Sample code as for what jsmith is proposing:

exten => 100,n,ExecIf($["${READSTATUS}" = "TIMEOUT"],Read,VAR,my-message2,1,,,0.001)
exten => 100,n,ExecIf($["${READSTATUS}" = "TIMEOUT"],Read,VAR,my-message3,1,,,86400)
exten => 100,n,GotoIf($["${VAR}" = ""]?PoundKeyPressed)

By: Michael FIG (michael-fig) 2007-10-16 13:31:10

The latest patch (asterisk-85883...) is against the SVN trunk, and also adds Doxygen documentation for the changes I made.

I'll cook up something using READSTATUS, and submit it under a separate feature report.

By: Michael FIG (michael-fig) 2007-10-16 14:54:45

I've submitted the READSTATUS patch under ASTERISK-1094004.  jsmith, you were right... it's much better than the 'd' flag, and doesn't require as intrusive a patch.



By: Jason Parker (jparker) 2007-11-05 17:36:54.000-0600

Does anything else need to be done here then?

It looks like the fractional timeout stuff was not committed - can you create a separate patch for this?

By: Michael FIG (michael-fig) 2007-11-06 11:49:00.000-0600

No, nothing more here.

Somebody else committed fractional timeouts to the SVN head, and the patch in ASTERISK-1094004 supercedes the rest of these patches (but has not yet been applied).