Network Caller ID (NCID)

From MythTV Official Wiki
Revision as of 16:53, 28 September 2007 by Wesmoc (talk | contribs) (Cleaned up the text)

Jump to: navigation, search

Caller ID

Caller ID is defined as "The service that allows someone being called to see the caller's name and phone number." MythTV does not come configured with the ability to display Caller ID information, but with the right tools this can be made to work.

Displaying Arbitrary Text On The MythTV Screen

As part of the entire MythTV bundle, there is a small script called myth2osd which allows for displaying any kind of text on the screen. Note that this only works when LiveTV, Recordings, or Videos are being displayed; it will not display at any other time.

Hardware

Getting the right hardware can be a pain. Although it initially seems appealing to use an internal modem with caller-id support, the problem is that the PCI modems are near brainless. They rely on software to do most of the work, and that software, in most cases, hasn't been ported over to Linux. I had some luck with an older PCI card under i386-based linux, but it wouldn't work under x86-64. You can try using an external modem, but, the easiest solution is to get your hands on a NetCallerID box which simply plugs in to the system's serial port and in to the phone line.

Try some google searching to find one. As of April 2007, they can be obtained from: http://www.electronicdiscountsales.com/store/0010_Net+Caller+ID+SKU-44598505+D-03-04-2006.htm for as little as $9.99US + $6US shipping.

Believe me, although the desire is to save money, the few dollars that you try to save by using another system (internal PCI card, external modem, etc) just aren't worth it.

Network Caller ID (NCID)

Network Caller ID is a freeware package that can be obtained from SourceForge. It contains both the client and server package. Configuring the server side of the package is outside the scope of this document. This document focuses on the client configuration and its integration with MythTV.

Download the source for NCID and built it on each of the Frontend systems that you have. If they are all the same architecture, then you can just build it on one and copy the tar file over to the others. If you are running an RPM based distribution (like Fedora Core), try building your own RPM for your architecture and install it on each of the clients.

The NCID Server on a MythTV Backend

It is possible to run the NCID server on a variety of hosts (I had it running on my Tivo for a while there). The important part is configuring the clients to point to the master NCID server. It is not unusual, though, to utilize the mythtv system for this purpose.

If you use the RPM method of installation, you will need to enable the server daemon and disable the client daemon on startup. Although this is the default, it is best to make sure.

#> chkconfig --level 345 ncidd on
#> chkconfig --level 345 ncid off

This document does not cover the hardware necessary in order to grab caller ID information. Most modern modems have this ability, but linux support varies per vendor. After a lot of trial and error with PCI modems and external modems, the best 'out of the box' experience can be had with the NetCallerID. External modems typically have much better linux support than internal PCI modems for reasons that need not be covered here.

Within /etc/ncid/ncidd.conf, be sure to configure the CallerID device accordingly. For example, if the NetCallerID unit is to be used, it connects to the computer via the serial port. A snippet from the configuration file might look like this:

#####################
# TTY Configuration #
#####################

# The default tty port: /dev/modem
# set ttyport = /dev/cu.modem # Macintosh OS X
set ttyport = /dev/ttyS0

# The default tty port speed: 19200
# The tty speed can be one of: 38400, 19200, 9600, 4800
set ttyspeed = 4800 # NetCallerID port speed

# Ignore tty control signals for internal modems and 3 wire serial cables
#   Disable tty control signals: ttyclocal = 1
#   Enable tty control signals: ttyclocal = 0 (default)
# set ttyclocal = 1

# The lockfile name is generated automatically
# If tty port is /dev/modem, lockfile is: /var/lock/LCK..modem
# set lockfile = /var/lock/LCK..ttyS0

#######################
# Serial or No Serial #
#######################

# Require a serial device for startup.  This is useful if you are
# using a network based plugin
#  network: noserial = 1 (do not try to initialize a serial port)
#  serial: noserial = 0 (default - Look for a serial port)
set noserial = 0

#####################
# Modem or No Modem #
#####################

# Obtain CallerID from a CID device or a modem
#  device: nomodem = 1 (do not send AT commands)
#  modem: nomodem = 0 (default - send AT commands)
set nomodem = 1

The NCID Client on a MythTV Frontend

If you use the RPM method of installation, you will need to disable the server daemon and enable the client daemon on startup. For some reason, the authors have the server daemon automatically enabled and the client daemon automatically disabled.

#> chkconfig --level 345 ncidd off
#> chkconfig --level 345 ncid on

Patching the Startup Script

The other catch is that, although there is an /etc/ncid/ncid.conf file, that file appears to be nothing more than a place holder under the RPM distribution. You need to edit /etc/init.d/ncid in order for the client to do what we want it to:

#!/bin/sh
#
# ncid          Start/Stop Network Caller ID client
#
# chkconfig: 2345 96 05
# description: the ncid client sends the CID to an external program

# Source function library.
. /etc/rc.d/init.d/functions

# Source networking configuration.
. /etc/sysconfig/network

# Check that networking is up.
[ ${NETWORKING} = "no" ] && exit 0

RETVAL=0
prog="ncid"
shell="tclsh"
extprog="ncid-mythtv"
opts="--no-gui -r 0 -C -P $extprog"
...

As seen above, the "extprog" has been set to "ncid-mythtv". NCID has a plug-in to talk to mythtv via mythtvosd. Save the updated init.d file.

Patching the Plugin

As of NCID 0.68, this patch has been integrated in to the source, so this step can safely be skipped.

The only other piece is to actually update the plugin "ncid-mythtv". At some point in time, the option "--template" became a required option to "mythtvosd" and the "ncid-mythtv" plugin was not updated to reflect this new requirement.

With that said, edit /usr/share/ncid/ncid-mythtv and make the code at the end of the file look like:

...
if [ -n "$CIDNMBR" ]
then
    # Display Caller ID information
    mythtvosd --template="cid" \
              --caller_name="$CIDNAME" \
              --caller_number="$CIDNMBR" \
              --caller_date="$CIDDATE" \
              --caller_time="$CIDTIME"
else
    # Display Message
    mythtvosd --template="alert" --alert_text="$CIDNAME"
fi

exit 0

Configuring the Client

The last step is to configure the client such that it knows where the server is. Thankfully, this is pretty easy just by editing the file /etc/ncid/ncid.conf. A lot of the options in that file are overridden via the integration in to mythtv or they just do not have any bearing in this configuration. The main ones to look for are the host and the port, making sure that they match with that of the server:

...
# Set Host to the NCID server address
# Host defaults to 127.0.0.1
set Host        192.168.0.100
# The NCID port default is 3333
set Port        3333
...

Start the Client

Start the daemon:

#> /etc/init.d/ncid start

And, with that, your MythTV FrontEnd will display incoming caller id information on the screen any time you are watching LiveTV or watching a Recording, all without having a phone line run to the box. It will not display information when you are in the menus, watching a DVD Video in MythVideo, or at any other time.

Note: At this time, the process does not detach from the current tty. Starting ncid by hand will cause your session to hang when you attempt to log out. This is not an issue when NCID is configured to automatically start up upon boot up.