Solved

C++ Builder 5: Can't hang up analog modem running the program

Posted on 2009-06-29
2
413 Views
Last Modified: 2013-12-27
Hi,

I have made a program under C++ Builder 5 Enterprise that exchanges data with several remote locations. Som of them are reached via analog lines and modems. The communications modules are located in a different thread to avoid conflict with the main window thread. All the program runs well except for the task of hanging up the modem. I use some lines like:
         WriteFile(Handle,"+++",3  ...
         Readfile(Handle,MyString, ...
         WriteFile(Handle,"ath\r",4  ...
         Readfile(Handle,MyString, ...

If I run these lines with the debugger, step by step, it runs OK, but if I let the program run alone, the modem does not hang up and the line gets stuck.
I have tried to insert Sleep() between lines in case the task needed some delay but without success. Even tried to insert Application->ProcessMessages() but with the same negative result.
Can anyone tell me why it is not working and a way to definitely hang up the modem?
If the "+++" command does not work, could I use the method of resetting the UART so that the lines gets free?

Thank you very much in advance.

Rafael Caballos
0
Comment
Question by:rafcab
2 Comments
 
LVL 16

Expert Comment

by:George Tokas
ID: 24744541
First of all Sleep() suspends execution of the thread calling that - usually the main thread of execution....
To use  Application->ProcessMessages() you have to be inside a kind of loop or else has no meaning....
What I'm proposing is the ComPort component from www.winsoft.sk ...
It has trial period, cost about $30 and will do the job...
I'm using it for more than 7 years without a problem...

George Tokas.
0
 

Accepted Solution

by:
rafcab earned 0 total points
ID: 24745689
Well, as far as I know, ComPort component from WinSoft or other similar products could be a better and easier job with my communications, but I understand that I could do without them.

Anyway it seems I have come out with the solution to my problem: I forgot to include a piece of information about the setup: the modems I am using are 3COM-USRobotics, and I have found that for security reasons they expect a small pause BEFORE receiving the hangup signal "+++" or they neglect it. So I have added a Sleep(1000), for the pause needs to be higher than 1 second at the beginning of my HangUp function, and the first results are OK. I hope this can help others with the same problem.

Rafael Caballos
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
configuring snmp v2 or v3 on Cisco switches 2 56
RCA to HDMI 4 69
HP Officejet Deskjet 460 Mobile Inkjet Printer 30 115
I could not build boost code, 10 88
Programmer's Notepad is, one of the best free text editing tools available, simply because the developers appear to have second-guessed every weird problem or issue a programmer is likely to run into. One of these problems is selecting and deleti…
Hi there, This article summarizes what you need if you are going to set up your home or small business Network Attached Storage (NAS) to be accessible from the internet. Of course there are configuration differences based on your NAS or router ma…
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.

777 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