or

How to Automatically Hang Up on Telesales Using .net, a Modem and Caller ID

or

Using Serial Ports from Mono on Raspbian

Since we seem to get a never-ending series of calls from telesales, market research and “your ISP”, I decided to start adding their caller IDs to our cordless phone book as “Scam n”.

The problem with this plan was that you still had to head to the phone to see that it wasn’t someone you wanted to bother with. If only there was something that could read a caller ID and automatically pick up the phone and hang up.

Like a modem.

Connected to a Raspberry Pi.

So I bought a cheap USB modem from Amazon, and wrote something in C# to check incoming CLID against a blacklist. I tested it on a Windows laptop, and then installed Mono on the Raspberry Pi. Watched it do nothing. Then I wrote it again. Twice.

1. Getting the modem to work

One important step was to tell the modem which country it was in, I did this via the properties page on the Windows laptop. Without this stage, it didn’t recognise the caller id information coming along with the calls.

The name of the port can be found on the device properties page in Windows, or on Raspbian / Debian / Ubuntu / whatever-linux by running

lsusb

And finding the entry for the modem

Bus 001 Device 007: ID 0572:1329 Conexant Systems (Rockwell), Inc.

And then finding the symlink to that device, of the form /dev/tty

 ls -l `find /dev -name '*Conexant*'`

(there’s backqoutes and single quotes in there, not smart quotes gone nuts)

2. Getting Mono on the Raspberry Pi

sudo apt-get install mono-complete

wait.

3. Using Serial Ports in Mono

Forget the DataReceived event. Spin up threads for the reading and writing from the serial ports.

4. TimeSpan in Mono 2.10.8.1 on Raspbian 3.2.27+ #250 PREEMPT

Forget it. Use an int for milliseconds. The following code

Console.WriteLine(TimeSpan.FromSeconds(1));

Produces

00:00:00

5. The source code

It’s quick and dirty, and it’s available on bitbucket.

6. Get your own

You can get a Raspberry Pi here, and there’s an Amazon ad for the type of modem I used below.

TRIXES USB 56K External Dial Up Voice Fax Data Modem Windows 7

Comments

Hi Mark, Could your project be modded to show ca…

Anonymous - Feb 03, 2013

Hi Mark,

Could your project be modded to show caller ID over a network?


Maybe, but if networked caller ID is the only feat…

Mark Lambert - Feb 03, 2013

Maybe, but if networked caller ID is the only feature you need, you could try getting ncidd working, from http://ncid.sourceforge.net/ncid/ncid.html


Thanks for the reply, I have the same modem as the…

Anonymous - Feb 03, 2013

Thanks for the reply, I have the same modem as the one listed above and am I correct in thinking this should work out the box with the Pi or if not do you have a more detailed guide showing how to get it working? i have played with NCID on Ubuntu but I could not get it working.


Yes, it connected without drivers on raspbian. The…

Mark Lambert - Feb 03, 2013

Yes, it connected without drivers on raspbian. The only tricky bit was finding the /dev/... entry, which I did with the lsusb and ls commands in the post.
But to get it set to UK standards, I connected it to a Windows box and set the modem properties to UK, then put it back on the Pi.


NCID 0.86 (released Mar 24 2013) now has support f…

Anonymous - Mar 25, 2013

NCID 0.86 (released Mar 24 2013) now has support for Raspberry Pi. http://ncid.sourceforge.net/ncid/INSTALL-Raspbian.txt


That's great. Thanks for letting me know!

Mark Lambert - Mar 25, 2013

That's great. Thanks for letting me know!


No problem. I was looking for the same type of so…

Anonymous - Mar 27, 2013

No problem. I was looking for the same type of solution as you were and ran across your blog where I learned the RPi could talk with a modem. Aside from the initial challenges of setting up ncid, it is very stable on the RPi for the couple of weeks I have been running it.