2


I know this is answered question however I want to know hardware required and how to setup.

I am trying to build a take-out's delivery system wherein users call and their phone number gets captured on a WINFORM.

I googled and it says I need to use TAPI API. That's fine but do I need to connect anything to the PC or will just using TAPI work?

This Link explains it in VB.net. I am looking for it in c#.net. I have also gone through the links provided here.

But nowhere does it explain the setup. So please help.

ProgrammingDude
  • 597
  • 1
  • 5
  • 25
mark
  • 623
  • 3
  • 21
  • 54
  • Take a look at this article: [TAPI 3.0 Application development using C# .NET](http://www.codeproject.com/Articles/10994/TAPI-Application-development-using-C-NET) – Tim Oct 07 '15 at 05:44
  • [Code](http://stackoverflow.com/questions/3128204/how-detect-caller-id-from-phone-line) here seems to be a bit more relevant , how ever my first concern is hardware setup. – mark Oct 07 '15 at 05:49
  • https://en.wikipedia.org/wiki/Telephony_Application_Programming_Interface see the hardware section – Abdul Rehman Sayed Dec 22 '15 at 05:26
  • Did you try asking on http://serverfault.com? – Marc L. Dec 22 '15 at 05:48
  • @AbdulRehmanSayed Can you please suggest cheap and best one. As the need is not for vast telephony application just to get the phone number. – mark Dec 22 '15 at 06:55
  • @MarcL. I am not sure if its network, related. Please advise – mark Dec 22 '15 at 06:56
  • @MarcL. [sf] doesn't handle programming questions. – Michael Hampton Dec 23 '15 at 05:08
  • @MichaelHampton Yes, but despite the title, the text of the question and comment makes it clear that TAPI resources abound and the OP needs info more specifically about hardware setup. Alternatively, if it doesn't belong on Server Fault it should *still* be closed as "off topic/too broad". – Marc L. Dec 23 '15 at 19:19
  • First thing ... just see if you hardware supports it (then open a serial port terminal program .. putty) and call the phone number connected to the modem and watch what happens, you should see something like ATA 5555555555 – Ahh ... It's a programming thi Dec 23 '15 at 20:38

2 Answers2

3

First thing

  • See if your hardware supports caller ID
  • Add the serial port control, set it to whatever comm port your modem is on and watch for the CALLER ID number, then react

To see if your modem supports Caller ID open a serial port terminal (I like putty) and set it to the com port of your modem then call the phone number attached to that that modem, you should see something like RING 5555555555 (where 5555555555 is the phone number of the person calling you)

You may have to turn caller id on for that modem (if so)

1) Open the "Phone And Modem Options" control panel

2) Click the "Modems" tab

3) Select your modem in the list (if it is not already selected)

4) Click the "Properties" button

5) Click the "Advanced" tab

6) Type "#CID=1" into the "Extra initialization commands" edit box Note: replace "#CID=1" with the command to enable caller id on your modem Do not include the "AT" part of the command Do not include the quotes 7) Click OK

8) Click OK

9) restart the computer

Here is some code for interacting with a serial port in c# (incase you need that)

public SerialPort sp;
string dataReceived = string.Empty;
private delegate void SetTextDeleg(string text);

private void FormLoad()
{
 sp = new SerialPort("COM1", 9600, Parity.None, 8, StopBits.One);
 this.sp.DataReceived += new SerialDataReceivedEventHandler(sp_DataReceived);
 sp.Open();
}

void sp_DataReceived(object sender, SerialDataReceivedEventArgs e)
{
 try
 {
      Thread.Sleep(500);
       string x = sp.ReadLine(); // will read to the first carriage return
       this.BeginInvoke(new SetTextDeleg(si_DataReceived), new object[] { x });
  }
  catch
  { }
}  

private void si_DataReceived(string data)
{
  dataReceived = data.Trim();

  // Do whatever with the data that is coming in.
}

Also I just searched amazon for "Caller ID Modem" and there seem to be alot for between 10 and 20 dollars (US) that support this exact use. I would recommend the Trendnet TFM-561U

  • I followed the steps ,on step 3, there was no modem so I manually setup it . Also on step 6, "Extra initialization commands" box was not enabled so I clicked on "General" and went to "Change Settings" then under advance I ran "#CID=1". After restarted PC and followed the code but nothing happened. Do I need this "Caller ID Modem". These settings are on Development PC , on clients end I dont see COMM port to install Modem , so what am I missing – mark Dec 24 '15 at 08:42
  • Do you have a physical modem installed on that computer ? You need a device that connects to the phone lines for any of this to work – Ahh ... It's a programming thi Dec 24 '15 at 15:02
  • I dont think so , will _Trendnet TFM-561U_ work what we are trying to achieve ? and I am guessing to use I need a phone splitter too ? – mark Dec 24 '15 at 15:25
  • The trendnet will work and you could use a splitter (which might be easier) or pull it in to a different phone jack. (Make sure you are plugging the phone line in to a analog phone line from the phone company, not a phone system) – Ahh ... It's a programming thi Dec 24 '15 at 16:18
  • Hi sorry for late reply, Just bought that _Trendnet_ device and did as you mentioned, however I am just getting _RING_ every incoming call. – mark Jan 07 '16 at 12:41
  • Do they have caller ID? (From the phone company ) – Ahh ... It's a programming thi Jan 07 '16 at 20:59
  • Client has a landline phone and caller id is working on it . Also send same issue to _Trendnet_ an they replied _Please note that Windows 8 is not supported and the modem does not have Caller ID as a feature._ – mark Jan 08 '16 at 06:49
  • Hi, I replaced the device with _TFM-561u_ earlier got _560U_ , however can you guide where I can find drivers for _Win 8.1_ – mark Jan 16 '16 at 07:02
3

If you are using a phone and fax modem, just plug-in your telephone line into the modem.

Next on your windows form drag-n-drop a SerialPort control and initialize it.

    this.serialPort1.PortName = "COM3"; 
    this.serialPort1.BaudRate = 9600;
    this.serialPort1.DataBits = 8;
    this.serialPort1.RtsEnable = true;
    this.serialPort1.DataReceived += serialPort1_DataReceived;
    this.serialPort1.Open();      

Pass the following command to modem in order to activate Caller-ID

    this.serialPort1.WriteLine("AT#cid=1" + System.Environment.NewLine);

Handle its DataReceived event and display the received data

     void serialPort1_DataReceived(object sender, SerialDataReceivedEventArgs e)
     {
          richTextBox1.Text += this.serialPort1.ReadLine();          
     }

Output:

RING               //On 1st Ring
DATE = xxxxx       //On 2nd Ring
TIME = xxxx
NMBR = xxxxxxxxx

RING               //On 3rd Ring    
RING               //On 4th Ring

P.S. If the telephone line sends DTMF tones as Caller-ID then you need DTMF to FSK converter to detect the number, or else you will receive the rings but not the number.

Marshal
  • 6,551
  • 13
  • 55
  • 91
  • Can you really just use a modem like a serial port? Just wrote a program that utilizes serial ports so I have been learning quite a bit about them lately. I didn't know that a modem worked like one. You learn something everyday...lol. – ProgrammingDude Dec 23 '15 at 21:10
  • Yes you can. There is as a virtual com port created to communicate with the modem. Serial Port can communicate with actual "Serial Ports" and "Virtual Com Ports" – Marshal Dec 23 '15 at 21:11
  • @ProgrammingDude sorry for being so naive, however wher do I write `this.serialPort1.WriteLine("AT#cid=1" + System.Environment.NewLine);` i mean event – mark Dec 24 '15 at 04:47
  • @mark you need to write that right after opening serial port. – Marshal Dec 24 '15 at 12:52
  • And you don't need to do that manually as described in above answer. So by that you don't have to worry id modem is reset etc – Marshal Dec 24 '15 at 13:04
  • right @Marshal about the hardware will "Caller ID modem" would be sufficient as explained above ? Also about the connection I need to split phone line into 2 , of which 1 goes to phone other to "Caller ID Modem" ? – mark Dec 24 '15 at 14:29
  • great I will order the hardwares , let me check all , if any issue will let you know thanks a lot @Marshal – mark Dec 24 '15 at 15:21
  • First check with the normal splitter. If you get RING messages but no number information, then you also need to get a DTMF to FSK converter. All the best with your adventure – Marshal Dec 24 '15 at 15:39
  • Hi @Marshal its been long time, still on same issue had to get a new USB Fax Modem _HiRO H50113_ they have _Phone Tray_ and this gets the number but my app just _Ring_ . Any idea whats wrong – mark Feb 03 '16 at 17:44
  • Can u elaborate "..this gets the number". Where do u get it, in a text box ? – Marshal Feb 03 '16 at 17:53