Very Urgent 5000 pts: Hyperterminal programming in C++

Hello Experts,

I have one use case to be programmed.

I have one modem device. I connect to it via hyperterminal.

Use case 1:

If I just sent 'AT' as a command then I get 'OK' as a response.

I have associated this use case with one VC++ Dialog. If I enter AT Command in one text box, I am able to display the output in another text box.

I call this AT command sequence as solicited AT Command request.

Use case 2:

I have one Unsolicited AT Command like 'AT+SIGNALSTRENGTH'

If I enter this command in hyperterminal once then I get unsolicited responses i.e. I get responses from the device randomly whenever state of device is changed. Hyperterminal is capturing these responses and displaying on screen. Whenever signal strength is changed then device will send notification to hyperterminal. I want to program this use case in VC++ MFC i.e. I want to display all the return values. Code returned for use case 1 does not support unsolicited response. How can we capture and print unsolicited responses.

Can anyone point me to mechanism with which I can program this?

If it would have been possible, I would have assigned 5000 points for this question.


Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

You should have one thread that continuosly listen on the serial port, even if no command was sent to the modem. You should display every char received

This is a good tutorial for implement worker thread from an MFC dialog:

"Threads in MFC Part I: Worker Threads" at
yogithiteAuthor Commented:
Hi alb66

Thank you for prompt immediate response.

I would implement a worker thread, but I have question still open in my mind - how to make it work like hyperterminal? I mean in hyperterminal, I type one AT command and device starts dumping information on the screen. How to simulate this in VC++ MFC?


Need More Insight Into What’s Killing Your Network

Flow data analysis from SolarWinds NetFlow Traffic Analyzer (NTA), along with Network Performance Monitor (NPM), can give you deeper visibility into your network’s traffic.

May be I don't understand your question but, if your program continuosly read from the serial line, you should see all the data coming from the modem. May be that acutally your code read from the serial line only after a command is sent to the modem.
yogithiteAuthor Commented:
Hi alb66,

Thank you for your response.

See, via Hyperterminal, if I send 'AT' i get OK as response from modem.

If I send command AT+CSQ then modem starts dumping its data whenever modem finds change in signal strength. + CSQ forces my modem to dump its messages randomly despite of hyperterminal sending command only once.

I would like to capture these random messages coming from the modem

Is my question clear or shall I explain more?

Thanks again for helping me out.


OK, it's clear. IMO my first comment is the solution
yogithiteAuthor Commented:
So  as per your opinion, solution is:

I have to send AT command from a worker thread and then i have to listen on COM port for all the responses, am I right?
No, the worker thread have to listen for all the responses. I think you can do that in the main thread otherwise your application can become no responsive.
Sorry, I wanted to write:
>>>> think you cannot do that in the main thread
The problem with serial communications is that if you request to read even one byte, and there is nothing in the queue, then your program stalls there, waiting for incoming data.
What I have done in this case is call
which fills a COMSTAT structure with some data, including how many bytes are available to be read.  So just read exactly that many bytes (and don't read at all if there are zero waiting).
All you need to do is periodiclly check the COMSTAT.cbInQue value.  I recommend doing so on a timer (as opposed to using a separate thread).

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Networking Hardware-Other

From novice to tech pro — start learning today.