1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
|
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <stdio.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <iostream>
#include <string>
#include <fstream>
#include <cstdlib>
#include <stdlib.h>
#include <qwt_plot_curve.h>
#include <QColorDialog>
using namespace std;
//CONSTRUCTEUR
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
}
//DESTRUCTEUR
MainWindow::~MainWindow()
{
delete ui;
}
//ACQUISITION DES DONNEES
void MainWindow::on_pushButton_clicked()
{
char integration_time_char[15];
int integration_time=10000000;
sprintf (integration_time_char,"%d",integration_time); //conversion de l'int en décimal pour le char
/* create the pipe */
int fds[2];
if (pipe(fds) == -1)
{
printf("pipe failed\n");
//return 1;
}
/* create the child */
int pid;
if ((pid = fork()) < 0)
{
printf("fork failed\n");
//return 2;
}
if (pid == 0)
{
/* child */
//char buffer[20];
close(fds[0]);
dup2(fds[1], STDOUT_FILENO);
execl("/Test/Acquisition","Acquisition",integration_time_char,NULL);
close(fds[1]);
}
else
{
/* parent */
waitpid(pid,NULL,0);
char buffer[1000];
close(fds[1]);
dup2(fds[0], STDIN_FILENO);
while (read(fds[0], buffer, 1000) != 0)
printf("%s\n", buffer);
close(fds[0]);
//printf("%s", buffer); printf("%s", buffer); printf("%s", buffer);
//std::cout << buffer << std::endl;
}
} |
Partager