F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
CmdResponseEnumAc.cpp
Go to the documentation of this file.
1 // ======================================================================
2 // \title CmdResponseEnumAc.cpp
3 // \author Generated by fpp-to-cpp
4 // \brief cpp file for CmdResponse enum
5 // ======================================================================
6 
7 #include <cstring>
8 #include <limits>
9 
10 #include "Fw/Types/Assert.hpp"
12 
13 namespace Fw {
14 
15  // ----------------------------------------------------------------------
16  // Operators
17  // ----------------------------------------------------------------------
18 
19  CmdResponse& CmdResponse ::
21  {
22  this->e = obj.e;
23  return *this;
24  }
25 
28  {
29  this->e = e1;
30  return *this;
31  }
32 
33 #ifdef BUILD_UT
34 
35  std::ostream& operator<<(std::ostream& os, const CmdResponse& obj) {
36  Fw::String s;
37  obj.toString(s);
38  os << s;
39  return os;
40  }
41 
42 #endif
43 
44  // ----------------------------------------------------------------------
45  // Member functions
46  // ----------------------------------------------------------------------
47 
48  bool CmdResponse ::
49  isValid() const
50  {
51  return ((e >= OK) && (e <= BUSY));
52  }
53 
57  Fw::Endianness mode
58  ) const
59  {
60  const Fw::SerializeStatus status = buffer.serializeFrom(
61  static_cast<SerialType>(this->e),
62  mode
63  );
64  return status;
65  }
66 
70  Fw::Endianness mode
71  )
72  {
73  SerialType es;
74  Fw::SerializeStatus status = buffer.deserializeTo(es, mode);
75  if (status == Fw::FW_SERIALIZE_OK) {
76  this->e = static_cast<T>(es);
77  if (!this->isValid()) {
79  }
80  }
81  return status;
82  }
83 
84 #if FW_SERIALIZABLE_TO_STRING
85 
86  void CmdResponse ::
87  toString(Fw::StringBase& sb) const
88  {
89  Fw::String s;
90  switch (e) {
91  case OK:
92  s = "OK";
93  break;
94  case INVALID_OPCODE:
95  s = "INVALID_OPCODE";
96  break;
97  case VALIDATION_ERROR:
98  s = "VALIDATION_ERROR";
99  break;
100  case FORMAT_ERROR:
101  s = "FORMAT_ERROR";
102  break;
103  case EXECUTION_ERROR:
104  s = "EXECUTION_ERROR";
105  break;
106  case BUSY:
107  s = "BUSY";
108  break;
109  default:
110  s = "[invalid]";
111  break;
112  }
113  sb.format("%s (%" PRIu8 ")", s.toChar(), e);
114  }
115 
116 #elif FW_ENABLE_TEXT_LOGGING
117 
118  void CmdResponse ::
119  toString(Fw::StringBase& sb) const
120  {
121  sb.format("%" PRIu8 "", e);
122  }
123 
124 #endif
125 
126 }
Serialization/Deserialization operation was successful.
Fw::SerializeStatus deserializeFrom(Fw::SerializeBufferBase &buffer, Fw::Endianness mode=Fw::Endianness::BIG)
Deserialize raw enum value from SerialType.
Invalid opcode dispatched.
Fw::SerializeStatus serializeTo(Fw::SerializeBufferBase &buffer, Fw::Endianness mode=Fw::Endianness::BIG) const
Serialize raw enum value to SerialType.
const char * toChar() const
Definition: String.hpp:50
SerializeStatus deserializeTo(U8 &val, Endianness mode=Endianness::BIG)
deserialize 8-bit unsigned int
Deserialization data had incorrect values (unexpected data types)
Enum representing a command response.
bool isValid() const
Check raw enum value for validity.
SerializeStatus
forward declaration for string
CmdResponse & operator=(const CmdResponse &obj)
Copy assignment operator (object)
T e
The raw enum value.
T
The raw enum type.
SerializeStatus serializeFrom(U8 val, Endianness mode=Endianness::BIG)
serialize 8-bit unsigned int
U8 SerialType
The serial representation type.
FormatStatus format(const CHAR *formatString,...)
write formatted string to buffer
Definition: StringBase.cpp:55
Command successfully executed.
Command failed to deserialize.
Command had execution error.
Command failed validation.
Implementation of malloc based allocator.
Endianness