For some reason when I set all the properties and then connect to the device (CONNECTION.CONNECT=On
), the connection is set back to Off state (CONNECTION.CONNECT=Off)
Besides only limited no of properties are extracted with the code, whereas "indi_getprop" shows more properties. Also There are no properties related to telescope movement and alignment.
I'm wondering if I am dointy ity wrong.
Here is the code I used:
import PyIndi
import time
class IndiClient(PyIndi.BaseClient):
def __init__(self):
super(IndiClient, self).__init__()
def newDevice(self, d):
global dmonitor
# We catch the monitored device
dmonitor = d
def newProperty(self, p):
global monitored
global cmonitor
global mmonitor
global amonitor
# we catch the "CONNECTION" property of the monitored device
if (p.getDeviceName() == monitored and p.getName() == "CONNECTION"):
cmonitor = p.getSwitch()
if (p.getDeviceName() == monitored and p.getName() == "CONNECTION_MODE"):
mmonitor = p.getSwitch()
if (p.getDeviceName() == monitored and p.getName() == "DEVICE_TCP_ADDRESS"):
amonitor = p.getText()
print("New property ", p.getName(), " for device ", p.getDeviceName())
def removeProperty(self, p):
print("removeProperty function")
pass
def newBLOB(self, bp):
print("newBLOB function")
pass
def newSwitch(self, svp):
print("newSwitch function")
print(svp.name)
print(svp[0].s)
pass
def newNumber(self, nvp):
print("newNumber function")
global newval
global prop
# We only monitor Number properties of the monitored device
prop = nvp
newval = True
def newText(self, tvp):
print("newText function")
pass
def newLight(self, lvp):
print("newLight function")
pass
def newMessage(self, d, m):
print("newMessage function")
pass
def serverConnected(self):
print("serverConnected function\n")
pass
def serverDisconnected(self, code):
print("serverDisconnected function\n")
pass
monitored = "Celestron GPS"
dmonitor = None
cmonitor = None
mmonitor = None
amonitor = None
indiclient = IndiClient()
indiclient.setServer("localhost", 7624)
# we are only interested in the telescope device properties
indiclient.watchDevice(monitored)
indiclient.connectServer()
# wait CONNECTION_MODE property be defined
while not(mmonitor):
time.sleep(0.05)
mmonitor[0].s = PyIndi.ISS_OFF # the "SERIAL" ISwitch
mmonitor[1].s = PyIndi.ISS_ON # the "TCP" ISwitch
indiclient.sendNewSwitch(mmonitor) # set the driver
# wait DEVICE_TCP_ADDRESS property be defined
while not(amonitor):
time.sleep(0.05)
amonitor[0].text = "1.2.3.4" # the "ADDRESS" ISwitch
amonitor[1].text = "2000" # the "PORT" ISwitch
indiclient.sendNewText(amonitor) # set the driver
# wait CONNECTION property be defined
while not(cmonitor):
time.sleep(0.05)
cmonitor[0].s = PyIndi.ISS_ON # the "CONNECT" switch
cmonitor[1].s = PyIndi.ISS_OFF # the "DISCONNECT" switch
indiclient.sendNewSwitch(cmonitor) # send this new value to the device
while(1):
pass