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:
Is this program written in correct way to receive data from serial port? Any help and advice is highly appreciated. Thanks!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!"); }



LinkBack URL
About LinkBacks


