I am writing an app which uses GnuPlot for ploting data. Instead of using text format to comunicate both programs though a pipe (it is slow because of the vprintf() and the big amount of data being passed) I decided to use "binary" format.
The problem is that in binary format GnuPlot expects a EOF (Ctrl+D) to end the transmission and plot the data. This is easy in UNIX console mode. Just pressing Ctrl+D will end the data input, plot the data AND mantain the console open waiting for more commands.
But in my C++ app the only way to send a EOF is to close the pipe. This causes the gnuplot process to die and does not show the plot to the screen.
¿Is there some trick to send a EOF to a pipe? ¿How does the UNIX terminal manage to send a EOF without closing its pipe with the running process?
PD: I can't close and reopen GnuPlot with "-persist", because that generates a NEW plot instead of updating the old plot (it is a real time system so it generates near ~inf plot windows).
I don't think what you want to do will work. See for example:
http://www.velocityreviews.com/forums/t365339-write-eof-without-closing.html
Can we write an EOF character ourselves?
Basically EOF is no character per se. It's the end of the file.
So as I noted in the comment above I suggest you try using a library which connects you directly to gnuplot. Then you should be able to control it such that your desired behaviour is achieved (most likely using something like replot
).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With