Solved

Multithreaded Serial Port  App

Posted on 2002-07-11
7
366 Views
Last Modified: 2013-11-20
I am trying to write a multi-threaded  and even based serial communciation application.
It will read data from txt file and write to the serial port.The other port will read this data and display it.
Does anyone have any idea how to do it?
0
Comment
Question by:Prash2002
7 Comments
 
LVL 23

Expert Comment

by:Roshan Davis
ID: 7145731
just look at site http://www.codeproject.com , You can find so many socket program samples there....

Good Luck
0
 
LVL 1

Accepted Solution

by:
joakimf earned 34 total points
ID: 7145774
0
 
LVL 4

Assisted Solution

by:mblat
mblat earned 33 total points
ID: 7147578
Good class for serial comm. is here

http://www.naughter.com/serialport.html

Hope it helps..
0
 
LVL 1

Assisted Solution

by:Mazen
Mazen earned 33 total points
ID: 7157445
Hi,
   you can use the Microsoft communications control for sending and receiving data from the serial port.
Your application has to be dialog based.
Go to : project->add to project-> components and controls
open the registered activex controls and select Microsoft communications control to insert it.
A new icon will appears in the controls menu. Add it to your application. Now from class wizard add a control to it(m_comm). To select and open the port write the following code:

m_comm.SetCommPort(1); // or any port
m_comm.SetSettings("4800,n,8,1");  // you can select the baud rate from here
m_comm.SetPortOpen(TRUE);

to send data write the following code:

m_comm.SetOutput(COleVariant(string)); // the output data is in this string

to receive data :
 COleVariant myvar;
myvar = m_comm.GetInput();
CString str(myvar.bstrval);

m_myedit+=str;  // put data in editbox
UpdateData(FASLE);

If you want the data  to appear every time the buffer is full , double click on the icon the you put in you dialog and select ok and place the above code in this method.
Or you can set a timer to get the data in buffer with the above code which i prefer more.

Regards,
Mazen
 
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

757 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

21 Experts available now in Live!

Get 1:1 Help Now