×

INDI Library v2.0.7 is Released (01 Apr 2024)

Bi-monthly release with minor bug fixes and improvements

launch ekos scheduler in command D-bus error

  • Posts: 27
  • Thank you received: 2
Hi,
I am trying to auto launch scheduler with a script.py and D-bus that I just discovered here by reading you.
here is the error :
Traceback (most recent call last):
File "startEkos.py", line 97, in <module>
"/KStars/Ekos/Scheduler" # Object's path
File "/usr/lib/python2.7/dist-packages/dbus/bus.py", line 241, in get_object
follow_name_owner_changes=follow_name_owner_changes)
File "/usr/lib/python2.7/dist-packages/dbus/proxies.py", line 248, in __init__
self._named_service = conn.activate_name_owner(bus_name)
File "/usr/lib/python2.7/dist-packages/dbus/bus.py", line 180, in activate_name_owner
self.start_service_by_name(bus_name)
File "/usr/lib/python2.7/dist-packages/dbus/bus.py", line 278, in start_service_by_name
'su', (bus_name, flags)))
File "/usr/lib/python2.7/dist-packages/dbus/connection.py", line 651, in call_blocking
message, timeout)
dbus.exceptions.DBusException: org.freedesktop.DBus.Error.ServiceUnknown: The name org.kde.kstars.Ekos.Scheduler was not provided by any .service files


here is the complete code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
 
# You must initialize the gobject/dbus support for threading
# before doing anything.
import gobject
import os
import time
 
gobject.threads_init()
 
from dbus import glib
glib.init_threads()
 
# Create a session bus.
import dbus
bus = dbus.SessionBus()
 
# Create an object that will proxy for a particular remote object.
start_ekos = bus.get_object("org.kde.kstars", # Connection name
                               "/kstars/MainWindow_1/actions/ekos" # Object's path
                              )
 
 
 
# Get Ekos interface
iface = dbus.Interface(start_ekos, 'org.qtproject.Qt.QAction')
 
 
 
# Start Ekos devices
iface.trigger()
 
print "Starting Ekos..."
 
#now start indi progile
# Create an object that will proxy for a particular remote object.
remote_object = bus.get_object("org.kde.kstars", # Connection name
                               "/KStars/INDI" # Object's path
                              )
 
# Introspection returns an XML document containing information
# about the methods supported by an interface.
print ("Introspection data:\n")
print remote_object.Introspect()
 
# Get INDI interface
iface = dbus.Interface(remote_object, 'org.kde.kstars.INDI')
 
myDevices = [ "indi_simulator_telescope", "indi_simulator_ccd" ]
 
# Start INDI devices
iface.stop("7624")
iface.start("7624", myDevices)
 
print "Waiting for INDI devices..."
# Create array for received devices
devices = []
 
while True:
    devices = iface.getDevices()
    if (len(devices) < len(myDevices)):
        time.sleep(1)
    else:
        break;
 
print "We received the following devices:"
for device in devices:
    print device
 
print "Establishing connection to Telescope and CCD..."
 
# Set connect switch to ON to connect the devices
iface.setSwitch("Telescope Simulator", "CONNECTION", "CONNECT", "On")
# Send the switch to INDI server so that it gets processed by the driver
iface.sendProperty("Telescope Simulator", "CONNECTION")
# Same thing for CCD Simulator
iface.setSwitch("CCD Simulator", "CONNECTION", "CONNECT", "On")
iface.sendProperty("CCD Simulator", "CONNECTION")
 
telescopeState = "Busy"
ccdState       = "Busy"
 
# Wait until devices are connected
while True:
    telescopeState = iface.getPropertyState("Telescope Simulator", "CONNECTION")
    ccdState       = iface.getPropertyState("CCD Simulator", "CONNECTION")
    if (telescopeState != "Ok" or ccdState != "Ok"):
        time.sleep(1)
    else:
        break
 
print "Connected to Telescope and CCD is established."
# Create an object that will proxy for a particular remote object.
 
start_scheduler = bus.get_object("org.kde.kstars.Ekos.Scheduler", # Connection name
                               "/KStars/Ekos/Scheduler" # Object's path
                              )
 
 
 
# StartEkos Scheduler interface
iface = dbus.Interface(start_scheduler, "org.kde.kstars.Ekos.Scheduler")
 
 
 
# Start Ekos devices
iface.loadScheduler(test.esl )
#iface.start()
 
print "Starting Scheduler..."
Wich is almost a copy-paste from your tutorial code with little bit change.
I am kind of new to coding, please be kind.
Can you point me out why it is saying that it is not a .service?
I first was thinking I was miss typing the "/KStars/Ekos/Scheduler" at line 97, but D-feet give me that exact name.
So, I am lost and asking here.
Thank you
6 years 1 month ago #24219
Attachments:

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

I just used the following to load a scheduler file and it works just fine:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
 
# You must initialize the gobject/dbus support for threading
# before doing anything.
import gobject
import os
import time
 
