Answer the question
In order to leave comments, you need to log in
Running a binary from a C program?
I'm writing a program for raspberry in C (WiringPi)
The camera is connected via CSI, access via raspistill
in the console everything works: $ raspistill -o image.jpg -w 800 -h 600 -t 200
- OK
with the iron in order.
in the program through
system("raspistill -o image.jpg -w 800 -h 600 -t 200");
exec("raspistill", ???);
exec("raspistill -o image.jpg -w 800 -h 600 -t 200", ???);
Answer the question
In order to leave comments, you need to log in
In order for the program to be executed in parallel, you need to create a copy of your process using fork() or vfork() and execute exec() in the child process. Parameters are passed as an array of strings or individual parameters with a terminating null..
...
if (fork() == 0) { // разделиться
execl("raspistill", "raspistill", "-o", "image.jpg", "-w" ,"800", "-h", "600", "-t", "200" , "echo", "this is", (char *) 0); // заменить процесс
perror("exec one failed"); // если что-то пошло не так, выдать ошибку
exit(1); // здесь завершаем новый процесс, если не отработал execl
}
// здесь продолжение старого процесса
...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question