split P60 dock HK into core and aux HK
All checks were successful
EIVE/eive-obsw/pipeline/head This commit looks good
All checks were successful
EIVE/eive-obsw/pipeline/head This commit looks good
This commit is contained in:
parent
68992e77dc
commit
4e3fa54ae2
@ -3,7 +3,6 @@
|
||||
#include "OBSWConfig.h"
|
||||
#include "fsfw/datapool/PoolReadGuard.h"
|
||||
#include "fsfw/timemanager/Clock.h"
|
||||
|
||||
#include "mission/utility/compileTime.h"
|
||||
|
||||
#if FSFW_DEV_HYPERION_GPS_CREATE_NMEA_CSV == 1
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
ACUHandler::ACUHandler(object_id_t objectId, object_id_t comIF, CookieIF *comCookie)
|
||||
: GomspaceDeviceHandler(objectId, comIF, comCookie, ACU::MAX_CONFIGTABLE_ADDRESS,
|
||||
ACU::MAX_HKTABLE_ADDRESS, ACU::HK_TABLE_REPLY_SIZE, &acuHkTableDataset),
|
||||
ACU::MAX_HKTABLE_ADDRESS, ACU::HK_TABLE_REPLY_SIZE),
|
||||
acuHkTableDataset(this) {}
|
||||
|
||||
ACUHandler::~ACUHandler() {}
|
||||
@ -39,6 +39,13 @@ void ACUHandler::letChildHandleHkReply(DeviceCommandId_t id, const uint8_t *pack
|
||||
#endif
|
||||
}
|
||||
|
||||
LocalPoolDataSetBase *ACUHandler::getDataSetHandle(sid_t sid) {
|
||||
if (sid == acuHkTableDataset.getSid()) {
|
||||
return &acuHkTableDataset;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void ACUHandler::parseHkTableReply(const uint8_t *packet) {
|
||||
uint16_t dataOffset = 0;
|
||||
acuHkTableDataset.read();
|
||||
|
@ -31,6 +31,8 @@ class ACUHandler : public GomspaceDeviceHandler {
|
||||
virtual ReturnValue_t childCommandHook(DeviceCommandId_t cmd, const uint8_t* commandData,
|
||||
size_t commandDataLen) override;
|
||||
|
||||
LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override;
|
||||
|
||||
private:
|
||||
static const DeviceCommandId_t PRINT_CHANNEL_STATS = 51;
|
||||
|
||||
|
@ -7,20 +7,14 @@
|
||||
|
||||
GomspaceDeviceHandler::GomspaceDeviceHandler(object_id_t objectId, object_id_t comIF,
|
||||
CookieIF* comCookie, uint16_t maxConfigTableAddress,
|
||||
uint16_t maxHkTableAddress, uint16_t hkTableReplySize,
|
||||
LocalPoolDataSetBase* hkTableDataset)
|
||||
uint16_t maxHkTableAddress, uint16_t hkTableReplySize)
|
||||
: DeviceHandlerBase(objectId, comIF, comCookie),
|
||||
maxConfigTableAddress(maxConfigTableAddress),
|
||||
maxHkTableAddress(maxHkTableAddress),
|
||||
hkTableReplySize(hkTableReplySize),
|
||||
hkTableDataset(hkTableDataset) {
|
||||
hkTableReplySize(hkTableReplySize) {
|
||||
if (comCookie == nullptr) {
|
||||
sif::error << "GomspaceDeviceHandler::GomspaceDeviceHandler: Invalid com cookie" << std::endl;
|
||||
}
|
||||
if (hkTableDataset == nullptr) {
|
||||
sif::error << "GomspaceDeviceHandler::GomspaceDeviceHandler: Invalid hk table data set"
|
||||
<< std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
GomspaceDeviceHandler::~GomspaceDeviceHandler() {}
|
||||
@ -405,14 +399,6 @@ ReturnValue_t GomspaceDeviceHandler::generateRequestFullHkTableCmd(uint16_t hkTa
|
||||
|
||||
uint32_t GomspaceDeviceHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return 0; }
|
||||
|
||||
LocalPoolDataSetBase* GomspaceDeviceHandler::getDataSetHandle(sid_t sid) {
|
||||
if (sid == hkTableDataset->getSid()) {
|
||||
return hkTableDataset;
|
||||
} else {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void GomspaceDeviceHandler::setModeNormal() { mode = MODE_NORMAL; }
|
||||
|
||||
ReturnValue_t GomspaceDeviceHandler::printStatus(DeviceCommandId_t cmd) {
|
||||
|
@ -39,7 +39,7 @@ class GomspaceDeviceHandler : public DeviceHandlerBase {
|
||||
*/
|
||||
GomspaceDeviceHandler(object_id_t objectId, object_id_t comIF, CookieIF *comCookie,
|
||||
uint16_t maxConfigTableAddress, uint16_t maxHkTableAddress,
|
||||
uint16_t hkTableReplySize, LocalPoolDataSetBase *hkTableDataset);
|
||||
uint16_t hkTableReplySize);
|
||||
virtual ~GomspaceDeviceHandler();
|
||||
|
||||
/**
|
||||
@ -100,7 +100,7 @@ class GomspaceDeviceHandler : public DeviceHandlerBase {
|
||||
*/
|
||||
virtual void letChildHandleHkReply(DeviceCommandId_t id, const uint8_t *packet) = 0;
|
||||
|
||||
virtual LocalPoolDataSetBase *getDataSetHandle(sid_t sid) override;
|
||||
virtual LocalPoolDataSetBase *getDataSetHandle(sid_t sid) = 0;
|
||||
|
||||
/**
|
||||
* @brief Can be overriden by child classes to implement device specific commands.
|
||||
|
@ -6,9 +6,9 @@
|
||||
|
||||
P60DockHandler::P60DockHandler(object_id_t objectId, object_id_t comIF, CookieIF *comCookie)
|
||||
: GomspaceDeviceHandler(objectId, comIF, comCookie, P60Dock::MAX_CONFIGTABLE_ADDRESS,
|
||||
P60Dock::MAX_HKTABLE_ADDRESS, P60Dock::HK_TABLE_REPLY_SIZE,
|
||||
&p60dockHkTableDataset),
|
||||
p60dockHkTableDataset(this) {}
|
||||
P60Dock::MAX_HKTABLE_ADDRESS, P60Dock::HK_TABLE_REPLY_SIZE),
|
||||
coreHk(this),
|
||||
auxHk(this) {}
|
||||
|
||||
P60DockHandler::~P60DockHandler() {}
|
||||
|
||||
@ -23,7 +23,7 @@ void P60DockHandler::letChildHandleHkReply(DeviceCommandId_t id, const uint8_t *
|
||||
* Hk table will be sent to the commander if hk table request was not triggered by the
|
||||
* P60DockHandler itself.
|
||||
*/
|
||||
handleDeviceTM(&p60dockHkTableDataset, id, true);
|
||||
handleDeviceTM(&coreHk, id, true);
|
||||
|
||||
#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_P60DOCK == 1
|
||||
p60dockHkTableDataset.read();
|
||||
@ -73,8 +73,12 @@ void P60DockHandler::letChildHandleHkReply(DeviceCommandId_t id, const uint8_t *
|
||||
void P60DockHandler::parseHkTableReply(const uint8_t *packet) {
|
||||
using namespace P60Dock;
|
||||
uint16_t dataOffset = 0;
|
||||
PoolReadGuard pg(&p60dockHkTableDataset);
|
||||
if (pg.getReadResult() != HasReturnvaluesIF::RETURN_OK) {
|
||||
PoolReadGuard pg0(&coreHk);
|
||||
PoolReadGuard pg1(&auxHk);
|
||||
if (pg0.getReadResult() != HasReturnvaluesIF::RETURN_OK or
|
||||
pg1.getReadResult() != HasReturnvaluesIF::RETURN_OK) {
|
||||
coreHk.setValidity(false, true);
|
||||
auxHk.setValidity(false, true);
|
||||
return;
|
||||
}
|
||||
/**
|
||||
@ -83,129 +87,116 @@ void P60DockHandler::parseHkTableReply(const uint8_t *packet) {
|
||||
*/
|
||||
dataOffset += 12;
|
||||
for (uint8_t idx = 0; idx < hk::CHNLS_LEN; idx++) {
|
||||
p60dockHkTableDataset.currents[idx] = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
|
||||
coreHk.currents[idx] = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
|
||||
dataOffset += 4;
|
||||
}
|
||||
for (uint8_t idx = 0; idx < hk::CHNLS_LEN; idx++) {
|
||||
p60dockHkTableDataset.voltages[idx] = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
|
||||
coreHk.voltages[idx] = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
|
||||
dataOffset += 4;
|
||||
}
|
||||
for (uint8_t idx = 0; idx < hk::CHNLS_LEN; idx++) {
|
||||
p60dockHkTableDataset.outputEnables[idx] = *(packet + dataOffset);
|
||||
coreHk.outputEnables[idx] = *(packet + dataOffset);
|
||||
dataOffset += 3;
|
||||
}
|
||||
|
||||
p60dockHkTableDataset.temperature1 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
|
||||
coreHk.temperature1 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
|
||||
dataOffset += 4;
|
||||
p60dockHkTableDataset.temperature2 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
|
||||
coreHk.temperature2 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
|
||||
dataOffset += 4;
|
||||
|
||||
p60dockHkTableDataset.bootcause = *(packet + dataOffset) << 24 |
|
||||
auxHk.bootcause = *(packet + dataOffset) << 24 |
|
||||
|
||||
*(packet + dataOffset + 1) << 16 |
|
||||
*(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3);
|
||||
*(packet + dataOffset + 1) << 16 | *(packet + dataOffset + 2) << 8 |
|
||||
*(packet + dataOffset + 3);
|
||||
dataOffset += 6;
|
||||
p60dockHkTableDataset.bootCount = *(packet + dataOffset) << 24 |
|
||||
*(packet + dataOffset + 1) << 16 |
|
||||
*(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3);
|
||||
coreHk.bootCount = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 |
|
||||
*(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3);
|
||||
dataOffset += 6;
|
||||
p60dockHkTableDataset.uptime = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 |
|
||||
*(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3);
|
||||
auxHk.uptime = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 |
|
||||
*(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3);
|
||||
dataOffset += 6;
|
||||
p60dockHkTableDataset.resetcause = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
|
||||
auxHk.resetcause = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
|
||||
dataOffset += 4;
|
||||
p60dockHkTableDataset.battMode = *(packet + dataOffset);
|
||||
coreHk.battMode = *(packet + dataOffset);
|
||||
dataOffset += 3;
|
||||
p60dockHkTableDataset.heaterOn = *(packet + dataOffset);
|
||||
auxHk.heaterOn = *(packet + dataOffset);
|
||||
/* + 13 because here begins a new gomspace csp data field */
|
||||
dataOffset += 13;
|
||||
p60dockHkTableDataset.converter5VStatus = *(packet + dataOffset);
|
||||
auxHk.converter5VStatus = *(packet + dataOffset);
|
||||
dataOffset += 3;
|
||||
|
||||
for (uint8_t idx = 0; idx < hk::CHNLS_LEN; idx++) {
|
||||
p60dockHkTableDataset.latchups[idx] = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
|
||||
auxHk.latchups[idx] = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
|
||||
dataOffset += 4;
|
||||
}
|
||||
|
||||
p60dockHkTableDataset.dockVbatVoltageValue =
|
||||
*(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
|
||||
auxHk.dockVbatVoltageValue = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
|
||||
dataOffset += 4;
|
||||
p60dockHkTableDataset.dockVccCurrent = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
|
||||
auxHk.dockVccCurrent = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
|
||||
dataOffset += 4;
|
||||
p60dockHkTableDataset.batteryCurrent = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
|
||||
coreHk.batteryCurrent = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
|
||||
dataOffset += 4;
|
||||
p60dockHkTableDataset.batteryVoltage = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
|
||||
coreHk.batteryVoltage = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
|
||||
dataOffset += 4;
|
||||
|
||||
p60dockHkTableDataset.batteryTemperature1 =
|
||||
*(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
|
||||
auxHk.batteryTemperature1 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
|
||||
dataOffset += 4;
|
||||
p60dockHkTableDataset.batteryTemperature2 =
|
||||
*(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
|
||||
auxHk.batteryTemperature2 = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
|
||||
dataOffset += 4;
|
||||
|
||||
for (uint8_t idx = 0; idx < NUM_DEVS; idx++) {
|
||||
p60dockHkTableDataset.devicesType[idx] = *(packet + dataOffset);
|
||||
auxHk.devicesType[idx] = *(packet + dataOffset);
|
||||
dataOffset += 3;
|
||||
}
|
||||
for (uint8_t idx = 0; idx < NUM_DEVS; idx++) {
|
||||
p60dockHkTableDataset.devicesStatus[idx] = *(packet + dataOffset);
|
||||
auxHk.devicesStatus[idx] = *(packet + dataOffset);
|
||||
dataOffset += 3;
|
||||
}
|
||||
|
||||
p60dockHkTableDataset.dearmStatus = *(packet + dataOffset);
|
||||
auxHk.dearmStatus = *(packet + dataOffset);
|
||||
dataOffset += 3;
|
||||
|
||||
p60dockHkTableDataset.wdtCntGnd = *(packet + dataOffset) << 24 |
|
||||
*(packet + dataOffset + 1) << 16 |
|
||||
*(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3);
|
||||
auxHk.wdtCntGnd = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 |
|
||||
*(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3);
|
||||
dataOffset += 6;
|
||||
p60dockHkTableDataset.wdtCntI2c = *(packet + dataOffset) << 24 |
|
||||
*(packet + dataOffset + 1) << 16 |
|
||||
*(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3);
|
||||
auxHk.wdtCntI2c = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 |
|
||||
*(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3);
|
||||
dataOffset += 6;
|
||||
p60dockHkTableDataset.wdtCntCan = *(packet + dataOffset) << 24 |
|
||||
*(packet + dataOffset + 1) << 16 |
|
||||
*(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3);
|
||||
auxHk.wdtCntCan = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 |
|
||||
*(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3);
|
||||
dataOffset += 6;
|
||||
p60dockHkTableDataset.wdtCntCsp1 = *(packet + dataOffset) << 24 |
|
||||
*(packet + dataOffset + 1) << 16 |
|
||||
*(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3);
|
||||
auxHk.wdtCntCsp1 = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 |
|
||||
*(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3);
|
||||
dataOffset += 6;
|
||||
p60dockHkTableDataset.wdtCntCsp2 = *(packet + dataOffset) << 24 |
|
||||
*(packet + dataOffset + 1) << 16 |
|
||||
*(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3);
|
||||
auxHk.wdtCntCsp2 = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 |
|
||||
*(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3);
|
||||
dataOffset += 6;
|
||||
|
||||
p60dockHkTableDataset.wdtGndLeft = *(packet + dataOffset) << 24 |
|
||||
*(packet + dataOffset + 1) << 16 |
|
||||
*(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3);
|
||||
auxHk.wdtGndLeft = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 |
|
||||
*(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3);
|
||||
dataOffset += 6;
|
||||
p60dockHkTableDataset.wdtI2cLeft = *(packet + dataOffset) << 24 |
|
||||
*(packet + dataOffset + 1) << 16 |
|
||||
*(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3);
|
||||
auxHk.wdtI2cLeft = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 |
|
||||
*(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3);
|
||||
dataOffset += 6;
|
||||
p60dockHkTableDataset.wdtCanLeft = *(packet + dataOffset) << 24 |
|
||||
*(packet + dataOffset + 1) << 16 |
|
||||
*(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3);
|
||||
auxHk.wdtCanLeft = *(packet + dataOffset) << 24 | *(packet + dataOffset + 1) << 16 |
|
||||
*(packet + dataOffset + 2) << 8 | *(packet + dataOffset + 3);
|
||||
/* +16 because here begins a new gomspace csp packet */
|
||||
dataOffset += 16;
|
||||
|
||||
p60dockHkTableDataset.wdtCspLeft1 = *(packet + dataOffset);
|
||||
auxHk.wdtCspLeft1 = *(packet + dataOffset);
|
||||
dataOffset += 3;
|
||||
p60dockHkTableDataset.wdtCspLeft2 = *(packet + dataOffset);
|
||||
auxHk.wdtCspLeft2 = *(packet + dataOffset);
|
||||
dataOffset += 3;
|
||||
|
||||
p60dockHkTableDataset.batteryChargeCurrent =
|
||||
*(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
|
||||
auxHk.batteryChargeCurrent = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
|
||||
dataOffset += 4;
|
||||
p60dockHkTableDataset.batteryDischargeCurrent =
|
||||
*(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
|
||||
auxHk.batteryDischargeCurrent = *(packet + dataOffset) << 8 | *(packet + dataOffset + 1);
|
||||
dataOffset += 4;
|
||||
p60dockHkTableDataset.ant6Depl = *(packet + dataOffset);
|
||||
auxHk.ant6Depl = *(packet + dataOffset);
|
||||
dataOffset += 3;
|
||||
p60dockHkTableDataset.ar6Depl = *(packet + dataOffset);
|
||||
p60dockHkTableDataset.setValidity(true, true);
|
||||
auxHk.ar6Depl = *(packet + dataOffset);
|
||||
coreHk.setValidity(true, true);
|
||||
auxHk.setValidity(true, true);
|
||||
}
|
||||
|
||||
ReturnValue_t P60DockHandler::initializeLocalDataPool(localpool::DataPool &localDataPoolMap,
|
||||
@ -260,7 +251,8 @@ ReturnValue_t P60DockHandler::initializeLocalDataPool(localpool::DataPool &local
|
||||
|
||||
localDataPoolMap.emplace(pool::P60DOCK_ANT6_DEPL, new PoolEntry<int8_t>({0}));
|
||||
localDataPoolMap.emplace(pool::P60DOCK_AR6_DEPL, new PoolEntry<int8_t>({0}));
|
||||
poolManager.subscribeForPeriodicPacket(p60dockHkTableDataset.getSid(), false, 10.0, false);
|
||||
poolManager.subscribeForPeriodicPacket(coreHk.getSid(), false, 10.0, false);
|
||||
poolManager.subscribeForPeriodicPacket(auxHk.getSid(), false, 30.0, false);
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
@ -268,16 +260,17 @@ ReturnValue_t P60DockHandler::printStatus(DeviceCommandId_t cmd) {
|
||||
ReturnValue_t result = RETURN_OK;
|
||||
switch (cmd) {
|
||||
case (GOMSPACE::PRINT_SWITCH_V_I): {
|
||||
PoolReadGuard pg(&p60dockHkTableDataset);
|
||||
result = pg.getReadResult();
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
PoolReadGuard pg0(&coreHk);
|
||||
PoolReadGuard pg1(&auxHk);
|
||||
if (pg0.getReadResult() != HasReturnvaluesIF::RETURN_OK or
|
||||
pg1.getReadResult() != HasReturnvaluesIF::RETURN_OK) {
|
||||
break;
|
||||
}
|
||||
printHkTableSwitchIV();
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
case (GOMSPACE::PRINT_LATCHUPS): {
|
||||
PoolReadGuard pg(&p60dockHkTableDataset);
|
||||
PoolReadGuard pg(&auxHk);
|
||||
result = pg.getReadResult();
|
||||
printHkTableLatchups();
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
@ -296,25 +289,22 @@ ReturnValue_t P60DockHandler::printStatus(DeviceCommandId_t cmd) {
|
||||
void P60DockHandler::printHkTableSwitchIV() {
|
||||
using namespace P60Dock;
|
||||
sif::info << "P60 Dock Info:" << std::endl;
|
||||
sif::info << "Boot Cause: " << p60dockHkTableDataset.bootcause
|
||||
<< " | Boot Count: " << std::setw(4) << std::right << p60dockHkTableDataset.bootCount
|
||||
<< std::endl;
|
||||
sif::info << "Reset Cause: " << p60dockHkTableDataset.resetcause
|
||||
<< " | Battery Mode: " << static_cast<int>(p60dockHkTableDataset.battMode.value)
|
||||
<< std::endl;
|
||||
sif::info << "Boot Cause: " << auxHk.bootcause << " | Boot Count: " << std::setw(4) << std::right
|
||||
<< coreHk.bootCount << std::endl;
|
||||
sif::info << "Reset Cause: " << auxHk.resetcause
|
||||
<< " | Battery Mode: " << static_cast<int>(coreHk.battMode.value) << std::endl;
|
||||
sif::info << "SwitchState, Currents [mA], Voltages [mV]:" << std::endl;
|
||||
sif::info << std::setw(MAX_CHANNEL_STR_WIDTH) << std::left << "Dock VBAT VCC" << std::dec
|
||||
<< "| -, " << std::setw(4) << std::right << p60dockHkTableDataset.dockVccCurrent << ", "
|
||||
<< std::setw(5) << p60dockHkTableDataset.dockVbatVoltageValue << std::endl;
|
||||
<< "| -, " << std::setw(4) << std::right << auxHk.dockVccCurrent << ", " << std::setw(5)
|
||||
<< auxHk.dockVbatVoltageValue << std::endl;
|
||||
sif::info << std::setw(MAX_CHANNEL_STR_WIDTH) << std::left << "BATT" << std::dec << "| -, "
|
||||
<< std::setw(4) << std::right << p60dockHkTableDataset.batteryCurrent.value << ", "
|
||||
<< std::setw(5) << p60dockHkTableDataset.batteryVoltage.value << std::endl;
|
||||
<< std::setw(4) << std::right << coreHk.batteryCurrent.value << ", " << std::setw(5)
|
||||
<< coreHk.batteryVoltage.value << std::endl;
|
||||
|
||||
auto genericPrintoutHandler = [&](std::string name, uint8_t idx) {
|
||||
sif::info << std::setw(MAX_CHANNEL_STR_WIDTH) << std::left << name << std::dec << "| "
|
||||
<< unsigned(p60dockHkTableDataset.outputEnables[idx]) << ", " << std::setw(4)
|
||||
<< std::right << p60dockHkTableDataset.currents[idx] << ", " << std::setw(5)
|
||||
<< p60dockHkTableDataset.voltages[idx] << std::endl;
|
||||
<< unsigned(coreHk.outputEnables[idx]) << ", " << std::setw(4) << std::right
|
||||
<< coreHk.currents[idx] << ", " << std::setw(5) << coreHk.voltages[idx] << std::endl;
|
||||
};
|
||||
|
||||
genericPrintoutHandler("ACU VCC", hk::ACU_VCC);
|
||||
@ -328,12 +318,21 @@ void P60DockHandler::printHkTableSwitchIV() {
|
||||
genericPrintoutHandler("Stack 5V", hk::STACK_5V);
|
||||
}
|
||||
|
||||
LocalPoolDataSetBase *P60DockHandler::getDataSetHandle(sid_t sid) {
|
||||
if (sid == coreHk.getSid()) {
|
||||
return &coreHk;
|
||||
} else if (sid == auxHk.getSid()) {
|
||||
return &auxHk;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void P60DockHandler::printHkTableLatchups() {
|
||||
using namespace P60Dock;
|
||||
sif::info << "P60 Latchup Information" << std::endl;
|
||||
auto genericPrintoutHandler = [&](std::string name, uint8_t idx) {
|
||||
sif::info << std::setw(MAX_CHANNEL_STR_WIDTH) << std::left << name << std::dec << "| "
|
||||
<< std::setw(4) << std::right << p60dockHkTableDataset.latchups[idx] << std::endl;
|
||||
<< std::setw(4) << std::right << auxHk.latchups[idx] << std::endl;
|
||||
};
|
||||
genericPrintoutHandler("ACU VCC", hk::ACU_VCC);
|
||||
genericPrintoutHandler("ACU VBAT", hk::ACU_VBAT);
|
||||
|
@ -31,12 +31,14 @@ class P60DockHandler : public GomspaceDeviceHandler {
|
||||
* @return
|
||||
*/
|
||||
ReturnValue_t printStatus(DeviceCommandId_t cmd) override;
|
||||
LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override;
|
||||
|
||||
void printHkTableSwitchIV();
|
||||
void printHkTableLatchups();
|
||||
|
||||
private:
|
||||
P60Dock::HkTableDataset p60dockHkTableDataset;
|
||||
P60Dock::CoreHkSet coreHk;
|
||||
P60Dock::HkTableDataset auxHk;
|
||||
static constexpr uint8_t MAX_CHANNEL_STR_WIDTH = 16;
|
||||
|
||||
PoolEntry<int16_t> hkCurrents = PoolEntry<int16_t>(P60Dock::hk::CHNLS_LEN);
|
||||
|
@ -7,8 +7,7 @@
|
||||
|
||||
PDU1Handler::PDU1Handler(object_id_t objectId, object_id_t comIF, CookieIF *comCookie)
|
||||
: GomspaceDeviceHandler(objectId, comIF, comCookie, PDU::MAX_CONFIGTABLE_ADDRESS,
|
||||
PDU::MAX_HKTABLE_ADDRESS, PDU::HK_TABLE_REPLY_SIZE,
|
||||
&pdu1HkTableDataset),
|
||||
PDU::MAX_HKTABLE_ADDRESS, PDU::HK_TABLE_REPLY_SIZE),
|
||||
pdu1HkTableDataset(this) {}
|
||||
|
||||
PDU1Handler::~PDU1Handler() {}
|
||||
@ -430,6 +429,13 @@ ReturnValue_t PDU1Handler::initializeLocalDataPool(localpool::DataPool &localDat
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
LocalPoolDataSetBase *PDU1Handler::getDataSetHandle(sid_t sid) {
|
||||
if (sid == pdu1HkTableDataset.getSid()) {
|
||||
return &pdu1HkTableDataset;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
ReturnValue_t PDU1Handler::printStatus(DeviceCommandId_t cmd) {
|
||||
ReturnValue_t result = RETURN_OK;
|
||||
switch (cmd) {
|
||||
|
@ -36,7 +36,7 @@ class PDU1Handler : public GomspaceDeviceHandler {
|
||||
virtual ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t* id) override;
|
||||
virtual void letChildHandleHkReply(DeviceCommandId_t id, const uint8_t* packet) override;
|
||||
ReturnValue_t printStatus(DeviceCommandId_t cmd) override;
|
||||
|
||||
LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override;
|
||||
ReturnValue_t setParamCallback(SetParamMessageUnpacker& unpacker, bool afterExectuion) override;
|
||||
|
||||
private:
|
||||
|
@ -7,8 +7,7 @@
|
||||
|
||||
PDU2Handler::PDU2Handler(object_id_t objectId, object_id_t comIF, CookieIF *comCookie)
|
||||
: GomspaceDeviceHandler(objectId, comIF, comCookie, PDU::MAX_CONFIGTABLE_ADDRESS,
|
||||
PDU::MAX_HKTABLE_ADDRESS, PDU::HK_TABLE_REPLY_SIZE,
|
||||
&pdu2HkTableDataset),
|
||||
PDU::MAX_HKTABLE_ADDRESS, PDU::HK_TABLE_REPLY_SIZE),
|
||||
pdu2HkTableDataset(this) {}
|
||||
|
||||
PDU2Handler::~PDU2Handler() {}
|
||||
@ -54,6 +53,13 @@ void PDU2Handler::assignChannelHookFunction(GOMSPACE::ChannelSwitchHook hook, vo
|
||||
this->hookArgs = args;
|
||||
}
|
||||
|
||||
LocalPoolDataSetBase *PDU2Handler::getDataSetHandle(sid_t sid) {
|
||||
if (sid == pdu2HkTableDataset.getSid()) {
|
||||
return &pdu2HkTableDataset;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void PDU2Handler::parseHkTableReply(const uint8_t *packet) {
|
||||
uint16_t dataOffset = 0;
|
||||
pdu2HkTableDataset.read();
|
||||
|
@ -36,6 +36,7 @@ class PDU2Handler : public GomspaceDeviceHandler {
|
||||
virtual void letChildHandleHkReply(DeviceCommandId_t id, const uint8_t* packet) override;
|
||||
ReturnValue_t printStatus(DeviceCommandId_t cmd) override;
|
||||
ReturnValue_t setParamCallback(SetParamMessageUnpacker& unpacker, bool afterExecution) override;
|
||||
LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override;
|
||||
|
||||
private:
|
||||
static constexpr uint8_t MAX_CHANNEL_STR_WIDTH = 24;
|
||||
|
@ -351,7 +351,9 @@ static const uint16_t MAX_CONFIGTABLE_ADDRESS = 408;
|
||||
static const uint16_t MAX_HKTABLE_ADDRESS = 187;
|
||||
static const uint16_t HK_TABLE_SIZE = 188;
|
||||
|
||||
static const uint8_t HK_TABLE_DATA_SET_ID = 0x3;
|
||||
static constexpr uint32_t CORE_TABLE_SET_ID = 0x3;
|
||||
static constexpr uint32_t AUX_TABLE_DATA_SET_ID = 0x4;
|
||||
|
||||
static const uint8_t HK_TABLE_ENTRIES = 100;
|
||||
|
||||
/**
|
||||
@ -360,18 +362,11 @@ static const uint8_t HK_TABLE_ENTRIES = 100;
|
||||
*/
|
||||
static const uint16_t HK_TABLE_REPLY_SIZE = 407;
|
||||
|
||||
/**
|
||||
* @brief This class defines a dataset for the hk table of the P60 Dock.
|
||||
* @details
|
||||
* The GS port and X3 are not required for EIVE. X3 is another slot on the P60 dock and
|
||||
* GS is required for a module from Gomspace which is not used.
|
||||
*/
|
||||
class HkTableDataset : public StaticLocalDataSet<HK_TABLE_ENTRIES> {
|
||||
class CoreHkSet : public StaticLocalDataSet<16> {
|
||||
public:
|
||||
HkTableDataset(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, HK_TABLE_DATA_SET_ID) {}
|
||||
CoreHkSet(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, CORE_TABLE_SET_ID) {}
|
||||
|
||||
HkTableDataset(object_id_t objectId)
|
||||
: StaticLocalDataSet(sid_t(objectId, HK_TABLE_DATA_SET_ID)) {}
|
||||
CoreHkSet(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, CORE_TABLE_SET_ID)) {}
|
||||
|
||||
/** Measured output currents */
|
||||
lp_vec_t<int16_t, P60Dock::hk::Index::CHNLS_LEN> currents =
|
||||
@ -387,22 +382,42 @@ class HkTableDataset : public StaticLocalDataSet<HK_TABLE_ENTRIES> {
|
||||
lp_vec_t<uint8_t, P60Dock::hk::Index::CHNLS_LEN> outputEnables =
|
||||
lp_vec_t<uint8_t, P60Dock::hk::Index::CHNLS_LEN>(sid.objectId, P60System::pool::OUTPUT_ENABLE,
|
||||
this);
|
||||
lp_var_t<uint32_t> bootCount =
|
||||
lp_var_t<uint32_t>(sid.objectId, P60System::pool::P60DOCK_BOOT_CNT, this);
|
||||
lp_var_t<uint8_t> battMode =
|
||||
lp_var_t<uint8_t>(sid.objectId, P60System::pool::P60DOCK_BATT_MODE, this);
|
||||
|
||||
// Difference between charge and discharge current
|
||||
lp_var_t<int16_t> batteryCurrent =
|
||||
lp_var_t<int16_t>(sid.objectId, P60System::pool::P60DOCK_BATTERY_CURRENT, this);
|
||||
lp_var_t<uint16_t> batteryVoltage =
|
||||
lp_var_t<uint16_t>(sid.objectId, P60System::pool::P60DOCK_BATTERY_VOLTAGE, this);
|
||||
|
||||
lp_var_t<int16_t> temperature1 =
|
||||
lp_var_t<int16_t>(sid.objectId, P60System::pool::P60DOCK_TEMPERATURE_1, this);
|
||||
lp_var_t<int16_t> temperature2 =
|
||||
lp_var_t<int16_t>(sid.objectId, P60System::pool::P60DOCK_TEMPERATURE_2, this);
|
||||
};
|
||||
/**
|
||||
* @brief This class defines a dataset for the hk table of the P60 Dock.
|
||||
* @details
|
||||
* The GS port and X3 are not required for EIVE. X3 is another slot on the P60 dock and
|
||||
* GS is required for a module from Gomspace which is not used.
|
||||
*/
|
||||
class HkTableDataset : public StaticLocalDataSet<32> {
|
||||
public:
|
||||
HkTableDataset(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, AUX_TABLE_DATA_SET_ID) {}
|
||||
|
||||
HkTableDataset(object_id_t objectId)
|
||||
: StaticLocalDataSet(sid_t(objectId, AUX_TABLE_DATA_SET_ID)) {}
|
||||
|
||||
lp_var_t<uint32_t> bootcause =
|
||||
lp_var_t<uint32_t>(sid.objectId, P60System::pool::P60DOCK_BOOT_CAUSE, this);
|
||||
lp_var_t<uint32_t> bootCount =
|
||||
lp_var_t<uint32_t>(sid.objectId, P60System::pool::P60DOCK_BOOT_CNT, this);
|
||||
lp_var_t<uint32_t> uptime =
|
||||
lp_var_t<uint32_t>(sid.objectId, P60System::pool::P60DOCK_UPTIME, this);
|
||||
lp_var_t<uint16_t> resetcause =
|
||||
lp_var_t<uint16_t>(sid.objectId, P60System::pool::P60DOCK_RESETCAUSE, this);
|
||||
lp_var_t<uint8_t> battMode =
|
||||
lp_var_t<uint8_t>(sid.objectId, P60System::pool::P60DOCK_BATT_MODE, this);
|
||||
|
||||
/** Battery heater control only possible on BP4 packs */
|
||||
lp_var_t<uint8_t> heaterOn =
|
||||
lp_var_t<uint8_t>(sid.objectId, P60System::pool::P60DOCK_HEATER_ON, this);
|
||||
@ -418,11 +433,6 @@ class HkTableDataset : public StaticLocalDataSet<HK_TABLE_ENTRIES> {
|
||||
lp_var_t<uint16_t>(sid.objectId, P60System::pool::P60DOCK_DOCK_VBAT, this);
|
||||
lp_var_t<int16_t> dockVccCurrent =
|
||||
lp_var_t<int16_t>(sid.objectId, P60System::pool::P60DOCK_DOCK_VCC_CURRENT, this);
|
||||
// Difference between charge and discharge current
|
||||
lp_var_t<int16_t> batteryCurrent =
|
||||
lp_var_t<int16_t>(sid.objectId, P60System::pool::P60DOCK_BATTERY_CURRENT, this);
|
||||
lp_var_t<uint16_t> batteryVoltage =
|
||||
lp_var_t<uint16_t>(sid.objectId, P60System::pool::P60DOCK_BATTERY_VOLTAGE, this);
|
||||
|
||||
lp_var_t<int16_t> batteryTemperature1 =
|
||||
lp_var_t<int16_t>(sid.objectId, P60System::pool::P60DOCK_BATTERY_TEMPERATURE_1, this);
|
||||
|
@ -5,14 +5,17 @@
|
||||
* Authors:
|
||||
*
|
||||
* Assembled from the code released on Stackoverflow by:
|
||||
* Dennis (instructable.com/member/nqtronix) | https://stackoverflow.com/questions/23032002/c-c-how-to-get-integer-unix-timestamp-of-build-time-not-string
|
||||
* Dennis (instructable.com/member/nqtronix) |
|
||||
* https://stackoverflow.com/questions/23032002/c-c-how-to-get-integer-unix-timestamp-of-build-time-not-string
|
||||
* and
|
||||
* Alexis Wilke | https://stackoverflow.com/questions/10538444/do-you-know-of-a-c-macro-to-compute-unix-time-and-date
|
||||
* Alexis Wilke |
|
||||
* https://stackoverflow.com/questions/10538444/do-you-know-of-a-c-macro-to-compute-unix-time-and-date
|
||||
*
|
||||
* Assembled by Jean Rabault
|
||||
*
|
||||
* UNIX_TIMESTAMP gives the UNIX timestamp (unsigned long integer of seconds since 1st Jan 1970) of compilation from macros using the compiler defined __TIME__ macro.
|
||||
* This should include Gregorian calendar leap days, in particular the 29ths of February, 100 and 400 years modulo leaps.
|
||||
* UNIX_TIMESTAMP gives the UNIX timestamp (unsigned long integer of seconds since 1st Jan 1970) of
|
||||
* compilation from macros using the compiler defined __TIME__ macro. This should include Gregorian
|
||||
* calendar leap days, in particular the 29ths of February, 100 and 400 years modulo leaps.
|
||||
*
|
||||
* Careful: __TIME__ is the local time of the computer, NOT the UTC time in general!
|
||||
*
|
||||
@ -22,76 +25,66 @@
|
||||
#define COMPILE_TIME_H_
|
||||
|
||||
// Some definitions for calculation
|
||||
#define SEC_PER_MIN 60UL
|
||||
#define SEC_PER_HOUR 3600UL
|
||||
#define SEC_PER_DAY 86400UL
|
||||
#define SEC_PER_YEAR (SEC_PER_DAY*365)
|
||||
#define SEC_PER_MIN 60UL
|
||||
#define SEC_PER_HOUR 3600UL
|
||||
#define SEC_PER_DAY 86400UL
|
||||
#define SEC_PER_YEAR (SEC_PER_DAY * 365)
|
||||
|
||||
// extracts 1..4 characters from a string and interprets it as a decimal value
|
||||
#define CONV_STR2DEC_1(str, i) (str[i]>'0'?str[i]-'0':0)
|
||||
#define CONV_STR2DEC_2(str, i) (CONV_STR2DEC_1(str, i)*10 + str[i+1]-'0')
|
||||
#define CONV_STR2DEC_3(str, i) (CONV_STR2DEC_2(str, i)*10 + str[i+2]-'0')
|
||||
#define CONV_STR2DEC_4(str, i) (CONV_STR2DEC_3(str, i)*10 + str[i+3]-'0')
|
||||
#define CONV_STR2DEC_1(str, i) (str[i] > '0' ? str[i] - '0' : 0)
|
||||
#define CONV_STR2DEC_2(str, i) (CONV_STR2DEC_1(str, i) * 10 + str[i + 1] - '0')
|
||||
#define CONV_STR2DEC_3(str, i) (CONV_STR2DEC_2(str, i) * 10 + str[i + 2] - '0')
|
||||
#define CONV_STR2DEC_4(str, i) (CONV_STR2DEC_3(str, i) * 10 + str[i + 3] - '0')
|
||||
|
||||
// Custom "glue logic" to convert the month name to a usable number
|
||||
#define GET_MONTH(str, i) (str[i]=='J' && str[i+1]=='a' && str[i+2]=='n' ? 1 : \
|
||||
str[i]=='F' && str[i+1]=='e' && str[i+2]=='b' ? 2 : \
|
||||
str[i]=='M' && str[i+1]=='a' && str[i+2]=='r' ? 3 : \
|
||||
str[i]=='A' && str[i+1]=='p' && str[i+2]=='r' ? 4 : \
|
||||
str[i]=='M' && str[i+1]=='a' && str[i+2]=='y' ? 5 : \
|
||||
str[i]=='J' && str[i+1]=='u' && str[i+2]=='n' ? 6 : \
|
||||
str[i]=='J' && str[i+1]=='u' && str[i+2]=='l' ? 7 : \
|
||||
str[i]=='A' && str[i+1]=='u' && str[i+2]=='g' ? 8 : \
|
||||
str[i]=='S' && str[i+1]=='e' && str[i+2]=='p' ? 9 : \
|
||||
str[i]=='O' && str[i+1]=='c' && str[i+2]=='t' ? 10 : \
|
||||
str[i]=='N' && str[i+1]=='o' && str[i+2]=='v' ? 11 : \
|
||||
str[i]=='D' && str[i+1]=='e' && str[i+2]=='c' ? 12 : 0)
|
||||
#define GET_MONTH(str, i) \
|
||||
(str[i] == 'J' && str[i + 1] == 'a' && str[i + 2] == 'n' ? 1 \
|
||||
: str[i] == 'F' && str[i + 1] == 'e' && str[i + 2] == 'b' ? 2 \
|
||||
: str[i] == 'M' && str[i + 1] == 'a' && str[i + 2] == 'r' ? 3 \
|
||||
: str[i] == 'A' && str[i + 1] == 'p' && str[i + 2] == 'r' ? 4 \
|
||||
: str[i] == 'M' && str[i + 1] == 'a' && str[i + 2] == 'y' ? 5 \
|
||||
: str[i] == 'J' && str[i + 1] == 'u' && str[i + 2] == 'n' ? 6 \
|
||||
: str[i] == 'J' && str[i + 1] == 'u' && str[i + 2] == 'l' ? 7 \
|
||||
: str[i] == 'A' && str[i + 1] == 'u' && str[i + 2] == 'g' ? 8 \
|
||||
: str[i] == 'S' && str[i + 1] == 'e' && str[i + 2] == 'p' ? 9 \
|
||||
: str[i] == 'O' && str[i + 1] == 'c' && str[i + 2] == 't' ? 10 \
|
||||
: str[i] == 'N' && str[i + 1] == 'o' && str[i + 2] == 'v' ? 11 \
|
||||
: str[i] == 'D' && str[i + 1] == 'e' && str[i + 2] == 'c' ? 12 \
|
||||
: 0)
|
||||
|
||||
// extract the information from the time string given by __TIME__ and __DATE__
|
||||
#define __TIME_SECONDS__ CONV_STR2DEC_2(__TIME__, 6)
|
||||
#define __TIME_MINUTES__ CONV_STR2DEC_2(__TIME__, 3)
|
||||
#define __TIME_HOURS__ CONV_STR2DEC_2(__TIME__, 0)
|
||||
#define __TIME_DAYS__ CONV_STR2DEC_2(__DATE__, 4)
|
||||
#define __TIME_MONTH__ GET_MONTH(__DATE__, 0)
|
||||
#define __TIME_YEARS__ CONV_STR2DEC_4(__DATE__, 7)
|
||||
#define __TIME_SECONDS__ CONV_STR2DEC_2(__TIME__, 6)
|
||||
#define __TIME_MINUTES__ CONV_STR2DEC_2(__TIME__, 3)
|
||||
#define __TIME_HOURS__ CONV_STR2DEC_2(__TIME__, 0)
|
||||
#define __TIME_DAYS__ CONV_STR2DEC_2(__DATE__, 4)
|
||||
#define __TIME_MONTH__ GET_MONTH(__DATE__, 0)
|
||||
#define __TIME_YEARS__ CONV_STR2DEC_4(__DATE__, 7)
|
||||
|
||||
// Days in February
|
||||
#define _UNIX_TIMESTAMP_FDAY(year) \
|
||||
(((year) % 400) == 0UL ? 29UL : \
|
||||
(((year) % 100) == 0UL ? 28UL : \
|
||||
(((year) % 4) == 0UL ? 29UL : \
|
||||
28UL)))
|
||||
(((year) % 400) == 0UL ? 29UL \
|
||||
: (((year) % 100) == 0UL ? 28UL : (((year) % 4) == 0UL ? 29UL : 28UL)))
|
||||
|
||||
// Days in the year
|
||||
#define _UNIX_TIMESTAMP_YDAY(year, month, day) \
|
||||
( \
|
||||
/* January */ day \
|
||||
/* February */ + (month >= 2 ? 31UL : 0UL) \
|
||||
/* March */ + (month >= 3 ? _UNIX_TIMESTAMP_FDAY(year) : 0UL) \
|
||||
/* April */ + (month >= 4 ? 31UL : 0UL) \
|
||||
/* May */ + (month >= 5 ? 30UL : 0UL) \
|
||||
/* June */ + (month >= 6 ? 31UL : 0UL) \
|
||||
/* July */ + (month >= 7 ? 30UL : 0UL) \
|
||||
/* August */ + (month >= 8 ? 31UL : 0UL) \
|
||||
/* September */+ (month >= 9 ? 31UL : 0UL) \
|
||||
/* October */ + (month >= 10 ? 30UL : 0UL) \
|
||||
/* November */ + (month >= 11 ? 31UL : 0UL) \
|
||||
/* December */ + (month >= 12 ? 30UL : 0UL) \
|
||||
)
|
||||
#define _UNIX_TIMESTAMP_YDAY(year, month, day) \
|
||||
(/* January */ day /* February */ + (month >= 2 ? 31UL : 0UL) /* March */ + \
|
||||
(month >= 3 ? _UNIX_TIMESTAMP_FDAY(year) : 0UL) /* April */ + \
|
||||
(month >= 4 ? 31UL : 0UL) /* May */ + (month >= 5 ? 30UL : 0UL) /* June */ + \
|
||||
(month >= 6 ? 31UL : 0UL) /* July */ + (month >= 7 ? 30UL : 0UL) /* August */ + \
|
||||
(month >= 8 ? 31UL : 0UL) /* September */ + (month >= 9 ? 31UL : 0UL) /* October */ + \
|
||||
(month >= 10 ? 30UL : 0UL) /* November */ + (month >= 11 ? 31UL : 0UL) /* December */ + \
|
||||
(month >= 12 ? 30UL : 0UL))
|
||||
|
||||
// get the UNIX timestamp from a digits representation
|
||||
#define _UNIX_TIMESTAMP(year, month, day, hour, minute, second) \
|
||||
( /* time */ second \
|
||||
+ minute * SEC_PER_MIN \
|
||||
+ hour * SEC_PER_HOUR \
|
||||
+ /* year day (month + day) */ (_UNIX_TIMESTAMP_YDAY(year, month, day) - 1) * SEC_PER_DAY \
|
||||
+ /* year */ (year - 1970UL) * SEC_PER_YEAR \
|
||||
+ ((year - 1969UL) / 4UL) * SEC_PER_DAY \
|
||||
- ((year - 1901UL) / 100UL) * SEC_PER_DAY \
|
||||
+ ((year - 1601UL) / 400UL) * SEC_PER_DAY \
|
||||
)
|
||||
#define _UNIX_TIMESTAMP(year, month, day, hour, minute, second) \
|
||||
(/* time */ second + minute * SEC_PER_MIN + hour * SEC_PER_HOUR + \
|
||||
/* year day (month + day) */ (_UNIX_TIMESTAMP_YDAY(year, month, day) - 1) * SEC_PER_DAY + \
|
||||
/* year */ (year - 1970UL) * SEC_PER_YEAR + ((year - 1969UL) / 4UL) * SEC_PER_DAY - \
|
||||
((year - 1901UL) / 100UL) * SEC_PER_DAY + ((year - 1601UL) / 400UL) * SEC_PER_DAY)
|
||||
|
||||
// the UNIX timestamp
|
||||
#define UNIX_TIMESTAMP (_UNIX_TIMESTAMP(__TIME_YEARS__, __TIME_MONTH__, __TIME_DAYS__, __TIME_HOURS__, __TIME_MINUTES__, __TIME_SECONDS__))
|
||||
#define UNIX_TIMESTAMP \
|
||||
(_UNIX_TIMESTAMP(__TIME_YEARS__, __TIME_MONTH__, __TIME_DAYS__, __TIME_HOURS__, \
|
||||
__TIME_MINUTES__, __TIME_SECONDS__))
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user