Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>What I did in my application for one similar task:</p> <ol> <li><p>To check that a modem is connected to particular port you can send AT command into this port. This function below returns true if we found a modem on the current COM port:</p> <pre><code>private bool CheckExistingModemOnComPort(SerialPort serialPort) { if ((serialPort == null) || !serialPort.IsOpen) return false; // Commands for modem checking string[] modemCommands = new string[] { "AT", // Check connected modem. After 'AT' command some modems autobaud their speed. "ATQ0" }; // Switch on confirmations serialPort.DtrEnable = true; // Set Data Terminal Ready (DTR) signal serialPort.RtsEnable = true; // Set Request to Send (RTS) signal string answer = ""; bool retOk = false; for (int rtsInd = 0; rtsInd &lt; 2; rtsInd++) { foreach (string command in modemCommands) { serialPort.Write(command + serialPort.NewLine); retOk = false; answer = ""; int timeout = (command == "AT") ? 10 : 20; // Waiting for response 1-2 sec for (int i = 0; i &lt; timeout; i++) { Thread.Sleep(100); answer += serialPort.ReadExisting(); if (answer.IndexOf("OK") &gt;= 0) { retOk = true; break; } } } // If got responses, we found a modem if (retOk) return true; // Trying to execute the commands without RTS serialPort.RtsEnable = false; } return false; } </code></pre></li> <li><p>On the next stage we can collect some data from the modem. I used the following commands:</p> <ul> <li><strong>ATQ0</strong> - switch on confirmations (receive OK on each request)</li> <li><strong>ATE0</strong> - switch on echo</li> <li><strong>ATI</strong> - get modem details</li> <li><strong>ATI3</strong> - get extended modem details (not all modems supports this command)</li> </ul></li> </ol>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload