Thanks to visit codestin.com
Credit goes to github.com

Skip to content

getDevices() returns incorrect devices  #42

@rkaczorek

Description

@rkaczorek

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)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions