×

INDI Library v2.0.6 is Released (02 Feb 2024)

Bi-monthly release with minor bug fixes and improvements

Driver OnStep (LX200 like) for INDI

  • Posts: 452
  • Thank you received: 71
@Norikyu,

may be setting time source in Kstars solves your problem.
I cannot test, have no time source in OnStep,

Select "Mount Updates Kstars"
The following user(s) said Thank You: norikyu
2 years 1 week ago #81589
Attachments:

Please Log in or Create an account to join the conversation.

  • Posts: 452
  • Thank you received: 71
Pull request issued, waiting for merge in master:

Current versions:
OnStep 4.24p
INDI Library: 1.9.5
indi_lx200_OnStep 1.15
kstars Version 3.5.8 Stable
2 years 1 week ago #81590

Please Log in or Create an account to join the conversation.

  • Posts: 174
  • Thank you received: 27

Wonderful!

Not sure about this particular issue, but in general, floating point math is very imprecise.
You may get some really unexpected results, e.g. instead of 2x2=4 you may get 3.999999008
The whole idea of pushing floating number back and forth for this use case is totally wrong and probably requires much bigger refactoring.
2 years 1 week ago #81599

Please Log in or Create an account to join the conversation.

  • Posts: 48
  • Thank you received: 7
Thank you for the hint.
But, I couldn't solve that.

I tried setting "Time & Location Updates" in the KStars INDI option to "Mount updates KStars".

When I tried it with Celestron AVX, I can get the location information and date and time of the AVX controller settings. And KStars will display the stars where the AVX is placed.

For OnStep Driver, the time will always be "UNIX Epoch-1 second", so KStars will display the wrong stars.
It looks like it is failing to get the internal time of OnStep.
Does the INDI OnStep Driver not support getting the OnStep internal time?
2 years 1 week ago #81602

Please Log in or Create an account to join the conversation.

  • Posts: 452
  • Thank you received: 71
@Alex,

I don't think this is due to Floatint Point Math but rather to some obscure ftoa() and atof() somewere between kstars / Ekos and Indi but I am not able to track it ...
By doing tests if I enter for example 3,75 into control panel everything is ok.
If I enter the same value via Geographic settings I get 1,8 in control panel and Indi

So must be in Ekos / Kstars but I can be wrong as many times :-)
Last edit: 2 years 1 week ago by Alain Zwingelstein.
2 years 1 week ago #81607

Please Log in or Create an account to join the conversation.

  • Posts: 452
  • Thank you received: 71
@Norikyu,

It is not OnStep that manages time and location but Indi so normally this should work.

I made the following test.
1) I did run Onstep as alway just to make sure Time / Location are as usual.
2) Disconnected OnStep and closed Kstars
3) Set my system location to Panama
4) Opened Kstars and set the Geographic Location to Panama
5) You can see Time in Time1.pgn
6) Started OnStep Driver see Time2.pgn
7) Connected OnStep see Time3.png

As you can see as soon I connect OnStep time is updates with Firmware Time




2 years 1 week ago #81608
Attachments:

Please Log in or Create an account to join the conversation.

  • Posts: 48
  • Thank you received: 7
I think you are right. But it didn't work in my environment.
I debugged and found the cause.

lx200_OnStep.cpp line 4790
Processing of the LX200_OnStep :: sendScopeTime () function.
    // Get local time epoch in UNIX seconds
    time_epoch = mktime(&ltm);

mktime is returning -1 and time_epoch is calculated with the wrong value.
The cause is that ltm is being used uninitialized and ltm.tm_isdst is set to the wrong value.
Initializing ltm cleared the error.
--- lx200_OnStep.cpp.bak        2022-03-22 09:15:28.455583393 +0900
+++ lx200_OnStep.cpp    2022-03-22 09:15:00.531800080 +0900
@@ -4750,6 +4750,9 @@
     struct tm utm;
     time_t time_epoch;
 
