How to Draw/Update a TGraph in realtime in stand-alone g++?

I would need a ROOT program, stand-alone where I can upgrade in “realtime” a TGraph plot.
The idea is to read in “realtime” some data from a serial port (by libserial) and put the read data in a plot.
I would like to do something in realtime as in the tutorial hsimple.C. But the problem is that it is works only in intepreted mode! Any ideas/hints about how to do that in a stand-alone g++ compiled program?

Cheers,
Mattia

hsimple.C can be compiled too. You can execute it using AClic; .x hsimple.C++

To make a standalone application you can take example on: $ROOTSYS/test/stressGraphics.C

Just remove the “Batch option”.

Thank you for your answer!
But I still prefer using g++ because I try to add the library SerialStream. But the command #include <SerialStream.h> in root give me some error like this:

... Error: Symbol B115200 is not defined in current scope /usr/include/SerialPort.h:73: Error: Symbol B230400 is not defined in current scope /usr/include/SerialPort.h:74: Error: Symbol B460800 is not defined in current scope /usr/include/SerialPort.h:80: *** Interpreter error recovered ***

Why?

Anyway I solved using g++ and the following code. I don’t know if it is philosophically correct but in my case it is working! (thanks to www-ekp.physik.uni-karlsruhe.de/ … ode24.html)

#include <TROOT.h>
#include <TSystem.h>
#include <TApplication.h>
#include <TCanvas.h>
#include <TGraph.h>
#include <TMath.h>
#include <SerialStream.h>

void myscript(int argc, char *argv[]){
 //MyScript
}


int main(int argc, char *argv[])
{
gROOT->Reset();
TApplication *app = new TApplication("app", &argc, argv);
myscript(app->Argc(), app->Argv());
app->Run();
return 0;
}         

I’m agree! It is solved! :slight_smile:
But actually, can somebody explain why of the error in root interpreter in case of “#include <SerialStream.h>”? :question:

[quote=“mattiad”]I’m agree! It is solved! :slight_smile:
But actually, can somebody explain why of the error in root interpreter in case of “#include <SerialStream.h>”? :question:[/quote]

To answer this question, we have to know what is this SerialStream.h and where did you take it.

[quote=“tpochep”][quote=“mattiad”]I’m agree! It is solved! :slight_smile:
But actually, can somebody explain why of the error in root interpreter in case of “#include <SerialStream.h>”? :question:[/quote]

To answer this question, we have to know what is this SerialStream.h and where did you take it.[/quote]

Ok, for compilation error you simply have to put #include <SerialStream.h> into
#ifndef CINT
#endif

pp-directives. You’ll also have to do something about linker errors though. For example, something like
gSystem->Load(“path to libserial”).

p.s. you’d better read ROOT’s docs on how to create your own GUI. something simply with embedded canvas (which contains TGraph) and push button buttons to read data and fill tgraph.