checking other way to get all data at once

This commit is contained in:
Robin Müller 2022-02-22 14:57:44 +01:00
parent 66b579a63a
commit 9e3d7bccd9
No known key found for this signature in database
GPG Key ID: 11D4952C8CCEF814
2 changed files with 22 additions and 17 deletions

View File

@ -327,11 +327,6 @@ void SpiTestClass::performOneShotMax1227Test() {
void SpiTestClass::performPeriodicMax1227Test() {
using namespace max1227;
adcCfg.testRadSensorExtConvWithDelay = false;
adcCfg.testRadSensorIntConv = true;
adcCfg.plPcduAdcExtConv = false;
adcCfg.plPcduAdcIntConv = false;
performMax1227Test();
}
@ -588,14 +583,19 @@ void SpiTestClass::max1227PlPcduTest(int fd) {
shiftOutZeros();
transfer(fd, gpioIds::PLPCDU_ADC_CS);
setSendBuffer();
arrayprinter::print(recvBuffer.data(), 26, OutputType::HEX);
//arrayprinter::print(recvBuffer.data(), 26, OutputType::HEX);
uint16_t adcRaw[n + 1] = {};
int16_t tempRaw = ((recvBuffer[0] & 0x0f) << 8) | recvBuffer[1];
sif::info << "Temperature: " << tempRaw * 0.125 << " C" << std::endl;
sif::info << "PL PCDU ADC int conv [" << std::hex << std::setfill('0');
for (int idx = 0; idx < n + 1; idx++) {
adcRaw[idx] = (recvBuffer[idx * 2 + 2] << 8) | recvBuffer[idx * 2 + 3];
sif::info << "ADC raw " << idx << ": " << adcRaw[idx] << std::endl;
sif::info << std::setw(3) << adcRaw[idx];
if(idx < n) {
sif::info << ",";
}
}
sif::info << "]" << std::endl;
sif::info << "Temperature: " << tempRaw * 0.125 << " C" << std::endl;
}
}

View File

@ -49,13 +49,11 @@ ReturnValue_t PayloadPcduHandler::buildNormalDeviceCommand(DeviceCommandId_t* id
switch (adcState) {
case (AdcStates::SEND_SETUP): {
*id = plpcdu::SETUP_CMD;
buildCommandFromCommand(*id, nullptr, 0);
break;
return buildCommandFromCommand(*id, nullptr, 0);
}
case (AdcStates::NORMAL): {
*id = plpcdu::READ_WITH_TEMP;
buildCommandFromCommand(*id, nullptr, 0);
break;
return buildCommandFromCommand(*id, nullptr, 0);
}
default: {
break;
@ -67,7 +65,7 @@ ReturnValue_t PayloadPcduHandler::buildNormalDeviceCommand(DeviceCommandId_t* id
ReturnValue_t PayloadPcduHandler::buildTransitionDeviceCommand(DeviceCommandId_t* id) {
if (adcState == AdcStates::SEND_SETUP) {
*id = plpcdu::SETUP_CMD;
buildCommandFromCommand(*id, nullptr, 0);
return buildCommandFromCommand(*id, nullptr, 0);
}
return NOTHING_TO_SEND;
}
@ -105,9 +103,13 @@ ReturnValue_t PayloadPcduHandler::buildCommandFromCommand(DeviceCommandId_t devi
max1227::prepareExternallyClockedTemperatureRead(cmdBuf.data() + sz, sz);
rawPacketLen = sz;
rawPacket = cmdBuf.data();
break;
}
default: {
return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED;
}
}
return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED;
return RETURN_OK;
}
ReturnValue_t PayloadPcduHandler::scanForReply(const uint8_t* start, size_t remainingSize,
@ -123,6 +125,9 @@ ReturnValue_t PayloadPcduHandler::interpretDeviceReply(DeviceCommandId_t id,
using namespace plpcdu;
switch (id) {
case (SETUP_CMD): {
if (mode == _MODE_TO_NORMAL) {
adcCmdExecuted = true;
}
break;
}
case (READ_TEMP): {
@ -184,14 +189,14 @@ void PayloadPcduHandler::handleExtConvRead(const uint8_t* bufStart) {
void PayloadPcduHandler::handlePrintout() {
if (periodicPrintout) {
if (opDivider.checkAndIncrement()) {
sif::info << "PL PCDU ADC hex [" << std::hex << std::setw(4);
sif::info << "PL PCDU ADC hex [" << std::setfill('0') << std::hex;
for (uint8_t idx = 0; idx < 12; idx++) {
sif::info << std::setfill('0') << adcSet.channels[idx];
sif::info << std::setw(3) << adcSet.channels[idx];
if (idx < 11) {
sif::info << ",";
}
}
sif::info << "] | T[C] " << std::dec << adcSet.tempC.value;
sif::info << "] | T[C] " << std::dec << adcSet.tempC.value << std::endl;
}
}
}