+    memset(&ltm, 0, sizeof(ltm));
+    memset(&utm, 0, sizeof(utm));
+
     double offset = 0;
     if (getUTFOffset(&offset))
     {

This problem happens by accident, but it can happen to anyone.
Similar errors are possible with other sources.
The source code using the mktime function is as follows.

indi-master/drivers/telescope/ioptronHC8406.cpp
indi-master/drivers/telescope/lx200_OnStep.cpp
indi-master/drivers/telescope/lx200_TeenAstro.cpp
indi-master/drivers/telescope/lx200pulsar2.cpp
indi-master/drivers/telescope/lx200telescope.cpp
indi-master/drivers/telescope/rainbow.cpp
indi-master/tools/evalINDI.c
2 years 1 week ago #81621

Please Log in or Create an account to join the conversation.

  • Posts: 174
  • Thank you received: 27
Post deleted
Last edit: 2 years 1 week ago by Alex Varakin. Reason: Post deleted
2 years 1 week ago #81630

Please Log in or Create an account to join the conversation.

  • Posts: 452
  • Thank you received: 71
@Norikyu,

thank you for the debugging and solution proposal.
Since it involves not only Onstep but also others drivers we should treat the complete set.
Do you take care of making the changes and issue the pull request?

If not I will see what I can do and by when.

By the way, could you please identify which system and versions you are running (OS, Kstars, OnStep, Indiserver)
Last edit: 2 years 6 days ago by Alain Zwingelstein.
2 years 6 days ago #81642

Please Log in or Create an account to join the conversation.

  • Posts: 276
  • Thank you received: 52
@alex

Is it not one of the following that is failing as it is meant to initialize ltm in the end ?
if (getLocalTime(ctime) == false)
{
LOG_WARN("Could not obtain local time from mount!");
return false;
}

if (getLocalDate(cdate) == false)
{
LOG_WARN("Could not obtain local date from mount!");
return false;
}

// To ISO 8601 format in LOCAL TIME!
char datetime[MAXINDINAME] = {0};
snprintf(datetime, MAXINDINAME, "%sT%s", cdate, ctime);

// Now that date+time are combined, let's get tm representation of it.
->>>>>> if (strptime(datetime, "%FT%T", &ltm) == nullptr)
{
LOGF_WARN("Could not process mount date and time: %s", datetime);
return false;
}

// Get local time epoch in UNIX seconds
time_epoch = mktime(&ltm);
2 years 6 days ago #81644

Please Log in or Create an account to join the conversation.

  • Posts: 452
  • Thank you received: 71
@Norikyu,

are these the changes you suggest?
-------------------- drivers/telescope/ioptronHC8406.cpp ---------------------
index 2626278d1..ca37ce08a 100644
@@ -1156,6 +1156,9 @@ bool ioptronHC8406::sendScopeTime()
     struct tm ltm;
     struct tm utm;
     time_t time_epoch;
+    
+    memset(&ltm, 0, sizeof(ltm));
+    memset(&utm, 0, sizeof(utm));
 
     if (isSimulation())
     {
 
---------------------- drivers/telescope/lx200_OnStep.cpp ----------------------
index 425d0f6ab..7bd1b4264 100644
@@ -4749,6 +4749,9 @@ bool LX200_OnStep::sendScopeTime()
     struct tm ltm;
     struct tm utm;
     time_t time_epoch;
+    
+    memset(&ltm, 0, sizeof(ltm));
+    memset(&utm, 0, sizeof(utm));
 
     double offset = 0;
     if (getUTFOffset(&offset))
 
-------------------- drivers/telescope/lx200_TeenAstro.cpp --------------------
index 548ad1660..325785aab 100644
@@ -888,6 +888,9 @@ bool LX200_TeenAstro::sendScopeTime()
     struct tm ltm;
     struct tm utm;
     time_t time_epoch;
+    
+    memset(&ltm, 0, sizeof(ltm));
+    memset(&utm, 0, sizeof(utm));
 
     double offset = 0;
 
 
---------------------- drivers/telescope/lx200pulsar2.cpp ----------------------
index ea2c29211..062c7c664 100644
@@ -3362,6 +3362,11 @@ bool LX200Pulsar2::storeScopeLocation()
 bool LX200Pulsar2::sendScopeTime()
 {
     struct tm ltm;
+    struct tm utm;
+    
+    memset(&ltm, 0, sizeof(ltm));
+    memset(&utm, 0, sizeof(utm));
+
     if (isSimulation())
     {
         const time_t t = time(nullptr);
@@ -3380,7 +3385,7 @@ bool LX200Pulsar2::sendScopeTime()
 
     // Get time epoch and convert to TimeT
     const time_t time_epoch = mktime(&ltm);
-    struct tm utm;
+
     localtime_r(&time_epoch, &utm);
 
     // Format it into ISO 8601
 
--------------------- drivers/telescope/lx200telescope.cpp ---------------------
index 786aeca4c..26b202276 100644
@@ -1315,6 +1315,9 @@ bool LX200Telescope::sendScopeTime()
     struct tm ltm;
     struct tm utm;
     time_t time_epoch;
+    
+    memset(&ltm, 0, sizeof(ltm));
+    memset(&utm, 0, sizeof(utm));
 
     double offset = 0;
     if (getUTFOffset(&offset))
 
------------------------ drivers/telescope/rainbow.cpp ------------------------
index 0c68f6b39..2456f88ef 100644
@@ -1516,6 +1516,9 @@ bool Rainbow::sendScopeTime()
     struct tm ltm;
     struct tm utm;
     time_t time_epoch;
+    
+    memset(&ltm, 0, sizeof(ltm));
+    memset(&utm, 0, sizeof(utm));
 
     double offset = 0;
     if (getUTFOffset(&offset))
 
------------------------------- tools/evalINDI.c -------------------------------
index d77395033..730518f27 100644
@@ -507,6 +507,8 @@ static int pstatestr(char *state)
 static time_t timestampINDI(char *ts)
 {
     struct tm tm;
+    
+    memset(&tm, 0, sizeof(tm));
 
     if (6 == sscanf(ts, "%d-%d-%dT%d:%d:%d", &tm.tm_year, &tm.tm_mon, &tm.tm_mday, &tm.tm_hour, &tm.tm_min, &tm.tm_sec))
     {
 
2 years 6 days ago #81646

Please Log in or Create an account to join the conversation.

  • Posts: 276
  • Thank you received: 52
@Alain,

I do beleive the changes with memset are only masking an error that should be caught in the code that is building the variables ctime and cdate, see my post above. If these are correct then the code to build datetime should be passing a valid string to strptime and ltm filled in correctly.

->>>>>> snprintf(datetime, MAXINDINAME, "%sT%s", cdate, ctime);

// Now that date+time are combined, let's get tm representation of it.
->>>>>> if (strptime(datetime, "%FT%T", &ltm) == nullptr)
2 years 5 days ago #81653

Please Log in or Create an account to join the conversation.

Time to create page: 1.210 seconds