VC++ Serial Comm
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: VC++ Serial Comm

  1. #1
    Join Date
    Apr 2010
    Posts
    1

    VC++ Serial Comm

    Hello Everyone,
    Im new to VC++ express 2008 though I've been using VB6 for a while. Im trying to write code that communicates to serial port using VC++ express 2008.

    This is my VB6 equivalent code:
    ' Port Initialization is done on different Sub.
    ' and .RThreshold = 1

    ' Send data to Port
    Private Sub sendBttn_Click()
    MSComm1.Output = "*idn?" & vbCrLf
    End Sub

    ' Detect Incoming Serial Data
    Private Sub MSComm1_OnComm() ' need an VC++ code for this Sub.
    Call InputHandler(MSComm1)
    End Sub

    ' Input Handler
    Sub InputHanlder(SelectedPort As MSComm)
    Dim Incommbuff As String
    Incommbuff = SelectedPort.Input
    RcvdBuffer = RcvdBuffer + Incommbuff ' Public RcvdBuffer as string
    If InStr(RcvdBuffer, "vbCr") Then
    Text1.Text = RcvdBuffer;
    RcvdBuffer = ""
    End If
    End Sub

    My Problem... How do i write an equivalent code (VB6 = "MSComm1_OnComm") for the Serial Event for VC++.



    Heres the VC++ partial code..

    #pragma endregion
    private: System::Void sendBttn_Click(System::Object^ sender, System::EventArgs^ e) {
    this->serialPort1->Write("*idn?\r\n");
    }
    };
    }

    /* how do i detect the response from the equipments???
    /* Can someone post a sample code...

  2. #2
    VictorN's Avatar
    VictorN is online now Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,421

    Re: VC++ Serial Comm

    Quote Originally Posted by myrodeo29 View Post
    ... Heres the VC++ partial code..

    #pragma endregion
    private: System::Void sendBttn_Click(System::Object^ sender, System::EventArgs^ e) {
    this->serialPort1->Write("*idn?\r\n");
    }
    };
    }
    It is *not* a VC++ code. It looks like Managed C++ and/or C++/CLI code. So try to ask in Managed C++ forum
    Victor Nijegorodov

Tags for this Thread

Posting Permissions

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


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center