Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++
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?
 
 
#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 20-Mar-13 20:11pm
Comments
Richard MacCutchan at 21-Mar-13 5:23am
   
What exactly is your problem?
Matthew Faithfull at 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)

  Print Answers RSS
0 OriginalGriff 350
1 Jochen Arndt 190
2 Richard MacCutchan 135
3 Sergey Alexandrovich Kryukov 130
4 DamithSL 95
0 OriginalGriff 6,045
1 DamithSL 4,601
2 Maciej Los 4,087
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,310


Advertise | Privacy | Mobile
Web03 | 2.8.141220.1 | Last Updated 21 Mar 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100