Solved

Multithreaded Serial Port  App

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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
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.

776 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