Solved

How to get com status?

Posted on 1998-07-13
10
155 Views
Last Modified: 2010-05-18
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
tone.

Hope someone can help.
Thanks
Derek
0
Comment
Question by:predator1
  • 4
  • 3
  • 3
10 Comments
 
LVL 1

Expert Comment

by:khaledc
ID: 1465641
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.

0
 
LVL 1

Expert Comment

by:khaledc
ID: 1465642
One more thing you can check the eventsunder the MSComm_OnComm events, you may detect what sort of signal you have.

0
 

Author Comment

by:predator1
ID: 1465643
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.

0
 
LVL 1

Expert Comment

by:khaledc
ID: 1465644
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.
Regards
0
 
LVL 4

Accepted Solution

by:
trkcorp earned 50 total points
ID: 1465645
pred,
  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.
0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 4

Expert Comment

by:trkcorp
ID: 1465646
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.
0
 

Author Comment

by:predator1
ID: 1465647
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.
0
 
LVL 1

Expert Comment

by:khaledc
ID: 1465648
predator1
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.
Regards
0
 

Author Comment

by:predator1
ID: 1465649
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.

Thanks

0
 
LVL 4

Expert Comment

by:trkcorp
ID: 1465650
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!
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now