star tracker read temperature and included arcsec lib

This commit is contained in:
Jakob.Meier 2021-07-08 11:20:19 +02:00
parent 6ea1600497
commit b66de77a72
9 changed files with 47 additions and 64 deletions

6
.gitmodules vendored
View File

@ -19,6 +19,6 @@
[submodule "generators/fsfwgen"]
path = generators/fsfwgen
url = https://egit.irs.uni-stuttgart.de/fsfw/fsfw-generators.git
[submodule "arcsec-start-tracker"]
path = arcsec-start-tracker
url = https://egit.irs.uni-stuttgart.de/eive/arcsec-star-tracker.git
[submodule "thirdparty/arcsec_star_tracker"]
path = thirdparty/arcsec_star_tracker
url = https://egit.irs.uni-stuttgart.de/eive/arcsec_star_tracker.git

View File

@ -50,6 +50,7 @@ set(LIB_ETL_NAME etl)
set(LIB_CSP_NAME libcsp)
set(LIB_FSFW_HAL_NAME fsfw_hal)
set(LIB_LWGPS_NAME lwgps)
set(LIB_ARCSEC wire)
set(THIRD_PARTY_FOLDER thirdparty)
# Set path names
@ -64,6 +65,7 @@ set(FSFW_HAL_LIB_PATH fsfw_hal)
set(CSP_LIB_PATH ${THIRD_PARTY_FOLDER}/libcsp)
set(ETL_LIB_PATH ${THIRD_PARTY_FOLDER}/etl)
set(LWGPS_LIB_PATH ${THIRD_PARTY_FOLDER}/lwgps)
set(ARCSEC_LIB_PATH ${THIRD_PARTY_FOLDER}/arcsec_star_tracker)
set(FSFW_WARNING_SHADOW_LOCAL_GCC OFF)
set(ADD_LINUX_FILES False)
@ -148,6 +150,7 @@ if(NOT Q7S_SIMPLE_MODE)
add_subdirectory(${MISSION_PATH})
add_subdirectory(${TEST_PATH})
add_subdirectory(${FSFW_HAL_LIB_PATH})
add_subdirectory(${ARCSEC_LIB_PATH})
endif()
@ -164,6 +167,7 @@ if(NOT Q7S_SIMPLE_MODE)
${LIB_OS_NAME}
${LIB_LWGPS_NAME}
${LIB_FSFW_HAL_NAME}
${LIB_ARCSEC}
)
endif()
@ -184,6 +188,7 @@ target_include_directories(${TARGET_NAME} PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}
${FSFW_CONFIG_PATH}
${CMAKE_CURRENT_BINARY_DIR}
${ARCSEC_LIB_PATH}
)

@ -1 +0,0 @@
Subproject commit 7103370d15c19a843e40dc880a29ace51f348f92

View File

@ -622,7 +622,7 @@ void ObjectFactory::produce(void* args){
rw4SpiCookie->setCallbackArgs(rwHandler4);
UartCookie* starTrackerCookie = new UartCookie(objects::START_TRACKER, std::string("/dev/ttyUL3"),
UartModes::NON_CANONICAL, 115200, StartTracker::MAX_FRAME_SIZE* 2 + 2);
UartModes::NON_CANONICAL, 115200, StarTracker::MAX_FRAME_SIZE* 2 + 2);
starTrackerCookie->setNoFixedSizeReply();
new StarTrackerHandler(objects::START_TRACKER, objects::UART_COM_IF, starTrackerCookie);

View File

@ -16,6 +16,7 @@ target_sources(${TARGET_NAME} PUBLIC
RadiationSensorHandler.cpp
GyroADIS16507Handler.cpp
RwHandler.cpp
StarTrackerHandler.cpp
)

View File

