?
Solved

MSComm

Posted on 2003-02-28
8
Medium Priority
?
668 Views
Last Modified: 2008-03-17
I need information on MSComm for VC++ 6.0.
I can sucessfully write to a port, but cannot read from a port.  Anyone know where there is any documentation on this topic?
Thanks in advance.
tdc808
0
Comment
Question by:tdc808
[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
  • 4
  • 3
8 Comments
 
LVL 1

Expert Comment

by:Ess
ID: 8048349
Try this link for documentation.
http://www.yes-tele.com/mscomm.html 
Alos if you own VB6 professional there is documentation in the reference section of MSDN on ActiveX controls included with it.  Note that the documentation includes constants that you cannot use with C++.  You must find out the numerical values of the constants.  Use OLE/VIEW for this.
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 8049508
MSDN provides documentation of rhtis control, but as with many such controls, it is written for users of Visual Basic.  Find it here:

   http://msdn.microsoft.com/library/en-us/comm98/html/vbobjComm.asp

And in C++, it is a bit of a pain to use because of the variant data types, and so forth.  Most C++ users prefer to use CreateFile(), ReadFile(), WriteFile() API fns, and the ever useful ClearCommError() -- to learn when there is any input available.

Here is a summary:
   http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnfiles/html/msdn_serial.asp

THough complete, it is overly complicated becasue it talks about CommEvents and Overlapped I/O -- which you don't really need when you are getting started.

-- Dan
0
 

Author Comment

by:tdc808
ID: 8067949
Thanks for the advice.
I have switch over to using CreateFile(), ReadFile(), WriteFile() API fns, and I can write to the ports fine, but I am still having problems reading from the ports.
Everytime I receive a character from the port it decimal(204).  
What I am trying to do is write from port one and receive on port two, so I have three threads (ie. the main thread, port_1_thread & port_2_thread) running to coordinate the timing.  
Any suggestions?
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 49

Accepted Solution

by:
DanRollins earned 400 total points
ID: 8068034
204 is 0xCC which is suspiciously like the value (0xcccc) that VC++ pre-fills all all uninitialized variables (in Debug release).  

Be certain to check the return value from the ReadFile() call -- if it is returning 0, then that is why the value remains as 0xcc.

Before reading, you should consider calling ClearCommError, since it will reveal how many bytes are waiting to be read.

-- Dan
0
 

Author Comment

by:tdc808
ID: 8075656
Hi Dan,

Thanks again.  I am just about to accept your comments, but if you have a second I would appreciate it if you could provide me feedback on the follow quick topics...

I am still having problem initiating and writing too two serial ports.  They are running on seperate threads.  The first one initiated works fine, but the second connection seems 'confused' (appears to receive some sort of cross talk)
Any ideas?

Another quick question.....
Any ideas on how to easily comment code...i.e. is there a special tool that allows you to comment/uncomment code?

0
 
LVL 49

Expert Comment

by:DanRollins
ID: 8076389
I'm nearly sure that it is possible to read and write on two COMM ports, where each port is being handled by a separate thread.  I have done it with two modems -- but I was actually using TAPI, which might have smoothed the way somehow.  I don't know if you are trying to handle events or if you are being careful to not get the comm handles confused, etc... so I can't be much help.

To make a comment,
1) insert  // at the start of a line
   or
2) put /* at the start and */ at the end of a multiple-line comment
   or
3) add a line like
     #ifdef NEVERDEF
at the beginning and
    #endif // ifdef NEVERDEF
at the end.

-- Dan
0
 

Author Comment

by:tdc808
ID: 8080497
Thanks for the additional information, Dan.

I apologize for the confusion....I was actually wondering if VC++ 6.0 had a menu option to comment/uncomment selected code.  Do you know of any such feature?

Thanks in advance.
tdc808
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 8084066
I can't be sure that there is no such feature, but I've never heard of it.  I know that VisualStudio.NET does that sort of thing (collasping functions in outline mode, etc.), but it would never occur to me to want my text editor to handle something like that when I could do it myself :-)

-- Dan
0

Featured Post

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them.

Question has a verified solution.

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

  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
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.
Suggested Courses

762 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