0

I need to create a windows application that read incoming phone call number from COMX and the following is the code I have:

public partial class frmMain : Form
{

    public frmMain ()
    {
        InitializeComponent();
        if (!serialPort1.IsOpen)
        {
            try
            {
                serialPort1.Open();
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
    }

delegate void OutputUpdateDelegate(string data);
private void OutputUpdateCallback(string data)
 {
     txtReceive.Text += data;
 }




    private void DataRec(object sender, System.IO.Ports.SerialDataReceivedEventArgs e)
    {
        try
        {
            string data = serialPort1.ReadExisting(); 
            txtReceive.Invoke(new OutputUpdateDelegate(OutputUpdateCallback),data);                
        }
        catch (System.Exception ex)
        {
            MessageBox.Show(ex.ToString());
        }
    }      

}

Since I don't have a modem to test, I need to know how to create a fake call for test and how to read only the Phone number instead of reading the whole string coming from "ReadExisting()" method, is there a way other than splitting the string? if no what does the incoming string look like?

Please Advise.

Fadl Assaad
  • 99
  • 13
  • Get the programming manual for your modem to get samples of the responses. Does your RJ11 cable use a 9/25 pin connector, USB, or Ethernet connection in your computers? A simple way of testing the messaging portion of the code is to make a virtual TCP connection with a client and server. The server would mimic the Modem and the client your PC sending messages. – jdweng May 30 '16 at 12:02
  • Thanks @jdweng I appreciate your hint, I search for the virtual TCP connection and I find a way to test with Hyper Terminal, but I can't make a fake phone call (like for example to enter a number +999999999) all what I'm able to is to write in the terminal and catch the value in my code. As to answer your question the modem that I plan to use has RJ11 port that use 9/25 pin connector. – Fadl Assaad May 31 '16 at 05:39
  • @jdweng, sorry the modem that I plan to use has RJ11 port and not any of what you mentioned above. – Fadl Assaad May 31 '16 at 05:59
  • The 9/25 connector can be jump by connecting pins 2 & 3 with a wire or paper clip. Done it plenty of times to test code. – jdweng May 31 '16 at 08:24
  • @jdweng I connect a modem and try to call, I only receive RING RING ... with no other information I expected to get NMBR = xxxxxxxx knowing that I enabled the CallerId using AT+VCID=1 I got OK but still doesn't receive the expected result, when I connect the cable to the telephone I see the caller number. How to deal with this? – Fadl Assaad Jun 01 '16 at 05:05
  • @jdweng I mean in my previous comment that the line support CallerID. – Fadl Assaad Jun 01 '16 at 05:19
  • @jdweng is it possible to get OK when I typed AT+VCID=1 but still the modem doesn't support Caller ID? the following link shows many possible command to enabling the Caller ID of the modem, I tried them all and receive "Error" except when I used "AT+VCID=1" it give OK, does this mean the modem accept Caller ID or what? What do I miss? the link I read is: "https://www.beiley.com/acallerid/enable.html" – Fadl Assaad Jun 01 '16 at 05:23
  • OK is probably just an acknowledgment that the device received the command, but doesn't necessarily mean the RJ11 line can operate in the mode. Measure the serial port is set to No hardware and No Software Handshaking. The Serial port should be set to 8 bit, no parity, one stop bit. The SEND can be Synchronous, but the Receive Data should be an Event. I suspect your errors my be due to the serial port not being set to 8 Bit No Parity. Using other settings can cause errors where some commands will work and other will not. Does the modem work with vendors application software? – jdweng Jun 01 '16 at 09:17
  • @jdweng the serial port is set to 8 bit, no parity, one stop bit, when I plug the RJ11 line to the telephone and receive a call the caller number appear on the screen, but when I plug the line on my laptop's built in modem I receive only Ring, I didn't try if the modem work with vendors application (since I don't have phone line at my home yet lol I need to get my laptop to my work to test for this I asked if I can make a fake phone calls). I'm sure the code above should work but it seems I miss something. How to make sure the built-in modem support CallerId? Any idea? – Fadl Assaad Jun 01 '16 at 11:17
  • That is why I recommended try the vendor software. You don't have to make a call, just check the settings. The cable between the PC and modem may have issues or the serial port driver installed in the PC. You may be using a generic Microsoft Serial Port Driver instead of the vendor driver. – jdweng Jun 01 '16 at 11:53
  • @jdweng Okay I will check about this, thanks again for your help :) – Fadl Assaad Jun 01 '16 at 11:55
  • Hi @jdweng, I bought TRENDnet modem "TFM-561u" that is support caller id, after I installed it and plug the cable I call the number but I'm still receive Rings in the Hyperterminal screen, I enabled the caller id by AT+VCID=1 and I put +VCID=1 in the modem properties and restart but still getting only Rings, my OS is win 8 64 bits. I'm out of ideas, what should I try? – Fadl Assaad Jun 06 '16 at 11:42
  • Does the vendor software run? Try calling a number and see if you hear the phone ring. Did you turn off Hardware and Software Controls in Hyperterminal? did you instal the drive on webpage : http://www.trendnet.com/support/supportdetail.asp?prod=130_TFM-561U? I don't have time right now to read manual. I think the ring means you are not going off hook which means the modem isn't closing the hook signal. Hook a telephone into the RJ11 on modem and see if you hear a dial tone. – jdweng Jun 06 '16 at 12:17
  • @jdweng **"Did you turn off Hardware and Software Controls in Hyperterminal? "** can you explain more please, **"Does the vendor software run? "** I have in the installation package **"Netwaiting"** and the **"Classic Phone Tools"** I guess you mean the second one, I open it but I didn't find a way to connect to COM. I read on stackoverflow that Win 8 is not supported for TFM-561u [link](http://stackoverflow.com/questions/32984598/how-to-make-caller-id-in-c-net) I don't want to be noisy :), I'm out of ideas, someone told me that maybe the modem is affected by the power supply of the pc weird! – Fadl Assaad Jun 07 '16 at 05:34
  • Does a phone work in wall jack? What interface does the Classic Phone tool support? There has to be a setup menu. Are you set for Dial or Pulse? Power supply of PC can effect a connection but I don't think right not we can come to any conclusions. Hyperterminal has comm setup menu. Don't have installed on my computer. Will check later. – jdweng Jun 07 '16 at 07:59
  • @jdweng a filter is plugged to the wall jack and the phone is plugged to the filter's phone port. I follow the setup menu they mentioned that the software automatically connect to the modem. I will try to setup the modem to another laptop with Win7 and repeat all the steps hopefully the problem will resolved. – Fadl Assaad Jun 07 '16 at 08:56
  • Do you have a splitter on the RJ11 jack? Phone jacks are 4 wire with two being used for each phone line. You can have 1 or 2 phone lines in a jack. There are two different types of splitters. One type that takes line 1 and allows two different devices to plug into line 1. The 2nd type takes line 1 and puts on one output jack and then puts line 2 one line 1 of 2nd output jack. If you only have one line on RJ11 then 2nd type will not work. Start testing by removing any splitter and connect directly to wall. – jdweng Jun 07 '16 at 09:19
  • @jdweng I tried to plug it directly the wall still not working, at the phone line that I have there is a DSL so the splitter is used as a filter here. I have one phone line and one local phone, when I'm testing the modem I unplugged the local phone and just use the modem. – Fadl Assaad Jun 07 '16 at 11:47
  • I have high speed dsl at home and use ethernet between PC and Modem. Verizon supplied me with software that automatically configured everything through the ethernet. Never tried other interfaces. – jdweng Jun 07 '16 at 13:34
  • @jdweng the story seems come to an end, the TFM-561u support replied to me mentioning that the modem doesn't support caller id "odd" the vendor said different words, anyway I met a person that face same issue before and his company orders special modems for this that is working as expected so I asked him to prepare one for me to test and if it works so I will buy it :) hopefully this will be the end of this problem :) – Fadl Assaad Jun 08 '16 at 08:03
  • A phone goes off hook when a low impedance is put across the phone line which creates a dial tone. Leaving the phone off hook will eventually give a fast busy tone and eventually the line will go dead. The DSL connection doesn't require an off hook. DSL is high speed (phone is low speed) and gets through a blocking capacitor that is used by phone connection. The adapter you bought is probably low impedance which is putting the phone off hook and you are getting a fast Busy Tone (phone left off hook) which the modem thinks is a Ring Tone. – jdweng Jun 08 '16 at 09:44
  • @jdweng Do you think that keeping the phone plugged plus the modem will make difference? currently I have one cable I'm unplug it from the phone and put in in the modem, do you think if I use a splitter and plug both it can affect the result? – Fadl Assaad Jun 08 '16 at 11:28
  • I suspect if you wait 1/2 hour with phone off hook that you may not get the RING on Hyperterminal. I have DSL at home with a splitter to a phone and never have an issue just using phone, modem, or both. – jdweng Jun 08 '16 at 12:58

1 Answers1

0

I finally bought a caller id product that communicate with the serial port and provide the caller number as the following: R99999999E and I made the appropriate code modification to read the number and everything is working as expected.

Notice: TRENDnet modem "TFM-561u" does not support caller id, and actually their support replied to me saying that TRENDNet has no product that support caller id.

Fadl Assaad
  • 99
  • 13