×

INDI Library v1.9.9 Released (30 Nov 2022)

Bi-monthly INDI Library released with new drivers and bug fixes.

Build a python-dbus script

  • Posts: 18
  • Thank you received: 1
Hi everyone,

I need to write a script that automates Kstar and Ekos to start, connect devices, start sequence and so on..

For now I’m at the beginning, and this is my code:
import os
import logging
import time
import shlex, subprocess
import sys
from dbus import glib
glib.init_threads()
 
import dbus
 
bus = dbus.SessionBus()
 
def open_ekos_window(bus):
    kstars = bus.get_object("org.kde.kstars", "/KStars")
    main_window = dbus.Interface(kstars, 'org.kde.KMainWindow')
    main_window.activateAction('ekos')
 
ekos_object = bus.get_object("org.kde.kstars", # Connection name
                               "/KStars/Ekos" # Object's path
                              )
# Get Ekos interface
E_iface = dbus.Interface(ekos_object, 'org.kde.kstars.Ekos')
 
# Start Ekos 
E_iface.start()
 
def main():
    open_ekos_window(bus)
 
if __name__ == '__main__':
    main()

I use the astroberry OS, where the INDI drivers are automatically started at the beginning.
So far so good, but now I would to get the status of the single devices the to perform some checks. And after load some scheduler to start some sequence.

Any suggestion?

Thanks,

Luca
5 months 2 weeks ago #83764

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

  • Posts: 241
  • Thank you received: 49

Replied by Gene N on topic Build a python-dbus script

Hi Luca,

Have you seen this tutorial?
indilib.org/support/tutorials/148-dbus-s...h-kstars-python.html

I believe it has some of what you are looking for.

The Kstars/Ekos API reference for controlling
api.kde.org/kstars/html/group__DBusInterface.html

Gene
5 months 2 weeks ago #83768

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

  • Posts: 18
  • Thank you received: 1
Ok, some progress has been made.

I can connect, checks the connection and also set the camera properties through the indi dbus interface.

Now I need to use some special functionality of ekos, like the autofocus. Looking in the introspection file of ekos, I didn't find any method that start the autofocus routine.
By now, the only way that came to mind is to load a scheduler with the autofocus setp selected. But is there another method? Maybe more simply and more "command line" like?

I try to look at the API reference of Kstars and Ekos, but I think that the methods reported are only valid for C language and not for python bindings.

Thanks,

Luca
5 months 1 week ago #83919

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

  • Posts: 241
  • Thank you received: 49

Replied by Gene N on topic Build a python-dbus script

Hi Luca,

Check out the focus.h, it identifies d_bus interfaces
github.com/KDE/kstars/blob/master/kstars/ekos/focus/focus.h

I have not used it but another data point
The following user(s) said Thank You: Luca Rosignoli
5 months 1 week ago #83923

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

  • Posts: 18
  • Thank you received: 1
Ok, very good!

I finally undestrand a little bit better how the DBus interfaces works.

hoping to do something pleasing, i post here a simple code to reach the focus section of ekos and print its introspection
import dbus
import time
 
bus = dbus.SessionBus()
kstars = bus.get_object("org.kde.kstars", "/KStars")
 
ekos_obj=bus.get_object("org.kde.kstars", "/KStars/Ekos")
e_iface=dbus.Interface(ekos_obj,"org.kde.kstars.Ekos")
e_iface.start()
 
time.sleep(1.0)
 
focus = bus.get_object("org.kde.kstars", "/KStars/Ekos/Focus")
 
print(focus.Introspect())
 

One thing that seems obvious but that I hadn’t realized before, was that the functionality that you want reach through DBus must be already active. I thought instead that it was enough to be present in the functionality of the parent program.

If I will meet another problem I will post here, hoping to make this discussion another help for the scripting and development section of Kstars/Ekos.

Luca.
The following user(s) said Thank You: Jack
5 months 1 week ago #83939

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

  • Posts: 2151
  • Thank you received: 205
I'll be highly interested in your focus dbus script.
Kstars Mac osx
Odroid C4 / WO Redcat51 / CEM25p / ZWO533MC / QHY5L-II-M (OAG)
4 months 1 day ago #85142

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

Time to create page: 0.488 seconds