Click here to Skip to main content
15,887,871 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi,

I send the data from sensor, data0,data1,data2,data3

result of my program is
data0
data1
data2
data3

but I want to save the each data in a buffer such as
y0=data0
y1=data1
y2=data2
y3=data4

any one can help me?

C++
#include <iostream>
#include <string>
#include <sstream>
#include <Windows.h>

#include "SerialClass.h"

char buffer[25];


using namespace std;

int i;
int main()
  {
	  Serial oSerial("COM8:");

	  oSerial.WriteData("1",1);
		   Sleep(100);
		   oSerial.ReadData(buffer,25);
    string str = buffer;
    string word;
    stringstream stream(str);

    while( getline(stream, word, ',') )	
		cout <<word << "\n";
	
	

	Sleep (10000);
  }
Posted
Comments
Richard MacCutchan 21-Mar-13 5:23am    
What exactly is your problem?
Matthew Faithfull 21-Mar-13 7:12am    
It sounds like maybe what you want to do is parse the data which you're recieving?
If this is the case you'll need to know what the format, language or protocol of that data is, and so will anyone who helps you.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900