How to get com status?

I want to be able to find out whether the com port has a valid dial tone
or not and also to distinguish between open port and a intermittent dial

Hope someone can help.
Who is Participating?
trkcorpConnect With a Mentor Commented:
  As described by khaldc, you may code the OnComm event... What will happen is the event will fire when (1) the RThreshold is met or exceeded.  The default value for this property is 0. This disables the firing of the OnComm event when characters are received at the comm port. If you were to set the value to say, 1, then the OnComm event would fire when a character hit the port. At this point within the OnComm Event you can use the Input method to read the characters in the input buffer...(Case comEvReceive ' Received RThreshold # of' chars. ) (If you set the value to one be sure to give the modem time to return all of the characters before you read the string or you may get just part of it.  You could also just get each char one at a time but you would work your poor program to death firing OnComm events and you would probably lose characters...)
   When you attempt to dial a number on an open comm port your modem will return "NO DIAL TONE" to the port if there is no tone. If there is then it will dial the number and you may monitor for a connection being established by again setting the RThreshold property > 0 and your modem will return a "CONNECT..." string defining your connection.  Also, checking the CDHolding property for true lets you confirm the connection.  You should also read about the InputLen property... I know of no way to detect a dial tone other than by attempting to dial or just listening to the modem speaker.  You can take the phone line off hook by issuing AT H1, AT H0 to hang up.   (2) one of the other values as stated in the above case set is changed.
   If by "Intermittent Dial Tone" you mean busy signal; your modem will return "BUSY" if it dials a number and gets a busy signal.  If you mean you have to dial 9 & wait to get out or something then you can insert commas in your dial string to make it wait before continuing to dial. (Ex: ATDT 9,,1234567 will dial 9, wait 4 seconds then continue to dial 1234567.  The wait time is determined by a value in the S8 register on your modem but generally defaults to 2 seconds. Read your modem manual to learn about S registers.
   You modem must be set to be "Verbal"; Use send AT V1 to the modem to turn on the phrases, AT V0 will cause the modem to return numeric codes. Most modems are verbal by default but not all are. Study your modem manual's AT command set to find out about all of the commands, initializations, return codes, etc.
   To understand the MSComm control you should thoroughly study each property and also have a rudimentary understanding of communications programming and protocol.
First you have to know what is attached to your com port, if it is a modem then you have to know how to communicate with the modem. In your case, you have to know what sort of signal is received by the modem, and if the modem can recognise different line sets.
As far as the communication port, you can know if the port itself is open or not by querying the PortOpen property, if it returns True than it is open and so forth.
One more useful thing is the Comm Event in MSCOMM, OnComm example:
Private Sub MSComm_OnComm ()
      Select Case MSComm1.CommEvent
      ' Handle each event or error by placing
      ' code below each case statement

      ' Errors
            Case comEventBreak      ' A Break was received.
            Case comEventCDTO      ' CD (RLSD) Timeout.
            Case comEventCTSTO      ' CTS Timeout.
            Case comEventDSRTO      ' DSR Timeout.
            Case comEventFrame      ' Framing Error
            Case comEventOverrun      ' Data Lost.
            Case comEventRxOver      ' Receive buffer overflow.
            Case comEventRxParity      ' Parity Error.

Case comEventTxFull      ' Transmit buffer full.
            Case comEventDCB      ' Unexpected error retrieving DCB]

      ' Events
            Case comEvCD      ' Change in the CD line.
            Case comEvCTS      ' Change in the CTS line.
            Case comEvDSR      ' Change in the DSR line.
            Case comEvRing      ' Change in the Ring Indicator.
            Case comEvReceive      ' Received RThreshold # of
                                                ' chars.
            Case comEvSend      ' There are SThreshold number of
                                          ' characters in the transmit
                                          ' buffer.

Case comEvEof      ' An EOF charater was found in                                                 ' the input stream
      End Select
End Sub

You can access this sub by double clicking on the MSCOMM icon.
This sub will tell what is happening with Communication port every time you use it or when an error occurs.
Hope that will get you started.

One more thing you can check the eventsunder the MSComm_OnComm events, you may detect what sort of signal you have.

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

predator1Author Commented:
I tried most of that already, and it doesn't seem to do what i want.
I will expand a bit,
I don't want to do any dialing.
we have a service here called "Call Answer", it is basically voice mail. When there are new messages waiting, i get a intermittent dial tone, and therefore the modem doesn't recognize that as the proper dial tone. in dun, it will tell me there is no dial tone.
I just want to have the program always checking the modem com port to check the status and only tell me when there is the intermittent dial tone there.

hope this is more clear.

In my opinion, Commport command can not help you in identifying the intermittent dial tone (which is at different Decibles and Hz of the normal one). Your modem hardware/software manual may be of more help to you to identify the intermittent dial tone.
Every modem has different commands,  settings, and capabilities. You may have to consider these in trying to check for intermittent dial tone.
I answered without seeing your further comments & K's reply. I will agree with K.  There is no way to check for the intermittent tone... The best test I can think of is just to attempt to dial and monitor for success or failure.
predator1Author Commented:
But every com app I've ever tried has always told there is no dial tone when I have that intermittent signal, and b4 dialing. It is similar to a busy signal, but it is not recognized as such by the modem. Can you pin point the call that checks for a dial tone? The only thing i can compare this to, is if you unhook one of ur phones and then try to dial out. I think u will get a "no dial tone" message. I just want to duplicate this but with a different message. The vb help isn't very good on this and i've tried searching for stuff with no luck either.
As I said, ComPort can not detect the dial tone. Some modems has the capabilities to do that, and the complexity of doing so is solely dependent on the modem manual.
predator1Author Commented:
ok, i'm sorry to beat a dead horse and all your help is appreciated, but to me that just does not make sense. If only certain modems have this capability, people that dial out with no dial tone must get pretty pissed off when they sit there for a while and finally figure  out there is no dial tone.
I guess i will try sending a command to dial and see what i get back with my intermittent dial tone.


khaldec is shooting straight.  ALL modems will detect connection or failed connection.  That is their primary purpose in life outside of exchanging data.  True: if the line is physically disconnected the modem will not dial; it can't and it will report same, but outside of that this detection is still only made by an attempt to USE the line!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.