Function Init_logs moved to right place.
authorMartin Prudek <prudemar@fel.cvut.cz>
Wed, 20 May 2015 19:23:56 +0000 (21:23 +0200)
committerMartin Prudek <prudemar@fel.cvut.cz>
Wed, 20 May 2015 19:23:56 +0000 (21:23 +0200)
pmsm-control/test_sw/cmd_proc.c
pmsm-control/test_sw/logs.c
pmsm-control/test_sw/logs.h
pmsm-control/test_sw/pmsm_state.h

index bb3be07..6846df5 100644 (file)
@@ -9,7 +9,7 @@
 #define PRUM_SOUC      6183
 
 static char doPrint = 1;
-static char error = 0;
+
 
 /*
  * \brief
@@ -143,27 +143,6 @@ static void setAlphaOff(struct rpi_state* state, int offset){
        sem_post(&state->thd_par_sem);
 }
 
-/*
- * \brief
- * Initialize logs
- */
-static void logInit(struct rpi_state* state){
-       int r;
-       state->log_col=0;
-       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;
-}
-
-
-
 /**
  * \brief
  * SetLog
@@ -291,6 +270,6 @@ void printData(struct rpi_state* state){
        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");
+       if (s.error) printf("error pri maloc logs!! \n");
 
 }
index f6c2a5f..3a3e9cc 100644 (file)
@@ -23,6 +23,25 @@ void freeLogs(struct rpi_state* this){
 
 /*
  * \brief
+ * Initialize logs
+ */
+void logInit(struct rpi_state* state){
+       int r;
+       state->log_col=0;
+       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){
+                       state->error=1;
+                       state->log_col_count=-1;
+                       return;
+               }
+       }
+       state->doLogs=1;
+}
+
+/*
+ * \brief
  * Makes log.
  */
 void makeLog(struct rpi_state* this){
index c0d1996..d3f2455 100644 (file)
@@ -16,6 +16,12 @@ void makeLog(struct rpi_state*);
 
 /*
  * \brief
+ * Initialize logs
+ */
+void logInit(struct rpi_state*);
+
+/*
+ * \brief
  * Free logs memory.
  */
 void freeLogs(struct rpi_state*);
index b1946a6..583eb73 100644 (file)
@@ -49,6 +49,8 @@ struct rpi_state{
 
        void (*main_commutator)(struct rpi_state*);     /* primarni komutator */
        void (*main_controller)(struct rpi_state*);     /* primarni regulator */
+
+       char error;                     /* detekce chyboveho stavu */
 };
 
 /**