diff --git a/linux/payload/FreshMpsocHandler.cpp b/linux/payload/FreshMpsocHandler.cpp index 07e3ec0f..610a7c5c 100644 --- a/linux/payload/FreshMpsocHandler.cpp +++ b/linux/payload/FreshMpsocHandler.cpp @@ -687,6 +687,15 @@ ReturnValue_t FreshMpsocHandler::commandTcCamTakePic(const uint8_t* commandData, if (result != returnvalue::OK) { 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); return returnvalue::OK; } diff --git a/linux/payload/plocMpsocHelpers.h b/linux/payload/plocMpsocHelpers.h index b2dd4c59..dda86329 100644 --- a/linux/payload/plocMpsocHelpers.h +++ b/linux/payload/plocMpsocHelpers.h @@ -914,24 +914,116 @@ class TcCamTakePic : public TcBase { : TcBase(params, apid::TC_CAM_TAKE_PIC, sequenceCount) {} 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; } - std::string fileName(reinterpret_cast(commandData)); - if (fileName.size() + sizeof(NULL_TERMINATOR) > MAX_FILENAME_SIZE) { + size_t deserLen = commandDataLen; + size_t serLen = 0; + fileName = reinterpret_cast(commandData); + if (fileName.size() + sizeof(NULL_TERMINATOR) > FILENAME_LEN) { return FILENAME_TOO_LONG; } - if (commandDataLen - (fileName.size() + sizeof(NULL_TERMINATOR)) != PARAMETER_SIZE) { - return INVALID_LENGTH; + deserLen -= FILENAME_LEN; + *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); - std::memcpy(payloadStart, commandData, commandDataLen); + result = SerializeAdapter::serialize(&encoderSettingY, payloadPtr, &serLen, FULL_PAYLOAD_SIZE, + 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; } + 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: - static const size_t MAX_DATA_LENGTH = 286; 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; }; /**