]> rtime.felk.cvut.cz Git - fpga/rpi-motor-control.git/blobdiff - pmsm-control/test_sw/cmd_proc.c
Changes made to logging process.
[fpga/rpi-motor-control.git] / pmsm-control / test_sw / cmd_proc.c
index a0b059274443aac36e320cd9392c3c1230664e1c..9625c1d9368921e2523bc7f935944b2fe9b7fb57 100644 (file)
@@ -8,6 +8,7 @@
 #define PRUM_SOUC      6183
 
 static char doPrint = 1;
+static char error = 0;
 
 /*
  * \brief
@@ -59,6 +60,9 @@ static void start(struct rpi_state* state){
 static void stop(struct rpi_state* state){
        sem_wait(&state->thd_par_sem);
        state->commutate=0;
+       state->pos_reg_ena=0;
+       state->spd_reg_ena=0;
+       state->duty=0;
        state->pwm1=0;
        state->pwm2=0;
        state->pwm3=0;
@@ -135,7 +139,13 @@ static void logInit(struct rpi_state* state){
        state->log_col_count=LOG_DEF_COL;
        for (r=0;r<LOG_ROWS;r++){
                state->logs[r]=malloc(state->log_col_count*sizeof(int));
+               if (state->logs[r]==NULL){
+                       error=1;
+                       state->log_col_count=-1;
+                       return;
+               }
        }
+       state->doLogs=1;
 }
 
 /*
@@ -146,7 +156,7 @@ static void saveLogs(struct rpi_state* state){
        FILE *f;
        int r,s;
 
-       f = fopen("logs.txt", "w");
+       f = fopen("logs.log", "w");
        if (f == NULL){
                printf("Error opening file!\n");
                return;
@@ -182,7 +192,6 @@ static void setLogSEM(struct rpi_state* state){
        /* spustim zachytavani logu */
        }else{
                logInit(state);
-               state->doLogs=1;
                sem_post(&state->thd_par_sem);
        }
 }
@@ -290,4 +299,7 @@ void printData(struct rpi_state* state){
        printf("duty=%d\n",s.duty);
        if (s.index_ok) printf("index ok\n");
        if (s.commutate) printf("commutation in progress\n");
+       if (s.doLogs) printf("logujeme\n");
+       if (error) printf("error pri maloc logs!! \n");
+
 }