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
 #include <stdio.h>
11
 #include <stdio.h>
12
 #include <signal.h>
12
 #include <signal.h>
13
 #include <string.h>
13
 #include <string.h>
14
+#include <unistd.h>
14
 
15
 
15
 #include <IOKit/IOKitLib.h>
16
 #include <IOKit/IOKitLib.h>
16
 
17
 
248
                 }
249
                 }
249
             }
250
             }
250
         }
251
         }
252
+
253
+        usleep(1000);
251
     }
254
     }
252
 
255
 
253
     printf("Closing serial port...\n");
256
     printf("Closing serial port...\n");

+ 3
- 0
src/protocol.c View File

10
 #include <stdint.h>
10
 #include <stdint.h>
11
 #include <stdio.h>
11
 #include <stdio.h>
12
 #include <signal.h>
12
 #include <signal.h>
13
+#include <unistd.h>
13
 
14
 
14
 #include "serial.h"
15
 #include "serial.h"
15
 
16
 
133
                 }
134
                 }
134
             }
135
             }
135
         }
136
         }
137
+
138
+        usleep(1000);
136
     }
139
     }
137
 
140
 
138
     serialClose(fd);
141
     serialClose(fd);

+ 4
- 0
src/serial.c View File

141
         } else {
141
         } else {
142
             processed += t;
142
             processed += t;
143
         }
143
         }
144
+
145
+        usleep(1000);
144
     }
146
     }
145
 
147
 
146
     return processed;
148
     return processed;
158
         } else {
160
         } else {
159
             processed += t;
161
             processed += t;
160
         }
162
         }
163
+
164
+        usleep(1000);
161
     }
165
     }
162
 
166
 
163
     return processed;
167
     return processed;

Loading…
Cancel
Save