Difference between revisions of "Setting up MythNotify"

From MythTV Official Wiki
Jump to: navigation, search
m (Cidbcast)
m (mark as outdated)
 
(10 intermediate revisions by 7 users not shown)
Line 1: Line 1:
 +
{{outdated2|This utility uses the old mythtvosd protocol, and is not compatible with [[MythMessage]] used in 0.25 and later.}}
 +
 
MythNotify is an add-on program which sends notifications, like caller-id information, to a running mythfrontend.
 
MythNotify is an add-on program which sends notifications, like caller-id information, to a running mythfrontend.
  
Line 5: Line 7:
  
 
''modifications by Geoff Scott''
 
''modifications by Geoff Scott''
 +
 +
''troubleshooting by Jim Shank''
  
 
== Overview ==
 
== Overview ==
  
 
I had heard of this feature some time ago but since I hardly knew Linux anyway I thought better of it. But now that I'm comfortable with it, here are a few instructions on getting it up and running.
 
I had heard of this feature some time ago but since I hardly knew Linux anyway I thought better of it. But now that I'm comfortable with it, here are a few instructions on getting it up and running.
 
Since I have compiled from source, Mythnotify resides in the contrib directory starting with version Mythtv-0.13. For anyone that has installed Mythtv using mythtv-suite, this can be found here /usr/share/doc/mythtv-0.18.1/contrib.
 
  
 
This is a nice little feature that allows you to see who's calling you while you're watching LiveTV. It simply pops up a rectangular box that has the name and phone number along with other miscellaneous information. The OSD font and number of seconds can be changed in the mythfrontend setup. Here's how you setup Mythnotify.
 
This is a nice little feature that allows you to see who's calling you while you're watching LiveTV. It simply pops up a rectangular box that has the name and phone number along with other miscellaneous information. The OSD font and number of seconds can be changed in the mythfrontend setup. Here's how you setup Mythnotify.
Line 23: Line 25:
 
* libxslt
 
* libxslt
  
First we need to be in the mythudprelay directory
+
First download the [[MythTV UDP Relay|mythudprelay]] program.
  
<pre><nowiki>
+
Then, compile this feature
cd /home/mythtv/mythtv-0.15.1/contrib/mythnotify/mythudprelay
+
# make
</nowiki></pre>
+
  
Once there we need to compile this feature
 
<pre><nowiki>
 
# su
 
enter password
 
# make
 
</nowiki></pre>
 
  
  
 
=== Cidbcast ===
 
=== Cidbcast ===
  
No dependencies are needed here. Change directory to cidbcast
+
No dependencies are needed here. Download the [[Caller ID Broadcaster]] program.
 
+
<pre><nowiki>
+
cd /home/mythtv/mythtv-0.15.1/contrib/mythnotify/cidbcast
+
</nowiki></pre>
+
  
 
Compile this feature
 
Compile this feature
  
<pre><nowiki>
+
# make
# su
+
enter password
+
# make
+
</nowiki></pre>
+
  
The one problem I had was trying to figure out how to make these two features startup at boot. It didn't seem to work in rc.local for some reason so I had to put on my thinking cap. What I came up with were two startup scripts that go into your Autostart folder of your desktop manager. That could be KDE or XfCE4 which is what I use. This is my path to Autostart.
+
=== Starting automatically ===
 +
==== Desktop Autostart ====
 +
The one problem I had was trying to figure out how to make these two features startup at boot. I came up with were two startup scripts that go into your Autostart folder of your desktop manager. That could be KDE or XfCE4 which is what I use. This is my path to Autostart.
  
<pre><nowiki>
+
cd /home/mythtv/Desktop/Autostart
cd /home/mythtv/Desktop/Autostart
+
</nowiki></pre>
+
 
Yours might be
 
