From 5ae6a61ec0bd3f2fd9fef0453387b83185cdf7df Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 15 Dec 2021 10:15:06 +0100 Subject: [PATCH] fixes for gyro adis handler --- linux/fsfwconfig/OBSWConfig.h.in | 4 ++-- mission/devices/GyroADIS1650XHandler.cpp | 20 ++++++++++---------- mission/devices/GyroADIS1650XHandler.h | 6 +++--- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/linux/fsfwconfig/OBSWConfig.h.in b/linux/fsfwconfig/OBSWConfig.h.in index 663ef00b..a95bbfd5 100644 --- a/linux/fsfwconfig/OBSWConfig.h.in +++ b/linux/fsfwconfig/OBSWConfig.h.in @@ -115,8 +115,8 @@ debugging. */ /*******************************************************************/ /** Hardcoded */ /*******************************************************************/ -// Leave at one as the BSP is linux. Used by the ADIS16507 device handler -#define OBSW_ADIS16507_LINUX_COM_IF 1 +// Leave at one as the BSP is linux. Used by the ADIS1650X device handler +#define OBSW_ADIS1650X_LINUX_COM_IF 1 #include "OBSWVersion.h" diff --git a/mission/devices/GyroADIS1650XHandler.cpp b/mission/devices/GyroADIS1650XHandler.cpp index 4acf9196..6124fc10 100644 --- a/mission/devices/GyroADIS1650XHandler.cpp +++ b/mission/devices/GyroADIS1650XHandler.cpp @@ -185,7 +185,7 @@ void GyroADIS1650XHandler::fillCommandAndReplyMap() { ReturnValue_t GyroADIS1650XHandler::scanForReply(const uint8_t *start, size_t remainingSize, DeviceCommandId_t *foundId, size_t *foundLen) { - /* For SPI, the ID will always be the one of the last sent command. */ + // For SPI, the ID will always be the one of the last sent command *foundId = this->getPendingCommand(); *foundLen = this->rawPacketLen; @@ -196,18 +196,19 @@ ReturnValue_t GyroADIS1650XHandler::interpretDeviceReply(DeviceCommandId_t id, const uint8_t *packet) { switch(id) { case(ADIS1650X::READ_OUT_CONFIG): { - PoolReadGuard rg(&configDataset); + uint16_t readProdId = packet[10] << 8 | packet[11]; if(((adisType == ADIS1650X::Type::ADIS16507) and (readProdId != ADIS1650X::PROD_ID_16507)) or ((adisType == ADIS1650X::Type::ADIS16505) and (readProdId != ADIS1650X::PROD_ID_16505))) { #if OBSW_VERBOSE_LEVEL >= 1 - sif::warning << "GyroADIS16507Handler::interpretDeviceReply: Invalid product ID " + sif::warning << "GyroADIS1650XHandler::interpretDeviceReply: Invalid product ID " << readProdId << std::endl; #endif return HasReturnvaluesIF::RETURN_FAILED; } + PoolReadGuard rg(&configDataset); configDataset.diagStatReg.value = packet[2] << 8 | packet[3]; configDataset.filterSetting.value = packet[4] << 8 | packet[5]; configDataset.mscCtrlReg.value = packet[6] << 8 | packet[7]; @@ -232,21 +233,20 @@ ReturnValue_t GyroADIS1650XHandler::handleSensorData(const uint8_t *packet) { switch(burstMode) { case(BurstModes::BURST_16_BURST_SEL_1): case(BurstModes::BURST_32_BURST_SEL_1): { - sif::warning << "GyroADIS16507Handler::interpretDeviceReply: Analysis with BURST_SEL1" + sif::warning << "GyroADIS1650XHandler::interpretDeviceReply: Analysis with BURST_SEL1" " not implemented!" << std::endl; return HasReturnvaluesIF::RETURN_OK; } case(BurstModes::BURST_16_BURST_SEL_0): { uint16_t checksum = packet[20] << 8 | packet[21]; - /* Now verify the read checksum with the expected checksum - according to datasheet p. 20 */ + // Now verify the read checksum with the expected checksum according to datasheet p. 20 uint16_t calcChecksum = 0; for(size_t idx = 2; idx < 20; idx ++) { calcChecksum += packet[idx]; } if(checksum != calcChecksum) { #if OBSW_VERBOSE_LEVEL >= 1 - sif::warning << "GyroADIS16507Handler::interpretDeviceReply: " + sif::warning << "GyroADIS1650XHandler::interpretDeviceReply: " "Invalid checksum detected!" << std::endl; #endif return HasReturnvaluesIF::RETURN_FAILED; @@ -277,7 +277,7 @@ ReturnValue_t GyroADIS1650XHandler::handleSensorData(const uint8_t *packet) { } else if(adisType == ADIS1650X::Type::ADIS16505) { accelScaling = ADIS1650X::ACCELEROMETER_RANGE_16505; } else { - sif::warning << "GyroADIS16507Handler::handleSensorData: " + sif::warning << "GyroADIS1650XHandler::handleSensorData: " "Unknown ADIS type" << std::endl; } int16_t accelXRaw = packet[10] << 8 | packet[11]; @@ -298,11 +298,11 @@ ReturnValue_t GyroADIS1650XHandler::handleSensorData(const uint8_t *packet) { #if FSFW_HAL_ADIS1650X_GYRO_DEBUG == 1 if(debugDivider->checkAndIncrement()) { - sif::info << "GyroADIS16507Handler: Angular velocities in deg / s" << std::endl; + sif::info << "GyroADIS1650XHandler: Angular velocities in deg / s" << std::endl; sif::info << "X: " << primaryDataset.angVelocX.value << std::endl; sif::info << "Y: " << primaryDataset.angVelocY.value << std::endl; sif::info << "Z: " << primaryDataset.angVelocZ.value << std::endl; - sif::info << "GyroADIS16507Handler: Accelerations in m / s^2: " << std::endl; + sif::info << "GyroADIS1650XHandler: Accelerations in m / s^2: " << std::endl; sif::info << "X: " << primaryDataset.accelX.value << std::endl; sif::info << "Y: " << primaryDataset.accelY.value << std::endl; sif::info << "Z: " << primaryDataset.accelZ.value << std::endl; diff --git a/mission/devices/GyroADIS1650XHandler.h b/mission/devices/GyroADIS1650XHandler.h index 60adeabe..b1ac50f5 100644 --- a/mission/devices/GyroADIS1650XHandler.h +++ b/mission/devices/GyroADIS1650XHandler.h @@ -8,7 +8,7 @@ #include "fsfw/globalfunctions/PeriodicOperationDivider.h" #include "fsfw/devicehandlers/DeviceHandlerBase.h" -#if OBSW_ADIS16507_LINUX_COM_IF == 1 +#if OBSW_ADIS1650X_LINUX_COM_IF == 1 class SpiComIF; class SpiCookie; #endif @@ -24,7 +24,7 @@ public: GyroADIS1650XHandler(object_id_t objectId, object_id_t deviceCommunication, CookieIF* comCookie, ADIS1650X::Type type); - /* DeviceHandlerBase abstract function implementation */ + // DeviceHandlerBase abstract function implementation void doStartUp() override; void doShutDown() override; ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t * id) override; @@ -66,7 +66,7 @@ private: BurstModes getBurstMode(); -#if OBSW_ADIS16507_LINUX_COM_IF == 1 +#if OBSW_ADIS1650X_LINUX_COM_IF == 1 static ReturnValue_t spiSendCallback(SpiComIF* comIf, SpiCookie *cookie, const uint8_t *sendData, size_t sendLen, void* args); #endif