When things finally click in the brain and work on the machine, happy things happen!
I keep adding to my home automation server. This time I got an old ISA modem. Found it in the piles of cards in my chicken coop (which I use for computer storage now). And I got caller ID working on it.
If your modem already works, skip this!
Had to get the modem detected and IRQs all set right. Yup, it's that old! Found a free IRQ by running
cat /proc/interrupts To detect the modem in Linux, I used wvdialconf. For newer (PCI) modems, I suggest using ScanModem
sudo apt-get install wvdialsudo wvdialconfcat /etc/wvdial.conf Now the fun part. I'm using Mgetty to get the caller ID info. (install mgetty-voice for vgetty - if you want to create an answering machine)
sudo apt-get install mgettySetup mgetty.config
sudo nano /etc/mgetty/mgetty.configdebug 8 # Log everything to /var/log/mgetty/mg_ttyS1.log
rings 2 # Answer phone after 2 rings - Need 2 because caller id info is sent between 1st and 2nd ring
speed 38400 # Buad rate to run modem at
port ttyS1 # Serial port of modem
init-chat "" AT#CID=1 OK # Turn on Caller ID
cnd-program /home/kliewer/homeauto/callerid/run_on_ring.sh # Script to run after 2 ringsMgetty doesn't run automatically, so we'll use ustart to do so:
sudo nano /etc/event.d/mgettystart on startup
start on runlevel 2
start on runlevel 3
start on runlevel 4
start on runlevel 5
respawn
exec /sbin/mgetty /dev/ttyS1sudo start mgettyMgetty should now be running and listening for incoming phone calls. It will run the script you specified in mgetty.config under cnd-program after 2 rings.
Here's my example run_on_ring.sh:
#!/bin/sh
NUMBER="$2"
NAME="$3"
# Do here whatever you want with the caller ID info
# Say the info out loud (must have festival installed)
echo "Incoming call from $NAME. $NUMBER" | festival --tts
# Or IM it over the LAN to clients using Bonjour
echo '<message type="chat"><body>Call From '$NAME'\nPhone Number: '$NUMBER'</body></message> ^] quit' | telnet 192.168.10.10 5298
# etc... :D
exit 1 # So mgetty will NOT answer the phone!There you go! Hope it works!
Comments
Not working under Kubuntu
Not working under Kubuntu 9.10
The above would not work for me under Kubuntu 9.10. Here is what I had to change:
1. for whatever the reason, I could not get upstart to work. So I stuck the initscript in /etc/init/mgetty.conf:
description "start and stop mgetty"
version "0.1"
start on runlevel [2345]
stop on runlevel [!2345]
respawn
exec /sbin/mgetty /dev/ttyUSB0
2. My version of mgetty (1.1.36-Jun15) would not parse out comments at the end of the line. Had to do it like this or it would not work:
set the global debug level to "4" (default from policy.h)
# numer of rings before answer
# tried two but sometimes lost the name in the CID
rings 3
# access the modem(s) with 115200 bps
speed 115200
# config for modem on ttyUSB0
port ttyUSB0
# configure the modem for caller id
init-chat "" AT#CID=1 OK
# run this upon receiving caller id
cnd-program /usr/local/bin/runonring.sh
I tried two rings, but most of the time lost the name string in the caller id. Three worked all the time.
BTW the modem is a USR Courier V.Everything x2 v.90 connected via a generic usb serial adapter. I bought it at a thrift store for $1.
I hope this helps someone else. There is little fresh info on anything to do with modems these days.
Post new comment