Yours might be
<pre><nowiki>
+
cd /home/mythtv/.kde/Autostart
cd /home/mythtv/.kde/Autostart
+
Let's go ahead and make a file called callerid.sh and place it in our Autostart folder.  
</nowiki></pre>
+
{{Note box|The modem that you use must have the correct AT command string. Notice the --init string below. This is what works for me. If you can't find your AT command sting then try mine to see if it works). Here is a link to a variety of modem command strings: http://modems.rosenet.net/init/ , or try here http://www.modemhelp.org/inits/ .}}
Let's go ahead and make a file called callerid.sh and place it in our Autostart folder. (note: The modem that you use must have the correct AT command string. Notice the --init string below. This is what works for me. If you can't find your AT command sting then try mine to see if it works). Here is a link to a variety of modem command strings: http://modems.rosenet.net/init/ , or try here http://www.modemhelp.org/inits/ .  
+
  
 
This is the contents of callerid.sh
 
This is the contents of callerid.sh
<pre><nowiki>
+
{{Code box|callerid.sh|
 +
<pre>
 
#!/bin/bash
 
#!/bin/bash
  
cd /home/mythtv/mythtv-0.13/contrib/mythnotify/cidbcast/
+
cd /home/mythtv/mythnotify/cidbcast/
  
 
./cidbcast --file cidbcast.xml --init="AT S7=45 S0=0 L0 V1 X4 Q0 +VCID=1"
 
./cidbcast --file cidbcast.xml --init="AT S7=45 S0=0 L0 V1 X4 Q0 +VCID=1"
</nowiki></pre>
+
</pre>
 +
}}
 
Give it permissions of 0775 for user mythtv or whatever your username is. Now for the second file, lets call it osd.sh and place it in our Autostart folder as well. This is the contents of osd.sh
 
Give it permissions of 0775 for user mythtv or whatever your username is. Now for the second file, lets call it osd.sh and place it in our Autostart folder as well. This is the contents of osd.sh
<pre><nowiki>
+
{{Code box|osd.sh|
 +
<pre>
 
#!/bin/bash
 
#!/bin/bash
  
cd /home/mythtv/mythtv-0.13/contrib/mythnotify/mythudprelay/
+
cd /home/mythtv/mythnotify/mythudprelay/
  
 
./mythudprelay --xslfile callerid.xsl --bcast="255.255.255.255" -- udpport_in=6947 --udpport_out=6948
 
./mythudprelay --xslfile callerid.xsl --bcast="255.255.255.255" -- udpport_in=6947 --udpport_out=6948
</nowiki></pre>
+
</pre>
 +
}}
 
Same permissions as above.
 
Same permissions as above.
 +
 +
==== rc.d startup ====
 +
The drawback to having your scripts in ~/.kde/Autostart is that they are only executed when a user logs in and opens a KDE session.  I wanted MythNotify to start automatically on my backend server without any intervention.  I found that the following lines work when added to /etc/rc.d/rc.local (Fedora/RedHat/CentOs):
 +
 +
 +
/path/to/cidbcast --file=/path/to/cidbcast.xml --device=/dev/modemDevice --init='InitString' &
 +
/path/to/mythudprelay --xslfile /path/to/callerid.xsl --bcast='255.255.255.255' --udpport_in=6947 --udpport_out=6948 &
 +
 +
Of course replace "/path/to" with the actual location of your files (mine are in /usr/local/bin), and "modemDevice" and "InitString" with the appropriate values for your modem (mine are ttySHCF0 and AT+VCID=1 for a Conexant HCF modem).
  
 
=== Remote-On/Off Setup ===
 
=== Remote-On/Off Setup ===
Line 88: Line 87:
 
To add another directory(s) to your PATH let's edit a file in your home directory under mythtv called .bash_profile. Where it says
 
To add another directory(s) to your PATH let's edit a file in your home directory under mythtv called .bash_profile. Where it says
  
<pre><nowiki>
+
PATH=$PATH:$HOME/bin
PATH=$PATH:$HOME/bin
+
</nowiki></pre>
+
 
change to something like this
 
change to something like this
  
<pre><nowiki>
+
PATH=$PATH:$HOME/bin:/usr/local/sbin:/usr/local/bin:/usr/lib/qt-3.2/bin:/home/mythtv/Desktop/Autostart
PATH=$PATH:$HOME/bin:/usr/local/sbin:/usr/local/bin:/usr/lib/qt-3.2/bin:/home/mythtv/Desktop/Autostart
+
</nowiki></pre>
+
 
This changes your PATH permanently. Restart X for the effects to take place
 
This changes your PATH permanently. Restart X for the effects to take place
  
Line 101: Line 96:
  
 
Now we need to build our on-off script. You can name this what you like. I've named mine callerIDtoggle.sh. Place this somewhere like /usr/local/bin
 
Now we need to build our on-off script. You can name this what you like. I've named mine callerIDtoggle.sh. Place this somewhere like /usr/local/bin
<pre><nowiki>
+
{{Code box|callerIDtoggle.sh|
 +
<pre>
 
#!/bin/bash
 
#!/bin/bash
  
Line 118: Line 114:
 
fi
 
fi
 
exit
 
exit
</nowiki></pre>
+
</pre>
 +
}}
 
The last part to all of this is irexec. Before using this program, make sure it's running first. This could possibly be loaded into your rc.local file or your Autostart folder where mine is. This program will allow us to use our remote control to turn CallerID on and off, by way of our script, with just one button. The two files that we're after are .lircrc and lircrc(.lircrc maybe a symlink). These two files reside in your mythtv home directory. Just use your favorite text editor to make changes. Doesn't really matter where you put this in the file. Since I'm using the grey hauppauge remote, spare buttons are running out. I did have one available so I used the BLANK button for this. The info below will be added to both lircrc files.
 
The last part to all of this is irexec. Before using this program, make sure it's running first. This could possibly be loaded into your rc.local file or your Autostart folder where mine is. This program will allow us to use our remote control to turn CallerID on and off, by way of our script, with just one button. The two files that we're after are .lircrc and lircrc(.lircrc maybe a symlink). These two files reside in your mythtv home directory. Just use your favorite text editor to make changes. Doesn't really matter where you put this in the file. Since I'm using the grey hauppauge remote, spare buttons are running out. I did have one available so I used the BLANK button for this. The info below will be added to both lircrc files.
  
<pre><nowiki>
+
<pre>
 
begin
 
begin
 
prog = irexec
 
prog = irexec
Line 127: Line 124:
 
config = /usr/local/bin/callerIDtoggle.sh
 
config = /usr/local/bin/callerIDtoggle.sh
 
end
 
end
</nowiki></pre>
+
</pre>
 +
 
 +
The [[Caller ID Broadcaster|cidbcast]] program automatically defaults to com1, which is ttyS0. Make sure you have proper permissions set on ttyS0 in the /dev directory. If your using an internal modem this will default to another comport such as /dev/ttyS15 or possibly /dev/modem. If your having problems setting up your modem correctly use "./cidbcast --help" for more help. Once this has been all setup, give your computer a reboot to see if it works. You should see the TR(transmit receive) light come on, using an external modem, when your desktop splash screen comes up. This means the modem is ready to accept incoming calls.
 +
 
 +
=== Troubleshooting ===
 +
 
 +
I have an Agere/TRENDNet Modem that doesn't seem to follow the conventional output for caller ID. You can verify that you are getting data by running:
 +
./cidbcast -v --file cidbcast.xml --init="AT S7=45 S0=0 L0 V1 X4 Q0 +VCID=1"
 +
 
 +
This will show you what data the modem is actually capturing and sending. In my case, [[Caller ID Broadcaster|cidbcast]] was unable to find the data in the caller id stream. Using Minicom, I found out the format of my caller id was:
 +
 
 +
<pre>
 +
DATE=0427
 +
TIME=1153
 +
NAME=SCHMOE,JOE
 +
NMBR=3035551212
 +
</pre>
 +
 
 +
What is expected by [[Caller ID Broadcaster|cidbcast]] is:
 +
 
 +
<pre>
 +
DATE = 0427
 +
TIME = 1153
 +
NAME = SCHMOE,JOE
 +
NMBR = 3035551212
 +
</pre>
 +
 
 +
I am not sure what the standard format is but a quick edit of the cidbcast.c to correct the fields:
 +
 
 +
<pre>
 +
  if ( (field_ptr = extract_cid_field(buffer, len, "NMBR=", &field_len))
 +
  || (field_ptr = extract_cid_field(buffer, len, "CALLER NUMBER: ", &field_len)) )
 +
</pre>
  
The cidbcast program automatically defaults to com1, which is ttyS0. Make sure you have proper permissions set on ttyS0 in the /dev directory. If your using an internal modem this will default to another comport such as /dev/ttyS15 or possibly /dev/modem. If your having problems setting up your modem correctly use "./cidbcast --help" for more help. Once this has been all setup, give your computer a reboot to see if it works. You should see the TR(transmit receive) light come on, using an external modem, when your desktop splash screen comes up. This means the modem is ready to accept incoming calls.
+
* notice the removal of the space between the = and the label/data pairs.
 +
make clean, make and retest as above to see if you got it right.
  
 
[[Category:HOWTO]] [[Category:Plugins]]
 
[[Category:HOWTO]] [[Category:Plugins]]

Latest revision as of 00:43, 15 March 2012

Time.png Outdated: This utility uses the old mythtvosd protocol, and is not compatible with MythMessage used in 0.25 and later.

MythNotify is an add-on program which sends notifications, like caller-id information, to a running mythfrontend.

How-To guide on setting up Mythnotify (callerid)

By Dennis Hand

modifications by Geoff Scott

troubleshooting by Jim Shank

Overview

I had heard of this feature some time ago but since I hardly knew Linux anyway I thought better of it. But now that I'm comfortable with it, here are a few instructions on getting it up and running.

This is a nice little feature that allows you to see who's calling you while you're watching LiveTV. It simply pops up a rectangular box that has the name and phone number along with other miscellaneous information. The OSD font and number of seconds can be changed in the mythfrontend setup. Here's how you setup Mythnotify.


Mythudprelay

These are the dependencies that are required for Mythnotify. Chances are they have already been installed on your system.

  • libxml2
  • libxslt

First download the mythudprelay program.

Then, compile this feature

# make


Cidbcast

No dependencies are needed here. Download the Caller ID Broadcaster program.

Compile this feature

# make

Starting automatically

Desktop Autostart

The one problem I had was trying to figure out how to make these two features startup at boot. I came up with were two startup scripts that go into your Autostart folder of your desktop manager. That could be KDE or XfCE4 which is what I use. This is my path to Autostart.

cd /home/mythtv/Desktop/Autostart

Yours might be

cd /home/mythtv/.kde/Autostart

Let's go ahead and make a file called callerid.sh and place it in our Autostart folder.

Important.png Note: The modem that you use must have the correct AT command string. Notice the --init string below. This is what works for me. If you can't find your AT command sting then try mine to see if it works). Here is a link to a variety of modem command strings: http://modems.rosenet.net/init/ , or try here http://www.modemhelp.org/inits/ .

This is the contents of callerid.sh

Script.png callerid.sh

#!/bin/bash

cd /home/mythtv/mythnotify/cidbcast/

./cidbcast --file cidbcast.xml --init="AT S7=45 S0=0 L0 V1 X4 Q0 +VCID=1"

Give it permissions of 0775 for user mythtv or whatever your username is. Now for the second file, lets call it osd.sh and place it in our Autostart folder as well. This is the contents of osd.sh

Script.png osd.sh

#!/bin/bash

cd /home/mythtv/mythnotify/mythudprelay/

./mythudprelay --xslfile callerid.xsl --bcast="255.255.255.255" -- udpport_in=6947 --udpport_out=6948

Same permissions as above.

rc.d startup

The drawback to having your scripts in ~/.kde/Autostart is that they are only executed when a user logs in and opens a KDE session. I wanted MythNotify to start automatically on my backend server without any intervention. I found that the following lines work when added to /etc/rc.d/rc.local (Fedora/RedHat/CentOs):


/path/to/cidbcast --file=/path/to/cidbcast.xml --device=/dev/modemDevice --init='InitString' &
/path/to/mythudprelay --xslfile /path/to/callerid.xsl --bcast='255.255.255.255' --udpport_in=6947 --udpport_out=6948 &

Of course replace "/path/to" with the actual location of your files (mine are in /usr/local/bin), and "modemDevice" and "InitString" with the appropriate values for your modem (mine are ttySHCF0 and AT+VCID=1 for a Conexant HCF modem).

Remote-On/Off Setup

Now that we can turn on-off the CallerID feature with the remote control, we now need to put callerid.sh into our PATH. This allows us to execute callerid.sh from anywhere by just giving it the filename rather than the entire path. Also we will be creating our on-off script to work with irexec. (note: Please note that I am using a newer version of QT so qt-3.2 in the command below reflects that. You may be using qt-3.1 so make sure you know what version you're running to add to your PATH. Also note that my last entry is the Autostart folder of my home directory. This is where my callerid.sh resides. Adjust yours to reflect your callerid.sh PATH).

To add another directory(s) to your PATH let's edit a file in your home directory under mythtv called .bash_profile. Where it says

PATH=$PATH:$HOME/bin

change to something like this

PATH=$PATH:$HOME/bin:/usr/local/sbin:/usr/local/bin:/usr/lib/qt-3.2/bin:/home/mythtv/Desktop/Autostart

This changes your PATH permanently. Restart X for the effects to take place


Now we need to build our on-off script. You can name this what you like. I've named mine callerIDtoggle.sh. Place this somewhere like /usr/local/bin

Script.png callerIDtoggle.sh

#!/bin/bash

DAEMON=cidbcast

# Test to see if process is running first
if ps -ef|grep -v grep|grep $DAEMON
then
#if process is found, slay it
echo "$DAEMON is found, we now will slay it"
killall -9 $DAEMON
else
#if process is not found, do nothing.
echo "$DAEMON was not found, let's start it"
callerid.sh &
fi
exit

The last part to all of this is irexec. Before using this program, make sure it's running first. This could possibly be loaded into your rc.local file or your Autostart folder where mine is. This program will allow us to use our remote control to turn CallerID on and off, by way of our script, with just one button. The two files that we're after are .lircrc and lircrc(.lircrc maybe a symlink). These two files reside in your mythtv home directory. Just use your favorite text editor to make changes. Doesn't really matter where you put this in the file. Since I'm using the grey hauppauge remote, spare buttons are running out. I did have one available so I used the BLANK button for this. The info below will be added to both lircrc files.

begin
prog = irexec
button = BLANK
config = /usr/local/bin/callerIDtoggle.sh
end

The cidbcast program automatically defaults to com1, which is ttyS0. Make sure you have proper permissions set on ttyS0 in the /dev directory. If your using an internal modem this will default to another comport such as /dev/ttyS15 or possibly /dev/modem. If your having problems setting up your modem correctly use "./cidbcast --help" for more help. Once this has been all setup, give your computer a reboot to see if it works. You should see the TR(transmit receive) light come on, using an external modem, when your desktop splash screen comes up. This means the modem is ready to accept incoming calls.

Troubleshooting

I have an Agere/TRENDNet Modem that doesn't seem to follow the conventional output for caller ID. You can verify that you are getting data by running:

./cidbcast -v --file cidbcast.xml --init="AT S7=45 S0=0 L0 V1 X4 Q0 +VCID=1"

This will show you what data the modem is actually capturing and sending. In my case, cidbcast was unable to find the data in the caller id stream. Using Minicom, I found out the format of my caller id was:

DATE=0427
TIME=1153
NAME=SCHMOE,JOE
NMBR=3035551212

What is expected by cidbcast is:

DATE = 0427
TIME = 1153
NAME = SCHMOE,JOE
NMBR = 3035551212

I am not sure what the standard format is but a quick edit of the cidbcast.c to correct the fields:

  if ( (field_ptr = extract_cid_field(buffer, len, "NMBR=", &field_len))
   || (field_ptr = extract_cid_field(buffer, len, "CALLER NUMBER: ", &field_len)) )
  • notice the removal of the space between the = and the label/data pairs.

make clean, make and retest as above to see if you got it right.