separated steps, everything seems to work

This commit is contained in:
Robin Müller 2020-09-03 00:17:01 +02:00
parent e8fa9816ce
commit 822a908353
3 changed files with 23 additions and 29 deletions

View File

@ -72,8 +72,11 @@ DeviceHandlerBase::~DeviceHandlerBase() {
ReturnValue_t DeviceHandlerBase::performOperation(uint8_t counter) { ReturnValue_t DeviceHandlerBase::performOperation(uint8_t counter) {
this->pstStep = counter; this->pstStep = counter;
if (getComAction() == CommunicationAction::NOTHING) {
return HasReturnvaluesIF::RETURN_OK;
}
if (getComAction() == SEND_WRITE) { if (getComAction() == CommunicationAction::PERFORM_OPERATION) {
cookieInfo.state = COOKIE_UNUSED; cookieInfo.state = COOKIE_UNUSED;
readCommandQueue(); readCommandQueue();
doStateMachine(); doStateMachine();
@ -88,21 +91,21 @@ ReturnValue_t DeviceHandlerBase::performOperation(uint8_t counter) {
return RETURN_OK; return RETURN_OK;
} }
switch (getComAction()) { switch (getComAction()) {
case SEND_WRITE: case CommunicationAction::SEND_WRITE:
if ((cookieInfo.state == COOKIE_UNUSED)) { if (cookieInfo.state == COOKIE_UNUSED) {
// if no external command was specified, build internal command.
buildInternalCommand(); buildInternalCommand();
} }
doSendWrite(); doSendWrite();
break; break;
case GET_WRITE: case CommunicationAction::GET_WRITE:
doGetWrite(); doGetWrite();
break; break;
case SEND_READ: case CommunicationAction::SEND_READ:
doSendRead(); doSendRead();
break; break;
case GET_READ: case CommunicationAction::GET_READ:
doGetRead(); doGetRead();
cookieInfo.state = COOKIE_UNUSED;
break; break;
default: default:
break; break;
@ -821,24 +824,27 @@ void DeviceHandlerBase::replyRawData(const uint8_t *data, size_t len,
} }
//Default child implementations //Default child implementations
DeviceHandlerIF::CommunicationAction_t DeviceHandlerBase::getComAction() { DeviceHandlerIF::CommunicationAction DeviceHandlerBase::getComAction() {
switch (pstStep) { switch (pstStep) {
case 0: case 0:
return SEND_WRITE; return CommunicationAction::PERFORM_OPERATION;
break; break;
case 1: case 1:
return GET_WRITE; return CommunicationAction::SEND_WRITE;
break; break;
case 2: case 2:
return SEND_READ; return CommunicationAction::GET_WRITE;
break; break;
case 3: case 3:
return GET_READ; return CommunicationAction::SEND_READ;
break;
case 4:
return CommunicationAction::GET_READ;
break; break;
default: default:
break; break;
} }
return NOTHING; return CommunicationAction::NOTHING;
} }
MessageQueueId_t DeviceHandlerBase::getCommandQueue() const { MessageQueueId_t DeviceHandlerBase::getCommandQueue() const {
@ -1129,19 +1135,6 @@ ReturnValue_t DeviceHandlerBase::handleDeviceHandlerMessage(
} }
replyReturnvalueToCommand(RETURN_OK); replyReturnvalueToCommand(RETURN_OK);
return RETURN_OK; return RETURN_OK;
// case DeviceHandlerMessage::CMD_SWITCH_IOBOARD:
// if (mode != MODE_OFF) {
// replyReturnvalueToCommand(WRONG_MODE_FOR_COMMAND);
// } else {
// result = switchCookieChannel(
// DeviceHandlerMessage::getIoBoardObjectId(message));
// if (result == RETURN_OK) {
// replyReturnvalueToCommand(RETURN_OK);
// } else {
// replyReturnvalueToCommand(CANT_SWITCH_IO_ADDRESS);
// }
// }
// return RETURN_OK;
case DeviceHandlerMessage::CMD_RAW: case DeviceHandlerMessage::CMD_RAW:
if ((mode != MODE_RAW)) { if ((mode != MODE_RAW)) {
DeviceHandlerMessage::clear(message); DeviceHandlerMessage::clear(message);

View File

@ -819,7 +819,7 @@ protected:
* @return The Rmap action to execute in this step * @return The Rmap action to execute in this step
*/ */
virtual CommunicationAction_t getComAction(); virtual CommunicationAction getComAction();
/** /**
* Build the device command to send for raw mode. * Build the device command to send for raw mode.

View File

@ -131,7 +131,8 @@ public:
* *
* This is used by the child class to tell the base class what to do. * This is used by the child class to tell the base class what to do.
*/ */
enum CommunicationAction_t: uint8_t { enum CommunicationAction: uint8_t {
PERFORM_OPERATION,
SEND_WRITE,//!< Send write SEND_WRITE,//!< Send write
GET_WRITE, //!< Get write GET_WRITE, //!< Get write
SEND_READ, //!< Send read SEND_READ, //!< Send read