diff --git a/src/eez/modules/dib-mio168/dib-mio168.cpp b/src/eez/modules/dib-mio168/dib-mio168.cpp index 8baef7d86..fab16071b 100644 --- a/src/eez/modules/dib-mio168/dib-mio168.cpp +++ b/src/eez/modules/dib-mio168/dib-mio168.cpp @@ -53,16 +53,22 @@ static const int DOUT_SUBCHANNEL_INDEX = 1; struct Mio168DinChannel : public Channel { Mio168DinChannel(int slotIndex, int channelIndex) : Channel(slotIndex, channelIndex, DIN_SUBCHANNEL_INDEX) - {} + { + flags.powerOk = 1; + } + + TestResult getTestResult() override; void getParams(uint16_t moduleRevision) override { params.features = CH_FEATURE_DINPUT; } - + + uint8_t getDigitalInputData() override; + + // defaults virtual void init() override {} bool test() override { return true; } void tickSpecific(uint32_t tickCount) override {} - TestResult getTestResult() override { return TEST_OK; } bool isInCcMode() override { return false; } bool isInCvMode() override { return false; } void adcMeasureUMon() override {} @@ -80,23 +86,28 @@ struct Mio168DinChannel : public Channel { void getPowerStepValues(StepValues *stepValues) override {} bool isPowerLimitExceeded(float u, float i, int *err) override { return false; } float readTemperature() override { return 25.0f; } - - uint8_t getDigitalInputData() override; }; struct Mio168DoutChannel : public Channel { Mio168DoutChannel(int slotIndex, int channelIndex) : Channel(slotIndex, channelIndex, DOUT_SUBCHANNEL_INDEX) - {} + { + flags.powerOk = 1; + } void getParams(uint16_t moduleRevision) override { params.features = CH_FEATURE_DOUTPUT; } + TestResult getTestResult() override; + + uint8_t getDigitalOutputData() override; + void setDigitalOutputData(uint8_t data) override; + + // defaults virtual void init() override {} bool test() override { return true; } void tickSpecific(uint32_t tickCount) override {} - TestResult getTestResult() override { return TEST_OK; } bool isInCcMode() override { return false; } bool isInCvMode() override { return false; } void adcMeasureUMon() override {} @@ -114,9 +125,6 @@ struct Mio168DoutChannel : public Channel { void getPowerStepValues(StepValues *stepValues) override {} bool isPowerLimitExceeded(float u, float i, int *err) override { return false; } float readTemperature() override { return 25.0f; } - - uint8_t getDigitalOutputData() override; - void setDigitalOutputData(uint8_t data) override; }; struct Mio168ModuleInfo : public ModuleInfo { @@ -308,11 +316,21 @@ Channel *Mio168ModuleInfo::createChannel(int slotIndex, int channelIndex, int su static Mio168ModuleInfo g_mio168ModuleInfo; ModuleInfo *g_moduleInfo = &g_mio168ModuleInfo; +TestResult Mio168DinChannel::getTestResult() { + auto mio168Module = (dib_mio168::Mio168Module *)g_slots[slotIndex]; + return mio168Module->testResult; +} + uint8_t Mio168DinChannel::getDigitalInputData() { auto mio168Module = (dib_mio168::Mio168Module *)g_slots[slotIndex]; return mio168Module->inputPinStates; } +TestResult Mio168DoutChannel::getTestResult() { + auto mio168Module = (dib_mio168::Mio168Module *)g_slots[slotIndex]; + return mio168Module->testResult; +} + uint8_t Mio168DoutChannel::getDigitalOutputData() { auto mio168Module = (dib_mio168::Mio168Module *)g_slots[slotIndex]; return mio168Module->outputPinStates; diff --git a/src/eez/modules/psu/scpi/params.cpp b/src/eez/modules/psu/scpi/params.cpp index a75eca6e1..c9619303b 100644 --- a/src/eez/modules/psu/scpi/params.cpp +++ b/src/eez/modules/psu/scpi/params.cpp @@ -194,17 +194,19 @@ void param_channels(scpi_t *context, scpi_parameter_t *parameter, int &numChanne channels[numChannels++] = value; } } else { + int value = valueFrom; + if (numChannels == MAX_NUM_CH_IN_CH_LIST) { numChannels = 0; return; } - if (!channelNumberToChannelIndex(valueFrom)) { + if (!channelNumberToChannelIndex(value)) { numChannels = 0; return; } - channels[numChannels++] = valueFrom; + channels[numChannels++] = value; } } else if (result == SCPI_EXPR_NO_MORE) { break; diff --git a/src/eez/modules/psu/scpi/sour.cpp b/src/eez/modules/psu/scpi/sour.cpp index 45bc4eb29..65d845661 100644 --- a/src/eez/modules/psu/scpi/sour.cpp +++ b/src/eez/modules/psu/scpi/sour.cpp @@ -1229,7 +1229,7 @@ scpi_result_t scpi_cmd_sourceDigitalDataByte(scpi_t *context) { return SCPI_RES_ERR; } - if (!(channel->params.features & CH_FEATURE_DINPUT)) { + if (!(channel->params.features & CH_FEATURE_DOUTPUT)) { return SCPI_RES_ERR; } @@ -1246,7 +1246,7 @@ scpi_result_t scpi_cmd_sourceDigitalDataByte(scpi_t *context) { channel->setDigitalOutputData(data); - return SCPI_RES_ERR; + return SCPI_RES_OK; } scpi_result_t scpi_cmd_sourceDigitalDataByteQ(scpi_t *context) { @@ -1262,7 +1262,7 @@ scpi_result_t scpi_cmd_sourceDigitalDataByteQ(scpi_t *context) { SCPI_ResultUInt8(context, channel->getDigitalOutputData()); - return SCPI_RES_ERR; + return SCPI_RES_OK; } } // namespace scpi