• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 681
  • Last Modified:

MSComm

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
tdc808
Asked:
tdc808
  • 4
  • 3
1 Solution
 
EssCommented:
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
 
DanRollinsCommented:
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
 
tdc808Author Commented:
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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
DanRollinsCommented:
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
 
tdc808Author Commented:
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
 
DanRollinsCommented:
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
 
tdc808Author Commented:
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
 
DanRollinsCommented:
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now