Dripline-Cpp  v2.4.2
Dripline Implementation in C++
dripline_constants.hh
Go to the documentation of this file.
1 /*
2  * dripline_constants.hh
3  *
4  * Created on: Jan 5, 2016
5  * Author: N.S. Oblath
6  */
7 
8 #ifndef DRIPLINE_CONSTANTS_HH_
9 #define DRIPLINE_CONSTANTS_HH_
10 
11 #include "dripline_api.hh"
12 
13 #include "macros.hh"
14 
15 #include <cstdint>
16 #include <limits>
17 #include <ostream>
18 
19 namespace dripline
20 {
21 #ifndef DL_MAX_PAYLOAD_SIZE
22 #define DL_MAX_PAYLOAD_SIZE 10000
23 #endif
24 
25  // Dripline message constants
26  // Conforming to the dripline wire protocol: https://github.com/project8/hardware/wiki/Wire-Protocol
27  // Please be sure that these constants are kept in sync with the dripline constants.
28 
33  enum class DRIPLINE_API op_t:uint32_t {
34  set = 0,
35  get = 1,
36  cmd = 9,
37  unknown = UINT32_MAX
38  };
39 
41  DRIPLINE_API uint32_t to_uint( op_t an_op );
44  DRIPLINE_API op_t to_op_t( uint32_t an_op_uint );
46  DRIPLINE_API std::ostream& operator<<( std::ostream& a_os, op_t an_op );
48  DRIPLINE_API std::string to_string( op_t an_op );
51  DRIPLINE_API op_t to_op_t( std::string an_op_str );
52 
57  enum class DRIPLINE_API msg_t:uint32_t
58  {
59  reply = 2,
60  request = 3,
61  alert = 4,
62  unknown = UINT32_MAX
63  };
64 
66  DRIPLINE_API uint32_t to_uint( msg_t a_msg );
69  DRIPLINE_API msg_t to_msg_t( uint32_t a_msg_uint );
71  DRIPLINE_API std::ostream& operator<<( std::ostream& a_os, msg_t a_msg );
73  DRIPLINE_API std::string to_string( msg_t a_msg );
76  DRIPLINE_API msg_t to_msg_t( std::string a_msg_str );
77 
78 } /* namespace dripline */
79 
80 #endif /* DRIPLINE_CONSTANTS_HH_ */
op_t to_op_t(uint32_t an_op_uint)
std::ostream & operator<<(std::ostream &a_os, op_t an_op)
Pass the integer-equivalent of a message-operation enum to an ostream.
#define DRIPLINE_API
Definition: dripline_api.hh:34
msg_t to_msg_t(uint32_t a_msg_uint)
std::string to_string(op_t an_op)
Gives the human-readable version of a message operation.
uint32_t to_uint(op_t an_op)
Convert a message-operation enum to an integer.