Dynamic events

Do you have questions about writing plugins or scripts in Python? Meet the coders here.
Post Reply
Freeeze
Posts: 6
Joined: Thu Jan 28, 2010 3:07 pm

Dynamic events

Post by Freeeze » Thu Jan 28, 2010 3:24 pm

Hello,

I have a problem with Caller ID detection from a modem.
I am using the Serial plugin which works great. When the phone rings I see the modem events. This is a great thing if I want to react on the
Serial.\nRING event (when the phone is ringing), however the Caller ID is transferred as Serial.\nNMBR = 555123456

As you can see the Caller ID is transferred as a part of the event name.

The macro would work fine if I had a gneric event:

Code: Select all

#get current event
event = eg.EventString
#check if it is the Caller ID Event
sfind = 'NMBR' in event
if sfind is True : print sfind
else : eg.StopMacro
#get the caller ID starting at the 16th digit
event = event[16:len(event)]
#store the number in global variable
eg.globals.myCallerID = event
How can I trigger my macro to react on the Caller ID Event? The following Event Items have not worked:

Serial.
Serial.*
Serial.\nNMBR{*}
Serial.{*}
Serial{*}


the Wildcards don't seem to have an effect...
Any ideas what can help?

Bartman
Plugin Developer
Posts: 881
Joined: Sun Feb 12, 2006 9:03 am

Re: Dynamic events

Post by Bartman » Thu Jan 28, 2010 3:30 pm

Serial.* should work.
To really work with the EG naming scheme you can make your own plugin with events like Modem.NMBR.555123456

Freeeze
Posts: 6
Joined: Thu Jan 28, 2010 3:07 pm

Re: Dynamic events

Post by Freeeze » Thu Jan 28, 2010 3:40 pm

Bartman wrote:Serial.* should work.
To really work with the EG naming scheme you can make your own plugin with events like Modem.NMBR.555123456
Hello Bartman,

Thank you - it worked!!! I have no idea why I have tested it as a false solution. Thanks as well for the plugin idea. :D

Freeeze
Posts: 6
Joined: Thu Jan 28, 2010 3:07 pm

Re: Dynamic events

Post by Freeeze » Thu Feb 11, 2010 12:20 pm

This is the code which worked for me:

on startup you need to initialize the modem. To do this use the serial port plug in. This AT command may not be correct for your modem, however it worked fine on my 8€ USB Modem from Singapore:

Code: Select all

AT+VCID=1\r
This is the actual python script which stores the caller ID in eg.globals:

Code: Select all

eg.globals.myCallerID=""
#get current event
event = eg.EventString
#check if it is the Caller ID Event
sfind = 'NMBR' in event
print sfind
if sfind is True : eg.globals.myCallerID = event[16:len(event)]
if sfind is False : eg.StopMacro()
if eg.globals.myCallerID == "P" : eg.globals.myCallerID = "Private"

kalia
Experienced User
Posts: 109
Joined: Wed Aug 12, 2009 1:10 am

Re: Dynamic events - Initialize Modem

Post by kalia » Sat Aug 28, 2010 6:28 am

Does anyone know if the modem needs to be reinitialized periodically using the "AT+VCID=1\r" command? My caller ID events don't always show up. Event is generated maybe every second phone call. Anyone else using the Serial plugin to get caller ID information from a modem?

Post Reply