Browse Source

change directories

Cyrille 10 years ago
parent
commit
6cde4f73c9
20 changed files with 37 additions and 24 deletions
  1. 1 1
      Makefile
  2. 0 0
      analyze.c
  3. 0 0
      analyze.h
  4. 0 0
      buffer.c
  5. 0 0
      buffer.h
  6. 0 0
      emit.c
  7. BIN
      emit/listen
  8. 5 5
      home_easy.c
  9. 0 0
      home_easy.h
  10. 0 0
      listen.c
  11. 0 0
      old/listen/Makefile
  12. BIN
      old/listen/listen
  13. 0 0
      old/listen/listen.c
  14. 0 0
      old/listen/listenlib.c
  15. 0 0
      old/listen/listenlib.h
  16. 7 0
      old/listen/toto.txt
  17. 0 0
      test/Makefile
  18. 0 0
      test/test.c
  19. 18 17
      utils.c
  20. 6 1
      utils.h

+ 1 - 1
emit/Makefile → Makefile

@@ -16,7 +16,7 @@ emit.o : emit.c
 	gcc -c $< -o $@
 
 clean:
-	rm -f emit *.o
+	rm -f emit listen *.o
 
 install: emit
 	cp -f emit /usr/local/bin/.

+ 0 - 0
emit/analyze.c → analyze.c


+ 0 - 0
emit/analyze.h → analyze.h


+ 0 - 0
emit/buffer.c → buffer.c


+ 0 - 0
emit/buffer.h → buffer.h


+ 0 - 0
emit/emit.c → emit.c


BIN
emit/listen


+ 5 - 5
emit/home_easy.c → home_easy.c

@@ -28,7 +28,7 @@ unsigned int timings[5][2] = {
     {275, 1300}, //  bit 1
     {275, 9900},  //  start of data
     {275, 2675}, //  start of frame
-    {275, 10000},  //  end of data
+    {275, 2675},  //  end of data
 };
 
 unsigned char homeEasyPinOut = 0;
@@ -146,7 +146,7 @@ void sendFrame(BYTE_BUFFER frame, unsigned int repeat)
 {
     unsigned int i;
     // switch to real time
-    scheduler_realtime();
+    cpuMode(REAL_TIME);
     // send header
     sendHomeEasyBit(START_OF_DATA);
     sendHomeEasyBit(START_OF_FRAME);
@@ -157,7 +157,7 @@ void sendFrame(BYTE_BUFFER frame, unsigned int repeat)
     }
     digitalWrite(homeEasyPinOut, LOW);
     // Exit real time mode
-    scheduler_standard();
+    cpuMode(STANDARD);
 }
 
 /**
@@ -333,14 +333,14 @@ BYTE_BUFFER readData(unsigned long int samples, unsigned int duration)
     result.size = samples;
     result.data = (char*) realloc(result.data, samples);
 
-    scheduler_realtime();
+    cpuMode(REAL_TIME);
     start = showTime(0);
     for(i=0; i<samples; i++) {
         result.data[i] = digitalRead(homeEasyPinIn);
         delayMicroseconds(duration);
     }
     showTime(start);
-    scheduler_standard();
+    cpuMode(STANDARD);
 
     return result;
 }

+ 0 - 0
emit/home_easy.h → home_easy.h


+ 0 - 0
emit/listen.c → listen.c


+ 0 - 0
listen/Makefile → old/listen/Makefile


BIN
old/listen/listen


+ 0 - 0
listen/listen.c → old/listen/listen.c


+ 0 - 0
listen/listenlib.c → old/listen/listenlib.c


+ 0 - 0
listen/listenlib.h → old/listen/listenlib.h


File diff suppressed because it is too large
+ 7 - 0
old/listen/toto.txt


+ 0 - 0
emit/test/Makefile → test/Makefile


+ 0 - 0
emit/test/test.c → test/test.c


+ 18 - 17
emit/utils.c → utils.c

@@ -30,25 +30,26 @@ struct timeval* showTime(struct timeval* start)
 }
 
 /**
- * Switch to real-time mode
- */
-void scheduler_realtime()
-{
-    struct sched_param p;
-    p.__sched_priority = sched_get_priority_max(SCHED_RR);
-    if( sched_setscheduler( 0, SCHED_RR, &p ) == -1 ) {
-        perror("Failed to switch to realtime scheduler.");
-    }
-}
-
-/**
- * Exit from real-time mode
+ * Switch between standard and  real-time mode
+ *
+ * @param mode (REAL_TIME | STANDARD)
  */
-void scheduler_standard()
+void cpuMode(int mode)
 {
     struct sched_param p;
-    p.__sched_priority = 0;
-    if( sched_setscheduler( 0, SCHED_OTHER, &p ) == -1 ) {
-        perror("Failed to switch to normal scheduler.");
+    switch (mode) {
+        case REAL_TIME:
+            p.__sched_priority = sched_get_priority_max(SCHED_RR);
+            if( sched_setscheduler( 0, SCHED_RR, &p ) == -1 ) {
+                perror("Failed to switch to realtime scheduler.");
+            }
+            break;
+        case STANDARD:
+        default:
+            p.__sched_priority = 0;
+            if( sched_setscheduler( 0, SCHED_OTHER, &p ) == -1 ) {
+                perror("Failed to switch to normal scheduler.");
+            }
+            break;
     }
 }

+ 6 - 1
emit/utils.h → utils.h

@@ -5,6 +5,9 @@
 #include <unistd.h>
 #include <sys/time.h>
 
+#define REAL_TIME 0
+#define STANDARD  1
+
 /**
  * Calculate a duration
  *
@@ -17,8 +20,10 @@ struct timeval* showTime(struct timeval* start);
 
 /**
  * Switch to real-time mode
+ *
+ * @param mode (REAL_TIME | STANDARD)
  */
-void scheduler_realtime();
+void cpuMode(int mode);
 
 /**
  * Exit from real-time mode

Some files were not shown because too many files changed in this diff