v1.10.0 #220
@ -128,7 +128,7 @@ ReturnValue_t PayloadPcduHandler::interpretDeviceReply(DeviceCommandId_t id,
|
|||||||
case (READ_TEMP): {
|
case (READ_TEMP): {
|
||||||
uint8_t tempStartIdx = TEMP_REPLY_SIZE - 2;
|
uint8_t tempStartIdx = TEMP_REPLY_SIZE - 2;
|
||||||
adcSet.tempC.value =
|
adcSet.tempC.value =
|
||||||
max1227::getTemperature(packet[tempStartIdx] << 8 | packet[tempStartIdx + 2]);
|
max1227::getTemperature(packet[tempStartIdx] << 8 | packet[tempStartIdx + 1]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case (READ_CMD): {
|
case (READ_CMD): {
|
||||||
@ -148,7 +148,7 @@ ReturnValue_t PayloadPcduHandler::interpretDeviceReply(DeviceCommandId_t id,
|
|||||||
handleExtConvRead(packet);
|
handleExtConvRead(packet);
|
||||||
uint8_t tempStartIdx = ADC_REPLY_SIZE + TEMP_REPLY_SIZE - 2;
|
uint8_t tempStartIdx = ADC_REPLY_SIZE + TEMP_REPLY_SIZE - 2;
|
||||||
adcSet.tempC.value =
|
adcSet.tempC.value =
|
||||||
max1227::getTemperature(packet[tempStartIdx] << 8 | packet[tempStartIdx + 2]);
|
max1227::getTemperature(packet[tempStartIdx] << 8 | packet[tempStartIdx + 1]);
|
||||||
handlePrintout();
|
handlePrintout();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -304,113 +304,3 @@ void PayloadPcduHandler::stateMachineToNormal() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PayloadPcduHandler::doShutDown() {}
|
|
||||||
|
|
||||||
ReturnValue_t PayloadPcduHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) {
|
|
||||||
switch(adcState) {
|
|
||||||
case(AdcStates::SEND_SETUP): {
|
|
||||||
*id = plpcdu::SETUP_CMD;
|
|
||||||
buildCommandFromCommand(*id, nullptr, 0);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case(AdcStates::NORMAL): {
|
|
||||||
*id = plpcdu::READ_WITH_TEMP;
|
|
||||||
buildCommandFromCommand(*id, nullptr, 0);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default: {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return NOTHING_TO_SEND;
|
|
||||||
}
|
|
||||||
|
|
||||||
ReturnValue_t PayloadPcduHandler::buildTransitionDeviceCommand(DeviceCommandId_t* id) {
|
|
||||||
if(adcState == AdcStates::SEND_SETUP) {
|
|
||||||
*id = plpcdu::SETUP_CMD;
|
|
||||||
buildCommandFromCommand(*id, nullptr, 0);
|
|
||||||
}
|
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
void PayloadPcduHandler::fillCommandAndReplyMap() {
|
|
||||||
insertInCommandAndReplyMap(plpcdu::READ_CMD, 2, &adcSet);
|
|
||||||
insertInCommandAndReplyMap(plpcdu::READ_TEMP, 1, &adcSet);
|
|
||||||
insertInCommandAndReplyMap(plpcdu::READ_WITH_TEMP, 1, &adcSet);
|
|
||||||
insertInCommandAndReplyMap(plpcdu::SETUP_CMD, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
ReturnValue_t PayloadPcduHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand,
|
|
||||||
const uint8_t* commandData,
|
|
||||||
size_t commandDataLen) {
|
|
||||||
switch(deviceCommand) {
|
|
||||||
case(plpcdu::SETUP_CMD): {
|
|
||||||
cmdBuf[0] = plpcdu::SETUP_BYTE;
|
|
||||||
rawPacket = cmdBuf.data();
|
|
||||||
rawPacketLen = 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case(plpcdu::READ_CMD): {
|
|
||||||
max1227::prepareExternallyClockedRead0ToN(cmdBuf.data(), plpcdu::CHANNEL_N, rawPacketLen);
|
|
||||||
rawPacket = cmdBuf.data();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case(plpcdu::READ_TEMP): {
|
|
||||||
max1227::prepareExternallyClockedTemperatureRead(cmdBuf.data(), rawPacketLen);
|
|
||||||
rawPacket = cmdBuf.data();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case(plpcdu::READ_WITH_TEMP): {
|
|
||||||
size_t sz = 0;
|
|
||||||
max1227::prepareExternallyClockedRead0ToN(cmdBuf.data(), plpcdu::CHANNEL_N, sz);
|
|
||||||
max1227::prepareExternallyClockedTemperatureRead(cmdBuf.data() + sz, sz);
|
|
||||||
rawPacketLen = sz;
|
|
||||||
rawPacket = cmdBuf.data();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED;
|
|
||||||
}
|
|
||||||
|
|
||||||
ReturnValue_t PayloadPcduHandler::scanForReply(const uint8_t* start, size_t remainingSize,
|
|
||||||
DeviceCommandId_t* foundId, size_t* foundLen) {
|
|
||||||
// SPI is full duplex
|
|
||||||
*foundId = getPendingCommand();
|
|
||||||
*foundLen = remainingSize;
|
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
ReturnValue_t PayloadPcduHandler::interpretDeviceReply(DeviceCommandId_t id,
|
|
||||||
const uint8_t* packet) {
|
|
||||||
using namespace plpcdu;
|
|
||||||
switch(id) {
|
|
||||||
case(SETUP_CMD): {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case(READ_WITH_TEMP): {
|
|
||||||
PoolReadGuard pg(&adcSet);
|
|
||||||
if(pg.getReadResult() != HasReturnvaluesIF::RETURN_OK) {
|
|
||||||
return pg.getReadResult();
|
|
||||||
}
|
|
||||||
for(uint8_t idx = 0; idx < 12; idx ++) {
|
|
||||||
adcSet.channels[idx] = packet[idx * 2 + 1] << 8 | packet[idx * 2 + 2];
|
|
||||||
}
|
|
||||||
uint8_t tempStartIdx = ADC_REPLY_SIZE + TEMP_REPLY_SIZE - 2;
|
|
||||||
adcSet.tempC.value = max1227::getTemperature(packet[tempStartIdx] << 8 | packet[tempStartIdx + 1]);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t PayloadPcduHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) {
|
|
||||||
// 20 minutes transition delay is allowed
|
|
||||||
return 20 * 60 * 60;
|
|
||||||
}
|
|
||||||
|
|
||||||
ReturnValue_t PayloadPcduHandler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
|
|
||||||
LocalDataPoolManager& poolManager) {
|
|
||||||
localDataPoolMap.emplace(plpcdu::PlPcduPoolIds::CHANNEL_VEC, &channelValues);
|
|
||||||
localDataPoolMap.emplace(plpcdu::PlPcduPoolIds::TEMP, &tempC);
|
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user