[Home]

Summary:ASTERISK-20484: Code Cleanup in app_alarmreceiver caused new issue where event are processed before receiving all digits
Reporter:Jean-Philippe Lord (jplord)Labels:
Date Opened:2012-09-27 11:33:34Date Closed:2012-10-16 14:40:26
Priority:MajorRegression?Yes
Status:Closed/CompleteComponents:Applications/app_alarmreceiver
Versions:SVN Frequency of
Occurrence
Constant
Related
Issues:
Environment:Attachments:( 0) 43933_OLD_DO_NOT_USE_app_alarmreceiver.c
( 1) app_alarmreceiver.c
( 2) ASTERISK-20484_v1.diff
( 3) ASTERISK-20484_v2.diff
Description:Issue caused since ASTERISK-20157

event are processed before receiving all digits

== AlarmReceiver: Received Event 010
== AlarmReceiver: Bad DTMF character ý == AlarmReceiver: Nonzero checksum
== AlarmReceiver: Received Event 100
== AlarmReceiver: Bad DTMF character ý == AlarmReceiver: Nonzero checksum
== AlarmReceiver: Received Event 0C2
== AlarmReceiver: Bad DTMF character ý == AlarmReceiver: Nonzero checksum
== AlarmReceiver: Received Event 299
Comments:By: Matt Jordan (mjordan) 2012-09-27 14:29:10.314-0500

Acknowledging the issue and assigning to Pedro Kiefer.

By: Kaloyan Kovachev (knk) 2012-09-28 04:00:47.590-0500

The attached patch should fix it.

By: Jean-Philippe Lord (jplord) 2012-10-01 21:37:34.208-0500

Hello Kaloyan,

I have done some more testing and it appears the new version from ASTERISK-20157 is causing an issue (with the workaround or with the attached patch)

I have a local panel attached to an ATA that dials into asterisk, codec ulaw. Tones are captured no issue.

However I also have a remote panel with an ATA, codec ulaw. Tones are not recognized when this panel dials. I get the following on the console:

 == AlarmReceiver: Incomplete string: , trying again...
      > AlarmReceiver: Sending 1400Hz 100ms burst (ACK)
      > AlarmReceiver: Sending 2300Hz 100ms burst (ACK)
      > AlarmReceiver: DTMF Digit Timeout on IAX2/matrix-6020
 == AlarmReceiver: Incomplete string: , trying again...
      > AlarmReceiver: Sending 1400Hz 100ms burst (ACK)
      > AlarmReceiver: Sending 2300Hz 100ms burst (ACK)
      > AlarmReceiver: DTMF Digit Timeout on IAX2/matrix-6020
 == AlarmReceiver: Incomplete string: , trying again...
      > AlarmReceiver: Sending 1400Hz 100ms burst (ACK)
      > AlarmReceiver: Sending 2300Hz 100ms burst (ACK)
      > AlarmReceiver: DTMF Digit Timeout on IAX2/matrix-6020
 == AlarmReceiver: Incomplete string: , trying again...
      > AlarmReceiver: Sending 1400Hz 100ms burst (ACK)
      > AlarmReceiver: Sending 2300Hz 100ms burst (ACK)
      > AlarmReceiver: DTMF Digit Timeout on IAX2/matrix-6020
 == AlarmReceiver: Incomplete string: , trying again...
      > AlarmReceiver: Sending 1400Hz 100ms burst (ACK)
      > AlarmReceiver: Sending 2300Hz 100ms burst (ACK)
      > AlarmReceiver: App exiting...

To further pinpoint the issue, I took revision 362635 from SVN and did a simple change to it to simply disable the send_tone_burst function and use astetisk built in functions (attached is this modified version) and for some reasons, both the local panel and remote panel work properly and tones are captures 1st try.

I am not sure what the issue may be. I can run other tests if you can help.

Thanks again.

By: Kaloyan Kovachev (knk) 2012-10-02 04:24:10.789-0500

My guess is that ast_safe_sleep() returns -1 on the first delay. Can you please test changing the send_tone_burst code:

if (delay && ast_safe_sleep(chan, delay)) {
return -1;
}

to:

if (delay) {
ast_safe_sleep(chan, delay);
}


By: Jean-Philippe Lord (jplord) 2012-10-02 16:56:05.979-0500

Hello,

I have tried and no changes...

