request version command
This commit is contained in:
parent
8b97528afb
commit
eb0e9c2a41
@ -12,7 +12,7 @@ extern "C" {
|
|||||||
|
|
||||||
StarTrackerHandler::StarTrackerHandler(object_id_t objectId, object_id_t comIF,
|
StarTrackerHandler::StarTrackerHandler(object_id_t objectId, object_id_t comIF,
|
||||||
CookieIF * comCookie) :
|
CookieIF * comCookie) :
|
||||||
DeviceHandlerBase(objectId, comIF, comCookie), temperatureSet(this) {
|
DeviceHandlerBase(objectId, comIF, comCookie), temperatureSet(this), versionSet(this) {
|
||||||
if (comCookie == NULL) {
|
if (comCookie == NULL) {
|
||||||
sif::error << "StarTrackerHandler: Invalid com cookie" << std::endl;
|
sif::error << "StarTrackerHandler: Invalid com cookie" << std::endl;
|
||||||
}
|
}
|
||||||
@ -61,6 +61,10 @@ ReturnValue_t StarTrackerHandler::buildCommandFromCommand(DeviceCommandId_t devi
|
|||||||
preparePingRequest();
|
preparePingRequest();
|
||||||
return RETURN_OK;
|
return RETURN_OK;
|
||||||
}
|
}
|
||||||
|
case (StarTracker::REQ_VERSION): {
|
||||||
|
prepareVersionRequest();
|
||||||
|
return RETURN_OK;
|
||||||
|
}
|
||||||
case (StarTracker::REBOOT): {
|
case (StarTracker::REBOOT): {
|
||||||
prepareRebootCommand();
|
prepareRebootCommand();
|
||||||
return RETURN_OK;
|
return RETURN_OK;
|
||||||
@ -80,6 +84,8 @@ void StarTrackerHandler::fillCommandAndReplyMap() {
|
|||||||
* is specified */
|
* is specified */
|
||||||
this->insertInCommandAndReplyMap(StarTracker::PING_REQUEST, 1, nullptr,
|
this->insertInCommandAndReplyMap(StarTracker::PING_REQUEST, 1, nullptr,
|
||||||
StarTracker::MAX_FRAME_SIZE * 2 + 2);
|
StarTracker::MAX_FRAME_SIZE * 2 + 2);
|
||||||
|
this->insertInCommandAndReplyMap(StarTracker::REQ_VERSION, 1, nullptr,
|
||||||
|
StarTracker::MAX_FRAME_SIZE * 2 + 2);
|
||||||
this->insertInCommandMap(StarTracker::REBOOT);
|
this->insertInCommandMap(StarTracker::REBOOT);
|
||||||
this->insertInCommandAndReplyMap(StarTracker::REQ_TEMPERATURE, 1, &temperatureSet,
|
this->insertInCommandAndReplyMap(StarTracker::REQ_TEMPERATURE, 1, &temperatureSet,
|
||||||
StarTracker::MAX_FRAME_SIZE * 2 + 2);
|
StarTracker::MAX_FRAME_SIZE * 2 + 2);
|
||||||
@ -124,6 +130,11 @@ ReturnValue_t StarTrackerHandler::scanForReply(const uint8_t *start, size_t rema
|
|||||||
*foundId = StarTracker::PING_REQUEST;
|
*foundId = StarTracker::PING_REQUEST;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case (static_cast<uint8_t>(StarTracker::REQ_VERSION)): {
|
||||||
|
*foundLen = decodedLength;
|
||||||
|
*foundId = StarTracker::PING_REQUEST;
|
||||||
|
break;
|
||||||
|
}
|
||||||
case (static_cast<uint8_t>(StarTracker::REQ_TEMPERATURE)): {
|
case (static_cast<uint8_t>(StarTracker::REQ_TEMPERATURE)): {
|
||||||
*foundLen = decodedLength;
|
*foundLen = decodedLength;
|
||||||
*foundId = StarTracker::REQ_TEMPERATURE;
|
*foundId = StarTracker::REQ_TEMPERATURE;
|
||||||
@ -149,6 +160,10 @@ ReturnValue_t StarTrackerHandler::interpretDeviceReply(DeviceCommandId_t id, con
|
|||||||
result = handlePingReply();
|
result = handlePingReply();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case (StarTracker::REQ_VERSION): {
|
||||||
|
result = handleVersionTm();
|
||||||
|
break;
|
||||||
|
}
|
||||||
case (StarTracker::REQ_TEMPERATURE): {
|
case (StarTracker::REQ_TEMPERATURE): {
|
||||||
handleTemperatureTm();
|
handleTemperatureTm();
|
||||||
break;
|
break;
|
||||||
@ -174,8 +189,13 @@ uint32_t StarTrackerHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo
|
|||||||
ReturnValue_t StarTrackerHandler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
|
ReturnValue_t StarTrackerHandler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
|
||||||
LocalDataPoolManager& poolManager) {
|
LocalDataPoolManager& poolManager) {
|
||||||
|
|
||||||
localDataPoolMap.emplace(StarTracker::TICKS, new PoolEntry<uint32_t>( { 0 }));
|
localDataPoolMap.emplace(StarTracker::TICKS_VERSION_SET, new PoolEntry<uint32_t>( { 0 }));
|
||||||
localDataPoolMap.emplace(StarTracker::TIME, new PoolEntry<uint64_t>( { 0 }));
|
localDataPoolMap.emplace(StarTracker::TIME_VERSION_SET, new PoolEntry<uint64_t>( { 0 }));
|
||||||
|
localDataPoolMap.emplace(StarTracker::PROGRAM, new PoolEntry<uint8_t>( { 0 }));
|
||||||
|
localDataPoolMap.emplace(StarTracker::MAJOR, new PoolEntry<uint8_t>( { 0 }));
|
||||||
|
localDataPoolMap.emplace(StarTracker::MINOR, new PoolEntry<uint8_t>( { 0 }));
|
||||||
|
localDataPoolMap.emplace(StarTracker::TICKS_TEMPERATURE_SET, new PoolEntry<uint32_t>( { 0 }));
|
||||||
|
localDataPoolMap.emplace(StarTracker::TIME_TEMPERATURE_SET, new PoolEntry<uint64_t>( { 0 }));
|
||||||
localDataPoolMap.emplace(StarTracker::MCU_TEMPERATURE, new PoolEntry<float>( { 0 }));
|
localDataPoolMap.emplace(StarTracker::MCU_TEMPERATURE, new PoolEntry<float>( { 0 }));
|
||||||
localDataPoolMap.emplace(StarTracker::CMOS_TEMPERATURE, new PoolEntry<float>( { 0 }));
|
localDataPoolMap.emplace(StarTracker::CMOS_TEMPERATURE, new PoolEntry<float>( { 0 }));
|
||||||
|
|
||||||
@ -204,6 +224,15 @@ void StarTrackerHandler::preparePingRequest() {
|
|||||||
rawPacketLen = encLength;
|
rawPacketLen = encLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void StarTrackerHandler::prepareVersionRequest() {
|
||||||
|
uint32_t length = 0;
|
||||||
|
arc_tm_pack_version_req(commandBuffer, &length);
|
||||||
|
uint32_t encLength = 0;
|
||||||
|
arc_transport_encode_body(commandBuffer, length, encBuffer, &encLength);
|
||||||
|
rawPacket = encBuffer;
|
||||||
|
rawPacketLen = encLength;
|
||||||
|
}
|
||||||
|
|
||||||
void StarTrackerHandler::prepareRebootCommand() {
|
void StarTrackerHandler::prepareRebootCommand() {
|
||||||
uint32_t length = 0;
|
uint32_t length = 0;
|
||||||
struct RebootActionRequest rebootReq;
|
struct RebootActionRequest rebootReq;
|
||||||
@ -240,6 +269,34 @@ ReturnValue_t StarTrackerHandler::handlePingReply() {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ReturnValue_t StarTrackerHandler::handleVersionTm() {
|
||||||
|
ReturnValue_t result = RETURN_OK;
|
||||||
|
PoolReadGuard rg(&versionSet);
|
||||||
|
uint32_t offset = 2;
|
||||||
|
uint8_t status = *(decodedFrame + offset);
|
||||||
|
offset += 1;
|
||||||
|
if(status != StarTracker::STATUS_OK) {
|
||||||
|
sif::warning << "StarTrackerHandler::handleTemperatureTm: Reply error: "
|
||||||
|
<< static_cast<unsigned int>(status) << std::endl;
|
||||||
|
result = TEMPERATURE_REQUEST_FAILED;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
versionSet.program = (*decodedFrame + offset);
|
||||||
|
offset += 1;
|
||||||
|
versionSet.major = (*decodedFrame + offset);
|
||||||
|
offset += 1;
|
||||||
|
versionSet.minor = (*decodedFrame + offset);
|
||||||
|
#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1
|
||||||
|
sif::info << "StarTrackerHandler::handleVersionTm: Program: "
|
||||||
|
<< versionSet.program << std::endl;
|
||||||
|
sif::info << "StarTrackerHandler::handleVersionTm: Major: "
|
||||||
|
<< versionSet.major << std::endl;
|
||||||
|
sif::info << "StarTrackerHandler::handleVersionTm: Minor: "
|
||||||
|
<< versionSet.minor << std::endl;
|
||||||
|
#endif /* OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1 */
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
ReturnValue_t StarTrackerHandler::handleTemperatureTm() {
|
ReturnValue_t StarTrackerHandler::handleTemperatureTm() {
|
||||||
ReturnValue_t result = RETURN_OK;
|
ReturnValue_t result = RETURN_OK;
|
||||||
PoolReadGuard rg(&temperatureSet);
|
PoolReadGuard rg(&temperatureSet);
|
||||||
@ -267,7 +324,7 @@ ReturnValue_t StarTrackerHandler::handleTemperatureTm() {
|
|||||||
temperatureSet.mcuTemperature = *(decodedFrame + offset) << 24
|
temperatureSet.mcuTemperature = *(decodedFrame + offset) << 24
|
||||||
| *(decodedFrame + offset + 1) << 16 | *(decodedFrame + offset + 2) << 8
|
| *(decodedFrame + offset + 1) << 16 | *(decodedFrame + offset + 2) << 8
|
||||||
| *(decodedFrame + offset + 3);
|
| *(decodedFrame + offset + 3);
|
||||||
#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1
|
#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1
|
||||||
sif::info << "StarTrackerHandler::handleTemperatureTm: Ticks: "
|
sif::info << "StarTrackerHandler::handleTemperatureTm: Ticks: "
|
||||||
<< temperatureSet.ticks << std::endl;
|
<< temperatureSet.ticks << std::endl;
|
||||||
sif::info << "StarTrackerHandler::handleTemperatureTm: Time: "
|
sif::info << "StarTrackerHandler::handleTemperatureTm: Time: "
|
||||||
|
@ -72,6 +72,7 @@ private:
|
|||||||
static const uint32_t PING_ID = 0x55;
|
static const uint32_t PING_ID = 0x55;
|
||||||
|
|
||||||
StarTracker::TemperatureSet temperatureSet;
|
StarTracker::TemperatureSet temperatureSet;
|
||||||
|
StarTracker::VersionSet versionSet;
|
||||||
|
|
||||||
uint8_t commandBuffer[StarTracker::MAX_FRAME_SIZE];
|
uint8_t commandBuffer[StarTracker::MAX_FRAME_SIZE];
|
||||||
uint8_t rxBuffer[StarTracker::MAX_FRAME_SIZE];
|
uint8_t rxBuffer[StarTracker::MAX_FRAME_SIZE];
|
||||||
@ -98,6 +99,11 @@ private:
|
|||||||
*/
|
*/
|
||||||
void preparePingRequest();
|
void preparePingRequest();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Fills command buffer with data to request the version telemetry packet
|
||||||
|
*/
|
||||||
|
void prepareVersionRequest();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Fills command buffer with data to reboot star tracker.
|
* @brief Fills command buffer with data to reboot star tracker.
|
||||||
*/
|
*/
|
||||||
@ -113,6 +119,11 @@ private:
|
|||||||
* @brief This function handles the telemetry reply of a temperature request.
|
* @brief This function handles the telemetry reply of a temperature request.
|
||||||
*/
|
*/
|
||||||
ReturnValue_t handleTemperatureTm();
|
ReturnValue_t handleTemperatureTm();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief This function handles the telemetry reply of a version request.
|
||||||
|
*/
|
||||||
|
ReturnValue_t handleVersionTm();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* MISSION_DEVICES_STARTRACKERHANDLER_H_ */
|
#endif /* MISSION_DEVICES_STARTRACKERHANDLER_H_ */
|
||||||
|
@ -14,24 +14,32 @@ static const uint8_t ADDRESS = 33;
|
|||||||
static const uint8_t STATUS_OK = 0;
|
static const uint8_t STATUS_OK = 0;
|
||||||
|
|
||||||
enum PoolIds: lp_id_t {
|
enum PoolIds: lp_id_t {
|
||||||
TICKS,
|
TICKS_VERSION_SET,
|
||||||
TIME,
|
TIME_VERSION_SET,
|
||||||
|
TICKS_TEMPERATURE_SET,
|
||||||
|
TIME_TEMPERATURE_SET,
|
||||||
MCU_TEMPERATURE,
|
MCU_TEMPERATURE,
|
||||||
CMOS_TEMPERATURE
|
CMOS_TEMPERATURE,
|
||||||
|
PROGRAM,
|
||||||
|
MAJOR,
|
||||||
|
MINOR
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static const DeviceCommandId_t PING_REQUEST = 0;
|
static const DeviceCommandId_t PING_REQUEST = 0;
|
||||||
|
static const DeviceCommandId_t REQ_VERSION = 2;
|
||||||
static const DeviceCommandId_t REBOOT = 7;
|
static const DeviceCommandId_t REBOOT = 7;
|
||||||
static const DeviceCommandId_t REQ_TEMPERATURE = 25;
|
static const DeviceCommandId_t REQ_TEMPERATURE = 25;
|
||||||
|
|
||||||
|
static const uint32_t VERSION_SET_ID = REQ_VERSION;
|
||||||
static const uint32_t TEMPERATURE_SET_ID = REQ_TEMPERATURE;
|
static const uint32_t TEMPERATURE_SET_ID = REQ_TEMPERATURE;
|
||||||
|
|
||||||
/** Max size of unencoded frame */
|
/** Max size of unencoded frame */
|
||||||
static const size_t MAX_FRAME_SIZE = 1200;
|
static const size_t MAX_FRAME_SIZE = 1200;
|
||||||
|
|
||||||
static const uint8_t TEMPERATURE_SET_ENTRIES = 5;
|
static const uint8_t TEMPERATURE_SET_ENTRIES = 4;
|
||||||
|
static const uint8_t VERSION_SET_ENTRIES = 3;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This dataset can be used to store the temperature of a reaction wheel.
|
* @brief This dataset can be used to store the temperature of a reaction wheel.
|
||||||
@ -50,16 +58,45 @@ public:
|
|||||||
|
|
||||||
// Ticks is time reference generated by interanl counter of the star tracker
|
// Ticks is time reference generated by interanl counter of the star tracker
|
||||||
lp_var_t<uint32_t> ticks = lp_var_t<uint32_t>(sid.objectId,
|
lp_var_t<uint32_t> ticks = lp_var_t<uint32_t>(sid.objectId,
|
||||||
PoolIds::TICKS, this);
|
PoolIds::TICKS_TEMPERATURE_SET, this);
|
||||||
/** Unix time in microseconds */
|
/** Unix time in microseconds */
|
||||||
lp_var_t<uint64_t> time = lp_var_t<uint64_t>(sid.objectId,
|
lp_var_t<uint64_t> time = lp_var_t<uint64_t>(sid.objectId,
|
||||||
PoolIds::TIME, this);
|
PoolIds::TIME_TEMPERATURE_SET, this);
|
||||||
lp_var_t<float> mcuTemperature = lp_var_t<float>(sid.objectId,
|
lp_var_t<float> mcuTemperature = lp_var_t<float>(sid.objectId,
|
||||||
PoolIds::MCU_TEMPERATURE, this);
|
PoolIds::MCU_TEMPERATURE, this);
|
||||||
lp_var_t<float> cmosTemperature = lp_var_t<float>(sid.objectId,
|
lp_var_t<float> cmosTemperature = lp_var_t<float>(sid.objectId,
|
||||||
PoolIds::CMOS_TEMPERATURE, this);
|
PoolIds::CMOS_TEMPERATURE, this);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Package to store version parameters
|
||||||
|
*/
|
||||||
|
class VersionSet:
|
||||||
|
public StaticLocalDataSet<VERSION_SET_ENTRIES> {
|
||||||
|
public:
|
||||||
|
|
||||||
|
VersionSet(HasLocalDataPoolIF* owner):
|
||||||
|
StaticLocalDataSet(owner, VERSION_SET_ID) {
|
||||||
|
}
|
||||||
|
|
||||||
|
VersionSet(object_id_t objectId):
|
||||||
|
StaticLocalDataSet(sid_t(objectId, VERSION_SET_ID)) {
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ticks is time reference generated by interanl counter of the star tracker
|
||||||
|
lp_var_t<uint32_t> ticks = lp_var_t<uint32_t>(sid.objectId,
|
||||||
|
PoolIds::TICKS_VERSION_SET, this);
|
||||||
|
/** Unix time in microseconds */
|
||||||
|
lp_var_t<uint64_t> time = lp_var_t<uint64_t>(sid.objectId,
|
||||||
|
PoolIds::TIME_VERSION_SET, this);
|
||||||
|
lp_var_t<uint8_t> program = lp_var_t<uint8_t>(sid.objectId,
|
||||||
|
PoolIds::PROGRAM, this);
|
||||||
|
lp_var_t<uint8_t> major = lp_var_t<uint8_t>(sid.objectId,
|
||||||
|
PoolIds::MAJOR, this);
|
||||||
|
lp_var_t<uint8_t> minor = lp_var_t<uint8_t>(sid.objectId,
|
||||||
|
PoolIds::MINOR, this);
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* MISSION_STARTRACKER_DEFINITIONS_H_ */
|
#endif /* MISSION_STARTRACKER_DEFINITIONS_H_ */
|
||||||
|
Loading…
Reference in New Issue
Block a user