Solved

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

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

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

Jaspersoft Studio is a plugin for Eclipse that lets you create reports from a datasource.  In this article, we'll go over creating a report from a default template and setting up a datasource that connects to your database.
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 NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.

707 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

18 Experts available now in Live!

Get 1:1 Help Now