Test version is written
This commit is contained in:
parent
d9b67f3fa6
commit
78a634dbc7
2 changed files with 56 additions and 1 deletions
|
|
@ -2,7 +2,8 @@ cmake_minimum_required(VERSION 3.5)
|
|||
|
||||
project(fft-spark LANGUAGES C)
|
||||
|
||||
add_executable(fft-spark main.c)
|
||||
|
||||
target_link_libraries(fft-spark pthread)
|
||||
|
||||
install(TARGETS fft-spark RUNTIME DESTINATION bin)
|
||||
|
||||
|
|
|
|||
54
main.c
54
main.c
|
|
@ -0,0 +1,54 @@
|
|||
#include <sys/types.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/wait.h>
|
||||
#include <string.h>
|
||||
#define MSGSIZE 64
|
||||
|
||||
char *SB = {"|||||||||| "};
|
||||
|
||||
int main() {
|
||||
int B[8];
|
||||
int Bm[8] = {0};
|
||||
int Bm_pre[8] = {0};
|
||||
int ret;
|
||||
int p[2], i;
|
||||
pipe(p);
|
||||
|
||||
pid_t a = fork();
|
||||
char *sas[] = {"cava", "-p", "/home/romenskiy2012/.config/cava/band8.conf", NULL};
|
||||
|
||||
char inbuf[MSGSIZE];
|
||||
if (a == 0) {
|
||||
if (dup2(p[1], STDOUT_FILENO) == -1) { perror("dup2"); _exit(127);}
|
||||
close(p[0]); // A не читает
|
||||
close(p[1]);
|
||||
execvp(sas[0], sas);
|
||||
_exit(127);
|
||||
}
|
||||
close(p[1]);
|
||||
FILE *r = fdopen(p[0], "r");
|
||||
for (int i = 0;1 == 1;i++){
|
||||
fgets(inbuf, sizeof inbuf, r);
|
||||
ret = sscanf(inbuf, "%i %i %i %i %i %i %i %i", &B[0], &B[1], &B[2], &B[3], &B[4], &B[5], &B[6], &B[7]);
|
||||
for (int i = 0; i != 10; i++){
|
||||
if (B[i] > Bm_pre[i]) Bm_pre[i] = B[i];
|
||||
}
|
||||
printf("B0 [%.*s] OUT: %3d PK: %3d\n", 10, SB + 10 + (B[0]/10*-1), B[0], Bm[0]); //B0
|
||||
printf("B1 [%.*s] OUT: %3d PK: %3d\n", 10, SB + 10 + (B[1]/10*-1), B[1], Bm[1]); //B1
|
||||
printf("B2 [%.*s] OUT: %3d PK: %3d\n", 10, SB + 10 + (B[2]/10*-1), B[2], Bm[2]); //B2
|
||||
printf("B3 [%.*s] OUT: %3d PK: %3d\n", 10, SB + 10 + (B[3]/10*-1), B[3], Bm[3]); //B3
|
||||
printf("B4 [%.*s] OUT: %3d PK: %3d\n", 10, SB + 10 + (B[4]/10*-1), B[4], Bm[4]); //B4
|
||||
printf("B5 [%.*s] OUT: %3d PK: %3d\n", 10, SB + 10 + (B[5]/10*-1), B[5], Bm[5]); //B5
|
||||
printf("B6 [%.*s] OUT: %3d PK: %3d\n", 10, SB + 10 + (B[6]/10*-1), B[6], Bm[6]); //B6
|
||||
printf("B7 [%.*s] OUT: %3d PK: %3d\n", 10, SB + 10 + (B[7]/10*-1), B[7], Bm[7]); //B7
|
||||
printf("\033[2J\033[H");
|
||||
if (i >= 10){
|
||||
memcpy(Bm, Bm_pre, sizeof Bm_pre);
|
||||
memset(Bm_pre, 0, sizeof Bm_pre);
|
||||
i = 0;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue