save failed integration state
This commit is contained in:
gomspace
gomspace.mk
libp60_client
libparam_client
libutil
include
conf_util.h
deprecated
gs
uthash
util
base16.hbytebuffer.hbyteorder.hcheck.hclock.hcrc32.hcrc8.hdelay.h
drivers
endian.herror.hfletcher.hfunction_scheduler.hgosh
hexdump.hlinux
log.hlog
minmax.hmutex.hpgm.hqueue.hrtc.hsem.hstdio.hstring.htest
thread.htime.htimestamp.htypes.hunistd.hvmem.hwatchdog
zip
src
base16.cbytebuffer.cbyteorder.cclock.ccrc32.ccrc8.c
wscriptbindings
python
drivers
error.cfletcher.cfunction_scheduler.cgosh
hexdump.clinux
argp.cclock.ccommand_line.ccwd.cdelay.c
lock.clock.hdrivers
function.cmutex.cqueue.crtc.csem.csignal.cstdio.csysfs_helper.cthread.ctime.clog
rtc.cstdio.cstring.cstrtoint.ctest
time.ctimestamp.cvmem
watchdog
zip
p60-dock_client
test/testtasks
36
gomspace/libutil/src/linux/stdio.c
Normal file
36
gomspace/libutil/src/linux/stdio.c
Normal file
@ -0,0 +1,36 @@
|
||||
/* Copyright (c) 2013-2017 GomSpace A/S. All rights reserved. */
|
||||
|
||||
#include <gs/util/stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <poll.h>
|
||||
|
||||
gs_error_t gs_stdio_putchar(int ch)
|
||||
{
|
||||
const int res = putchar(ch);
|
||||
if (res < 0) {
|
||||
return GS_ERROR_IO;
|
||||
}
|
||||
return GS_OK;
|
||||
}
|
||||
|
||||
gs_error_t gs_stdio_getchar_timed(int timeout_ms, int * ch)
|
||||
{
|
||||
struct pollfd fds = {STDIN_FILENO, POLLIN, 0};
|
||||
const int res = poll(&fds, 1, timeout_ms);
|
||||
|
||||
if (res == 0) {
|
||||
return GS_ERROR_TIMEOUT;
|
||||
}
|
||||
|
||||
if ((res > 0) && (fds.revents & POLLIN)) {
|
||||
int tmp = getchar();
|
||||
if (tmp >= 0) {
|
||||
if (ch) {
|
||||
*ch = tmp;
|
||||
}
|
||||
return GS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
return GS_ERROR_IO;
|
||||
}
|
Reference in New Issue
Block a user