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

Threaded View

  1. #1
    Join Date
    Apr 2010
    Posts
    11

    Errors in Serial Communication Programming

    Hi everyone! I'm a new member here.

    First of all I would like to address my problem on C++ programming in serial communication. My program is expected to receive float number from the serial port COM7 and show it on exe window. But while I'm trying to compile it, there are quite a lot of errors.

    Below is the code that I've written:


    Code:
    #include <iostream>
    using namespace std;
    #include "serial.h"
    
    void main() {
    CSerial serial;
    
    if (serial.Open(2, 9600))
    {
         char* lpBuffer = new char[500];
         float NumberRead = serial.ReadData(lpBuffer, 500);
         cout<<"Temperature = "<<NumberRead<<endl;
         delete []lpBuffer;
    }
    
    else
         AfxMessageBox("Failed to open port!");
    }
    Is this program written in correct way to receive data from serial port? Any help and advice is highly appreciated. Thanks!
    Last edited by coolrox86; April 23rd, 2010 at 03:59 PM.

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