Repository navigation
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #576
Summary
When a serial LED controller (such as WLED or an Arduino/USB-serial adapter) is power-cycled or disconnected without a system suspend event,
QSerialPort::isOpen()could remaintruein a wedged state wherebytesToWrite() > 0causedwriteBuffer()andwriteLastWill()to skip every frame and never trigger device recovery inLedDeviceManager.This applies symmetric serial error and TX-stall recovery to both
LedDeviceAdalightandLedDeviceArdulight:QSerialPortsetup: AllocateQSerialPortonce with the device as parent and connectQSerialPort::errorOccurredandQSerialPort::bytesWrittenonce ininitSerialPort()instead of recreating/reconnecting on everyopen().open()/close()lifecycle: Guardopen()withm_isOpeningso synchronous open failures only emitopenDeviceSuccess(false)(never duplicateioDeviceSuccess(false)), close the port inopen()ifsetBaudRate()orsetDataBits()fails, and stop bothm_txStallTimerandm_lastWillTimeronopen()andclose()(guarded bym_isClosingto avoid re-entrant error emission).QSerialPort::errorOccurred; onResourceError,WriteError,DeviceNotFoundError,PermissionError,OpenError, orNotOpenErroroutsideopen()/close(), stop timers, close and clear error state on the port, and emitioDeviceSuccess(false)soLedDeviceManagerschedules device recreation and state replay.2000mssingle-shot): Armm_txStallTimerwhen a write leavesbytesToWrite() > 0, stop/restart it inonBytesWritten()as bytes drain, and if it fires whileisOpen() && bytesToWrite() > 0, log a warning, stopm_lastWillTimer, close the port, clear error state, and emitioDeviceSuccess(false).Testing
PrismatikandLightpackTestswithqmake6 -r && make -j2.QT_QPA_PLATFORM=offscreen ./bin/LightpackTests: all 8 test suites passed (GrabCalculationTest,SettingsMigrationTest,LightpackMathTest,LightpackApiTest,AppVersionTest,LightpackCommandLineParserTest,LedDeviceManagerTest[19 passed, 0 failed],PluginHardeningTest).Software/tests/LedDeviceManagerTest.{hpp,cpp}covering:ioDeviceSuccess(false)recovery and state replay (SetColorsandStatusOff/OffLeds).LedDeviceAdalightandLedDeviceArdulightopen()failure suppression, non-fatal vs fatalQSerialPort::errorOccurredhandling, guard checks, and timer cleanup.setBaudRate(-1)failure, watchdog stop/restart on drain, TX-stall watchdog closure +ioDeviceSuccess(false)+ reopen recovery, and end-to-endLedDeviceManagerdisconnect/backoff/reconnect/frame replay.