I did a chanspy while the alarm panel called and I could hear the 2 short tones from app_alarmreceiver then no sound for about 1 second and the the 2 tones again... over and over again.

It seems that for some reasons, the remote panel is not recognizing the ack tone and does not start to send anything.

For some odd reason, the version I sent yesterday worked when I rolled back to it after this test and the tones from the remote panel came thru.



By: Kaloyan Kovachev (knk) 2012-10-03 03:29:48.920-0500

Got it! You hear the tones, but without a pause between them. My fault sorry.

res = send_tone_burst(chan, "2300", 100, 0);

should be:

res = send_tone_burst(chan, "2300", 100, 100);

By: Jean-Philippe Lord (jplord) 2012-10-03 17:33:00.124-0500

Hello Kaloyan,

You got it right ! It works 1st time with the attached patch and this one line change for the delay.
                               /* res = send_tone_burst(chan, "2300", 100, tldn, 0); */
                               res = send_tone_burst(chan, "2300", 100, tldn, 100);



By: Kaloyan Kovachev (knk) 2012-10-04 03:15:22.044-0500

v2 with the second fix included

By: Jean-Philippe Lord (jplord) 2012-10-12 09:27:54.490-0500

Thanks Kaloyan,

The patch works perfect and no issue found in testing. Thanks for you help.

By: Pedro Kiefer (pedrokiefer) 2012-10-16 13:41:52.774-0500

I'm review and testing the patch.

If everything is good I'll push the fix, or should I open a review first?

By: Pedro Kiefer (pedrokiefer) 2012-10-16 14:40:26.336-0500

Fix pushed to SVN trunk.

By: Jean-Philippe Lord (jplord) 2012-10-16 15:12:31.735-0500

Thanks !

By: John Bonzey (jbonzey) 2012-12-03 21:48:06.074-0600

Jean-Philippe or Pedro

I was trying to figure out when the this fix would be pushed to a release.  I asked the question on the help forum and someone came back with the response that it looks like it won't be until 12 and even then it will have problems.  Could you read the topic at the below link and comment.  I have used the alarmreceiver module for years and broke it when i upgraded to 10.10.  Thanks and sorry to post here but couldn't figure out how to reach either of you.  Link is below and thanks for maintaining this module !!!!


http://forums.asterisk.org/viewtopic.php?f=1&t=84875#p181108



By: Pedro Kiefer (pedrokiefer) 2012-12-04 07:53:39.994-0600

What do you mean by "even then it will have problems"? If it's a bug, please file a new bug report.

I'll see if I can backport the changes to 10 and 11. Do know what is broken on 10?

By: John Bonzey (jbonzey) 2012-12-04 08:04:06.070-0600

The comment in the forum (link above) had to do with one fix building on another etc. I'm sure everything will work.  Thanks for your work and getting the fixes applied to 10 and 11 in an update

By: Joshua C. Colp (jcolp) 2012-12-04 08:06:57.083-0600

A discussion occurred about this on the asterisk-dev IRC channel. It's policy for only bug fixes to be applied to release branches unless unavoidable. If there's a legitimate problem in 10 and 11 that can be isolated and fixed by backporting part of the trunk changes, I've told Pedro that's fine. I'm just not fine with ignoring the policy and bringing everything back.

By: Kaloyan Kovachev (knk) 2012-12-04 09:58:09.648-0600

