After testing more, the code works fine but there is still something wrong with Ekos.
When I Park the mount Ekos considers TrackState as Parked which is OK,
but when I unpark Ekos considers TrackState as Idle (despite the fact that the driver says Tracking).
So as James said there is still something to do somewhere ...
When I manually "stop/start" tracking in the control panel things are synced again between driver and Ekos ????
I'm testing your repository (github.com/azwing/indi) and i have always the same problem :-(
On Kstars 3.5.4 Stable:
2021-07-07T19:56:01 Shutdown complete.
2021-07-07T19:56:01 Ekos stopped.
2021-07-07T19:56:00 INDI devices disconnected.
2021-07-07T19:55:56 Mount parked.
2021-07-07T19:55:55 Parking mount in progress...
2021-07-07T19:55:54 Cap parked.
2021-07-07T19:55:49 Parking Cap...
2021-07-07T19:55:48 Warming up CCD...
2021-07-07T19:55:48 No jobs left in the scheduler queue.
2021-07-07T19:55:47 Job 'HD 97277' is terminated due to errors.
2021-07-07T19:55:47 Warning: job 'HD 97277' slew failed, marking terminated due to errors.
2021-07-07T19:55:46 Job 'HD 97277' is slewing to target.
2021-07-07T19:55:46 Warning: job 'HD 97277' found not slewing, restarting.
2021-07-07T19:55:45 Job 'HD 97277' is slewing to target.
2021-07-07T19:55:45 Warning: job 'HD 97277' found not slewing, restarting.
2021-07-07T19:55:43 Job 'HD 97277' is slewing to target.
2021-07-07T19:55:41 Cap unparked.
2021-07-07T19:55:36 Unparking cap...
2021-07-07T19:55:35 Mount unparked.
2021-07-07T19:55:30 Scheduler started.
2021-07-07T19:54:39 Scheduler list saved to /home/serge/testflat2.esl
I think, it's a Kstars problem
Status of Indi GU#:
LX200 OnStep.OnStep Status.Tracking=Parked
LX200 OnStep.OnStep Status.Tracking=Tracking
LX200 OnStep.OnStep Status.Tracking=Slewing
-> Kstars error (Warning: job 'HD 97277' found not slewing, restarting.)
Tested with CCDciel and skychart: Seems to work fine \o/
[NOK the mount is in parking progress, not parked] 2021-07-08T18:21:18 Mount parked.
[OK] 2021-07-08T18:21:17 Parking mount in progress...
2021-07-08T18:21:16 No jobs left in the scheduler queue.
[OK] 2021-07-08T18:21:15 Job 'Mars2' is complete.
2021-07-08T18:21:14 Job 'Mars2' capture is in progress...
[OK] 2021-07-08T18:21:13 Job 'Mars2' slew is complete.
[OK] 2021-07-08T18:20:43 Job 'Mars2' is slewing to target.
[OK] 2021-07-08T18:20:40 Mount unparked.
2021-07-08T18:20:35 Scheduler started.
[OK] Kstars is waiting for the mount is tracking (end of goto).
[NOK] But after the "park" command it consider the mount is already parked
however the Indi driver seems to give the right values...
And i have more and more crash of Kstars 3.5.4 (I think, it's not the indi driver)
Good news anyway It seems to work well with CCDCiel.
I think I will only use CCDciel
From a glance it seems like it's going to cause extra state changes on certain codes with regard to parking (calling setParked(x) results in a change to either PARKED or IDLE, and a variable IsParked being set (accessible through isParked()) and I think that's changed in the past.
Issues with what you've got:
F shouldn't change TrackState. (Park failed, but the state should be processed via n/N )
p and nN only, if it's pn, it'll produce TRACKING when it should be IDLE (here again state should be processed via n/N)
Not sure why the myTrackState?
That own-goto branch of mine, I didn't handle it right, either, when I looked at your code: (F, I and p should be moved in my code before the n/N/P processing, because of the potential call to setParked(false) in them, which could result in an idle state.) Basically moving up the ==parkdata== / ==end...== section should have fixed that issue. (I have pushed the branch, but not tested it, as I need to get away from the computer for a bit, as I keep looking and running through the same logic and questioning it, so I'm going to stop and come back in a while so I don't break anything too badly.)
Issues/TrackState manipulation remaining with mine:
Scope may get set for a split second to TrackState=SCOPE_IDLE when unparking, but that will be correct shortly thereafter within the function. due to the call to set IsParked
Same with parking (but to the correct TrackState=SCOPE_PARKED) so non issue
One thing that could be done is skip the OSStat == OldOSStat check. That would resolve the sync issue and why when you start/stop tracking it gets corrected. (With the isParked() guards around it shouldn't cause any issues for the correct things to be set with regards to TrackState, not sure about the rest of it.) So we'd need to make sure things don't cause issues like messing with TrackState can, but that I think is probably the best case. But it could mask TrackState and other issues as well.
Alright, I'm off, let me know what you all think. (Apologies, I left this up last night, but aside from me being less tired everything else should be the same.)
Yes leaving coding away some time will do good.
Looking all the time at a problem makes us blind
I will have a look on your code.
In the meantime "myTrackState" is removed (was just a testing variable)
I have now a situation where OnStep TrackState is sync with Ekos except for SCOPE_PARKING where Ekos still states Slewing.
But I notice no other strange behavior.
I experience no crashes with Kstars (I have 3.5.5 Beta, but I had also none with 3.5.4 Stable)
I cannot reproduce the Park issues, it works fine for me but I must agree I do test all manually not in sequencing.
I never tested the Ekos automation so far.
Can you share your scripts?
I have removed all Indi drivers (just keep CCD simulator and LX200OnStep) and i have no crashes.
The park problem is only in automated sessions.
My sequence is very simple:
- Unpark mount
- Goto a star
- take one shoot (light, 1s)
- Park the mount
Perhaps for Kstars, "Park"ing and "Park"ed are the sames
For me, in the mount tab (Ctrl K, tab mount, i unpark mount, goto a star, the unpark button is grey (mount is really unparked)
If I click on the park button, it instantly turns grey (parked mount) as the mount continues to move to the park point.
I can click on the unpark button while the mount is not yet parked (it is moving to its park position). So the mount stops where it is. and goes into tracking.
Maybe this is the normal operation.
The only problem is that the automatic sequence stops when the mount is not yet parked.
My shelter can send the park order to the mount directly on OnStep (by WiFi).
I can use this solution.
I do not park the mount at the end of the sequence but only the shelter (which will park the mount for him).