Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getDevices() returns incorrect devices #42

Open
rkaczorek opened this issue Sep 19, 2023 · 0 comments
Open

getDevices() returns incorrect devices #42

rkaczorek opened this issue Sep 19, 2023 · 0 comments
Assignees

Comments

@rkaczorek
Copy link

I'm not sure if that's INDI backend issue (INDI Library: 2.0.3) or pyindi-client issue (1.9.1) or I'm missing something.
Looks like getDevices() client function always returns devices set at the first time client connected to INDI server. The value is not updated between reconnects.

How to reproduce:

  1. Simple INDI client working in infinite loop and printing names of active devices (see below)
  2. While script running start indiserver with 3 drivers of your choice. Observe list of connected devices printed by the script.
  3. Stop indiserver (DO NOT restart python script) and rerun indiserver with 5 drivers of your choice. Observe list of connected devices printed by the script. You will notice that not all devices are printed out by the script.
#!/usr/bin/env python3
# coding=utf-8

import PyIndi, time

class IndiClient(PyIndi.BaseClient):
	def __init__(self):
		super(IndiClient, self).__init__()

	def serverConnected(self):
		'''Emmited when the server is connected.'''
		print(f"Server connected ({self.getHost()}:{self.getPort()})")

	def serverDisconnected(self, code):
		'''Emmited when the server gets disconnected.'''
		print(f"Server disconnected (exit code = {code},{self.getHost()}:{self.getPort()})")
		self.disconnectServer() # double shot to disconnect


indiclient = IndiClient()
indiclient.setServer("localhost", 7624)

while True:
    while not indiclient.isServerConnected():
        indiclient.connectServer()

        if indiclient.isServerConnected():
            time.sleep(1)
        else:
            print(f"Cannot connect to INDI server on {indiclient.getHost()}:{str(indiclient.getPort())}. Retrying in 5 seconds.")
            time.sleep(5)

    devices = indiclient.getDevices() # Get all devices from INDI server
    for device in devices:
        device_name = device.getDeviceName()
        print(device_name)

    time.sleep(1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants