Anyone who ends up working on the code can just use doxygen to generate the documentation themselves.
We'll include the generated documentation with the final release.
Document stuff!
# identify the project. Note that if you do not use Doxywizard you need
# to put quotes around the project name if it contains spaces.
-PROJECT_NAME = "My Project"
+PROJECT_NAME = "MCTX3420 Server Software"
# The PROJECT_NUMBER tag can be used to enter a project or revision number.
# This could be handy for archiving the generated documentation or
# for a project that appears at the top of each page and should give viewer
# a quick idea about the purpose of the project. Keep the description short.
-PROJECT_BRIEF =
+PROJECT_BRIEF = Server side software to poll sensors, control actuators, and allow remote access
# With the PROJECT_LOGO tag one can specify an logo or icon that is
# included in the documentation. The maximum height of the logo should not
# If a relative path is entered, it will be relative to the location
# where doxygen was started. If left blank the current directory will be used.
-OUTPUT_DIRECTORY =
+OUTPUT_DIRECTORY = doc
# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create
# 4096 sub-directories (in 2 levels) under the output directory of each output
# The TAB_SIZE tag can be used to set the number of spaces in a tab.
# Doxygen uses this value to replace tabs by spaces in code fragments.
-TAB_SIZE = 8
+TAB_SIZE = 4
# This tag can be used to specify a number of aliases that acts
# as commands in the documentation. An alias has the form "name=value".
# For instance, some of the names that are used will be different. The list
# of all members will be omitted, etc.
-OPTIMIZE_OUTPUT_FOR_C = NO
+OPTIMIZE_OUTPUT_FOR_C = YES
# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java
# sources only. Doxygen will then generate output that is more tailored for
-This code will run on the Raspberry Pi server.
+This code will run on the server.
The software will implement an interface between requests made by a browser using HTTP and low level sensors/control on the server.
-Multiple threads will be used; one running a HTTP server, and one or more for interacting with sensors/actuators.
-A watchdog program should be created to start the main server program and handle software crashes.
+Multiple threads will be used; one responding to HTTP requests, and one or more for interacting with sensors/actuators.
+A watchdog bash script can becreated to start the main server program and handle software crashes.
+
+Note: Documentation can be generated using Doxygen.
// --- Function implementations --- //
/**
- * @funct Log
- * @purpose Print a message to stderr
+ * Print a message to stderr
* @param level - Specify how severe the message is.
If level is higher (less urgent) than the program's verbosity (see options.h) no message will be printed
* @param funct - String indicating the function name from which this function was called.
}
/**
- * @funct Fatal
- * @purpose Handle a Fatal error in the program by printing a message and exiting the program
+ * Handle a Fatal error in the program by printing a message and exiting the program
CALLING THIS FUNCTION WILL CAUSE THE PROGAM TO EXIT
* @param funct - Name of the calling function
* @param fmt - A format string
/**
* @file main.c
- * @purpose Entry point to the program, starts threads, handles cleanup on program exit
+ * @purpose main and its helper functions, signal handling and cleanup functions
*/
#define _POSIX_C_SOURCE 200809L // For strsignal to work
// --- Function definitions --- //
/**
- * @funct ParseArguments
- * @purpose Parse command line arguments, set up an options variable
- * @param argc - Num args
- * @param argv - Array of args
- * @param opts - Pointer to options. &g_options
+ * Parse command line arguments, initialise g_options
+ * @param argc - Number of arguments
+ * @param argv - Array of argument strings
*/
-void ParseArguments(int argc, char ** argv, Options * opts)
+void ParseArguments(int argc, char ** argv)
{
- opts->program = argv[0]; // program name
- opts->verbosity = LOGDEBUG; // default log level
- Log(LOGDEBUG, "ParseArguments", "Called as %s with %d arguments.", opts->program, argc);
+ g_options.program = argv[0]; // program name
+ g_options.verbosity = LOGDEBUG; // default log level
+ Log(LOGDEBUG, "ParseArguments", "Called as %s with %d arguments.", g_options.program, argc);
}
/**
- * @funct SignalHandler
- * @purpose Handle signals
- * @param sig - The signal
+ * Handle a signal
+ * @param signal - The signal number
*/
-void SignalHandler(int sig)
+void SignalHandler(int signal)
{
// At the moment just always exit.
// Call `exit` so that Cleanup will be called to... clean up.
- Log(LOGWARN, "SignalHandler", "Got signal %d (%s). Exiting.", sig, strsignal(sig));
+ Log(LOGWARN, "SignalHandler", "Got signal %d (%s). Exiting.", signal, strsignal(signal));
exit(sig);
}
/**
- * @funct Cleanup
- * @purpose Called when program exits
+ * Cleanup before the program exits
*/
void Cleanup()
{
}
/**
- * @funct main
- * @purpose Main entry point; start worker threads, setup signal handling, wait for threads to exit, exit
+ * Main entry point; start worker threads, setup signal handling, wait for threads to exit, exit
* @param argc - Num args
* @param argv - Args
* @returns 0 on success, error code on failure
/**
* @file options.h
- * @purpose Declaration of structure to handle options passed to program
+ * @purpose Define the Options structure and the g_options variable
*/
#ifndef _OPTIONS_H
#define _OPTIONS_H
+
+/** Store options passed or calculated from arguments to the program **/
typedef struct
{
- const char * program; //name of program
- int verbosity; // verbosity level
+ /** Name of program **/
+ const char * program;
+ /** Determines at what level log messages are shown **/
+ int verbosity;
} Options;
-extern Options g_options; // global options structure
+/** The only instance of the Options struct **/
+extern Options g_options;
#endif //_OPTIONS_H
+/**
+ * @file sensor.c
+ * @purpose Implementation of sensor thread
+ * TODO: Finalise implementation
+ */
+
+#include "sensor.h"
+
+/**
+ * Run the main sensor polling loop
+ * @param args - IGNORED (void* required to use the function with pthreads)
+ * @returns NULL (void* required to use the function with pthreads)
+ */
+void * Sensor_Main(void * args)
+{
+
+}
+
/**
* @file sensor.h
- * @purpose Declarations for sensor thread stuff
+ * @purpose Declarations for sensor thread related stuff
*/
-///TODO: Add more; this is currently just for testing
+
#ifndef _SENSOR_H
#define _SENSOR_H