Link to home
Start Free TrialLog in
Avatar of jkelly061597
jkelly061597

asked on

Serial Port Communication

Hello,

Project: Create a dialog app to receive serial port input from a microcontroller and display in your GUI.

The Dialog app is created and ready for incorporation of  communication methods.

So,
What is the easiest way to communicate over the serial port using MFC? I have found various classes online and am aware that ActiveX may be a solution but I dont know which to go for / what the benefits of each are.

One ability I will need is to ignore a significant portion of the incoming messages. They will be in the form of several text numbers which I will process, but I only need them at set intervals of a 1/2 second or so.

I'll need guidance in the form of online documentation or code presented here also.

Thanks to everyone.
Avatar of jkr
jkr
Flag of Germany image

See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnwbgen/html/msdn_serial.asp ("Serial Communications in Win32") - this is the IMHO most comprehensive article on this issue, and it comes with sample code.
BTW - you might want to check these out, also:

http://www.codeguru.com/network/serial.shtml ("CSerial - A C++ Class for Serial Communications")

http://www.codeguru.com/network/serialport.shtml ("A communication class for serial port")
Avatar of Crius
Crius

Reusing the VCTERM code from the MSDN library would be one of the easiest ways of using MFC to handle comport communications.

The code to either use or ignore incoming strings/values is up to your own switch statements or code, and not actually part of the MFC code/ActiveX/COM control.

Most of the classes in the sample program you won't actually need, but you will need to look at the CMainFrame for samples of how to use the CommCtrl, and you will need to add in the CCommCtrl COM object.
ASKER CERTIFIED SOLUTION
Avatar of Mazen
Mazen

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jkelly061597

ASKER

Thanks all, I ended up using straight active x as my solution
Can u give me a specific answer, where to add the activex. do u mean build a new project and then add the project to my own application?
Can u give me a specific answer, where to add the activex. do u mean build a new project and then add the project to my own application?
Hi gaohuanzx,
  If you look at the menu of VC++ program, you will see the word  "project".(you know, next to :file - edit ...)
Click on it and then click "Add to Project -> Components and Controls".
Your application has to be dialog based inorder to be able to add this activex.
If you need any more help, just ask.
Best Regards,
  Mazen