![]() |
SmartCradle v1
Baby smart cradle
|
Main process implementation. More...
#include <stdio.h>#include <stdlib.h>#include <unistd.h>#include <pthread.h>#include <sched.h>#include <errno.h>#include <string.h>#include <mqueue.h>#include <sys/mman.h>#include <sys/shm.h>#include <sys/stat.h>#include <linux/types.h>#include <signal.h>#include <sys/time.h>#include "../inc/database.h"#include "../inc/microphone.h"#include "../inc/livestream.h"#include "../inc/motor.h"#include "../inc/dht.h"
Go to the source code of this file.
Macros | |
| #define | SHMEMOBJ_NAME "/shLocalDaemon" |
| #define | MSGQOBJ_NAME "/mqLocalDaemon" |
| #define | MAX_MSG_LEN 10 |
| #define | streamPrio 2 |
| #define | motorPrio 2 |
| #define | updateDatabasePrio 3 |
| #define | sensorPrio 4 |
| #define | motorTimeout 10 |
| #define | sensorSample 10 |
Functions | |
| void | initThread (int priority, pthread_attr_t *pthread_attr, struct sched_param *pthread_param) |
| Initializes the thread parameters with defined priority. More... | |
| void | checkErrors (int status) |
| Check for errors upon creating threads. More... | |
| static void | signalHandler (int signo) |
| Proces signal handler. More... | |
| void * | tReadSensor (void *arg) |
| Reads from temperature and humidity sensor and stores values. More... | |
| void * | tStartStopStream (void *arg) |
| Controls the livestream depending on livestream flag value. More... | |
| void * | tStartStopMotor (void *arg) |
| Controls the motor depending on swing flag value. More... | |
| void * | tUpdateDatabase (void *arg) |
| Update values to/from database. More... | |
| int | main (int argc, char *argv[]) |
Variables | |
| mqd_t | msgq_id |
| struct mq_attr | msgq_attr |
| _Bool | motorFlag = 0 |
| _Bool | streamFlag = 0 |
| _Bool | sensorFlag = 0 |
| pthread_mutex_t | motorFlag_mutex = PTHREAD_MUTEX_INITIALIZER |
| pthread_mutex_t | streamFlag_mutex = PTHREAD_MUTEX_INITIALIZER |
| pthread_mutex_t | sensorFlag_mutex = PTHREAD_MUTEX_INITIALIZER |
| float | databaseTemperature = 0 |
| float | databaseHumidity = 0 |
| pid_t | daemonPID |
| void checkErrors | ( | int | status | ) |
| void initThread | ( | int | priority, |
| pthread_attr_t * | pthread_attr, | ||
| struct sched_param * | pthread_param | ||
| ) |
|
static |
| void * tReadSensor | ( | void * | arg | ) |
| void * tStartStopMotor | ( | void * | arg | ) |
| void * tStartStopStream | ( | void * | arg | ) |
| void * tUpdateDatabase | ( | void * | arg | ) |
| pthread_mutex_t motorFlag_mutex = PTHREAD_MUTEX_INITIALIZER |
| pthread_mutex_t sensorFlag_mutex = PTHREAD_MUTEX_INITIALIZER |