gyro handler finished
This commit is contained in:
@ -17,25 +17,25 @@ MGMHandlerRM3100::MGMHandlerRM3100(object_id_t objectId,
|
||||
MGMHandlerRM3100::~MGMHandlerRM3100() {}
|
||||
|
||||
void MGMHandlerRM3100::doStartUp() {
|
||||
if(internalState == STATE_NONE) {
|
||||
internalState = STATE_CONFIGURE_CMM;
|
||||
if(internalState == InternalState::STATE_NONE) {
|
||||
internalState = InternalState::STATE_CONFIGURE_CMM;
|
||||
}
|
||||
|
||||
if(internalState == STATE_CONFIGURE_CMM) {
|
||||
internalState = STATE_READ_CMM;
|
||||
if(internalState == InternalState::STATE_CONFIGURE_CMM) {
|
||||
internalState = InternalState::STATE_READ_CMM;
|
||||
}
|
||||
else if(internalState == STATE_READ_CMM) {
|
||||
else if(internalState == InternalState::STATE_READ_CMM) {
|
||||
if(commandExecuted) {
|
||||
internalState = STATE_CONFIGURE_TMRC;
|
||||
internalState = InternalState::STATE_CONFIGURE_TMRC;
|
||||
}
|
||||
}
|
||||
|
||||
if(internalState == STATE_CONFIGURE_TMRC) {
|
||||
internalState = STATE_READ_TMRC;
|
||||
if(internalState == InternalState::STATE_CONFIGURE_TMRC) {
|
||||
internalState = InternalState::STATE_READ_TMRC;
|
||||
}
|
||||
else if(internalState == STATE_READ_TMRC) {
|
||||
else if(internalState == InternalState::STATE_READ_TMRC) {
|
||||
if(commandExecuted) {
|
||||
internalState = STATE_NORMAL;
|
||||
internalState = InternalState::STATE_NORMAL;
|
||||
setMode(_MODE_TO_ON);
|
||||
}
|
||||
}
|
||||
@ -47,20 +47,32 @@ void MGMHandlerRM3100::doShutDown() {
|
||||
|
||||
ReturnValue_t MGMHandlerRM3100::buildTransitionDeviceCommand(
|
||||
DeviceCommandId_t *id) {
|
||||
if(internalState == STATE_CONFIGURE_CMM) {
|
||||
switch(internalState) {
|
||||
case(InternalState::STATE_NONE):
|
||||
case(InternalState::STATE_NORMAL): {
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
case(InternalState::STATE_CONFIGURE_CMM): {
|
||||
*id = RM3100::CONFIGURE_CMM;
|
||||
break;
|
||||
}
|
||||
|
||||
if(internalState == STATE_READ_CMM) {
|
||||
case(InternalState::STATE_READ_CMM): {
|
||||
*id = RM3100::READ_CMM;
|
||||
break;
|
||||
}
|
||||
|
||||
if(internalState == STATE_CONFIGURE_TMRC) {
|
||||
case(InternalState::STATE_CONFIGURE_TMRC): {
|
||||
*id = RM3100::CONFIGURE_TMRC;
|
||||
break;
|
||||
}
|
||||
|
||||
if(internalState == STATE_READ_TMRC) {
|
||||
case(InternalState::STATE_READ_TMRC): {
|
||||
*id = RM3100::READ_TMRC;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
// might be a configuration error.
|
||||
sif::debug << "GyroHandler::buildTransitionDeviceCommand: Unknown "
|
||||
<< "internal state!" << std::endl;
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
return buildCommandFromCommand(*id, nullptr, 0);
|
||||
@ -137,22 +149,26 @@ ReturnValue_t MGMHandlerRM3100::scanForReply(const uint8_t *start,
|
||||
if (start[0] == 0b11111111) {
|
||||
return RETURN_OK;
|
||||
}
|
||||
else {
|
||||
return DeviceHandlerIF::INVALID_DATA;
|
||||
}
|
||||
return DeviceHandlerIF::INVALID_DATA;
|
||||
}
|
||||
|
||||
ReturnValue_t MGMHandlerRM3100::interpretDeviceReply(
|
||||
DeviceCommandId_t id, const uint8_t *packet) {
|
||||
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
|
||||
switch(id) {
|
||||
case(RM3100::CONFIGURE_CMM):
|
||||
case(RM3100::CONFIGURE_CYCLE_COUNT):
|
||||
case(RM3100::CONFIGURE_TMRC): {
|
||||
// We can only check whether write was sucessful with read operation.
|
||||
break;
|
||||
}
|
||||
case(RM3100::READ_CMM): {
|
||||
if(packet[1] == cmmRegValue) {
|
||||
commandExecuted = true;
|
||||
}
|
||||
else {
|
||||
// Attempt reconfiguration.
|
||||
internalState = STATE_CONFIGURE_CMM;
|
||||
internalState = InternalState::STATE_CONFIGURE_CMM;
|
||||
return DeviceHandlerIF::DEVICE_REPLY_INVALID;
|
||||
}
|
||||
break;
|
||||
@ -167,7 +183,7 @@ ReturnValue_t MGMHandlerRM3100::interpretDeviceReply(
|
||||
}
|
||||
else {
|
||||
// Attempt reconfiguration.
|
||||
internalState = STATE_CONFIGURE_TMRC;
|
||||
internalState = InternalState::STATE_CONFIGURE_TMRC;
|
||||
return DeviceHandlerIF::DEVICE_REPLY_INVALID;
|
||||
}
|
||||
break;
|
||||
@ -284,7 +300,7 @@ void MGMHandlerRM3100::fillCommandAndReplyMap() {
|
||||
}
|
||||
|
||||
void MGMHandlerRM3100::modeChanged(void) {
|
||||
internalState = STATE_NONE;
|
||||
internalState = InternalState::STATE_NONE;
|
||||
}
|
||||
|
||||
ReturnValue_t MGMHandlerRM3100::initializeLocalDataPool(
|
||||
|
Reference in New Issue
Block a user