?
Solved

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

Posted on 2009-06-29
2
Medium Priority
?
421 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

Question has a verified solution.

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

Here is a helpful source code for C++ Builder programmers that allows you to manage and manipulate HTML content from C++ code, while also handling HTML events like onclick, onmouseover, ... Some objects defined and used in this source include: …
Before I go to far, let's explain HA (High Availability) and why you should consider it.  High availability is the mechanism used to provide redundancy to any service at the same site and appears as a single service to the users of that service.  As…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.
Suggested Courses

719 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