Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Why won't it work? - modem with mscomm 1

Status
Not open for further replies.

AdaHacker

Programmer
Sep 6, 2001
392
0
0
US
Okay, here's my problem. I'm trying to contact a remote system via a modem. It works fine when I dial the site up through hyperterminal, but from code I never get any data back.
Here's some of my test code.
Code:
Private Sub Form_Load()
' Set up the control with the right settings and open the port.
With MSComm1
    .Settings = "1200,n,8,1"
    .CommPort = 1
    .PortOpen = True
    .InputLen = 0
End With
End Sub

Private Sub Command1_Click()
' Allows me to dial, send commands, etc.
' There's also a button that does the same thing, 
' but with no carriage return after the string
Dim str As String
str = Text2.Text & Chr$(13)
MSComm1.Output = str
End Sub

Private Sub Timer1_Timer()
' Lets me keep track of the input recieved.
' I have a similar statement in the onComm event.
Text1.Text = Text1.Text & MSComm1.Input
End Sub
When I dial a number using, e.g., "ATDT 9,555-1234", the modem seems to connect. It echoes back the dialing command and gives me a message saying "CONNECT 1200/NONE" and the onComm event registers a carrier detect change. However, after that, nothing happens. I can send as much data as I want, but I never get anything back. Normally (through hyperterminal) I send 2 carriage returns and then I get a sign on prompt, but through code, I can send them all day and I don't get a thing back. I can issue the modem a "+++" to drop it back into command mode, after which it will give me output, so I know it's functioning, but while it's active I get nothing.

What's going on here? Can anyone give me any tips/ideas? Is there some key setting that I'm just missing? Anything? I've never done any serial communications before, and I'm starting to get desparate.
 
Make sure inbuffersize is not set to 0
Try Chr$(10) instead of chr$(13)
 
The input buffer size is set to 1024. Using the linefeed character instead of a carriage return doesn't seem to help.

Upon further tinkering, I've found that the data I'm trying to send is getting received by the remote machine. If I dial in, send 2 carriage returns and the password, then send the exit command to the remote system, I get disconnected, which is what happens through hyperterminal. I can also send other commands before the exit (but since I'm not seeing any data, I don't know what's happening with them). So the data I'm sending is apparently being received and responded to, but I'm never seeing anything come back. Nothing in the input buffer, no activity on the modem's receive light, nothing.

Does anyone have any clue what could possibly be wrong?
 
Try use the OnComm event instead of the Timer...

Private Sub MSComm1_OnComm()
ReceiveBuffer = MSComm1.Input
....

End Sub
 
Actually, I'm using both. I added the timer because I had the send and receive thresholds set to 0, so the send and receive events weren't being generated. Right now, this is my OnComm
Code:
Private Sub MSComm1_OnComm()
Text1.Text = Text1.Text & "Buffers: " & MSComm1.InBufferCount & "  " & MSComm1.OutBufferCount & vbCrLf
Text1.Text = Text1.Text & MSComm1.Input & vbCrLf & "Error #: " & MSComm1.CommEvent & vbCrLf
End Sub
I'm just checking the buffer sizes and dumping any data I get back into a textbox. (Yeah, using a textbox for all my incoming data probably isn't the best way to do it, but this is just test code.)
 
Well, I finally figured it out. Thanks a lot for the help everybody.

After trying other systems and determining that the problem was definitely my code, I searched MSDN and found what was listed as a VB3 problem. It seems that sending but not receiving data can happen if you don't have the MSComm.RTSEnable property set to true. It seems that this property is set to false by default in VB6. I set this property to true and now everything works perfectly. I can't believe I wasted an entire day on this yesterday. I should have known it was going to be some stupid little setting like that. Problem is, there are lots of them, and if you don't know what to look for, you're out of luck.
 
Hey, don't we all just LOVE Microsoft's intuative controls?
 
Addhacker, I know this is an old post but I was wondering if you are still using this method to transfer data. I am currently trying to do the same thing except instead of being two Pc's one is a pc the second is a handheld. I need to be able to upload a file and download a file, what are your thoughts?

[afro]Zeroanarchy Experience is a wonderful thing. It enables you to recognize a mistake
when you make it again.
 
ZeroAnarchy,

Yes, I am indeed still using this method to transfer data, but I think you may have misunderstood my situation a little. It's not actually two PCs that I'm transfering between. The remote system is actually a proprietary control terminal that controls access to fuel pumps. It essentially allows you to dial up, give a password, and then drops you at a command prompt. There aren't any files involved, as everything is sent and received through the remote system's standard output. I just "print" what I'm interested in to the screen and capture the output.

I think you could probably use a similar method to send data over a serial connection between the handheld and PC, but I'm not entirely sure how you would do it. It's hard for me to make a suggestion without knowing the details of your situation. Really, it all depends on the handheld. (I'm assuming you're using a direct serial connection rather than a modem, like I did.) With the MSComm control, you have can read and write to the serial port of the PC. Although it's not very transparent, you can certainly use it to send a file a few bytes at a time. But, as I said, what you do is going to be mostly determined by the software the handheld uses to "listen" on the serial port. Anything you write for the PC will have to conform to that. Without knowing how to interface with it, there's not really a lot I can tell you.

Sorry I can't be more specific. If there's anything else I can tell you, just let me know.
 
here is what I am trying to do.

(1) Connect my infra red mobile to infa red Handheld.
(2) dial into my desktop modem from my mobile phone
(2) Conenct to a desktop modem.
(3) Run an EXE file that uploads and downloads data

So far I have 1 & 2 working I also have the upload download part working all I need is to be able to activate the EXE file on connection.

I was hoping that Activesync was dial-in compatiable but it doesnt seem to be.


Handheld: Compaq IPAQ

Any ideas????

Thanks
ZeroAnarchy Experience is a wonderful thing. It enables you to recognize a mistake
when you make it again.
 
Dear Zeroanarchy
can u plz send me the code for waht u did in your app.
I'll be really thankfull

hash
 
Hi Zero.
I am aslo interested in IR communications.

I think I have to go throough msCOMM seeing that IR port is actually a com port.

To what com port do I set the mscomm?

**********************************
May the Code Be With You...
----------
x50-8 (X Fifty Eigt)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top