1
0
mirror of https://github.com/preble/libpinproc synced 2026-02-22 18:15:25 +01:00

cleanup: unbuffered stdout to avoid fflush()

By setting stdout to unbuffered, the user always sees our output and we
can eliminate the fflush() calls sprinkled throughout the programs.
This commit is contained in:
Tom Collins
2020-06-26 16:00:38 -07:00
committed by Gerry Stellenberg
parent c36d48bc64
commit ed6540858b
2 changed files with 6 additions and 16 deletions

View File

@@ -48,7 +48,6 @@ void ConfigureAccelerometerMotion(PRHandle proc)
PRReadData(proc, P3_ROC_BUS_ACCELEROMETER_SELECT, 0x10D, 1, readData);
printf("Accel chip id: %x\n", readData[0]);
fflush(stdout);
// Set FF_MT_COUNT (0x18)
readData[0] = 1;
@@ -96,7 +95,6 @@ void ConfigureAccelerometerTransient(PRHandle proc)
PRReadData(proc, P3_ROC_BUS_ACCELEROMETER_SELECT, 0x10D, 1, readData);
printf("Accel chip id: %x\n", readData[0]);
fflush(stdout);
// Set to standby so register changes will take.
readData[0] = 0x0;
@@ -255,9 +253,6 @@ void RunLoop(PRHandle proc)
printf("Unknown event: %x:%x\n", event->type, event->value);
}
}
if (numEvents > 0) {
fflush(stdout);
}
PRFlushWriteData(proc);
#ifdef _MSC_VER
Sleep(10);
@@ -292,6 +287,9 @@ int main(int argc, const char **argv)
{
int i;
// Set stdout unbuffered to eliminate need to fflush()
setbuf(stdout, NULL);
// Set a signal handler so that we can exit gracefully on Ctrl-C:
signal(SIGINT, sigint);
startTime = time(NULL);