2021-08-12 13:46:25 -04:00
|
|
|
/*
|
|
|
|
ept.cpp
|
|
|
|
|
|
|
|
Copyright (c) 2021 Kevin Matz (kevin.matz@gmail.com)
|
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
|
|
in the Software without restriction, including without limitation the rights
|
|
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
|
|
furnished to do so, subject to the following conditions:
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included in all
|
|
|
|
copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
|
SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "ept.h"
|
2021-08-17 16:18:40 -04:00
|
|
|
#include "rdmnet.h"
|
|
|
|
#include "rpt.h"
|
2021-08-12 13:46:25 -04:00
|
|
|
|
|
|
|
namespace RDMnet {
|
|
|
|
namespace EPT {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief EPT::Pdu::Pdu
|
|
|
|
*/
|
|
|
|
Pdu::Pdu()
|
2021-08-13 10:09:14 -04:00
|
|
|
: RDMnet::Pdu(4)
|
2021-08-12 13:46:25 -04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief EPT::Pdu::iStream
|
|
|
|
* @param stream
|
|
|
|
*/
|
2021-08-16 10:14:39 -04:00
|
|
|
void Pdu::iStream(ACN::PDU::Stream stream)
|
2021-08-12 13:46:25 -04:00
|
|
|
{
|
2021-08-16 10:14:39 -04:00
|
|
|
RDMnet::Pdu::iStream(stream); // flags, length, and vector
|
2021-08-17 16:18:40 -04:00
|
|
|
createHeader<ept_header>(); // header
|
|
|
|
switch (vector()) // data
|
|
|
|
{
|
|
|
|
case VECTOR_EPT_DATA:
|
|
|
|
createData<DATA::Pdu>();
|
|
|
|
break;
|
|
|
|
case VECTOR_EPT_STATUS:
|
|
|
|
createData<STATUS::Pdu>();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return;
|
|
|
|
}
|
2021-08-12 13:46:25 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
namespace DATA {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief EPT::DATA::Pdu::Pdu
|
|
|
|
*/
|
|
|
|
Pdu::Pdu()
|
2021-08-13 10:09:14 -04:00
|
|
|
: RDMnet::Pdu(4)
|
2021-08-12 13:46:25 -04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief EPT::DATA::Pdu::iStream
|
|
|
|
* @param stream
|
|
|
|
*/
|
2021-08-16 10:14:39 -04:00
|
|
|
void Pdu::iStream(ACN::PDU::Stream stream)
|
2021-08-12 13:46:25 -04:00
|
|
|
{
|
2021-08-16 10:14:39 -04:00
|
|
|
RDMnet::Pdu::iStream(stream); // flags, length, and vector
|
2021-08-17 16:18:40 -04:00
|
|
|
// has no header segment // header
|
|
|
|
createData<data_data>(); // data
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief data_data::iStream
|
|
|
|
* @param stream
|
|
|
|
*/
|
|
|
|
void data_data::iStream(ACN::PDU::Stream stream)
|
|
|
|
{
|
|
|
|
while (stream->good())
|
|
|
|
data.push_back(stream->readType<uint8_t>());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief data_data::oStream
|
|
|
|
* @param stream
|
|
|
|
*/
|
|
|
|
void data_data::oStream(ACN::PDU::Stream stream) const
|
|
|
|
{
|
|
|
|
for (const auto & byte : data)
|
|
|
|
*stream << byte;
|
2021-08-12 13:46:25 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace DATA
|
|
|
|
|
|
|
|
|
|
|
|
namespace STATUS {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief EPT::STATUS::Pdu::Pdu
|
|
|
|
*/
|
|
|
|
Pdu::Pdu()
|
2021-08-13 10:09:14 -04:00
|
|
|
: RDMnet::Pdu(2)
|
2021-08-12 13:46:25 -04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief EPT::STATUS::Pdu::iStream
|
|
|
|
* @param stream
|
|
|
|
*/
|
2021-08-16 10:14:39 -04:00
|
|
|
void Pdu::iStream(ACN::PDU::Stream stream)
|
2021-08-12 13:46:25 -04:00
|
|
|
{
|
2021-08-17 16:29:27 -04:00
|
|
|
RDMnet::Pdu::iStream(stream); // flags, length, and vector
|
|
|
|
// has no header segment // header
|
|
|
|
createData<RPT::STATUS::status_string_data>(); // data
|
2021-08-12 13:46:25 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace STATUS
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace EPT
|
|
|
|
} // namespace RDMnet
|