v1.9.0 #175
@ -248,6 +248,8 @@ void initmission::createPstTasks(TaskFactory& factory,
|
|||||||
sif::error << "InitMission::initTasks: Creating PST failed!" << std::endl;
|
sif::error << "InitMission::initTasks: Creating PST failed!" << std::endl;
|
||||||
}
|
}
|
||||||
taskVec.push_back(gpioPst);
|
taskVec.push_back(gpioPst);
|
||||||
|
|
||||||
|
#if OBSW_ADD_I2C_TEST_CODE == 0
|
||||||
FixedTimeslotTaskIF* i2cPst = factory.createFixedTimeslotTask(
|
FixedTimeslotTaskIF* i2cPst = factory.createFixedTimeslotTask(
|
||||||
"I2C_PST", 70, PeriodicTaskIF::MINIMUM_STACK_SIZE * 4, 0.2, missedDeadlineFunc);
|
"I2C_PST", 70, PeriodicTaskIF::MINIMUM_STACK_SIZE * 4, 0.2, missedDeadlineFunc);
|
||||||
result = pst::pstI2c(i2cPst);
|
result = pst::pstI2c(i2cPst);
|
||||||
@ -255,6 +257,7 @@ void initmission::createPstTasks(TaskFactory& factory,
|
|||||||
sif::error << "InitMission::initTasks: Creating PST failed!" << std::endl;
|
sif::error << "InitMission::initTasks: Creating PST failed!" << std::endl;
|
||||||
}
|
}
|
||||||
taskVec.push_back(i2cPst);
|
taskVec.push_back(i2cPst);
|
||||||
|
#endif
|
||||||
|
|
||||||
FixedTimeslotTaskIF* gomSpacePstTask = factory.createFixedTimeslotTask(
|
FixedTimeslotTaskIF* gomSpacePstTask = factory.createFixedTimeslotTask(
|
||||||
"GS_PST_TASK", 70, PeriodicTaskIF::MINIMUM_STACK_SIZE * 4, 1.0, missedDeadlineFunc);
|
"GS_PST_TASK", 70, PeriodicTaskIF::MINIMUM_STACK_SIZE * 4, 1.0, missedDeadlineFunc);
|
||||||
@ -348,7 +351,7 @@ void initmission::createTestTasks(TaskFactory& factory,
|
|||||||
TaskDeadlineMissedFunction missedDeadlineFunc,
|
TaskDeadlineMissedFunction missedDeadlineFunc,
|
||||||
std::vector<PeriodicTaskIF*>& taskVec) {
|
std::vector<PeriodicTaskIF*>& taskVec) {
|
||||||
#if OBSW_ADD_TEST_TASK == 1 || OBSW_ADD_SPI_TEST_CODE == 1 || \
|
#if OBSW_ADD_TEST_TASK == 1 || OBSW_ADD_SPI_TEST_CODE == 1 || \
|
||||||
(BOARD_TE0720 == 1 && OBSW_TEST_LIBGPIOD == 1)
|
OBSW_ADD_I2C_TEST_CODE == 1 || (BOARD_TE0720 == 1 && OBSW_TEST_LIBGPIOD == 1)
|
||||||
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
|
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
|
||||||
#endif
|
#endif
|
||||||
PeriodicTaskIF* testTask = factory.createPeriodicTask(
|
PeriodicTaskIF* testTask = factory.createPeriodicTask(
|
||||||
@ -366,6 +369,12 @@ void initmission::createTestTasks(TaskFactory& factory,
|
|||||||
initmission::printAddObjectError("SPI_TEST", objects::SPI_TEST);
|
initmission::printAddObjectError("SPI_TEST", objects::SPI_TEST);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
#if OBSW_ADD_I2C_TEST_CODE == 1
|
||||||
|
result = testTask->addComponent(objects::I2C_TEST);
|
||||||
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
|
initmission::printAddObjectError("I2C_TEST", objects::I2C_TEST);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
#if BOARD_TE0720 == 1 && OBSW_TEST_LIBGPIOD == 1
|
#if BOARD_TE0720 == 1 && OBSW_TEST_LIBGPIOD == 1
|
||||||
result = testTask->addComponent(objects::LIBGPIOD_TEST);
|
result = testTask->addComponent(objects::LIBGPIOD_TEST);
|
||||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
#include <linux/boardtest/I2cTestClass.h>
|
||||||
#include "ObjectFactory.h"
|
#include "ObjectFactory.h"
|
||||||
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
@ -1130,4 +1131,7 @@ void ObjectFactory::createTestComponents(LinuxLibgpioIF* gpioComIF) {
|
|||||||
#if OBSW_ADD_SPI_TEST_CODE == 1
|
#if OBSW_ADD_SPI_TEST_CODE == 1
|
||||||
new SpiTestClass(objects::SPI_TEST, gpioComIF);
|
new SpiTestClass(objects::SPI_TEST, gpioComIF);
|
||||||
#endif
|
#endif
|
||||||
|
#if OBSW_ADD_I2C_TEST_CODE == 1
|
||||||
|
new I2cTestClass(objects::I2C_TEST, q7s::I2C_DEFAULT_DEV);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
2
fsfw
2
fsfw
@ -1 +1 @@
|
|||||||
Subproject commit fca48257b7a156f4563d5a5a6ca71b0ab98bb9fc
|
Subproject commit b3151a0ba033e7c72c3ead1e8958d7be596baa45
|
@ -1,5 +1,100 @@
|
|||||||
#include <linux/boardtest/I2cTestClass.h>
|
#include "I2cTestClass.h"
|
||||||
|
#include <fsfw_hal/linux/UnixFileGuard.h>
|
||||||
|
#include "fsfw/serviceinterface.h"
|
||||||
|
#include "fsfw/globalfunctions/arrayprinter.h"
|
||||||
|
|
||||||
I2cTestClass::I2cTestClass(object_id_t objectId) : TestTask(objectId) {}
|
#include <sys/ioctl.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <linux/i2c-dev.h>
|
||||||
|
|
||||||
ReturnValue_t I2cTestClass::performPeriodicAction() { return HasReturnvaluesIF::RETURN_OK; }
|
I2cTestClass::I2cTestClass(object_id_t objectId, std::string i2cdev)
|
||||||
|
: TestTask(objectId), i2cdev(i2cdev) {
|
||||||
|
mode = TestModes::BPX_BATTERY;
|
||||||
|
}
|
||||||
|
|
||||||
|
ReturnValue_t I2cTestClass::initialize() {
|
||||||
|
if(mode == TestModes::BPX_BATTERY) {
|
||||||
|
battInit();
|
||||||
|
}
|
||||||
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
ReturnValue_t I2cTestClass::performPeriodicAction() {
|
||||||
|
if(mode == TestModes::BPX_BATTERY) {
|
||||||
|
battPeriodic();
|
||||||
|
}
|
||||||
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
void I2cTestClass::battInit() {
|
||||||
|
sif::info << "I2cTestClass: BPX Initialization" << std::endl;
|
||||||
|
UnixFileGuard fileHelper(i2cdev, &bpxInfo.fd, O_RDWR, "I2cTestClass::sendMessage");
|
||||||
|
if (fileHelper.getOpenResult() != HasReturnvaluesIF::RETURN_OK) {
|
||||||
|
sif::error << "Opening I2C device" << i2cdev << " failed" << std::endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(ioctl(bpxInfo.fd, I2C_SLAVE, bpxInfo.addr) < 0) {
|
||||||
|
sif::error << "Failed to acquire bus access and/or talk to slave" << std::endl;
|
||||||
|
}
|
||||||
|
cmdBuf[0] = BpxBattery::PORT_PING;
|
||||||
|
cmdBuf[1] = 0x42;
|
||||||
|
sendLen = 2;
|
||||||
|
ReturnValue_t result = i2cWrite(bpxInfo.fd, cmdBuf.data(), sendLen);
|
||||||
|
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Receive back port, error byte and ping reply
|
||||||
|
recvLen = 3;
|
||||||
|
result = i2cRead(bpxInfo.fd, replyBuf.data(), recvLen);
|
||||||
|
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
sif::info << "Ping reply:" << std::endl;
|
||||||
|
arrayprinter::print(replyBuf.data(), recvLen);
|
||||||
|
if(replyBuf[2] != 0x42) {
|
||||||
|
sif::warning << "Received ping reply not expected value 0x42" << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void I2cTestClass::battPeriodic() {
|
||||||
|
UnixFileGuard fileHelper(i2cdev, &bpxInfo.fd, O_RDWR, "I2cTestClass::sendMessage");
|
||||||
|
if (fileHelper.getOpenResult() != HasReturnvaluesIF::RETURN_OK) {
|
||||||
|
sif::error << "Opening I2C device" << i2cdev << " failed" << std::endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(ioctl(bpxInfo.fd, I2C_SLAVE, bpxInfo.addr) < 0) {
|
||||||
|
sif::error << "Failed to acquire bus access and/or talk to slave" << std::endl;
|
||||||
|
}
|
||||||
|
cmdBuf[0] = BpxBattery::PORT_GET_HK;
|
||||||
|
sendLen = 1;
|
||||||
|
ReturnValue_t result = i2cWrite(bpxInfo.fd, cmdBuf.data(), sendLen);
|
||||||
|
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Receive back HK set
|
||||||
|
recvLen = 23;
|
||||||
|
result = i2cRead(bpxInfo.fd, replyBuf.data(), recvLen);
|
||||||
|
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
sif::info << "HK reply:" << std::endl;
|
||||||
|
arrayprinter::print(replyBuf.data(), recvLen);
|
||||||
|
}
|
||||||
|
|
||||||
|
ReturnValue_t I2cTestClass::i2cWrite(int fd, uint8_t* data, size_t len) {
|
||||||
|
if (write(fd, data, len) != static_cast<ssize_t>(len)) {
|
||||||
|
sif::error << "Failed to write to I2C bus" << std::endl;
|
||||||
|
sif::error << "Error " << errno << ": " << strerror(errno) << std::endl;
|
||||||
|
return HasReturnvaluesIF::RETURN_FAILED;
|
||||||
|
}
|
||||||
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
ReturnValue_t I2cTestClass::i2cRead(int fd, uint8_t* data, size_t len) {
|
||||||
|
if( read (fd, data, len) != static_cast<ssize_t>(len)) {
|
||||||
|
sif::error << "Failed to read from I2C bus" << std::endl;
|
||||||
|
sif::error << "Error " << errno << ": " << strerror(errno) << std::endl;
|
||||||
|
return HasReturnvaluesIF::RETURN_FAILED;
|
||||||
|
}
|
||||||
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
|
}
|
||||||
|
@ -3,13 +3,40 @@
|
|||||||
|
|
||||||
#include <test/testtasks/TestTask.h>
|
#include <test/testtasks/TestTask.h>
|
||||||
|
|
||||||
|
#include "mission/devices/devicedefinitions/BpxBatteryDefinitions.h"
|
||||||
|
#include <string>
|
||||||
|
#include <array>
|
||||||
|
|
||||||
class I2cTestClass : public TestTask {
|
class I2cTestClass : public TestTask {
|
||||||
public:
|
public:
|
||||||
I2cTestClass(object_id_t objectId);
|
I2cTestClass(object_id_t objectId, std::string i2cdev);
|
||||||
|
|
||||||
|
ReturnValue_t initialize() override;
|
||||||
ReturnValue_t performPeriodicAction() override;
|
ReturnValue_t performPeriodicAction() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
enum TestModes {
|
||||||
|
NONE,
|
||||||
|
BPX_BATTERY
|
||||||
|
};
|
||||||
|
struct I2cInfo {
|
||||||
|
int addr = 0;
|
||||||
|
int fd = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
TestModes mode = TestModes::NONE;
|
||||||
|
void battInit();
|
||||||
|
void battPeriodic();
|
||||||
|
|
||||||
|
I2cInfo bpxInfo = { .addr = 0x07, .fd = 0 };
|
||||||
|
std::string i2cdev;
|
||||||
|
size_t sendLen = 0;
|
||||||
|
size_t recvLen = 0;
|
||||||
|
std::array<uint8_t, 64> cmdBuf = {};
|
||||||
|
std::array<uint8_t, 64> replyBuf = {};
|
||||||
|
|
||||||
|
ReturnValue_t i2cWrite(int fd, uint8_t* data, size_t len);
|
||||||
|
ReturnValue_t i2cRead(int fd, uint8_t* data, size_t len);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* LINUX_BOARDTEST_I2CTESTCLASS_H_ */
|
#endif /* LINUX_BOARDTEST_I2CTESTCLASS_H_ */
|
||||||
|
@ -17,6 +17,25 @@
|
|||||||
UartTestClass::UartTestClass(object_id_t objectId) : TestTask(objectId) {}
|
UartTestClass::UartTestClass(object_id_t objectId) : TestTask(objectId) {}
|
||||||
|
|
||||||
ReturnValue_t UartTestClass::initialize() {
|
ReturnValue_t UartTestClass::initialize() {
|
||||||
|
if (mode == TestModes::GPS) {
|
||||||
|
gpsInit();
|
||||||
|
}
|
||||||
|
|
||||||
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
ReturnValue_t UartTestClass::performOneShotAction() {
|
||||||
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
ReturnValue_t UartTestClass::performPeriodicAction() {
|
||||||
|
if(mode == TestModes::GPS) {
|
||||||
|
gpsPeriodic();
|
||||||
|
}
|
||||||
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
void UartTestClass::gpsInit() {
|
||||||
#if RPI_TEST_GPS_DEVICE == 1
|
#if RPI_TEST_GPS_DEVICE == 1
|
||||||
int result = lwgps_init(&gpsData);
|
int result = lwgps_init(&gpsData);
|
||||||
if (result == 0) {
|
if (result == 0) {
|
||||||
@ -62,16 +81,9 @@ ReturnValue_t UartTestClass::initialize() {
|
|||||||
// Flush received and unread data. Those are old NMEA strings which are not relevant anymore
|
// Flush received and unread data. Those are old NMEA strings which are not relevant anymore
|
||||||
tcflush(serialPort, TCIFLUSH);
|
tcflush(serialPort, TCIFLUSH);
|
||||||
#endif
|
#endif
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t UartTestClass::performOneShotAction() {
|
void UartTestClass::gpsPeriodic() {
|
||||||
#if RPI_TEST_GPS_DEVICE == 1
|
|
||||||
#endif
|
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
ReturnValue_t UartTestClass::performPeriodicAction() {
|
|
||||||
#if RPI_TEST_GPS_DEVICE == 1
|
#if RPI_TEST_GPS_DEVICE == 1
|
||||||
int bytesRead = 0;
|
int bytesRead = 0;
|
||||||
do {
|
do {
|
||||||
@ -107,5 +119,4 @@ ReturnValue_t UartTestClass::performPeriodicAction() {
|
|||||||
}
|
}
|
||||||
} while (bytesRead > 0);
|
} while (bytesRead > 0);
|
||||||
#endif
|
#endif
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,15 @@ class UartTestClass : public TestTask {
|
|||||||
ReturnValue_t performPeriodicAction() override;
|
ReturnValue_t performPeriodicAction() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
enum TestModes {
|
||||||
|
GPS,
|
||||||
|
// Solar Cell Experiment
|
||||||
|
SCE
|
||||||
|
};
|
||||||
|
|
||||||
|
void gpsInit();
|
||||||
|
void gpsPeriodic();
|
||||||
|
TestModes mode = TestModes::GPS;
|
||||||
lwgps_t gpsData = {};
|
lwgps_t gpsData = {};
|
||||||
struct termios tty = {};
|
struct termios tty = {};
|
||||||
int serialPort = 0;
|
int serialPort = 0;
|
||||||
|
@ -73,6 +73,7 @@ static constexpr size_t FSFW_MAX_TM_PACKET_SIZE = 2048;
|
|||||||
}
|
}
|
||||||
|
|
||||||
#define FSFW_HAL_SPI_WIRETAPPING 0
|
#define FSFW_HAL_SPI_WIRETAPPING 0
|
||||||
|
#define FSFW_HAL_I2C_WIRETAPPING 0
|
||||||
#define FSFW_DEV_HYPERION_GPS_CREATE_NMEA_CSV 0
|
#define FSFW_DEV_HYPERION_GPS_CREATE_NMEA_CSV 0
|
||||||
|
|
||||||
#define FSFW_HAL_L3GD20_GYRO_DEBUG 0
|
#define FSFW_HAL_L3GD20_GYRO_DEBUG 0
|
||||||
|
@ -66,9 +66,11 @@ debugging. */
|
|||||||
#define OBSW_SWITCH_TO_NORMAL_MODE_AFTER_STARTUP 1
|
#define OBSW_SWITCH_TO_NORMAL_MODE_AFTER_STARTUP 1
|
||||||
#define OBSW_PRINT_MISSED_DEADLINES 1
|
#define OBSW_PRINT_MISSED_DEADLINES 1
|
||||||
|
|
||||||
// If this is enabled, all other SPI code should be disabled
|
|
||||||
#define OBSW_ADD_TEST_CODE 0
|
#define OBSW_ADD_TEST_CODE 0
|
||||||
|
// If this is enabled, all other SPI code should be disabled
|
||||||
#define OBSW_ADD_SPI_TEST_CODE 0
|
#define OBSW_ADD_SPI_TEST_CODE 0
|
||||||
|
// If this is enabled, all other I2C code should be disabled
|
||||||
|
#define OBSW_ADD_I2C_TEST_CODE 0
|
||||||
#define OBSW_ADD_TEST_PST 0
|
#define OBSW_ADD_TEST_PST 0
|
||||||
#define OBSW_ADD_TEST_TASK 0
|
#define OBSW_ADD_TEST_TASK 0
|
||||||
#define OBSW_TEST_LIBGPIOD 0
|
#define OBSW_TEST_LIBGPIOD 0
|
||||||
|
@ -62,6 +62,7 @@ enum sourceObjects : uint32_t {
|
|||||||
LIBGPIOD_TEST = 0x54123456,
|
LIBGPIOD_TEST = 0x54123456,
|
||||||
SPI_TEST = 0x54000010,
|
SPI_TEST = 0x54000010,
|
||||||
UART_TEST = 0x54000020,
|
UART_TEST = 0x54000020,
|
||||||
|
I2C_TEST = 0x54000030,
|
||||||
DUMMY_INTERFACE = 0x5400CAFE,
|
DUMMY_INTERFACE = 0x5400CAFE,
|
||||||
DUMMY_HANDLER = 0x5400AFFE,
|
DUMMY_HANDLER = 0x5400AFFE,
|
||||||
P60DOCK_TEST_TASK = 0x00005060,
|
P60DOCK_TEST_TASK = 0x00005060,
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
#include "BpxBatteryHandler.h"
|
#include "BpxBatteryHandler.h"
|
||||||
#include "OBSWConfig.h"
|
|
||||||
|
|
||||||
#include <fsfw/datapool/PoolReadGuard.h>
|
#include <fsfw/datapool/PoolReadGuard.h>
|
||||||
|
|
||||||
|
#include "OBSWConfig.h"
|
||||||
|
|
||||||
BpxBatteryHandler::BpxBatteryHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie)
|
BpxBatteryHandler::BpxBatteryHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie)
|
||||||
: DeviceHandlerBase(objectId, comIF, comCookie), hkSet(this), cfgSet(this) {
|
: DeviceHandlerBase(objectId, comIF, comCookie), hkSet(this), cfgSet(this) {}
|
||||||
}
|
|
||||||
|
|
||||||
BpxBatteryHandler::~BpxBatteryHandler() {}
|
BpxBatteryHandler::~BpxBatteryHandler() {}
|
||||||
|
|
||||||
@ -42,18 +42,23 @@ ReturnValue_t BpxBatteryHandler::buildTransitionDeviceCommand(DeviceCommandId_t*
|
|||||||
}
|
}
|
||||||
|
|
||||||
void BpxBatteryHandler::fillCommandAndReplyMap() {
|
void BpxBatteryHandler::fillCommandAndReplyMap() {
|
||||||
insertInCommandAndReplyMap(BpxBattery::GET_HK, 1, &hkSet);
|
insertInCommandAndReplyMap(BpxBattery::GET_HK, 1, &hkSet, 23);
|
||||||
insertInCommandAndReplyMap(BpxBattery::PING, 1);
|
insertInCommandAndReplyMap(BpxBattery::PING, 1, nullptr, 3);
|
||||||
insertInCommandAndReplyMap(BpxBattery::REBOOT, 1);
|
insertInCommandAndReplyMap(BpxBattery::REBOOT, 1);
|
||||||
insertInCommandAndReplyMap(BpxBattery::RESET_COUNTERS, 1);
|
insertInCommandAndReplyMap(BpxBattery::RESET_COUNTERS, 1);
|
||||||
insertInCommandAndReplyMap(BpxBattery::CONFIG_CMD, 1);
|
insertInCommandAndReplyMap(BpxBattery::CONFIG_CMD, 1);
|
||||||
insertInCommandAndReplyMap(BpxBattery::CONFIG_GET, 1, &cfgSet);
|
insertInCommandAndReplyMap(BpxBattery::CONFIG_GET, 1, &cfgSet, 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t BpxBatteryHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand,
|
ReturnValue_t BpxBatteryHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand,
|
||||||
const uint8_t* commandData,
|
const uint8_t* commandData,
|
||||||
size_t commandDataLen) {
|
size_t commandDataLen) {
|
||||||
switch (deviceCommand) {
|
switch (deviceCommand) {
|
||||||
|
case (BpxBattery::GET_HK): {
|
||||||
|
cmdBuf[0] = BpxBattery::PORT_GET_HK;
|
||||||
|
this->rawPacketLen = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
case (BpxBattery::PING): {
|
case (BpxBattery::PING): {
|
||||||
if (commandDataLen == 1 and commandData != nullptr) {
|
if (commandDataLen == 1 and commandData != nullptr) {
|
||||||
sentPingByte = commandData[0];
|
sentPingByte = commandData[0];
|
||||||
@ -137,42 +142,40 @@ ReturnValue_t BpxBatteryHandler::scanForReply(const uint8_t* start, size_t remai
|
|||||||
DeviceCommandId_t* foundId, size_t* foundLen) {
|
DeviceCommandId_t* foundId, size_t* foundLen) {
|
||||||
switch (lastCmd) {
|
switch (lastCmd) {
|
||||||
case (BpxBattery::GET_HK): {
|
case (BpxBattery::GET_HK): {
|
||||||
if (remainingSize != 21) {
|
if (remainingSize != 23) {
|
||||||
return DeviceHandlerIF::LENGTH_MISSMATCH;
|
return DeviceHandlerIF::LENGTH_MISSMATCH;
|
||||||
}
|
}
|
||||||
*foundLen = 21;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case (BpxBattery::PING):
|
case (BpxBattery::PING):
|
||||||
case (BpxBattery::MAN_HEAT_ON):
|
case (BpxBattery::MAN_HEAT_ON):
|
||||||
case (BpxBattery::MAN_HEAT_OFF): {
|
case (BpxBattery::MAN_HEAT_OFF): {
|
||||||
if (remainingSize != 1) {
|
if (remainingSize != 3) {
|
||||||
return DeviceHandlerIF::LENGTH_MISSMATCH;
|
return DeviceHandlerIF::LENGTH_MISSMATCH;
|
||||||
}
|
}
|
||||||
*foundLen = 1;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case (BpxBattery::REBOOT):
|
case (BpxBattery::REBOOT):
|
||||||
case (BpxBattery::RESET_COUNTERS):
|
case (BpxBattery::RESET_COUNTERS):
|
||||||
case (BpxBattery::CONFIG_CMD):
|
case (BpxBattery::CONFIG_CMD):
|
||||||
case (BpxBattery::CONFIG_SET): {
|
case (BpxBattery::CONFIG_SET): {
|
||||||
if (remainingSize != 0) {
|
if (remainingSize != 2) {
|
||||||
return DeviceHandlerIF::LENGTH_MISSMATCH;
|
return DeviceHandlerIF::LENGTH_MISSMATCH;
|
||||||
}
|
}
|
||||||
*foundLen = 0;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case (BpxBattery::CONFIG_GET): {
|
case (BpxBattery::CONFIG_GET): {
|
||||||
if (remainingSize != 3) {
|
if (remainingSize != 5) {
|
||||||
return DeviceHandlerIF::LENGTH_MISSMATCH;
|
return DeviceHandlerIF::LENGTH_MISSMATCH;
|
||||||
}
|
}
|
||||||
*foundLen = 3;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
return DeviceHandlerIF::UNKNOWN_DEVICE_REPLY;
|
return DeviceHandlerIF::UNKNOWN_DEVICE_REPLY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*foundLen = remainingSize;
|
||||||
*foundId = lastCmd;
|
*foundId = lastCmd;
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
}
|
}
|
||||||
@ -181,14 +184,14 @@ ReturnValue_t BpxBatteryHandler::interpretDeviceReply(DeviceCommandId_t id, cons
|
|||||||
switch (id) {
|
switch (id) {
|
||||||
case (BpxBattery::GET_HK): {
|
case (BpxBattery::GET_HK): {
|
||||||
PoolReadGuard rg(&hkSet);
|
PoolReadGuard rg(&hkSet);
|
||||||
ReturnValue_t result = hkSet.parseRawHk(packet, 21);
|
ReturnValue_t result = hkSet.parseRawHk(packet + 2, 21);
|
||||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
#if OBSW_DEBUG_BPX_BATT == 1
|
#if OBSW_DEBUG_BPX_BATT == 1
|
||||||
sif::info << "BPX Battery HK output:" << std::endl;
|
sif::info << "BPX Battery HK output:" << std::endl;
|
||||||
sif::info << "Charge current [mA]: " << hkSet.chargeCurrent << std::endl;
|
sif::info << "Charge current [mA]: " << hkSet.chargeCurrent << std::endl;
|
||||||
sif::info << "Discharge current [mA]; " << hkSet.dischargeCurrent << std::endl;
|
sif::info << "Discharge current [mA]: " << hkSet.dischargeCurrent << std::endl;
|
||||||
sif::info << "Heater current [mA]: " << hkSet.heaterCurrent << std::endl;
|
sif::info << "Heater current [mA]: " << hkSet.heaterCurrent << std::endl;
|
||||||
sif::info << "Battery voltage [mV]: " << hkSet.battVoltage << std::endl;
|
sif::info << "Battery voltage [mV]: " << hkSet.battVoltage << std::endl;
|
||||||
sif::info << "Battery Temperature 1 [C]: " << hkSet.battTemp1 << std::endl;
|
sif::info << "Battery Temperature 1 [C]: " << hkSet.battTemp1 << std::endl;
|
||||||
@ -196,12 +199,12 @@ ReturnValue_t BpxBatteryHandler::interpretDeviceReply(DeviceCommandId_t id, cons
|
|||||||
sif::info << "Battery Temperature 3 [C]: " << hkSet.battTemp3 << std::endl;
|
sif::info << "Battery Temperature 3 [C]: " << hkSet.battTemp3 << std::endl;
|
||||||
sif::info << "Battery Temperature 4 [C]: " << hkSet.battTemp4 << std::endl;
|
sif::info << "Battery Temperature 4 [C]: " << hkSet.battTemp4 << std::endl;
|
||||||
sif::info << "Battery Reboot Counter: " << hkSet.rebootCounter << std::endl;
|
sif::info << "Battery Reboot Counter: " << hkSet.rebootCounter << std::endl;
|
||||||
sif::info << "Battery Boot Cause: " << hkSet.bootcause << std::endl;
|
sif::info << "Battery Boot Cause: " << static_cast<int>(hkSet.bootcause.value) << std::endl;
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case (BpxBattery::PING): {
|
case (BpxBattery::PING): {
|
||||||
if (packet[0] != sentPingByte) {
|
if (packet[2] != sentPingByte) {
|
||||||
return DeviceHandlerIF::INVALID_DATA;
|
return DeviceHandlerIF::INVALID_DATA;
|
||||||
}
|
}
|
||||||
if (mode == _MODE_START_UP) {
|
if (mode == _MODE_START_UP) {
|
||||||
@ -216,14 +219,14 @@ ReturnValue_t BpxBatteryHandler::interpretDeviceReply(DeviceCommandId_t id, cons
|
|||||||
}
|
}
|
||||||
case (BpxBattery::MAN_HEAT_ON):
|
case (BpxBattery::MAN_HEAT_ON):
|
||||||
case (BpxBattery::MAN_HEAT_OFF): {
|
case (BpxBattery::MAN_HEAT_OFF): {
|
||||||
if (packet[0] != 0x01) {
|
if (packet[2] != 0x01) {
|
||||||
return DeviceHandlerIF::DEVICE_DID_NOT_EXECUTE;
|
return DeviceHandlerIF::DEVICE_DID_NOT_EXECUTE;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case (BpxBattery::CONFIG_GET): {
|
case (BpxBattery::CONFIG_GET): {
|
||||||
PoolReadGuard rg(&cfgSet);
|
PoolReadGuard rg(&cfgSet);
|
||||||
ReturnValue_t result = cfgSet.parseRawHk(packet, 3);
|
ReturnValue_t result = cfgSet.parseRawHk(packet + 2, 3);
|
||||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -250,6 +253,7 @@ ReturnValue_t BpxBatteryHandler::initializeLocalDataPool(localpool::DataPool& lo
|
|||||||
localDataPoolMap.emplace(BpxBattery::HkPoolIds::BATT_VOLTAGE, &battVolt);
|
localDataPoolMap.emplace(BpxBattery::HkPoolIds::BATT_VOLTAGE, &battVolt);
|
||||||
localDataPoolMap.emplace(BpxBattery::HkPoolIds::REBOOT_COUNTER, &rebootCounter);
|
localDataPoolMap.emplace(BpxBattery::HkPoolIds::REBOOT_COUNTER, &rebootCounter);
|
||||||
localDataPoolMap.emplace(BpxBattery::HkPoolIds::BOOTCAUSE, &bootCause);
|
localDataPoolMap.emplace(BpxBattery::HkPoolIds::BOOTCAUSE, &bootCause);
|
||||||
|
poolManager.subscribeForPeriodicPacket(hkSet.getSid(), false, 1.0, false);
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,6 +4,8 @@
|
|||||||
#include <fsfw/datapoollocal/StaticLocalDataSet.h>
|
#include <fsfw/datapoollocal/StaticLocalDataSet.h>
|
||||||
#include <fsfw/serialize/SerialLinkedListAdapter.h>
|
#include <fsfw/serialize/SerialLinkedListAdapter.h>
|
||||||
|
|
||||||
|
#include "fsfw/devicehandlers/DeviceHandlerIF.h"
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
namespace BpxBattery {
|
namespace BpxBattery {
|
||||||
@ -197,7 +199,6 @@ class BpxBatteryHk : public StaticLocalDataSet<BpxBattery::HK_ENTRIES> {
|
|||||||
lp_var_t<uint8_t>(sid.objectId, BpxBattery::HkPoolIds::BOOTCAUSE, this);
|
lp_var_t<uint8_t>(sid.objectId, BpxBattery::HkPoolIds::BOOTCAUSE, this);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
friend class BpxBatteryHandler;
|
friend class BpxBatteryHandler;
|
||||||
/**
|
/**
|
||||||
* Constructor for data creator
|
* Constructor for data creator
|
||||||
|
Loading…
Reference in New Issue
Block a user