Repository navigation
Conversation
There was a problem hiding this comment.
Pull request overview
This PR addresses loss of cord-wrap settings across driver restarts by persisting cord-wrap toggle/position/base-mode to the INDI config and restoring them during property initialization, aligning cord-wrap behavior with other persisted driver options.
Changes:
- Persist cord-wrap properties by saving config from ISNewSwitch handlers and loading config in ISGetProperties().
- Add mount read/write helpers and error handling around cord-wrap queries, with fallback to saved config when mount queries fail.
- Add a system test suite covering cord-wrap config persistence behavior and update the simulator/test plan/versioning.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| indi-celestronaux/celestronaux.cpp | Loads/saves cord-wrap config, adds mount read/write helpers, and updates switch handlers/error paths. |
| indi-celestronaux/celestronaux.h | Updates cord-wrap API signatures and adds helper/utility declarations. |
| indi-celestronaux/tests/system/test_cordwrap.py | Adds system tests that validate cord-wrap config values are written as expected. |
| indi-celestronaux/simulator/nse_simulator.py | Adjusts entrypoint behavior to avoid curses in headless/test mode. |
| indi-celestronaux/TEST_PLAN.md | Documents a new test phase for cord-wrap persistence. |
| indi-celestronaux/CMakeLists.txt | Bumps the driver minor version. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Please note the values of an INDI property can be loaded like this: However, this would ONLY load the values from config in this property, it's not going to trigger ISNewSwitch(...). Just wanted to share this as it may be what you wanted to use instead of loadConfig(true, CordWrapToggleSP.getName()); The full loadConfig version would call ISNewXXX functions. |
I am not sure - I wanted UI to reflect the state of the driver so I think triggering ISNewSwitch is ok. I am a little rusty on the INDI UI conventions - I was following the patterns of other parts of the driver and other drivers. When I finish with co-pilot review I would appreciate your review as well before I merge. |
- Add switch clear in updateProperties to avoid multiple ON states - Check writeCordWrapToMount return in CordWrapPositionSP and CordWrapBaseSP handlers - Check getCordWrapEnabled return in CordWrapToggleSP handler - Add LOGF_INFO for cord wrap enabled status after mount query - Fix simulator to accept both -t and t flags - Add config backup/restore fixture for system tests Also restores LOGF_INFO for cord wrap position angle in updateProperties which was accidentally removed by copilot's switch clear suggestion.
|
I discovered some more issues regarding this cordwrap - so changed to draft while I am dealing with them. |
|
This was a fairly hairy issue. Multiple code paths and strategies. Some obviously ad-hoc code too. I hope, I spotted all the paths and variants. At least it keeps the settings in three scenarios I could test (HC/HBG3/network). When it cannot read from the mount or from the settings it defaults to sane (I hope) defaults. I think it is ready for review. The intermittent build failures are due to the high server load on builders. |
|
We should delay this for next INDI release as we are too close to the next release in 1 week. |
|
@knro I was hoping to sqeeze it before the release. Right now the CW code simply resets the state to North/Off at each start of the driver... The setting works but needs to be reapplied at the start of each driver session. |
| // Sync member variables from property state | ||
| m_CordWrapActive = CordWrapToggleSP[INDI_ENABLED].s == ISS_ON; | ||
| int onIdx = CordWrapPositionSP.findOnSwitchIndex(); | ||
| if (onIdx >= 0) | ||
| m_RequestedCordwrapPos = onIdx * 45; | ||
| } |
| void CelestronAUX::syncCoordWrapPosition() | ||
| { | ||
| // No coord wrap for equatorial mounts. | ||
| if (m_MountType != ALT_AZ) | ||
| return; | ||
|
|
||
| uint32_t coordWrapPosition = 0; | ||
| if (CordWrapBaseSP[CW_BASE_SKY].s == ISS_ON) | ||
| coordWrapPosition = range360(m_RequestedCordwrapPos + getNorthAz()) * STEPS_PER_DEGREE; | ||
| if (isCordWrapSkyMode()) | ||
| writeCordWrapToMount(); | ||
| else | ||
| coordWrapPosition = range360(m_RequestedCordwrapPos) * STEPS_PER_DEGREE; | ||
| setCordWrapPosition(coordWrapPosition); | ||
| getCordWrapPosition(); | ||
| readCordWrapFromMount(); | ||
| } |
Cord wrap properties (toggle, position, base mode) were not being saved to config when changed via the UI. This caused settings to be lost on driver restart. Root cause: ISNewSwitch handlers for CORDWRAP, CORDWRAP_POS, and CW_BASE were missing saveConfig() calls after updating properties. Changes: - Add saveConfig() calls to all three cord wrap ISNewSwitch handlers - Add loadConfig() calls in ISGetProperties() to restore settings - Fix CORDWRAP_NE default from ISS_ON to ISS_OFF in initProperties() - Add error handling for getCordWrapEnabled/getCordWrapPosition - Update updateProperties() to fallback to config on mount query failure - Add isCordWrapSkyMode() helper method - Add comprehensive cord wrap persistence tests (7 tests) Follows the same pattern as ApproachDirectionSP, PortTypeSP, and GuidePulseMode which already call saveConfig() in their handlers.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
- Add switch clear in updateProperties to avoid multiple ON states - Check writeCordWrapToMount return in CordWrapPositionSP and CordWrapBaseSP handlers - Check getCordWrapEnabled return in CordWrapToggleSP handler - Add LOGF_INFO for cord wrap enabled status after mount query - Fix simulator to accept both -t and t flags - Add config backup/restore fixture for system tests Also restores LOGF_INFO for cord wrap position angle in updateProperties which was accidentally removed by copilot's switch clear suggestion.
- startupWithoutHC(): replace hardcoded 270° with priority lookup Mount → Config → North default, log in degrees - updateProperties(): defineProperty before loadConfig for reliable config restore on reconnect; sync member vars from property state - Initialize m_RequestedCordwrapPos to 0 in header Fixes second-reconnect bug where all positions mapped to 270° (W).
95bb5f7 to
124f1a0
Compare
|
The last sequence is a no-op, it is a side-effect of my rearangement of branches. There were no additional changes. |
Cord wrap properties (toggle, position, base mode) were not being saved to config when changed via the UI. This caused settings to be lost on driver restart.
Root cause: ISNewSwitch handlers for CORDWRAP, CORDWRAP_POS, and CW_BASE were missing saveConfig() calls after updating properties.
Changes:
Follows the same pattern as ApproachDirectionSP, PortTypeSP, and GuidePulseMode which already call saveConfig() in their handlers.
Tested in simulation and on real mount with HC and HBG3 and over network.