Adding tty thread primitive which only reports alive status every 10 seconds.

This commit is contained in:
Luka Miljak 2014-03-14 17:28:29 +01:00
parent be121ac22f
commit 3926b7738d
4 changed files with 37 additions and 7 deletions

28
tty.c
View file

@ -1,5 +1,7 @@
#include "moxerver.h"
#include <string.h>
#define TTY_THREAD_TIMEOUT_SEC 30
#define NAME "tty"
/* Opens the tty device and configures it. */
int tty_open(struct tty_t *tty_dev, char* path) {
@ -34,4 +36,26 @@ int tty_read(struct tty_t *tty_dev) {
int tty_write(struct tty_t *tty_dev, char *databuf, int datalen) {
// databuf should point to client data buffer
return 0;
}
}
void *tty_thread_func(void *arg) {
int i = 0;
char *str;
str = (char*)arg;
fprintf(stderr, "[%s] tty thread started with passed argument: %s\n", NAME, str);
//while ((i * 10) < TTY_THREAD_TIMEOUT_SEC) {
while (1) {
sleep(10);
fprintf(stderr, "[%s] tty thread reporting ...\n", NAME);
i++;
}
fprintf(stderr, "[%s] tty thread stoped\n", NAME);
strncpy(str, "bye", strlen(str));
return (void *)str;
}