app_alarmreceiver was unmaintained and broken for several releases (since 1.4 i think) and the cleanup from 20157 was actually the bugfix (for a number of JIRA issues see review https://reviewboard.asterisk.org/r/2075/ ).
As the app from trunk is compatible (i think) with 10 and 11, and the users of this functionality are not much, maybe just 'copy the app from trunk and recompile' is the best choice here for them, because backporting without the cleanup, would mean applying all the changes in place, all over the code and the full changes (with cleanup) are against the policy.

By: John Bonzey (jbonzey) 2012-12-14 12:08:55.998-0600

Currently running Asterisk 1.8.18.0
I copied latest app_alarmreceiver.c with fixes from http://svnview.digium.com/svn/asterisk/trunk/apps/app_alarmreceiver.c?annotate=375081

I put the file in /usr/src/asterisk/apps and tried to compile using:

gcc app_alarmreceiver.c -o app_alarmreceiver.so


I received the errors below.  Are these errors because the fix is not compatible with 1.8 or
am i compiling it wrong etc?

root@pbx:/usr/src/asterisk/apps $ gcc app_alarmreceiver.c -o app_alarmreceiver.so
app_alarmreceiver.c: In function âdatabase_incrementâ:
app_alarmreceiver.c:125: error: âAST_MODULEâ undeclared (first use in this function)
app_alarmreceiver.c:125: error: (Each undeclared identifier is reported only once
app_alarmreceiver.c:125: error: for each function it appears in.)
app_alarmreceiver.c: In function âsend_tone_burstâ:
app_alarmreceiver.c:213: error: âAST_MODULEâ undeclared (first use in this function)
app_alarmreceiver.c: In function âreceive_dtmf_digitsâ:
app_alarmreceiver.c:248: error: âAST_MODULEâ undeclared (first use in this function)
app_alarmreceiver.c: In function âwrite_metadataâ:
app_alarmreceiver.c:346: error: âAST_MODULEâ undeclared (first use in this function)
app_alarmreceiver.c: In function âlog_eventsâ:
app_alarmreceiver.c:391: error: âAST_MODULEâ undeclared (first use in this function)
app_alarmreceiver.c: In function âreceive_ademco_contact_idâ:
app_alarmreceiver.c:444: error: âAST_MODULEâ undeclared (first use in this function)
app_alarmreceiver.c: In function âalarmreceiver_execâ:
app_alarmreceiver.c:583: error: âAST_MODULEâ undeclared (first use in this function)
app_alarmreceiver.c: In function âload_configâ:
app_alarmreceiver.c:654: error: âAST_MODULEâ undeclared (first use in this function)
app_alarmreceiver.c: At top level:
app_alarmreceiver.c:738: error: âAST_MODULEâ undeclared here (not in a function)


By: Pedro Kiefer (pedrokiefer) 2012-12-14 12:21:17.101-0600

Try running make, and make sure you've selected app_alarmreceiver on menuselect.

By: John Bonzey (jbonzey) 2012-12-22 18:18:15.988-0600

Hey Guys,
I know this is not the right place to post questions but hoping you can help me out.  i wrote up a big procedure on how to configure and implement your alarmreceiver module but since the latest asterisk code doesn't work without your patches I can't get it to work.  I have 1.11 asterisk running but can not get your latest alarmreceiver.c fixes implemented.  Could someone post on http://forums.asterisk.org/viewtopic.php?p=181097 how to take the 2 or 3 patches you have created and get it to work with the the asterisk release.  I have spent a lot of time trying to compile the new alarmreciever.c file and cant get it to work.  I wrote up a big procedure on asterisk.org and http://www.freepbx.org/forum/freepbx/tips-and-tricks/alarmreceiver-event-translation-procedure-with-email
but without your patches it is worthless.  Any detailed help on how to take your patches and apply to asterisk 11 would be appreciated.  I know you guys spent a lot of time creating the patches and hoping you can walk us less technical people through the necessary steps for implementation so we can can all take advantage of you work.

thanks
John


By: Kaloyan Kovachev (knk) 2012-12-23 02:35:50.837-0600

Hi,
just as i wrote in my previous post - 'copy the app from trunk and recompile'. You can get it from here: http://svnview.digium.com/svn/asterisk/trunk/apps/app_alarmreceiver.c?revision=375215

By: John Bonzey (jbonzey) 2012-12-24 14:35:22.401-0600

I have been trying to compile as you recommended the last time.  I'm likely doing this incorrectly as i continue to get errors.  Will the .so file be system specific because if not is there anyway someone can post a compiled version.  I'm running asterisk 11 now. Menuselect shows app_alarmreceiver checked but not sure how to use the make command as you suggested

The errors i'm getting are below:
Thanks for your help!!!!!


root@pbx:/tmp $ gcc app_alarmreceiver.c -o app_alarmreceiver.so -lsrtp
app_alarmreceiver.c: In function âreceive_dtmf_digitsâ:
app_alarmreceiver.c:266: error: âAST_MODULEâ undeclared (first use in this function)
app_alarmreceiver.c:266: error: (Each undeclared identifier is reported only once
app_alarmreceiver.c:266: error: for each function it appears in.)
app_alarmreceiver.c: In function âwrite_metadataâ:
app_alarmreceiver.c:370: error: âAST_MODULEâ undeclared (first use in this function)
app_alarmreceiver.c: In function âlog_eventsâ:
app_alarmreceiver.c:421: error: âAST_MODULEâ undeclared (first use in this function)
app_alarmreceiver.c: In function âademco_detect_formatâ:
app_alarmreceiver.c:595: error: âAST_MODULEâ undeclared (first use in this function)
app_alarmreceiver.c: In function âreceive_ademco_eventâ:
app_alarmreceiver.c:683: error: âAST_MODULEâ undeclared (first use in this function)
app_alarmreceiver.c: In function âalarmreceiver_execâ:
app_alarmreceiver.c:847: error: âAST_MODULEâ undeclared (first use in this function)
app_alarmreceiver.c: In function âload_configâ:
app_alarmreceiver.c:876: error: âAST_MODULEâ undeclared (first use in this function)
app_alarmreceiver.c: At top level:
app_alarmreceiver.c:996: error: âAST_MODULEâ undeclared here (not in a function)


By: Pedro Kiefer (pedrokiefer) 2012-12-24 16:15:49.803-0600

Just run make!

By: John Bonzey (jbonzey) 2012-12-24 17:17:31.495-0600

Pedro i would but don't know the command.  Can you tell me the exact command to issue at the command line?  I know this is a dumb question but have read about a million posts on asterisk.org trying to figure it out.  Thanks and Merry Christmas !!!!


By: Pedro Kiefer (pedrokiefer) 2012-12-24 21:43:50.472-0600

John,
May I suggest you this link: https://wiki.asterisk.org/wiki/display/AST/Installing+Asterisk+From+Source it contains all the info you need to compile asterisk from source. As for the specific command:
{noformat}
make
{noformat}

Merry Christmas to you too.

By: John Bonzey (jbonzey) 2012-12-26 15:25:13.491-0600

Okay i'm getting closer. Currently running Asterisk 11.0.1   I downloaded the app_alarmreceiver.c file from the link recommended: http://svnview.digium.com/svn/asterisk/trunk/apps/app_alarmreceiver.c?revision=375215

I compiled it with make and all went well.  However when alarmreciever picks up and sends it's 2 tones it's as if the alarm panel doesn't hear it. When i initiate an alarm i now get the same error as reported a while back:

 == AlarmReceiver: Incomplete string: , trying again...
      > AlarmReceiver: Sending 1400Hz 100ms burst (ACK)
      > AlarmReceiver: Sending 2300Hz 100ms burst (ACK)
      > AlarmReceiver: DTMF Digit Timeout on SIP/4994-00000005
 == AlarmReceiver: Incomplete string: , trying again...
      > AlarmReceiver: Sending 1400Hz 100ms burst (ACK)
      > AlarmReceiver: Sending 2300Hz 100ms burst (ACK)
      > AlarmReceiver: DTMF Digit Timeout on SIP/4994-00000005
 == AlarmReceiver: Incomplete string: , trying again...
      > AlarmReceiver: Sending 1400Hz 100ms burst (ACK)
      > AlarmReceiver: Sending 2300Hz 100ms burst (ACK)
      > AlarmReceiver: DTMF Digit Timeout on SIP/4994-00000005
 == AlarmReceiver: Incomplete string: , trying again...
      > AlarmReceiver: Sending 1400Hz 100ms burst (ACK)
      > AlarmReceiver: Sending 2300Hz 100ms burst (ACK)

I have an Asterisk system running 1.4.21.2 and the app_alarmreceiver module works perfect.  I have attached the old working version 43933 app_alarmreceiver.c file named -  43933_OLD DO NOT USE_app_alarmreceiver.c

I hope someone can tell me what to change in the latest alarmreceiver.c file to make it work with Asterisk 11.0.1.

Thanks


By: Pedro Kiefer (pedrokiefer) 2012-12-27 13:53:16.022-0600

Did you run
{noformat}
sudo make install
{noformat}
before testing the AlarmReceiver?

By: John Bonzey (jbonzey) 2012-12-27 13:58:11.099-0600

i used make, then when complete entered make install not sudo make install



By: John Bonzey (jbonzey) 2012-12-27 16:23:34.821-0600

Pedro did a fresh Asterisk 11.0.1 install.  Copied app_alarmreceiver.c to usr/src/asterisk/apps directory.  Executed sudo make, the file compiled, then issued sudo make install - it completed.  Rebooted and initiated an alarm from the panel and got the following:

-- Executing [s@custom-myalarmreceiver:1] NoOp("SIP/4994-00000002", "Alarm r                                                                                                 eceived") in new stack
   -- Executing [s@custom-myalarmreceiver:2] Answer("SIP/4994-00000002", "") in                                                                                                  new stack
   -- Executing [s@custom-myalarmreceiver:3] Ringing("SIP/4994-00000002", "") i                                                                                                 n new stack
   -- Executing [s@custom-myalarmreceiver:4] Wait("SIP/4994-00000002", "6") in                                                                                                  new stack
   -- Executing [s@custom-myalarmreceiver:5] AlarmReceiver("SIP/4994-00000002",                                                                                                  "") in new stack
      > AlarmReceiver: Setting write format to Mu-law
      > AlarmReceiver: Waiting for connection to stabilize
[2012-12-27 17:19:16] WARNING[2459][C-00000002]: channel.c:5048 ast_write: Codec                                                                                                  mismatch on channel SIP/4994-00000002 setting write format to slin from ulaw na                                                                                                 tive formats (ulaw)
      > AlarmReceiver: Waiting for first event from panel...
      > AlarmReceiver: Sending 1400Hz 100ms burst (ACK)
      > AlarmReceiver: Sending 2300Hz 100ms burst (ACK)
      > AlarmReceiver: DTMF Digit Timeout on SIP/4994-00000002
 == AlarmReceiver: Incomplete string: , trying again...
      > AlarmReceiver: Sending 1400Hz 100ms burst (ACK)
      > AlarmReceiver: Sending 2300Hz 100ms burst (ACK)
      > AlarmReceiver: DTMF Digit Timeout on SIP/4994-00000002
 == AlarmReceiver: Incomplete string: , trying again...
      > AlarmReceiver: Sending 1400Hz 100ms burst (ACK)
      > AlarmReceiver: Sending 2300Hz 100ms burst (ACK)
      > AlarmReceiver: DTMF Digit Timeout on SIP/4994-00000002


By: Jean-Philippe Lord (jplord) 2012-12-27 17:28:21.803-0600

This is likely ASTERISK-19610. Fast DTMF recognition was broken around 1.8 and was fixed just recently.

By: John Bonzey (jbonzey) 2012-12-27 18:05:34.914-0600

I am running 11.0.1  Pedro you stated earlier the fix was tested with Asterisk 11 so maybe the panel didn't incorporate fast dtmf?


I tried taking file dsp.c in ASTERISK 19610 and do a sudo make and
a sudo make install but getting errors during make.  Not sure if it's because I'm running 11.0.1 or if i need to do something else here.  

By: John Bonzey (jbonzey) 2013-01-03 16:02:16.674-0600

Looking at the change logs, the fix for dsp.c fast dtmf detection issue should be in Asterisk 11.0

The compiled alarmreceiver.c is not working in asterisk 11 for my DSC alarm panel.  Any suggestions from anyone as it works great in 1.4


By: Jean-Philippe Lord (jplord) 2013-01-04 07:57:06.644-0600

It could very well be the codec you use between asterisk and the panel. I could also be the DTMF mode. This is what works well if you use an ATA. Both asterisk and ata need to be configured the same way:

dtmfmode=inband
disallow=all
allow=ulaw



By: John Bonzey (jbonzey) 2013-01-05 20:52:46.534-0600

I finally got the alarmreceiver module to work with Asterisk 1.8.18.0 without any modifications to anything.
Neither 10.10 or 11.0.1 worked.  Not sure what is going on with asterisk 10 or 11 but I could not get it to function compiling the lastest alarmreceiver.c file as suggested.

Looking at the changelog for 1.8 i don't see anything regarding alarmreceiver which makes me want to believe that all the changes to the alarmreceiver module lately have broken the functionality - at least in my case with a DSC 832 alarm panel.

Thanks for your support, I have learned a lot about Asterisk in the process !!!!!!!

http://downloads.asterisk.org/pub/telephony/asterisk/ChangeLog-1.8-current

By: Paul Langner (plangner) 2020-05-04 09:31:39.280-0500

DTMF tones from an alarm panel can be very short.  Consequently, mindtmfduration in asterisk.conf needs to be shortened.  I recommend mindtmfduration = 20