gobject.threads_init()
 
from dbus import glib
glib.init_threads()
 
# Create a session bus.
import dbus
bus = dbus.SessionBus()
 
remote_object = bus.get_object("org.kde.kstars", "/KStars/Ekos/Scheduler")
iface = dbus.Interface(remote_object, 'org.kde.kstars.Ekos.Scheduler')
iface.loadScheduler("/home/jasem/Pictures/SchedularTest/capella.esl")
6 years 1 month ago #24242

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

  • Posts: 27
  • Thank you received: 2
Hi. Thank you. I am not sure to fully understand what I am doing, but I found my error in my previous code.
I finaly manage to get something working. Here is the code I made:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
 
# You must initialize the gobject/dbus support for threading
# before doing anything.
import argparse
import gobject
import os
import time
parser = argparse.ArgumentParser (description='auto start Ekos sequence')
parser.add_argument('-s','--scheduler',type=str, help='scheduler file name located in /home/pi/filename, enter full path')
parser.add_argument('-p','--profile', default="Simulators", help='enter equippement profile name')
args = parser.parse_args()
 
gobject.threads_init()
 
from dbus import glib
glib.init_threads()
 
# Create a session bus.
import dbus
bus = dbus.SessionBus()
 
INDI = bus.get_object("org.kde.kstars", # Connection name
                               "/KStars/INDI" # Object's path
                              )
# Get INDI interface
iface = dbus.Interface(INDI, 'org.kde.kstars.INDI')
 
# Stop INDI devices (because that was giving me bug after in ekos)
iface.stop("7624")
 
# Create an object that will proxy for a particular remote object.
start_ekos = bus.get_object("org.kde.kstars", # Connection name
                               "/kstars/MainWindow_1/actions/ekos" # Object's path
                              )
 
 
 
# Get Ekos interface
iface = dbus.Interface(start_ekos, 'org.qtproject.Qt.QAction')
 
 
 
# Start Ekos devices
iface.trigger()
 
print ("Starting Ekos...")
 
#now start ekos progile
# Create an object that will proxy for a particular remote object.
Ekos = bus.get_object("org.kde.kstars", # Connection name
                               "/KStars/Ekos" # Object's path
                              )
 
 
# Get ekos interface
iface = dbus.Interface(Ekos, 'org.kde.kstars.Ekos')
 
#myDevices = [ "indi_simulator_telescope", "indi_simulator_ccd" ]
 
# Start INDI devices
 
iface.stop()
iface.disconnectDevices()
iface.setProfile(args.profile)
iface.start()
iface.connectDevices()
print "Waiting for INDI devices..."
 
 
run_scheduler = bus.get_object("org.kde.kstars", # Connection name
                                  "/KStars/Ekos/Scheduler" # Object's path
                              )
 
 
 
# StartEkos Scheduler interface
iface = dbus.Interface(run_scheduler, "org.kde.kstars.Ekos.Scheduler")
 
 
 
# Start Ekos devices
iface.loadScheduler(args.scheduler)
iface.start()
 
print "Starting Scheduler..."
 

This code take 2 optional arguments, --scheduler path/to/schedulerFile.esl
And --profile profile_name_as_string

So running python startEkos.py -s observing/target/sequence.esl -p equippement_profile_name

Automatically launch ekos and connect equippement and load sequence and start the auto focus platesolving auto guiding capturing session.

I could then change target in command line loading another scheduler file in command line.
Or auto start the whole process by just pluggin in the raspberry pi at boot.

This have been tested with simulators, not with real equippement yet.
The following user(s) said Thank You: Hans
6 years 1 month ago #24251

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

You're mixing INDI & Ekos commands here unnecessarily. You only need to use the INDI interface if you need low-level access to the drivers. So if you load a scheduler file, and then issue Start then It should start INDI server + drivers...by itself.
6 years 1 month ago #24275

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

  • Posts: 85
  • Thank you received: 40
While looking into what can be done with EKOS an dbus I changed your code into a more generic cli, and moved to python3.
./ekos_cli.py  --help
usage: ekos_cli.py [-h] [--start_ekos] [--stop_ekos] [--profile PROFILE]
                   [--load_schedule LOAD_SCHEDULE] [--start_scheduler]
                   [--stop_scheduler] [--reset_scheduler]
 
Ekos cli
 
optional arguments:
  -h, --help            show this help message and exit
  --start_ekos          start ekos
  --stop_ekos           stop ekos
  --profile PROFILE     equipment profile name, fi Simulators
  --load_schedule LOAD_SCHEDULE
                        schedule .esl file path. Note: this replaces the
                        entire observation list with this single entry.
  --start_scheduler     start the scheduler
  --stop_scheduler      stop the scheduler
  --reset_scheduler     reset all jobs in the scheduler
Do we already have a tool like this ?

ps code lives here github.com/d33psky/rolloffroof/blob/master/ekos/ekos_cli.py

-- Hans
4 years 11 months ago #38486

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

Time to create page: 0.802 seconds