checksum command
All checks were successful
EIVE/eive-obsw/pipeline/pr-develop This commit looks good
All checks were successful
EIVE/eive-obsw/pipeline/pr-develop This commit looks good
This commit is contained in:
@ -420,6 +420,10 @@ ReturnValue_t StarTrackerHandler::buildCommandFromCommand(DeviceCommandId_t devi
|
||||
result = prepareUnlockCommand(commandData, commandDataLen);
|
||||
return result;
|
||||
}
|
||||
case (StarTracker::CHECKSUM): {
|
||||
result = prepareChecksumCommand(commandData, commandDataLen);
|
||||
return result;
|
||||
}
|
||||
default:
|
||||
return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED;
|
||||
}
|
||||
@ -480,6 +484,8 @@ void StarTrackerHandler::fillCommandAndReplyMap() {
|
||||
StarTracker::MAX_FRAME_SIZE * 2 + 2);
|
||||
this->insertInCommandAndReplyMap(StarTracker::UNLOCK, 3, nullptr,
|
||||
StarTracker::MAX_FRAME_SIZE * 2 + 2);
|
||||
this->insertInCommandAndReplyMap(StarTracker::CHECKSUM, 3, nullptr,
|
||||
StarTracker::MAX_FRAME_SIZE * 2 + 2);
|
||||
}
|
||||
|
||||
ReturnValue_t StarTrackerHandler::scanForReply(const uint8_t *start, size_t remainingSize,
|
||||
@ -555,6 +561,10 @@ ReturnValue_t StarTrackerHandler::interpretDeviceReply(DeviceCommandId_t id, con
|
||||
result = handleActionReply();
|
||||
break;
|
||||
}
|
||||
case (StarTracker::CHECKSUM): {
|
||||
result = handleChecksumReply();
|
||||
break;
|
||||
}
|
||||
case (StarTracker::REQ_VERSION): {
|
||||
result = handleTm(versionSet, StarTracker::VersionSet::SIZE);
|
||||
if (result != RETURN_OK) {
|
||||
@ -834,6 +844,10 @@ ReturnValue_t StarTrackerHandler::scanForActionReply(DeviceCommandId_t *foundId)
|
||||
*foundId = StarTracker::UNLOCK;
|
||||
break;
|
||||
}
|
||||
case (StarTracker::ID::CHECKSUM): {
|
||||
*foundId = StarTracker::CHECKSUM;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
sif::warning << "StarTrackerHandler::scanForParameterReply: Unknown parameter reply id"
|
||||
<< std::endl;
|
||||
@ -970,7 +984,7 @@ ReturnValue_t StarTrackerHandler::executeWriteCommand(const uint8_t* commandData
|
||||
size_t size = sizeof(address);
|
||||
const uint8_t* addressPtr = commandData + WriteCmd::ADDRESS_OFFSET;
|
||||
result = SerializeAdapter::deSerialize(&address, addressPtr, &size,
|
||||
SerializeIF::Endianness::LITTLE);
|
||||
SerializeIF::Endianness::BIG);
|
||||
if (result != RETURN_OK) {
|
||||
sif::debug << "StarTrackerHandler::executeWriteCommand: Deserialization of address failed"
|
||||
<< std::endl;
|
||||
@ -1003,7 +1017,7 @@ ReturnValue_t StarTrackerHandler::executeReadCommand(const uint8_t* commandData,
|
||||
size_t size = sizeof(address);
|
||||
const uint8_t* addressPtr = commandData + ReadCmd::ADDRESS_OFFSET;
|
||||
result = SerializeAdapter::deSerialize(&address, addressPtr, &size,
|
||||
SerializeIF::Endianness::LITTLE);
|
||||
SerializeIF::Endianness::BIG);
|
||||
if (result != RETURN_OK) {
|
||||
sif::debug << "StarTrackerHandler::executeReadCommand: Deserialization of address failed"
|
||||
<< std::endl;
|
||||
@ -1062,6 +1076,44 @@ ReturnValue_t StarTrackerHandler::prepareUnlockCommand(const uint8_t* commandDat
|
||||
return result;
|
||||
}
|
||||
|
||||
ReturnValue_t StarTrackerHandler::prepareChecksumCommand(const uint8_t* commandData,
|
||||
size_t commandDataLen) {
|
||||
struct ChecksumActionRequest req;
|
||||
ReturnValue_t result = RETURN_OK;
|
||||
if (commandDataLen != ChecksumCmd::LENGTH) {
|
||||
sif::warning << "StarTrackerHandler::prepareChecksumCommand: Invalid length" << std::endl;
|
||||
return INVALID_LENGTH;
|
||||
}
|
||||
req.region = *(commandData);
|
||||
size_t size = sizeof(req.address);
|
||||
const uint8_t* addressPtr = commandData + ChecksumCmd::ADDRESS_OFFSET;
|
||||
result = SerializeAdapter::deSerialize(&req.address, addressPtr, &size,
|
||||
SerializeIF::Endianness::BIG);
|
||||
if (result != RETURN_OK) {
|
||||
sif::debug << "StarTrackerHandler::prepareChecksumCommand: Deserialization of address "
|
||||
<< "failed" << std::endl;
|
||||
return result;
|
||||
}
|
||||
size = sizeof(req.length);
|
||||
const uint8_t* lengthPtr = commandData + ChecksumCmd::LENGTH_OFFSET;
|
||||
result = SerializeAdapter::deSerialize(&req.length, lengthPtr, &size,
|
||||
SerializeIF::Endianness::BIG);
|
||||
if (result != RETURN_OK) {
|
||||
sif::debug << "StarTrackerHandler::prepareChecksumCommand: Deserialization of length failed"
|
||||
<< std::endl;
|
||||
return result;
|
||||
}
|
||||
uint32_t rawCmdLength = 0;
|
||||
arc_pack_checksum_action_req(&req, commandBuffer, &rawCmdLength);
|
||||
dataLinkLayer.encodeFrame(commandBuffer, rawCmdLength);
|
||||
rawPacket = dataLinkLayer.getEncodedFrame();
|
||||
rawPacketLen = dataLinkLayer.getEncodedLength();
|
||||
checksumCmd.rememberRegion = req.region;
|
||||
checksumCmd.rememberAddress = req.address;
|
||||
checksumCmd.rememberLength = req.length;
|
||||
return result;
|
||||
}
|
||||
|
||||
void StarTrackerHandler::prepareTimeRequest() {
|
||||
uint32_t length = 0;
|
||||
arc_tm_pack_time_req(commandBuffer, &length);
|
||||
@ -1240,6 +1292,32 @@ ReturnValue_t StarTrackerHandler::handleActionReply() {
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t StarTrackerHandler::handleChecksumReply() {
|
||||
ReturnValue_t result = RETURN_OK;
|
||||
result = handleActionReply();
|
||||
if (result != RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
const uint8_t* replyData = dataLinkLayer.getReply() + ACTION_DATA_OFFSET;
|
||||
StarTracker::ChecksumReply checksumReply(replyData);
|
||||
if (checksumReply.getRegion() != checksumCmd.rememberRegion) {
|
||||
sif::warning << "StarTrackerHandler::handleChecksumReply: Region mismatch" << std::endl;
|
||||
return REGION_MISMATCH;
|
||||
}
|
||||
if (checksumReply.getAddress() != checksumCmd.rememberAddress) {
|
||||
sif::warning << "StarTrackerHandler::handleChecksumReply: Address mismatch" << std::endl;
|
||||
return ADDRESS_MISMATCH;
|
||||
}
|
||||
if (checksumReply.getLength() != checksumCmd.rememberLength) {
|
||||
sif::warning << "StarTrackerHandler::handleChecksumReply: Length mismatch" << std::endl;
|
||||
return LENGTH_MISSMATCH;
|
||||
}
|
||||
#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1
|
||||
checksumReply.printChecksum();
|
||||
#endif /* OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1 */
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t StarTrackerHandler::handlePingReply() {
|
||||
ReturnValue_t result = RETURN_OK;
|
||||
uint32_t pingId = 0;
|
||||
|
Reference in New Issue
Block a user