COSMOS core  1.0.2 (beta)
Comprehensive Open-architecture Solution for Mission Operations Systems
spp.h
Go to the documentation of this file.
1 /********************************************************************
2 * Copyright (C) 2015 by Interstel Technologies, Inc.
3 * and Hawaii Space Flight Laboratory.
4 *
5 * This file is part of the COSMOS/core that is the central
6 * module for COSMOS. For more information on COSMOS go to
7 * <http://cosmos-project.com>
8 *
9 * The COSMOS/core software is licenced under the
10 * GNU Lesser General Public License (LGPL) version 3 licence.
11 *
12 * You should have received a copy of the
13 * GNU Lesser General Public License
14 * If not, go to <http://www.gnu.org/licenses/>
15 *
16 * COSMOS/core is free software: you can redistribute it and/or
17 * modify it under the terms of the GNU Lesser General Public License
18 * as published by the Free Software Foundation, either version 3 of
19 * the License, or (at your option) any later version.
20 *
21 * COSMOS/core is distributed in the hope that it will be useful, but
22 * WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
24 * Lesser General Public License for more details.
25 *
26 * Refer to the "licences" folder for further information on the
27 * condititons and terms to use this software.
28 ********************************************************************/
29 
30 #ifndef SPP_H
31 #define SPP_H
32 
33 #include "support/configCosmos.h"
34 #include "support/sliplib.h"
35 
36 namespace Cosmos {
37  namespace Protocols {
38  namespace Ccsds {
39 
40  class Spp
41  {
42  public:
43  Spp(uint16_t apid=0, bool telecommand=static_cast<bool>(PacketType::Telemetry), bool secondary_header=false, uint8_t version=0);
44 // ~Spp();
45 
46 
47  enum class PacketType : uint8_t
48  {
49  Telemetry,
51  };
52 
53  enum class SequenceFlags : uint8_t
54  {
55  ContinuationSegment,
56  FirstSegment,
57  LastSegment,
58  UnSegmented
59  };
60 
61  enum class PacketStage : uint16_t
62  {
63  Start,
64  HeaderByte0,
65  HeaderByte1,
66  HeaderByte2,
67  HeaderByte3,
68  HeaderByte4,
69  HeaderByte5,
70  DataBytes
71  };
72 
74  {
75  unsigned apid_msb : 3;
76  unsigned secondary_header_flag : 1;
77  unsigned type : 1;
78  unsigned version : 3;
79  unsigned apid_lsb : 8;
80  unsigned sequence_count_msb : 6;
81  unsigned sequence_flags : 2;
82  unsigned sequence_count_lsb : 8;
83  unsigned data_length_msb : 8;
84  unsigned data_length_lsb : 8;
85  };
86 
87  struct packet
88  {
89  union
90  {
91  uint8_t primary_header_bytes[6];
93  };
94  vector <uint8_t> data_bytes;
95  };
96 
97  int32_t setHeaderByte(uint8_t number, uint8_t value);
98  int32_t setVersion(uint8_t version);
99  int32_t setApid(uint16_t apid);
100  int32_t setApidIdle();
101  int32_t setType(PacketType type);
102  int32_t setSecondaryHeaderFlag(bool present);
103  int32_t setSequenceFlags(SequenceFlags flag);
104  int32_t setSequenceCount(uint16_t count);
105  int32_t setDataLength(uint32_t length);
106 
107  uint8_t getVersion();
108  uint16_t getApid();
110  bool getSecondaryHeaderFlag();
112  uint16_t getSequenceCount();
113  uint32_t getDataLength();
114  packet getFrame();
115 
116  int32_t clearPacket();
117  int32_t clearHeaderBytes();
118  int32_t clearDataBytes();
119  int32_t getDataBytes(vector <uint8_t> &dbytes);
120  int32_t addByte(uint8_t dbyte);
121  int32_t addDataByte(uint8_t dbyte);
122  int32_t setDataBytes(vector <uint8_t> &dbytes);
123  int32_t getHeaderBytes(uint8_t* &header);
124 
125  protected:
127  int32_t error;
129  };
130  }
131  }
132 
133 } // end of namepsace Cosmos
134 #endif // SPP_H
Definition: agentclass.cpp:54
uint16_t getApid()
Definition: spp.cpp:177
uint8_t getVersion()
Definition: spp.cpp:172
Spp(uint16_t apid=0, bool telecommand=static_cast< bool >(PacketType::Telemetry), bool secondary_header=false, uint8_t version=0)
Definition: spp.cpp:37
COSMOS SLIP support include file.
int32_t setApidIdle()
Definition: spp.cpp:97
int count
Definition: rw_test.cpp:36
int32_t error
Definition: spp.h:127
int32_t addByte(uint8_t dbyte)
Definition: spp.cpp:225
uint16_t getSequenceCount()
Definition: spp.cpp:197
int32_t setType(PacketType type)
Definition: spp.cpp:104
int32_t getDataBytes(vector< uint8_t > &dbytes)
Definition: spp.cpp:269
int32_t clearPacket()
Definition: spp.cpp:212
bool getSecondaryHeaderFlag()
Definition: spp.cpp:187
int32_t getHeaderBytes(uint8_t *&header)
Definition: spp.cpp:288
int32_t setApid(uint16_t apid)
Definition: spp.cpp:83
int32_t setSequenceFlags(SequenceFlags flag)
Definition: spp.cpp:144
packet frame
Definition: spp.h:126
int32_t setSecondaryHeaderFlag(bool present)
Definition: spp.cpp:117
Headers and definitions common to all COSMOS.
PacketType getType()
Definition: spp.cpp:182
vector< uint8_t > data_bytes
Definition: spp.h:94
int32_t addDataByte(uint8_t dbyte)
Definition: spp.cpp:256
uint32_t getDataLength()
Definition: spp.cpp:202
PacketStage stage
Definition: spp.h:128
int32_t setDataLength(uint32_t length)
Definition: spp.cpp:157
int32_t setSequenceCount(uint16_t count)
Definition: spp.cpp:130
int32_t clearDataBytes()
Definition: spp.cpp:219
PacketStage
Definition: spp.h:61
png_uint_32 length
Definition: png.c:2173
SequenceFlags
Definition: spp.h:53
int32_t setHeaderByte(uint8_t number, uint8_t value)
Definition: spp.cpp:60
SequenceFlags getSequenceFlags()
Definition: spp.cpp:192
packet getFrame()
Definition: spp.cpp:207
int32_t setDataBytes(vector< uint8_t > &dbytes)
Definition: spp.cpp:282
PacketType
Definition: spp.h:47
primary_header primary_header_fields
Definition: spp.h:92
Definition: spp.h:40
int32_t setVersion(uint8_t version)
Definition: spp.cpp:70