How to send DTMF commands after using AT in C#? RRS feed

  • Question

  • I need to dial a number from USB modem, after other side answer the call I need to send several DTMF commands. I have tried to do this code - But it exit the call when I try to send DTMF:

     SerialPort port = new SerialPort("COM7", 115200);
            port.ReadTimeout = 1000000;
            port.NewLine = "\r";
            port.WriteLine("ATZ"); // reset the modem
            //port.ReadTo("OK\r\n"); // wait for "OK" from modem
            port.WriteLine("ATDT 123456789"); // dial number with dialtone
            port.WriteLine("AT+VTS 2"); // dial DTMF
            string response = port.ReadTo("\r").Trim(); // read until first newline
    Sunday, October 14, 2018 9:37 AM

All replies

  • It looks good. I would add as a first command an "AAAT". Most modems can use this for synchronizing themselves with the incoming character stream. Wait for an "OK" after sending your commands. Waiting for a single "\r" is not enough because the modem will echo the same characters that you send to it, and therefore you will see the \r from the end of your own WriteLine before the modem has processed the command that you sent.

    Sunday, October 14, 2018 12:57 PM
  • can you please rewrite it?

    I just need to send several DTMF tones after line answer.

    Sunday, October 14, 2018 4:23 PM
  • Hi igorbigu,

    Please check the link below. It maybe helpful.

    Best Regards,


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact

    • Proposed as answer by Stanly Fan Thursday, October 18, 2018 8:59 AM
    Tuesday, October 16, 2018 7:53 AM