CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Jun 2009
    Posts
    6

    Serial Communication using MSCOMM32

    Hi, I'm using the Microsoft communications control v6 in my program to communicate from my computer to a remote device using an rs232 port. I have successfully managed to get incoming data and process it, but I am having problems sending data. Here's my current code:


    COleVariant aVar;
    OLECHAR aArray[270];

    aArray[0]='A';
    aArray[1]='B';
    aArray[2]='C';
    aArray[3]='!';
    aArray[4]= 26;
    aVar = aArray;
    CommControl12.put_Output(aVar);

    I am using visual studio 9, and MSComm is imported as an active X control. The program compiles and runs, but no data is sent (this was checked by sending data to another computer). Any help would be appreciated!

  2. #2
    Join Date
    Jul 2002
    Posts
    2,543

    Re: Serial Communication using MSCOMM32

    To check whether you really send or receive data, use PortMon program:
    http://technet.microsoft.com/en-us/s.../bb896644.aspx

    Using ActiveX control in C++ is most complicated way of serial communications. ActiveX controls are for VB programmers. Most C++ programmers prefer to work with COM ports using plain API:
    http://msdn.microsoft.com/en-us/library/ms810467.aspx

    There are also number of COM port wrappers like:
    http://www.codeproject.com/KB/system/cserialport.aspx
    http://www.codeproject.com/KB/system/serial.aspx
    which are more convenient for C++ developer than ActiveX control.

  3. #3
    Join Date
    Jun 2009
    Posts
    6

    Re: Serial Communication using MSCOMM32

    Thanks for the links. I'm looking into using the wrapper classes. I was wondering though if anyone knows how to solve my original code problem; the use of the active x control is currently widely used in my program.

  4. #4
    Join Date
    Jun 2009
    Posts
    6

    Re: Serial Communication using MSCOMM32

    Problem solved. We were using the wrong type of modem cable.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured