TAS PLOC SUPV 3 #326

Merged
muellerr merged 9 commits from mueller/tas_ploc_supv_3 into develop 2022-11-28 18:26:44 +01:00
5 changed files with 41 additions and 12 deletions
Showing only changes of commit 2c223712ff - Show all commits

View File

@ -60,7 +60,7 @@ static constexpr UartBaudRate SYRLINKS_BAUD = UartBaudRate::RATE_38400;
static constexpr UartBaudRate SCEX_BAUD = UartBaudRate::RATE_115200; static constexpr UartBaudRate SCEX_BAUD = UartBaudRate::RATE_115200;
static constexpr UartBaudRate GNSS_BAUD = UartBaudRate::RATE_9600; static constexpr UartBaudRate GNSS_BAUD = UartBaudRate::RATE_9600;
static constexpr UartBaudRate PLOC_MPSOC_BAUD = UartBaudRate::RATE_115200; static constexpr UartBaudRate PLOC_MPSOC_BAUD = UartBaudRate::RATE_115200;
static constexpr UartBaudRate PLOC_SUPV_BAUD = UartBaudRate::RATE_115200; static constexpr UartBaudRate PLOC_SUPV_BAUD = UartBaudRate::RATE_921600;
static constexpr UartBaudRate STAR_TRACKER_BAUD = UartBaudRate::RATE_921600; static constexpr UartBaudRate STAR_TRACKER_BAUD = UartBaudRate::RATE_921600;
} // namespace uart } // namespace uart

View File

