diff options
author | David Crocker <dcrocker@eschertech.com> | 2022-01-13 12:50:07 +0300 |
---|---|---|
committer | David Crocker <dcrocker@eschertech.com> | 2022-01-13 12:50:07 +0300 |
commit | a96f0d11d89f75276c4ec80efe0a438c0a65a3f8 (patch) | |
tree | 58593ae48379e670efa0ee30e019096052431640 /src/GPIO | |
parent | af7177e086137b955742eb6ba9d1cf5ffedb9e9a (diff) |
Fix for M280 on remote ports
Needed to store the frequency in the local port object even when the
port is remote.
Diffstat (limited to 'src/GPIO')
-rw-r--r-- | src/GPIO/GpOutPort.cpp | 60 |
1 files changed, 35 insertions, 25 deletions
diff --git a/src/GPIO/GpOutPort.cpp b/src/GPIO/GpOutPort.cpp index f17eec12..44156164 100644 --- a/src/GPIO/GpOutPort.cpp +++ b/src/GPIO/GpOutPort.cpp @@ -104,22 +104,23 @@ GCodeResult GpOutputPort::Configure(uint32_t gpioNumber, bool isServo, GCodeBuff else #endif { - if (port.AssignPort(pinName.c_str(), reply, PinUsedBy::gpout, (isServo) ? PinAccess::servo : PinAccess::pwm)) - { - rslt = GCodeResult::ok; - port.SetFrequency(freq); - } - else - { - rslt = GCodeResult::error; - } + rslt = (port.AssignPort(pinName.c_str(), reply, PinUsedBy::gpout, (isServo) ? PinAccess::servo : PinAccess::pwm)) + ? GCodeResult::ok + : GCodeResult::error; } - reprap.StateUpdated(); + if (Succeeded(rslt)) + { + port.SetFrequency(freq); // we need to set the frequency even if it is a remote port because M280 uses it + reprap.StateUpdated(); + } return rslt; } - else if (seenFreq) + + // If we get here then there was no port name parameter + if (seenFreq) { + GCodeResult rslt; #if SUPPORT_CAN_EXPANSION if (boardAddress != CanInterface::GetCanAddress()) { @@ -127,25 +128,34 @@ GCodeResult GpOutputPort::Configure(uint32_t gpioNumber, bool isServo, GCodeBuff cons.AddUParam('P', gpioNumber); cons.AddUParam('Q', freq); reprap.StateUpdated(); - return cons.SendAndGetResponse(CanMessageType::m950Gpio, boardAddress, reply); + rslt = cons.SendAndGetResponse(CanMessageType::m950Gpio, boardAddress, reply); } + else #endif - port.SetFrequency(freq); - reprap.StateUpdated(); - } - else - { -#if SUPPORT_CAN_EXPANSION - if (boardAddress != CanInterface::GetCanAddress()) { - CanMessageGenericConstructor cons(M950GpioParams); - cons.AddUParam('P', gpioNumber); - return cons.SendAndGetResponse(CanMessageType::m950Gpio, boardAddress, reply); + rslt = GCodeResult::ok; } -#endif - reply.printf("GPIO/servo port %" PRIu32, gpioNumber); - port.AppendFullDetails(reply); + + if (Succeeded(rslt)) + { + port.SetFrequency(freq); + reprap.StateUpdated(); + } + return rslt; + } + + // If we get here then we have neither a port name nor a frequency, so just print the port details +#if SUPPORT_CAN_EXPANSION + if (boardAddress != CanInterface::GetCanAddress()) + { + CanMessageGenericConstructor cons(M950GpioParams); + cons.AddUParam('P', gpioNumber); + return cons.SendAndGetResponse(CanMessageType::m950Gpio, boardAddress, reply); } +#endif + + reply.printf("GPIO/servo port %" PRIu32, gpioNumber); + port.AppendFullDetails(reply); return GCodeResult::ok; } |