Solved

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

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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Hello All, I have been training on Multicast for a while now and whenever I start the topic , I find out that my friends /  Colleagues mention that they do not know how to test Multicast Joins. As most of the multicast would be video traffic and …
#Citrix #Citrix Netscaler #HTTP Compression #Load Balance
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.
Suggested Courses

623 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