STR time #611
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <fsfw/filesystem/HasFileSystemIF.h>
|
#include <fsfw/filesystem/HasFileSystemIF.h>
|
||||||
|
#include <fsfw/globalfunctions/arrayprinter.h>
|
||||||
#include <fsfw/tasks/TaskFactory.h>
|
#include <fsfw/tasks/TaskFactory.h>
|
||||||
#include <fsfw/timemanager/Stopwatch.h>
|
#include <fsfw/timemanager/Stopwatch.h>
|
||||||
#include <mission/acs/str/strHelpers.h>
|
#include <mission/acs/str/strHelpers.h>
|
||||||
@ -23,6 +24,8 @@ extern "C" {
|
|||||||
|
|
||||||
using namespace returnvalue;
|
using namespace returnvalue;
|
||||||
|
|
||||||
|
static constexpr bool PACKET_WIRETAPPING = false;
|
||||||
|
|
||||||
StrComHandler::StrComHandler(object_id_t objectId) : SystemObject(objectId) {
|
StrComHandler::StrComHandler(object_id_t objectId) : SystemObject(objectId) {
|
||||||
lock = MutexFactory::instance()->createMutex();
|
lock = MutexFactory::instance()->createMutex();
|
||||||
semaphore.acquire();
|
semaphore.acquire();
|
||||||
@ -51,7 +54,7 @@ ReturnValue_t StrComHandler::performOperation(uint8_t operationCode) {
|
|||||||
switch (state) {
|
switch (state) {
|
||||||
case InternalState::POLL_ONE_REPLY: {
|
case InternalState::POLL_ONE_REPLY: {
|
||||||
// Stopwatch watch;
|
// Stopwatch watch;
|
||||||
replyTimeout.setTimeout(200);
|
replyTimeout.setTimeout(400);
|
||||||
replyResult = readOneReply(static_cast<uint32_t>(state));
|
replyResult = readOneReply(static_cast<uint32_t>(state));
|
||||||
{
|
{
|
||||||
MutexGuard mg(lock);
|
MutexGuard mg(lock);
|
||||||
@ -680,6 +683,10 @@ ReturnValue_t StrComHandler::sendMessage(CookieIF* cookie, const uint8_t* sendDa
|
|||||||
const uint8_t* txFrame;
|
const uint8_t* txFrame;
|
||||||
size_t frameLen;
|
size_t frameLen;
|
||||||
datalinkLayer.encodeFrame(sendData, sendLen, &txFrame, frameLen);
|
datalinkLayer.encodeFrame(sendData, sendLen, &txFrame, frameLen);
|
||||||
|
if(PACKET_WIRETAPPING) {
|
||||||
|
sif::debug << "Sendign STR frame" << std::endl;
|
||||||
|
arrayprinter::print(txFrame, frameLen);
|
||||||
|
}
|
||||||
ssize_t bytesWritten = write(serialPort, txFrame, frameLen);
|
ssize_t bytesWritten = write(serialPort, txFrame, frameLen);
|
||||||
if (bytesWritten != static_cast<ssize_t>(frameLen)) {
|
if (bytesWritten != static_cast<ssize_t>(frameLen)) {
|
||||||
sif::warning << "StrComHandler: Sending packet failed" << std::endl;
|
sif::warning << "StrComHandler: Sending packet failed" << std::endl;
|
||||||
@ -782,8 +789,10 @@ ReturnValue_t StrComHandler::handleSerialReception() {
|
|||||||
<< std::endl;
|
<< std::endl;
|
||||||
return FAILED;
|
return FAILED;
|
||||||
} else if (bytesRead > 0) {
|
} else if (bytesRead > 0) {
|
||||||
// sif::info << "Received " << bytesRead << " bytes from the STR" << std::endl;
|
if(PACKET_WIRETAPPING) {
|
||||||
// arrayprinter::print(recBuf.data(), bytesRead);
|
sif::info << "Received " << bytesRead << " bytes from the STR" << std::endl;
|
||||||
|
arrayprinter::print(recBuf.data(), bytesRead);
|
||||||
|
}
|
||||||
datalinkLayer.feedData(recBuf.data(), bytesRead);
|
datalinkLayer.feedData(recBuf.data(), bytesRead);
|
||||||
}
|
}
|
||||||
return OK;
|
return OK;
|
||||||
@ -797,6 +806,10 @@ ReturnValue_t StrComHandler::readOneReply(uint32_t failParameter) {
|
|||||||
handleSerialReception();
|
handleSerialReception();
|
||||||
result = datalinkLayer.checkRingBufForFrame(&replyPtr, replyLen);
|
result = datalinkLayer.checkRingBufForFrame(&replyPtr, replyLen);
|
||||||
if (result == returnvalue::OK) {
|
if (result == returnvalue::OK) {
|
||||||
|
if(PACKET_WIRETAPPING) {
|
||||||
|
sif::debug << "Received STR reply frame" << std::endl;
|
||||||
|
arrayprinter::print(replyPtr, replyLen);
|
||||||
|
}
|
||||||
return returnvalue::OK;
|
return returnvalue::OK;
|
||||||
} else if (result != ArcsecDatalinkLayer::DEC_IN_PROGRESS) {
|
} else if (result != ArcsecDatalinkLayer::DEC_IN_PROGRESS) {
|
||||||
triggerEvent(STR_HELPER_DEC_ERROR, result, failParameter);
|
triggerEvent(STR_HELPER_DEC_ERROR, result, failParameter);
|
||||||
|
@ -352,7 +352,7 @@ ReturnValue_t StarTrackerHandler::buildTransitionDeviceCommand(DeviceCommandId_t
|
|||||||
}
|
}
|
||||||
case (FwBootState::SET_TIME): {
|
case (FwBootState::SET_TIME): {
|
||||||
bootState = FwBootState::WAIT_FOR_EXECUTION;
|
bootState = FwBootState::WAIT_FOR_EXECUTION;
|
||||||
*id = startracker::SET_TIME;
|
*id = startracker::SET_TIME_FROM_SYS_TIME;
|
||||||
return buildCommandFromCommand(*id, nullptr, 0);
|
return buildCommandFromCommand(*id, nullptr, 0);
|
||||||
}
|
}
|
||||||
case (FwBootState::LOGLEVEL): {
|
case (FwBootState::LOGLEVEL): {
|
||||||
@ -465,7 +465,8 @@ ReturnValue_t StarTrackerHandler::buildCommandFromCommand(DeviceCommandId_t devi
|
|||||||
preparePingRequest();
|
preparePingRequest();
|
||||||
return returnvalue::OK;
|
return returnvalue::OK;
|
||||||
}
|
}
|
||||||
case (startracker::SET_TIME): {
|
case (startracker::SET_TIME_FROM_SYS_TIME): {
|
||||||
|
// Might be buggy, need more answers from arcsec...
|
||||||
SetTimeActionRequest setTimeRequest{};
|
SetTimeActionRequest setTimeRequest{};
|
||||||
timeval tv;
|
timeval tv;
|
||||||
Clock::getClock(&tv);
|
Clock::getClock(&tv);
|
||||||
@ -674,7 +675,7 @@ void StarTrackerHandler::fillCommandAndReplyMap() {
|
|||||||
startracker::MAX_FRAME_SIZE * 2 + 2);
|
startracker::MAX_FRAME_SIZE * 2 + 2);
|
||||||
this->insertInCommandAndReplyMap(startracker::LOGLEVEL, 3, nullptr,
|
this->insertInCommandAndReplyMap(startracker::LOGLEVEL, 3, nullptr,
|
||||||
startracker::MAX_FRAME_SIZE * 2 + 2);
|
startracker::MAX_FRAME_SIZE * 2 + 2);
|
||||||
this->insertInCommandAndReplyMap(startracker::SET_TIME, 3, nullptr,
|
this->insertInCommandAndReplyMap(startracker::SET_TIME_FROM_SYS_TIME, 3, nullptr,
|
||||||
startracker::MAX_FRAME_SIZE * 2 + 2);
|
startracker::MAX_FRAME_SIZE * 2 + 2);
|
||||||
this->insertInCommandAndReplyMap(startracker::LOGSUBSCRIPTION, 3, nullptr,
|
this->insertInCommandAndReplyMap(startracker::LOGSUBSCRIPTION, 3, nullptr,
|
||||||
startracker::MAX_FRAME_SIZE * 2 + 2);
|
startracker::MAX_FRAME_SIZE * 2 + 2);
|
||||||
@ -890,7 +891,7 @@ ReturnValue_t StarTrackerHandler::scanForReply(const uint8_t* start, size_t rema
|
|||||||
switch (startracker::getReplyFrameType(start)) {
|
switch (startracker::getReplyFrameType(start)) {
|
||||||
case TMTC_ACTIONREPLY: {
|
case TMTC_ACTIONREPLY: {
|
||||||
*foundLen = remainingSize;
|
*foundLen = remainingSize;
|
||||||
arrayprinter::print(start, remainingSize);
|
// arrayprinter::print(start, remainingSize);
|
||||||
return scanForActionReply(startracker::getId(start), foundId);
|
return scanForActionReply(startracker::getId(start), foundId);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -923,7 +924,7 @@ ReturnValue_t StarTrackerHandler::interpretDeviceReply(DeviceCommandId_t id,
|
|||||||
ReturnValue_t result = returnvalue::OK;
|
ReturnValue_t result = returnvalue::OK;
|
||||||
|
|
||||||
switch (id) {
|
switch (id) {
|
||||||
case (startracker::SET_TIME): {
|
case (startracker::SET_TIME_FROM_SYS_TIME): {
|
||||||
result = handleActionReply(packet);
|
result = handleActionReply(packet);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1394,7 +1395,7 @@ ReturnValue_t StarTrackerHandler::scanForActionReply(uint8_t replyId, DeviceComm
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case (ARC_ACTION_REQ_SETTIME_ID): {
|
case (ARC_ACTION_REQ_SETTIME_ID): {
|
||||||
*foundId = startracker::SET_TIME;
|
*foundId = startracker::SET_TIME_FROM_SYS_TIME;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case (startracker::ID::CHECKSUM): {
|
case (startracker::ID::CHECKSUM): {
|
||||||
|
@ -326,7 +326,7 @@ static const DeviceCommandId_t DEBUG_CAMERA = 83;
|
|||||||
static const DeviceCommandId_t FIRMWARE_UPDATE = 84;
|
static const DeviceCommandId_t FIRMWARE_UPDATE = 84;
|
||||||
static const DeviceCommandId_t DISABLE_TIMESTAMP_GENERATION = 85;
|
static const DeviceCommandId_t DISABLE_TIMESTAMP_GENERATION = 85;
|
||||||
static const DeviceCommandId_t ENABLE_TIMESTAMP_GENERATION = 86;
|
static const DeviceCommandId_t ENABLE_TIMESTAMP_GENERATION = 86;
|
||||||
static constexpr DeviceCommandId_t SET_TIME = 87;
|
static constexpr DeviceCommandId_t SET_TIME_FROM_SYS_TIME = 87;
|
||||||
static const DeviceCommandId_t NONE = 0xFFFFFFFF;
|
static const DeviceCommandId_t NONE = 0xFFFFFFFF;
|
||||||
|
|
||||||
static const uint32_t VERSION_SET_ID = REQ_VERSION;
|
static const uint32_t VERSION_SET_ID = REQ_VERSION;
|
||||||
|
2
tmtc
2
tmtc
@ -1 +1 @@
|
|||||||
Subproject commit 9be81f1725004b55e937718fbaddc4f4e4e74081
|
Subproject commit 1f2f2aac13b0b32c22f0a75e557743ad32f7dc70
|
Loading…
Reference in New Issue
Block a user