@ -4,10 +4,13 @@
#include <fsfw/globalfunctions/CRC.h>
#include <fsfw/datapool/PoolReadGuard.h>
#include <arcsec-start-tracker/client/generated/telemetry.h>
extern "C" {
#include <thirdparty/arcsec_star_tracker/client/generated/telemetry.h>
#include "common/misc.h"
}
StarTrackerHandler::StarTrackerHandler(object_id_t objectId, object_id_t comIF,
CookieIF * comCookie, LinuxLibgpioIF* gpioComIF, gpioId_t enableGpio) :
CookieIF * comCookie) :
DeviceHandlerBase(objectId, comIF, comCookie), temperatureSet(this) {
if (comCookie == NULL) {
sif::error << "StarTrackerHandler: Invalid com cookie" << std::endl;
@ -34,7 +37,7 @@ void StarTrackerHandler::doShutDown() {
ReturnValue_t StarTrackerHandler::buildNormalDeviceCommand(DeviceCommandId_t * id) {
switch (internalState) {
case InternalState::TEMPERATURE_REQUEST:
*id = StartTracker::REQ_TEMPERATURE;
*id = StarTracker::REQ_TEMPERATURE;
break;
default:
sif::debug << "StarTrackerHandler::buildNormalDeviceCommand: Invalid internal step"
@ -52,7 +55,7 @@ ReturnValue_t StarTrackerHandler::buildCommandFromCommand(DeviceCommandId_t devi
const uint8_t * commandData, size_t commandDataLen) {
switch (deviceCommand) {
case (StartTracker::REQ_TEMPERATURE): {
case (StarTracker::REQ_TEMPERATURE): {
prepareTemperatureRequest();
return RETURN_OK;
}
@ -65,8 +68,8 @@ ReturnValue_t StarTrackerHandler::buildCommandFromCommand(DeviceCommandId_t devi
void StarTrackerHandler::fillCommandAndReplyMap() {
/** Reply lengths are unknown because of the slip encoding. Thus always maximum reply size
* is specified */
this->insertInCommandAndReplyMap(StartTracker::REQ_TEMPERATURE, 1, &temperatureSet,
sStartTracker::MAX_FRAME_SIZE * 2 + 2);
this->insertInCommandAndReplyMap(StarTracker::REQ_TEMPERATURE, 1, &temperatureSet,
StarTracker::MAX_FRAME_SIZE * 2 + 2);
}
ReturnValue_t StarTrackerHandler::scanForReply(const uint8_t *start, size_t remainingSize,
@ -74,8 +77,8 @@ ReturnValue_t StarTrackerHandler::scanForReply(const uint8_t *start, size_t rema
uint32_t decodedLength = 0;
for (int i = 0; i < remainingSize; i++) {
enum arc_dec_result decResult = arc_transport_decode_body(*(start + i), &slipInfo,
for (size_t idx = 0; idx < remainingSize; idx++) {
enum arc_dec_result decResult = arc_transport_decode_body(*(start + idx), &slipInfo,
decodedFrame, &decodedLength);
switch (decResult) {
@ -102,10 +105,10 @@ ReturnValue_t StarTrackerHandler::scanForReply(const uint8_t *start, size_t rema
}
}
switch (*(decodedFrame[1])) {
case (static_cast<uint8_t>(StartTracker::REQ_TEMPERATURE)): {
switch (decodedFrame[1]) {
case (static_cast<uint8_t>(StarTracker::REQ_TEMPERATURE)): {
*foundLen = decodedLength;
*foundId = StartTracker::REQ_TEMPERATURE;
*foundId = StarTracker::REQ_TEMPERATURE;
break;
}
default: {
@ -122,7 +125,7 @@ ReturnValue_t StarTrackerHandler::scanForReply(const uint8_t *start, size_t rema
ReturnValue_t StarTrackerHandler::interpretDeviceReply(DeviceCommandId_t id, const uint8_t *packet) {
switch (id) {
case (StartTracker::REQ_TEMPERATURE): {
case (StarTracker::REQ_TEMPERATURE): {
handleTemperatureTm();
break;
}
@ -146,38 +149,11 @@ uint32_t StarTrackerHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo
ReturnValue_t StarTrackerHandler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
LocalDataPoolManager& poolManager) {
localDataPoolMap.emplace(RwDefinitions::TEMPERATURE_C, new PoolEntry<int32_t>( { 0 }));
localDataPoolMap.emplace(RwDefinitions::CURR_SPEED, new PoolEntry<int32_t>( { 0 }));
localDataPoolMap.emplace(RwDefinitions::REFERENCE_SPEED, new PoolEntry<int32_t>( { 0 }));
localDataPoolMap.emplace(RwDefinitions::STATE, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(RwDefinitions::CLC_MODE, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(RwDefinitions::LAST_RESET_STATUS, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(RwDefinitions::CURRRENT_RESET_STATUS, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(RwDefinitions::TM_LAST_RESET_STATUS, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(RwDefinitions::TM_MCU_TEMPERATURE, new PoolEntry<int32_t>( { 0 }));
localDataPoolMap.emplace(RwDefinitions::TM_RW_STATE, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(RwDefinitions::TM_CLC_MODE, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(RwDefinitions::TM_RW_CURR_SPEED, new PoolEntry<int32_t>( { 0 }));
localDataPoolMap.emplace(RwDefinitions::TM_RW_REF_SPEED, new PoolEntry<int32_t>( { 0 }));
localDataPoolMap.emplace(RwDefinitions::INVALID_CRC_PACKETS, new PoolEntry<uint32_t>( { 0 }));
localDataPoolMap.emplace(RwDefinitions::INVALID_LEN_PACKETS, new PoolEntry<uint32_t>( { 0 }));
localDataPoolMap.emplace(RwDefinitions::INVALID_CMD_PACKETS, new PoolEntry<uint32_t>( { 0 }));
localDataPoolMap.emplace(RwDefinitions::EXECUTED_REPLIES, new PoolEntry<uint32_t>( { 0 }));
localDataPoolMap.emplace(RwDefinitions::COMMAND_REPLIES, new PoolEntry<uint32_t>( { 0 }));
localDataPoolMap.emplace(RwDefinitions::UART_BYTES_WRITTEN, new PoolEntry<uint32_t>( { 0 }));
localDataPoolMap.emplace(RwDefinitions::UART_BYTES_READ, new PoolEntry<uint32_t>( { 0 }));
localDataPoolMap.emplace(RwDefinitions::UART_PARITY_ERRORS, new PoolEntry<uint32_t>( { 0 }));
localDataPoolMap.emplace(RwDefinitions::UART_NOISE_ERRORS, new PoolEntry<uint32_t>( { 0 }));
localDataPoolMap.emplace(RwDefinitions::UART_FRAME_ERRORS, new PoolEntry<uint32_t>( { 0 }));
localDataPoolMap.emplace(RwDefinitions::UART_REG_OVERRUN_ERRORS, new PoolEntry<uint32_t>( { 0 }));
localDataPoolMap.emplace(RwDefinitions::UART_TOTAL_ERRORS, new PoolEntry<uint32_t>( { 0 }));
localDataPoolMap.emplace(RwDefinitions::SPI_BYTES_WRITTEN, new PoolEntry<uint32_t>( { 0 }));
localDataPoolMap.emplace(RwDefinitions::SPI_BYTES_READ, new PoolEntry<uint32_t>( { 0 }));
localDataPoolMap.emplace(RwDefinitions::SPI_REG_OVERRUN_ERRORS, new PoolEntry<uint32_t>( { 0 }));
localDataPoolMap.emplace(RwDefinitions::SPI_TOTAL_ERRORS, new PoolEntry<uint32_t>( { 0 }));
localDataPoolMap.emplace(StarTracker::STATUS, new PoolEntry<uint8_t>( { 0 }));
localDataPoolMap.emplace(StarTracker::TICKS, new PoolEntry<uint32_t>( { 0 }));
localDataPoolMap.emplace(StarTracker::TIME, new PoolEntry<uint64_t>( { 0 }));
localDataPoolMap.emplace(StarTracker::MCU_TEMPERATURE, new PoolEntry<float>( { 0 }));
localDataPoolMap.emplace(StarTracker::CMOS_TEMPERATURE, new PoolEntry<float>( { 0 }));
return RETURN_OK;
}
@ -188,7 +164,7 @@ size_t StarTrackerHandler::getNextReplyLength(DeviceCommandId_t commandId){
void StarTrackerHandler::slipInit() {
slipInfo.buffer = rxBuffer;
slipInfo.maxlength = StartTracker::MAX_FRAME_SIZE;
slipInfo.maxlength = StarTracker::MAX_FRAME_SIZE;
slipInfo.length = 0;
slipInfo.unescape_next = 0;
slipInfo.prev_state = SLIP_COMPLETE;
@ -196,7 +172,7 @@ void StarTrackerHandler::slipInit() {
void StarTrackerHandler::prepareTemperatureRequest() {
uint32_t length = 0;
arc_tm_pack_temperature_req(commandBuffer);
arc_tm_pack_temperature_req(commandBuffer, &length);
uint32_t encLength = 0;
arc_transport_encode_body(commandBuffer, length, encBuffer, &encLength);
rawPacket = encBuffer;
@ -210,15 +186,17 @@ void StarTrackerHandler::handleTemperatureTm() {
offset += 1;
if(temperatureSet.status.value != 0) {
sif::warning << "StarTrackerHandler::handleTemperatureTm: Reply error: "
<< static_const<unsigned int>(temperatureSet.status.value) << std::endl;
<< static_cast<unsigned int>(temperatureSet.status.value) << std::endl;
triggerEvent(TM_REPLY_ERROR, temperatureSet.status.value);
}
temperatureSet.ticks = *(decodedFrame + offset) << 24
| *(decodedFrame + offset + 1) << 16 | *(decodedFrame + offset + 2) << 8
| *(decodedFrame + offset + 3);
offset += 4;
temperatureSet.time = *(decodedFrame + offset) << 56 | *(decodedFrame + offset + 1) << 48
| *(decodedFrame + offset + 2) << 40 | *(decodedFrame + offset + 3) << 32
temperatureSet.time = static_cast<uint64_t>(*(decodedFrame + offset)) << 56
| static_cast<uint64_t>(*(decodedFrame + offset + 1)) << 48
| static_cast<uint64_t>(*(decodedFrame + offset + 2)) << 40
| static_cast<uint64_t>(*(decodedFrame + offset + 3)) << 32
| *(decodedFrame + offset + 4) << 24 | *(decodedFrame + offset + 5) << 16
| *(decodedFrame + offset + 6) << 8 | *(decodedFrame + offset + 7);
offset += 8;

View File

@ -3,6 +3,7 @@
#include <fsfw/devicehandlers/DeviceHandlerBase.h>
#include <mission/devices/devicedefinitions/StarTrackerDefinitions.h>
#include <thirdparty/arcsec_star_tracker/common/SLIP.h>
/**
* @brief This is the device handler for the star tracker from arcsec.
@ -58,6 +59,7 @@ private:
//! [EXPORT] : [COMMENT] Received reply is too short
static const ReturnValue_t REPLY_TOO_SHORT = MAKE_RETURN_CODE(0xB0);
//! [EXPORT] : [COMMENT] Received reply with invalid CRC
static const ReturnValue_t CRC_FAILURE = MAKE_RETURN_CODE(0xB0);
static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::STR_HANDLER;
@ -65,19 +67,16 @@ private:
static const ReturnValue_t TM_REPLY_ERROR = MAKE_RETURN_CODE(0xA0);
//! P1: TM id
LinuxLibgpioIF* gpioComIF = nullptr;
gpioId_t enableGpio = gpio::NO_GPIO;
StarTracker::TemperatureSet temperatureSet;
uint8_t commandBuffer[StartTracker::MAX_FRAME_SIZE];
uint8_t rxBuffer[StartTracker::MAX_FRAME_SIZE];
uint8_t decodedFrame[StartTracker::MAX_FRAME_SIZE];
uint8_t commandBuffer[StarTracker::MAX_FRAME_SIZE];
uint8_t rxBuffer[StarTracker::MAX_FRAME_SIZE];
uint8_t decodedFrame[StarTracker::MAX_FRAME_SIZE];
/** Size of buffer derived from the egse source code */
uint8_t encBuffer[StartTracker::MAX_FRAME_SIZE * 2 + 2];
uint8_t encBuffer[StarTracker::MAX_FRAME_SIZE * 2 + 2];
static slip_decode_state slipInfo = {0};
slip_decode_state slipInfo;
enum class InternalState {
TEMPERATURE_REQUEST
@ -90,7 +89,7 @@ private:
*/
void slipInit();
void prepareTemperatureRequest(DeviceCommandId_t id);
void prepareTemperatureRequest();
/**
* @brief This function handles the telemetry reply of a temperature request.

View File

@ -50,7 +50,7 @@ public:
lp_var_t<uint32_t> ticks = lp_var_t<uint32_t>(sid.objectId,
PoolIds::TICKS, this);
/** Unix time in microseconds */
lp_var_t<uint64_t> ticks = lp_var_t<uint64_t>(sid.objectId,
lp_var_t<uint64_t> time = lp_var_t<uint64_t>(sid.objectId,
PoolIds::TIME, this);
lp_var_t<float> mcuTemperature = lp_var_t<float>(sid.objectId,
PoolIds::MCU_TEMPERATURE, this);

1
thirdparty/arcsec_star_tracker vendored Submodule

@ -0,0 +1 @@
Subproject commit 65dfee8191cd0254d4988b08c9607024389e2b08