×

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

Bi-monthly release with minor bug fixes and improvements

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
1 year 9 months ago #83764

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

  • Posts: 276
  • Thank you received: 52

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
1 year 9 months 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
1 year 8 months ago #83919

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

  • Posts: 276
  • Thank you received: 52

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
1 year 8 months 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
1 year 8 months ago #83939

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

  • Posts: 2247
  • Thank you received: 223
I'll be highly interested in your focus dbus script.
1 year 7 months ago #85142

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

Time to create page: 2.978 seconds