Solved

Multithreaded Serial Port  App

Posted on 2002-07-11
7
367 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

920 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

13 Experts available now in Live!

Get 1:1 Help Now