Solved

connect to another com-port  through modem

Posted on 2002-03-13
12
247 Views
Last Modified: 2007-12-19
I am writing a software to read the output of a com port of an instrument. The instrument, continuously send its status condition thro its com port. I have developed a program to read the com port data from a pc.
Now, I want to read this com port from a remote pc, using modem. I wrote MSCOMM1.OUTPUT = ATDT & phone number & vbcr
My phone dials the modem which is connected to the com port of the instrument.(Both externam com ports) It connects and the connecting sound stops. But I don't get any meaningful data. Is it necessary for me to implement any modem protocol? Or do I need some soecial modems?

Please help
0
Comment
Question by:shivajivarma
  • 6
  • 5
12 Comments
 

Expert Comment

by:bill02
ID: 6861378
are you using 2 phone lines? if not there is a special modem i can't rember the name of the setting but the courrier v everything modem had this setting it allowed you to connect 2 modems together without needing a dial tone.
0
 
LVL 17

Expert Comment

by:inthedark
ID: 6861667
From your question I understand the following:

You have a device on COM PORT X
You have a modem on COM PORT Y

Yoy want to pipe the output from comport x down the phone line via com port y

So first you have to make you phone answer a call:


' to set waiting
MSCOM1.Output "ATZ"+vbcrlf ' Reset modem
MSCOM1.Output "ATV1"+vbcrlf ' select verbose modem responses
MSCOM1.Output "ATS0=1"+vbcrlf ' answer after one ring


Buffer=""
Do
  Buffer=Buffer+mscom1.input
   
  ' the actual connection message will vary
  ' dependent on the modem
  if instr(Buffer,"CONNECTED")>0 Then exit do
  Sleep 5000
loop

you are now on line and can pipe the data between x/y


0
 
LVL 17

Expert Comment

by:inthedark
ID: 6861697
You can set the outward dialing as follows:

' to set waiting
MSCOM1.Output "ATZ"+vbcrlf ' Reset modem
MSCOM1.Output "ATV1"+vbcrlf ' select verbose modem responses
MSCOM1.Output "ATD T1234565"+vbcrlf ' Dial


' Now you can loop until connected

Dim Starter as Date
Dim TimeOut as single
TimeOut=60 ' seconds
Starter=now
Buffer=""
Do
 Buffer=Buffer+mscom1.input
   
 ' the actual connection message will vary
 ' dependent on the modem
 if instr(Buffer,"CONNECTED")>0 Then exit do
 Sleep 100

  if DateDiff("s",Starter,Now)> TimeOut Then
     msgbox "No answer: " + buffer
     exit Sub
  end if
loop

You are now connected
0
 
LVL 17

Accepted Solution

by:
inthedark earned 300 total points
ID: 6861760
So now you keep polling until you reveive a CONNECTION LOST MESSAGE.

Do

  ' get input from modem
  A$=MSC1.Input
  if len(a$) then
    iF INSTR("CONNECTION LOST NO CONNECTION",A$)>0 THEN
       ' You are no longer connected
       exit sub
    End If
  end if
  MSC2.OutPut A$
  A$=MSC2.Input
  if len(a$)>0 then msc1.output a$  
 
loop

But what I would do is log the results to a file and then use MAPI control to send them to you via email. Toy will find this takes a major amount less effort.


Best advice:

Use pcAnywhere! It is excellent at allowing a remote pc to call, connect and totally control a host pc.


But if you realy wan;t to do it the hard way then you may need a bit more info:

You will need Some hayes AT Command Links:

http://www.spiralspider.demon.co.uk/hayes.htm

http://support.microsoft.com/directory/article.asp?ID=KB;EN-US;Q164660&

You also need so know the modem responses:

http://readthetruth.com/modems.htm
(THis is a good line it even shows how to send/receive faxes.)


More advanced Modem programmer may wish to turn verbose off and use numeric commands.

ATV0 - use numeric messages

Have fun, forever inthedark.......
0
 

Author Comment

by:shivajivarma
ID: 6871093
As I have mentioned , I am able to connect to another modem. Connection is not the problem, but transmission of the data is. The first modem has an instrument connected to it which continuously pumps data out. After the modem connects, I am not able to receive anything other than junk in the PC hyperterminal/my comm program.
Probably,the modem is using some kind of protocol like z modem/ x modem etc.
0
 

Author Comment

by:shivajivarma
ID: 6873544
Dear inthedark,

we have not used the command

MSCOM1.Output "ATV1"+vbcrlf ' select verbose modem esponses

but modem connects alright. We don't get any meaning ful data. The device which connects to the modem is sending ascii data. we can make that device send any specific string if required. But without doing that itself, connection is made. Baud is 300, both sides.
0
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
LVL 17

Expert Comment

by:inthedark
ID: 6873626
shivajivarma, you are thinking along the right lines.  You must force each modem to use a common protocol.  When your modems connect, you should see a connection message like:

CONNECT9600

If you don't use verbose you will get a number which you have to inperpret from the modem's documentation.  In the old days modems were shipped with the complete programmer's reference, but nowdays it is hard to find any documentation at all.

You must use verbose to start with to see what the default connection is being made by the modem.

Check that you are using a common baude rate for you connection.  Try 9600 AT BOTH ENDS.  Also set a scefic protocol, compatible with your baud rate:

Send "ATF8" to select V.32 bis or V.32 9600.

The problem now is how to force use of V.32 9600

There is also a problem in that  some modems are not exactly hayes compatible.  While reseaching this issue I found this:


\ _^/    ,^,
 \>@@</   ((       "Out of order, there is chaos.
  (..)    );)       Out of chaos, there is order."
   vv\^^^^ /
  /==  ))) )
 ( ==/ )=< \
{{{)=(}}}(_}}}

If use of "ATF8" and using baud rate 9600 does not fix it post another message.
0
 

Author Comment

by:shivajivarma
ID: 6873640
thanks a lot sir. Lemme try and come back to you
0
 
LVL 17

Expert Comment

by:inthedark
ID: 6873852
p.s. Unless the connection strings at both ends are not the same it won't work.

0
 

Author Comment

by:shivajivarma
ID: 6904555
Dear inthedark,

I am still trying. I am not sure whether the current modems are hayes compatable. Please bear with me.

0
 
LVL 17

Expert Comment

by:inthedark
ID: 6904575
I always use PC anywhere to monitor another pc.
0
 

Author Comment

by:shivajivarma
ID: 6952843
Thank you for the help. Your comments were helpful. I guess the problem is with the modem.
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

746 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

11 Experts available now in Live!

Get 1:1 Help Now