HARDT - The Ham Radio DSP Toolkit
hcommand.h
1 #ifndef __HCOMMAND_H
2 #define __HCOMMAND_H
3 
4 #include "hexceptions.h"
5 
7 enum H_COMMAND_CLASS
8 {
16  NONE = 0,
17 
23  ANY = 1,
24 
30  TUNER = 2,
31 };
32 
34 enum H_COMMAND_OPCODE
35 {
43  NOP = 0,
44 
55  SET_FREQUENCY = 1,
56 
64  SET_GAIN = 2
65 };
66 
68 union HCommandData {
69 
71  int32_t Value;
72 
74  bool State;
75 
77  void *Content;
78 };
79 
81 struct HCommand
82 {
84  int16_t Class;
85 
87  int16_t Opcode;
88 
98  int16_t Length;
99 
104 };
105 
106 /* The absolut minimum size of a command, a command that holds either a boolean value or an integer value
107  * This is the absolut minimum size of a chunk of data that can be converted to a HCommand struct */
108 static int HCommandMinimumsSize = sizeof(HCommand);
109 
111 inline size_t HCommandSize(HCommand* command) {
112  return HCommandSize(command);
113 }
114 
116 inline size_t HCommandSize(HCommand& command) {
117  switch(command.Opcode) {
118  case NOP:
119  case SET_FREQUENCY:
120  case SET_GAIN:
121  return HCommandMinimumsSize + 0;
122 
123  // Unknownn opcode.
124  default: throw new HUnknownCommandOpcodeException("Unknown opcode in call to HCommandSize (or macro HCOMMAND_LENGTH)");
125  }
126 }
127 
128 #endif
HCommand::Opcode
int16_t Opcode
Definition: hcommand.h:87
HCommand::Data
HCommandData Data
Definition: hcommand.h:103
HCommandData::Value
int32_t Value
Definition: hcommand.h:71
HCommandData::State
bool State
Definition: hcommand.h:74
HUnknownCommandOpcodeException
Definition: hexceptions.h:193
HCommand::Length
int16_t Length
Definition: hcommand.h:98
HCommand::Class
int16_t Class
Definition: hcommand.h:84
HCommand
Definition: hcommand.h:81
HCommandData
Definition: hcommand.h:68
HCommandData::Content
void * Content
Definition: hcommand.h:77