Solved

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

Posted on 2009-06-29
2
416 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

If you’re like me and you like peace and quiet, saving money, and pretty lights, then this article is for you. For financial reasons, I buy all the Cisco equipment for my home lab second-hand. The first thing to wear out is usually one of the coo…
Every server (virtual or physical) needs a console: and the console can be provided through hardware directly connected, software for remote connections, local connections, through a KVM, etc. This document explains the different types of consol…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.

735 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