Create basic command handler skeleton
The groundwork for the command handler has been created.
This commit is contained in:
parent
39c91a18dd
commit
06d5c3c464
5
prosjekt.X/command-handler.c
Normal file
5
prosjekt.X/command-handler.c
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
#include "command-handler.h"
|
||||||
|
|
||||||
|
command_t parse_command(char *command_str);
|
||||||
|
|
||||||
|
void route_command(command_t command);
|
||||||
65
prosjekt.X/command-handler.h
Normal file
65
prosjekt.X/command-handler.h
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
/*
|
||||||
|
* File: command-handler.h
|
||||||
|
* Author: Sebastian H. Gabrielli
|
||||||
|
*
|
||||||
|
* Created on March 6, 2024, 12:43 PM
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef COMMAND_HANDLER_H
|
||||||
|
#define COMMAND_HANDLER_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Enum of all valid command types
|
||||||
|
typedef enum {
|
||||||
|
WRITE_CHANGE, // Change the configuration
|
||||||
|
READ_CONFIG, // Read, and print the current configuration
|
||||||
|
READ_VOLTAGE, // Read, and print a voltage
|
||||||
|
READ_TERMPERATURE, // Read, and print the temperature
|
||||||
|
READ_FAN_SPEED, // Read, and print the current fan speed
|
||||||
|
READ_BULK_FAN_SPEED, // Read, and print the stored back fan speed data
|
||||||
|
CLEAR_BULK_FAN_SPEED, // Clear the buffer of stored fan speed data
|
||||||
|
UNKNOWN_COMMAND // An unrecognized command has been sent
|
||||||
|
} command_t;
|
||||||
|
|
||||||
|
// Enum of all valid voltage sources
|
||||||
|
typedef enum {
|
||||||
|
SRC_INTERNAL, // Internal volage
|
||||||
|
SRC_EXTRNAL, // External voltage
|
||||||
|
SRC_NONE // No voltage source selected
|
||||||
|
} src_voltage_t;
|
||||||
|
|
||||||
|
// Enum of all valid config options
|
||||||
|
// TODO: Move into config header file
|
||||||
|
typedef enum {
|
||||||
|
CNF_NONE, // No config option
|
||||||
|
} config_option_t;
|
||||||
|
|
||||||
|
// Enum of all valid fans
|
||||||
|
// TODO: Consider moving into it's own fan page
|
||||||
|
typedef enum {
|
||||||
|
FAN1, // The first fan
|
||||||
|
FAN2, // The second fan
|
||||||
|
FAN_NONE // No fan
|
||||||
|
} fans_t;
|
||||||
|
|
||||||
|
// Struct with command context
|
||||||
|
typedef struct {
|
||||||
|
command_t command; // The command to execute
|
||||||
|
src_voltage_t src_voltage; // The selected voltage source
|
||||||
|
config_option_t conf; // The configuration option to cange
|
||||||
|
} command_context_t;
|
||||||
|
|
||||||
|
// Parses the input string and outputs one of the valid commands
|
||||||
|
command_context_t parse_command(char *command_str);
|
||||||
|
|
||||||
|
// Routes the provided command to the appropriate function to handle it
|
||||||
|
void route_command(command_context_t command);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* COMMAND_HANDLER_H */
|
||||||
@ -4,6 +4,7 @@
|
|||||||
<logicalFolder name="HeaderFiles"
|
<logicalFolder name="HeaderFiles"
|
||||||
displayName="Header Files"
|
displayName="Header Files"
|
||||||
projectFiles="true">
|
projectFiles="true">
|
||||||
|
<itemPath>command-handler.h</itemPath>
|
||||||
</logicalFolder>
|
</logicalFolder>
|
||||||
<logicalFolder name="LinkerScript"
|
<logicalFolder name="LinkerScript"
|
||||||
displayName="Linker Files"
|
displayName="Linker Files"
|
||||||
@ -13,6 +14,7 @@
|
|||||||
displayName="Source Files"
|
displayName="Source Files"
|
||||||
projectFiles="true">
|
projectFiles="true">
|
||||||
<itemPath>main.c</itemPath>
|
<itemPath>main.c</itemPath>
|
||||||
|
<itemPath>command-handler.c</itemPath>
|
||||||
</logicalFolder>
|
</logicalFolder>
|
||||||
<logicalFolder name="ExternalFiles"
|
<logicalFolder name="ExternalFiles"
|
||||||
displayName="Important Files"
|
displayName="Important Files"
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user