#include <iostream>
#include <string.h>
#include <wiringSerial.h> //simple serial port library
#include <sstream>        //stream string to int

using namespace std;

int main(int argc, char ** argv){
	string s = "";
	int x=0,y=0;	
	int handle = serialOpen("/dev/ttyACM0", 9600);
	
	while (1){
	   char data =serialGetchar(handle);      
       s.push_back(data);  //concatinate chars into string
    
    if (strtok(&data, ",")){
		//istringstream(s) >> x;
		cout << s ;
		//cout << x;
         s="";
         }
    if (strtok(&data, "\0")){
	//istringstream(s) >> y;
	//cout  << s;
	//cout  << y;
	}
	}

	return 0;
}


/*
 * sudo apt-get install libwiringpi-dev
 * 
 * compiled with g++ -Wall -o readSerial  readSerial.cpp -lwiringPi
 * IDONT even here some reading I Guess
 * https://www.geeksforgeeks.org/converting-strings-numbers-cc/
 * https://www.techiedelight.com/convert-string-to-int-cpp/
 */
