Skip to content
Snippets Groups Projects
Commit 1ada5b23 authored by Valerio Pastore's avatar Valerio Pastore
Browse files

added astri horn support

parent 86245889
No related branches found
No related tags found
No related merge requests found
cmake_minimum_required(VERSION 3.9)
project(Astri_Packet)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -std=c++1y")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
option(ASTRIPACKET_BUILD_SHARED "Build astripacket as a shared library." OFF)
set(SOURCES
src/PacketStructureTxt.cpp
src/PacketStructureJson.cpp
src/AstriPacketGeneric.cpp
src/AstriMaGeneric.cpp
src/AstriHornGeneric.cpp
)
......
File moved
File moved
Subproject commit ea71ffe16732d5e26080485197bdbeaa9309ee7e
Subproject commit f6d907797091997c42a2a3419a68fa161881ed84
#ifndef INCLUDE_INAF_OAS_PACKETS_ASTRI_PACKER_GENERIC_H_
#define INCLUDE_INAF_OAS_PACKETS_ASTRI_PACKER_GENERIC_H_
#pragma once
#include <Base_Packet.h>
namespace inaf::oasbo::Packets {
class AstriPacketGeneric : public inaf::oasbo::PacketLib::BasePacket {
class AstriHornGeneric : public inaf::oasbo::PacketLib::BasePacket {
public:
AstriPacketGeneric(inaf::oasbo::PacketLib::BasePacketStructure &structure) : BasePacket(structure){}
AstriHornGeneric(inaf::oasbo::PacketLib::BasePacketStructure &structure) : BasePacket(structure){}
uint getHeaderSize() const override;
uint getPayloadSize() const override;
uint getTailSize() const override;
bool isRecognizedHeader() const override;
bool isRecognizedHeader(std::vector<uint8_t> buff) const override;
};
}
#endif /* INCLUDE_INAF_OAS_PACKETS_ASTRI_PACKER_GENERIC_H_ */
/*
*
* Created on: Mar 1, 2021
* Author: astrisw
*/
#pragma once
#include <vector>
#include <tuple>
namespace inaf::oasbo::Packets::AstriHorn {
static std::vector<std::tuple<size_t, size_t, size_t>> recognizedPackets = {
std::make_tuple(1, 1, 13268), std::make_tuple(1, 2, 13268),
std::make_tuple(1, 3, 13268), std::make_tuple(1, 4, 13268),
std::make_tuple(2, 1, 9568), std::make_tuple(2, 2, 10900),
std::make_tuple(10, 1, 4526), std::make_tuple(10, 2, 19040),
std::make_tuple(15, 1, 12)
};
}
#pragma once
#include <Base_Packet.h>
namespace inaf::oasbo::Packets {
class AstriMaGeneric : public inaf::oasbo::PacketLib::BasePacket {
public:
AstriMaGeneric(inaf::oasbo::PacketLib::BasePacketStructure &structure) : BasePacket(structure){}
uint getHeaderSize() const override;
uint getPayloadSize() const override;
uint getTailSize() const override;
bool isRecognizedHeader() const override;
bool isRecognizedHeader(std::vector<uint8_t> buff) const override;
};
}
/*
*
* Created on: Mar 1, 2021
* Author: astrisw
*/
#pragma once
#include <vector>
#include <tuple>
namespace inaf::oasbo::Packets::AstriMa {
static std::vector<std::tuple<size_t, size_t, size_t>> recognizedPackets = {
std::make_tuple(1, 1, 9942), std::make_tuple(1, 4, 13056),
std::make_tuple(2, 2, 13052), std::make_tuple(10, 1, 1578),
std::make_tuple(10, 2, 9568), std::make_tuple(10, 3, 9568),
std::make_tuple(15, 1, 12)
};
}
/*
* AstriPacketGeneric.cpp
*
* Created on: Jan 26, 2023
* Author: valerio
*/
#include <AstriHornGeneric.h>
#include <AstriHornRecognizedPacket.h>
using namespace inaf::oasbo::Packets;
uint AstriHornGeneric::getHeaderSize() const {
return 6;
}
uint AstriHornGeneric::getPayloadSize() const {
auto val = this->operator [](5);
if(val.has_value())
return val.value()-1;
else{
std::cerr << "Error: cannot access index 5 to get payload size." << std::endl;
exit(EXIT_FAILURE);
}
}
uint AstriHornGeneric::getTailSize() const {
return 2;
}
bool AstriHornGeneric::isRecognizedHeader() const {
size_t type = this->operator []("type").value();
size_t subtype = this->operator []("subtype").value();
ssize_t length = this->operator []("length").value();
ssize_t totLength = this->getHeaderSize() + length + this->getTailSize();
std::tuple<size_t, size_t, size_t> target = std::make_tuple(type, subtype,totLength);
auto it = std::find(AstriHorn::recognizedPackets.begin(),
AstriHorn::recognizedPackets.end(), target);
if (it != AstriHorn::recognizedPackets.end())
return true;
else
return false;
}
bool AstriHornGeneric::isRecognizedHeader(std::vector<uint8_t> buff) const {
if( buff.size() != this->getHeaderSize())
return false;
size_t type = buff[1] >> 4;
size_t subtype = buff[1] & 0x0F;
ssize_t length = (buff[4] << 8) + buff[5] -1;
ssize_t totLength = this->getHeaderSize() + length + this->getTailSize();
std::tuple<size_t, size_t, size_t> target = std::make_tuple(type, subtype,totLength);
auto it = std::find(AstriHorn::recognizedPackets.begin(),
AstriHorn::recognizedPackets.end(), target);
if (it != AstriHorn::recognizedPackets.end())
return true;
else
return false;
}
/*
* AstriPacketGeneric.cpp
*
* Created on: Jan 26, 2023
* Author: valerio
*/
#include <AstriMaGeneric.h>
#include <AstriMaRecognizedPacket.h>
using namespace inaf::oasbo::Packets;
uint AstriMaGeneric::getHeaderSize() const {
return 6;
}
uint AstriMaGeneric::getPayloadSize() const {
auto val = this->operator [](5);
if(val.has_value())
return val.value()-1;
else{
std::cerr << "Error: cannot access index 5 to get payload size." << std::endl;
exit(EXIT_FAILURE);
}
}
uint AstriMaGeneric::getTailSize() const {
return 2;
}
bool AstriMaGeneric::isRecognizedHeader() const {
size_t type = this->operator []("type").value();
size_t subtype = this->operator []("subtype").value();
ssize_t length = this->operator []("length").value();
ssize_t totLength = this->getHeaderSize() + length + this->getTailSize();
std::tuple<size_t, size_t, size_t> target = std::make_tuple(type, subtype,totLength);
auto it = std::find(AstriMa::recognizedPackets.begin(),
AstriMa::recognizedPackets.end(), target);
if (it != AstriMa::recognizedPackets.end())
return true;
else
return false;
}
bool AstriMaGeneric::isRecognizedHeader(std::vector<uint8_t> buff) const {
if( buff.size() != this->getHeaderSize())
return false;
size_t type = buff[1] >> 4;
size_t subtype = buff[1] & 0x0F;
ssize_t length = (buff[4] << 8) + buff[5] -1;
ssize_t totLength = this->getHeaderSize() + length + this->getTailSize();
std::tuple<size_t, size_t, size_t> target = std::make_tuple(type, subtype,totLength);
auto it = std::find(AstriMa::recognizedPackets.begin(),
AstriMa::recognizedPackets.end(), target);
if (it != AstriMa::recognizedPackets.end())
return true;
else
return false;
}
/*
* AstriPacketGeneric.cpp
*
* Created on: Jan 26, 2023
* Author: valerio
*/
#include <AstriPacketGeneric.h>
using namespace inaf::oasbo::Packets;
uint AstriPacketGeneric::getHeaderSize() const {
return 6;
}
uint AstriPacketGeneric::getPayloadSize() const {
auto val = this->operator [](5);
if(val.has_value())
return val.value()-1;
else{
std::cerr << "Error: cannot access index 5 to get payload size." << std::endl;
exit(EXIT_FAILURE);
}
}
uint AstriPacketGeneric::getTailSize() const {
return 2;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment