allow validation of CAM cmd params in the future
All checks were successful
EIVE/eive-obsw/pipeline/pr-main This commit looks good
All checks were successful
EIVE/eive-obsw/pipeline/pr-main This commit looks good
This commit is contained in:
parent
b03e53b6e9
commit
37211e2c5f
@ -687,6 +687,15 @@ ReturnValue_t FreshMpsocHandler::commandTcCamTakePic(const uint8_t* commandData,
|
|||||||
if (result != returnvalue::OK) {
|
if (result != returnvalue::OK) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
sif::info << "PLOC MPSoC Take Picture Command" << std::endl;
|
||||||
|
sif::info << "filename: " << tcCamTakePic.fileName << std::endl;
|
||||||
|
sif::info << "encoder [Y, Cb, Cr]: [" << (int)tcCamTakePic.encoderSettingY << ", "
|
||||||
|
<< (int)tcCamTakePic.encoderSettingsCb << ", " << (int)tcCamTakePic.encoderSettingsCr
|
||||||
|
<< "]" << std::endl;
|
||||||
|
sif::info << "quantization [Y, Cb, Cr]: [" << tcCamTakePic.quantizationY << ", "
|
||||||
|
<< tcCamTakePic.quantizationCb << ", " << tcCamTakePic.quantizationCr << "]"
|
||||||
|
<< std::endl;
|
||||||
|
sif::info << "bypass compressor: " << (int)tcCamTakePic.bypassCompressor << std::endl;
|
||||||
finishAndSendTc(mpsoc::TC_CAM_TAKE_PIC, tcCamTakePic);
|
finishAndSendTc(mpsoc::TC_CAM_TAKE_PIC, tcCamTakePic);
|
||||||
return returnvalue::OK;
|
return returnvalue::OK;
|
||||||
}
|
}
|
||||||
|
@ -914,24 +914,116 @@ class TcCamTakePic : public TcBase {
|
|||||||
: TcBase(params, apid::TC_CAM_TAKE_PIC, sequenceCount) {}
|
: TcBase(params, apid::TC_CAM_TAKE_PIC, sequenceCount) {}
|
||||||
|
|
||||||
ReturnValue_t setPayload(const uint8_t* commandData, size_t commandDataLen) {
|
ReturnValue_t setPayload(const uint8_t* commandData, size_t commandDataLen) {
|
||||||
if (commandDataLen > MAX_DATA_LENGTH) {
|
const uint8_t** dataPtr = &commandData;
|
||||||
|
if (commandDataLen > FULL_PAYLOAD_SIZE) {
|
||||||
return INVALID_LENGTH;
|
return INVALID_LENGTH;
|
||||||
}
|
}
|
||||||
std::string fileName(reinterpret_cast<const char*>(commandData));
|
size_t deserLen = commandDataLen;
|
||||||
if (fileName.size() + sizeof(NULL_TERMINATOR) > MAX_FILENAME_SIZE) {
|
size_t serLen = 0;
|
||||||
|
fileName = reinterpret_cast<const char*>(commandData);
|
||||||
|
if (fileName.size() + sizeof(NULL_TERMINATOR) > FILENAME_LEN) {
|
||||||
return FILENAME_TOO_LONG;
|
return FILENAME_TOO_LONG;
|
||||||
}
|
}
|
||||||
if (commandDataLen - (fileName.size() + sizeof(NULL_TERMINATOR)) != PARAMETER_SIZE) {
|
deserLen -= FILENAME_LEN;
|
||||||
return INVALID_LENGTH;
|
*dataPtr += FILENAME_LEN;
|
||||||
|
uint8_t** payloadPtr = &payloadStart;
|
||||||
|
memcpy(payloadStart, fileName.data(), fileName.size());
|
||||||
|
*payloadStart += FILENAME_LEN;
|
||||||
|
serLen += FILENAME_LEN;
|
||||||
|
ReturnValue_t result = SerializeAdapter::deSerialize(&encoderSettingY, dataPtr, &deserLen,
|
||||||
|
SerializeIF::Endianness::NETWORK);
|
||||||
|
if (result != returnvalue::OK) {
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
spParams.setFullPayloadLen(commandDataLen + CRC_SIZE);
|
result = SerializeAdapter::serialize(&encoderSettingY, payloadPtr, &serLen, FULL_PAYLOAD_SIZE,
|
||||||
std::memcpy(payloadStart, commandData, commandDataLen);
|
SerializeIF::Endianness::NETWORK);
|
||||||
|
if (result != returnvalue::OK) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
result = SerializeAdapter::deSerialize(&quantizationY, dataPtr, &deserLen,
|
||||||
|
SerializeIF::Endianness::NETWORK);
|
||||||
|
if (result != returnvalue::OK) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
result = SerializeAdapter::serialize(&quantizationY, payloadPtr, &serLen, FULL_PAYLOAD_SIZE,
|
||||||
|
SerializeIF::Endianness::NETWORK);
|
||||||
|
if (result != returnvalue::OK) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
result = SerializeAdapter::deSerialize(&encoderSettingsCb, dataPtr, &deserLen,
|
||||||
|
SerializeIF::Endianness::NETWORK);
|
||||||
|
if (result != returnvalue::OK) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
result = SerializeAdapter::serialize(&encoderSettingsCb, payloadPtr, &serLen, FULL_PAYLOAD_SIZE,
|
||||||
|
SerializeIF::Endianness::NETWORK);
|
||||||
|
if (result != returnvalue::OK) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
result = SerializeAdapter::deSerialize(&quantizationCb, dataPtr, &deserLen,
|
||||||
|
SerializeIF::Endianness::NETWORK);
|
||||||
|
if (result != returnvalue::OK) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
result = SerializeAdapter::serialize(&quantizationCb, payloadPtr, &serLen, FULL_PAYLOAD_SIZE,
|
||||||
|
SerializeIF::Endianness::NETWORK);
|
||||||
|
if (result != returnvalue::OK) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
result = SerializeAdapter::deSerialize(&encoderSettingsCr, dataPtr, &deserLen,
|
||||||
|
SerializeIF::Endianness::NETWORK);
|
||||||
|
if (result != returnvalue::OK) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
result = SerializeAdapter::serialize(&encoderSettingsCr, payloadPtr, &serLen, FULL_PAYLOAD_SIZE,
|
||||||
|
SerializeIF::Endianness::NETWORK);
|
||||||
|
if (result != returnvalue::OK) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
result = SerializeAdapter::deSerialize(&quantizationCr, dataPtr, &deserLen,
|
||||||
|
SerializeIF::Endianness::NETWORK);
|
||||||
|
if (result != returnvalue::OK) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
result = SerializeAdapter::serialize(&quantizationCr, payloadPtr, &serLen, FULL_PAYLOAD_SIZE,
|
||||||
|
SerializeIF::Endianness::NETWORK);
|
||||||
|
if (result != returnvalue::OK) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
result = SerializeAdapter::deSerialize(&bypassCompressor, dataPtr, &deserLen,
|
||||||
|
SerializeIF::Endianness::NETWORK);
|
||||||
|
if (result != returnvalue::OK) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
result = SerializeAdapter::serialize(&bypassCompressor, payloadPtr, &serLen, FULL_PAYLOAD_SIZE,
|
||||||
|
SerializeIF::Endianness::NETWORK);
|
||||||
|
if (result != returnvalue::OK) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
spParams.setFullPayloadLen(FULL_PAYLOAD_SIZE + CRC_SIZE);
|
||||||
return returnvalue::OK;
|
return returnvalue::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string fileName;
|
||||||
|
uint8_t encoderSettingY = 7;
|
||||||
|
uint64_t quantizationY = 0;
|
||||||
|
uint8_t encoderSettingsCb = 7;
|
||||||
|
uint64_t quantizationCb = 0;
|
||||||
|
uint8_t encoderSettingsCr = 7;
|
||||||
|
uint64_t quantizationCr = 0;
|
||||||
|
uint8_t bypassCompressor = 0;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static const size_t MAX_DATA_LENGTH = 286;
|
|
||||||
static const size_t PARAMETER_SIZE = 28;
|
static const size_t PARAMETER_SIZE = 28;
|
||||||
|
static constexpr size_t FILENAME_LEN = 64;
|
||||||
|
static constexpr size_t FULL_PAYLOAD_SIZE = FILENAME_LEN + PARAMETER_SIZE;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user