Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How do I communicate with the RS232 port in VC++ 6.0

Posted on 1998-10-14
4
Medium Priority
?
344 Views
Last Modified: 2012-06-21
I´m working on a project including communication with external processors via the Serial RS232-port. The problem is, I don´t really know how to communicate with the serial port using VC++ at all! soo if anyone knows how to just read the info on the port using normal 19.2 kBaud should be enoungh to start with...

Thanks!
_____________________________
Ulf Andersson
Microlab Systems Co.
Gothenburg, Sweden.
0
Comment
Question by:uffe78
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 

Accepted Solution

by:
jbalagop earned 150 total points
ID: 1175097
hi, you would need 2 threads for listening to the port and for reading from the port. the below pseudo-code, is just some of the funtions you might use. let me know if you need more than this.

    //
    // open communication port handle
    //
CreateFile( gszPort, GENERIC_READ | GENERIC_WRITE, 0, 0,
                                      OPEN_EXISTING,
                                      FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED,
                                      0);
GetCommTimeouts();
 
// set comm buffer sizes
SetupComm();

// raise DTR

EscapeCommFunction()

    //
    // start threads and set initial thread state to not done
    //
    AfxBeginThread()

    //
    // set overall connect flag
    //
 
0
 

Expert Comment

by:jbalagop
ID: 1175098
The above is a comment. Also, since you used CreateFile() it retuerns a handle to the communication port. You may read or write using this handle. Make sure you have status checking in your reader and writer threads, because the connection may be reset and you have to make sure it isn;t so before writing , etc/
0
 

Author Comment

by:uffe78
ID: 1175099
Since I haven´t got into this language yet, could you please rewrite the code so that it matches 19.2kBaud on serial comport 2 The transfer is standard 8bit, 1 stop-bit and without parity...

/Ulf
0
 

Expert Comment

by:jbalagop
ID: 1175100
hi uffe78, all the above functions have detailed examples in the help files or check out the msdn.microsoft.com (the library).
i believe that they even have a serial communication example.
0

Featured Post

Tech or Treat! - Giveaway

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

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

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

610 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