another try to read out the adc

This commit is contained in:
Jakob Meier 2021-05-03 12:05:19 +02:00
parent f708a67fa8
commit 31b4246bca

View File

@ -31,8 +31,29 @@ void RadiationSensorHandler::doShutDown(){
ReturnValue_t RadiationSensorHandler::buildNormalDeviceCommand(
DeviceCommandId_t * id) {
*id = RAD_SENSOR::PERFORM_CONVERSION;
return buildCommandFromCommand(*id, nullptr, 0);
switch (communicationStep) {
case CommunicationStep::FIRST_CONVERSION: {
*id = RAD_SENSOR::FIRST_CONVERSION;
communicationStep = CommunicationStep::READ_CONVERSIONS;
break;
}
case CommunicationStep::PERFORM_CONVERSION: {
*id = RAD_SENSOR::PERFORM_CONVERSION;
communicationStep = CommunicationStep::READ_CONVERSIONS;
break;
}
case CommunicationStep::READ_CONVERSIONS: {
*id = RAD_SENSOR::READ_CONVERSIONS;
communicationStep = CommunicationStep::PERFRORM_CONVERSION;
break;
}
default: {
sif::debug << "RadiationSensorHandler::buildNormalDeviceCommand: Unknwon communication "
<< "step" << std::endl;
return HasReturnvaluesIF::RETURN_OK;
}
}
return buildCommandFromCommand(*id, nullptr, 0);
}
ReturnValue_t RadiationSensorHandler::buildTransitionDeviceCommand(
@ -57,6 +78,13 @@ ReturnValue_t RadiationSensorHandler::buildCommandFromCommand(
internalState = InternalState::CONFIGURED;
return RETURN_OK;
}
case(RAD_SENSOR::FIRST_CONVERSION): {
/* Dummy bytes are written to remove old values from fifo */
cmdBuffer[0] = RAD_SENSOR::FIRST_CONVERSION_DEFINITION;
rawPacket = cmdBuffer;
rawPacketLen = RAD_SENSOR::READ_SIZE;
return RETURN_OK;
}
case(RAD_SENSOR::PERFORM_CONVERSION): {
/* Dummy bytes are written to remove old values from fifo */
cmdBuffer[0] = RAD_SENSOR::CONVERSION_DEFINITION;