@ -122,6 +122,7 @@ static const DeviceCommandId_t RESET_PL = 58;
static const DeviceCommandId_t ENABLE_NVMS = 59; static const DeviceCommandId_t ENABLE_NVMS = 59;
static const DeviceCommandId_t CONTINUE_UPDATE = 60; static const DeviceCommandId_t CONTINUE_UPDATE = 60;
static const DeviceCommandId_t MEMORY_CHECK_WITH_FILE = 61; static const DeviceCommandId_t MEMORY_CHECK_WITH_FILE = 61;
static constexpr DeviceCommandId_t MEMORY_CHECK = 62;
/** Reply IDs */ /** Reply IDs */
enum ReplyId : DeviceCommandId_t { enum ReplyId : DeviceCommandId_t {

View File

@ -411,6 +411,7 @@ void PlocSupervisorHandler::fillCommandAndReplyMap() {
insertInCommandMap(SET_GPIO); insertInCommandMap(SET_GPIO);
insertInCommandMap(READ_GPIO); insertInCommandMap(READ_GPIO);
insertInCommandMap(FACTORY_RESET); insertInCommandMap(FACTORY_RESET);
insertInCommandMap(MEMORY_CHECK);
insertInCommandMap(SET_SHUTDOWN_TIMEOUT); insertInCommandMap(SET_SHUTDOWN_TIMEOUT);
insertInCommandMap(FACTORY_FLASH); insertInCommandMap(FACTORY_FLASH);
insertInCommandMap(SET_ADC_ENABLED_CHANNELS); insertInCommandMap(SET_ADC_ENABLED_CHANNELS);
@ -421,6 +422,7 @@ void PlocSupervisorHandler::fillCommandAndReplyMap() {
// ACK replies, use countdown for them // ACK replies, use countdown for them
insertInReplyMap(ACK_REPORT, 0, nullptr, SIZE_ACK_REPORT, false, &acknowledgementReportTimeout); insertInReplyMap(ACK_REPORT, 0, nullptr, SIZE_ACK_REPORT, false, &acknowledgementReportTimeout);
insertInReplyMap(EXE_REPORT, 0, nullptr, SIZE_EXE_REPORT, false, &executionReportTimeout); insertInReplyMap(EXE_REPORT, 0, nullptr, SIZE_EXE_REPORT, false, &executionReportTimeout);
insertInReplyMap(MEMORY_CHECK, 5, nullptr, 0, false);
// TM replies // TM replies
insertInReplyMap(HK_REPORT, 3, &hkset, SIZE_HK_REPORT); insertInReplyMap(HK_REPORT, 3, &hkset, SIZE_HK_REPORT);
@ -507,6 +509,16 @@ ReturnValue_t PlocSupervisorHandler::enableReplyInReplyMap(DeviceCommandMap::ite
} }
break; break;
} }
case MEMORY_CHECK: {
enabledReplies = 3;
result =
DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true, MEMORY_CHECK);
if (result != returnvalue::OK) {
sif::debug << "PlocSupervisorHandler::enableReplyInReplyMap: Reply with id " << MEMORY_CHECK
<< " not in replyMap" << std::endl;
}
break;
}
case START_MPSOC: case START_MPSOC:
case SHUTDOWN_MPSOC: case SHUTDOWN_MPSOC:
case SEL_MPSOC_BOOT_IMAGE: case SEL_MPSOC_BOOT_IMAGE:
@ -625,10 +637,7 @@ ReturnValue_t PlocSupervisorHandler::scanForReply(const uint8_t* start, size_t r
static_cast<uint8_t>(supv::tm::MemManId::UPDATE_STATUS_REPORT)) { static_cast<uint8_t>(supv::tm::MemManId::UPDATE_STATUS_REPORT)) {
*foundLen = tmReader.getFullPacketLen(); *foundLen = tmReader.getFullPacketLen();
*foundId = ReplyId::UPDATE_STATUS_REPORT; *foundId = ReplyId::UPDATE_STATUS_REPORT;
// TODO: I think this will be handled by the uart manager? return OK;
// Actually, this is a bit tricky. Maybe the lower level will have two separate ring
// buffers, one for internally handled packets and one for packets which are handled
// here?
} }
} }
} }
@ -667,6 +676,10 @@ ReturnValue_t PlocSupervisorHandler::interpretDeviceReply(DeviceCommandId_t id,
result = handleExecutionReport(packet); result = handleExecutionReport(packet);
break; break;
} }
case (UPDATE_STATUS_REPORT): {
// TODO: handle status report here
break;
}
default: { default: {
sif::debug << "PlocSupervisorHandler::interpretDeviceReply: Unknown device reply id" sif::debug << "PlocSupervisorHandler::interpretDeviceReply: Unknown device reply id"
<< std::endl; << std::endl;

View File

@ -116,7 +116,9 @@ ReturnValue_t PlocSupvUartManager::performOperation(uint8_t operationCode) {
break; break;
} }
case InternalState::DEDICATED_REQUEST: { case InternalState::DEDICATED_REQUEST: {
updateVtime(1);
handleRunningLongerRequest(); handleRunningLongerRequest();
updateVtime(2);
MutexGuard mg(lock); MutexGuard mg(lock);
state = InternalState::DEFAULT; state = InternalState::DEFAULT;
break; break;
@ -380,9 +382,9 @@ ReturnValue_t PlocSupvUartManager::writeUpdatePackets() {
#endif /* OBSW_DEBUG_PLOC_SUPERVISOR == 1 */ #endif /* OBSW_DEBUG_PLOC_SUPERVISOR == 1 */
uint8_t tempData[supv::WriteMemory::CHUNK_MAX + 1]{}; uint8_t tempData[supv::WriteMemory::CHUNK_MAX + 1]{};
if (not std::filesystem::exists(update.file)) { if (not std::filesystem::exists(update.file)) {
sif::error << "PlocSupvUartManager::writeUpdatePackets: File " sif::error << "PlocSupvUartManager::writeUpdatePackets: File " << update.file
<< update.file << " does not exist" << std::endl; << " does not exist" << std::endl;
return HasFileSystemIF::FILE_DOES_NOT_EXIST; return HasFileSystemIF::FILE_DOES_NOT_EXIST;
} }
std::ifstream file(update.file, std::ifstream::binary); std::ifstream file(update.file, std::ifstream::binary);
uint16_t dataLength = 0; uint16_t dataLength = 0;
@ -553,6 +555,7 @@ ReturnValue_t PlocSupvUartManager::handlePacketTransmissionNoReply(
return result; return result;
} }
Countdown countdown(timeoutExecutionReport); Countdown countdown(timeoutExecutionReport);
dur_millis_t currentDelay = 5;
bool ackReceived = false; bool ackReceived = false;
bool packetWasHandled = false; bool packetWasHandled = false;
while (true) { while (true) {
@ -590,7 +593,10 @@ ReturnValue_t PlocSupvUartManager::handlePacketTransmissionNoReply(
decodedRingBuf.deleteData(packetLen); decodedRingBuf.deleteData(packetLen);
} }
} else { } else {
TaskFactory::delayTask(20); TaskFactory::delayTask(currentDelay);
if (currentDelay < 20) {
currentDelay *= 2;
}
} }
if (countdown.hasTimedOut()) { if (countdown.hasTimedOut()) {
return result::NO_REPLY_TIMEOUT; return result::NO_REPLY_TIMEOUT;
@ -1095,9 +1101,11 @@ void PlocSupvUartManager::addHdlcFraming(const uint8_t* src, size_t slen, uint8_
} }
size_t dummy = 0; size_t dummy = 0;
uint8_t crcRaw[2];
// hdlc crc16 is in little endian format // hdlc crc16 is in little endian format
SerializeAdapter::serialize(&crc16, dst + tlen, &dummy, maxDest, SerializeIF::Endianness::LITTLE); SerializeAdapter::serialize(&crc16, crcRaw, &dummy, maxDest, SerializeIF::Endianness::LITTLE);
tlen += dummy; hdlc_add_byte(crcRaw[0], dst, &tlen);
hdlc_add_byte(crcRaw[1], dst, &tlen);
dst[tlen++] = 0x7C; dst[tlen++] = 0x7C;
*dlen = tlen; *dlen = tlen;
@ -1141,3 +1149,9 @@ bool PlocSupvUartManager::longerRequestActive() const {
MutexGuard mg(lock); MutexGuard mg(lock);
return state == InternalState::DEDICATED_REQUEST; return state == InternalState::DEDICATED_REQUEST;
} }
void PlocSupvUartManager::updateVtime(uint8_t vtime) {
tcgetattr(serialPort, &tty);
tty.c_cc[VTIME] = vtime;
tcsetattr(serialPort, TCSANOW, &tty);
}

View File

@ -253,7 +253,7 @@ class PlocSupvUartManager : public DeviceCommunicationIF,
std::array<uint8_t, supv::MAX_COMMAND_SIZE> tmBuf{}; std::array<uint8_t, supv::MAX_COMMAND_SIZE> tmBuf{};
bool printTc = true; bool printTc = false;
bool debugMode = false; bool debugMode = false;
bool timestamping = true; bool timestamping = true;
@ -368,6 +368,7 @@ class PlocSupvUartManager : public DeviceCommunicationIF,
ReturnValue_t readReceivedMessage(CookieIF* cookie, uint8_t** buffer, size_t* size) override; ReturnValue_t readReceivedMessage(CookieIF* cookie, uint8_t** buffer, size_t* size) override;
void performUartShutdown(); void performUartShutdown();
void updateVtime(uint8_t vtime);
}; };
#endif /* BSP_Q7S_DEVICES_PLOCSUPVHELPER_H_ */ #endif /* BSP_Q7S_DEVICES_PLOCSUPVHELPER_H_ */