Browse Source

Quick and dirty CPU usage fix

Thomas Buck 8 years ago
parent
commit
2169c5749e
3 changed files with 10 additions and 0 deletions
  1. 3
    0
      src/foohid.c
  2. 3
    0
      src/protocol.c
  3. 4
    0
      src/serial.c

+ 3
- 0
src/foohid.c View File

@@ -11,6 +11,7 @@
11 11
 #include <stdio.h>
12 12
 #include <signal.h>
13 13
 #include <string.h>
14
+#include <unistd.h>
14 15
 
15 16
 #include <IOKit/IOKitLib.h>
16 17
 
@@ -248,6 +249,8 @@ int main(int argc, char* argv[]) {
248 249
                 }
249 250
             }
250 251
         }
252
+
253
+        usleep(1000);
251 254
     }
252 255
 
253 256
     printf("Closing serial port...\n");

+ 3
- 0
src/protocol.c View File

@@ -10,6 +10,7 @@
10 10
 #include <stdint.h>
11 11
 #include <stdio.h>
12 12
 #include <signal.h>
13
+#include <unistd.h>
13 14
 
14 15
 #include "serial.h"
15 16
 
@@ -133,6 +134,8 @@ int main(int argc, char* argv[]) {
133 134
                 }
134 135
             }
135 136
         }
137
+
138
+        usleep(1000);
136 139
     }
137 140
 
138 141
     serialClose(fd);

+ 4
- 0
src/serial.c View File

@@ -141,6 +141,8 @@ unsigned int serialWriteRaw(int fd, const char *d, int len) {
141 141
         } else {
142 142
             processed += t;
143 143
         }
144
+
145
+        usleep(1000);
144 146
     }
145 147
 
146 148
     return processed;
@@ -158,6 +160,8 @@ unsigned int serialReadRaw(int fd, char *d, int len) {
158 160
         } else {
159 161
             processed += t;
160 162
         }
163
+
164
+        usleep(1000);
161 165
     }
162 166
 
163 167
     return processed;

Loading…
Cancel
Save