I wrote python and c++ demo to control my camera to exposure 1 second, and the python version worked but c++ verison didn't.
Here are my codes. And the C++ running error is in below.It means the error is in "indiclient.sendNewNumber(ccd_exposure);"
import PyIndi
import time
class IndiClient(PyIndi.BaseClient):
def __init__(self):
super(IndiClient, self).__init__()
def newDevice(self, d):
pass
def newBLOB(self, bp):
pass
def newSwitch(self, svp):
pass
def newNumber(self, nvp):
pass
def newMessage(self, d, m):
pass
def serverConnected(self):
pass
def serverDisconnected(self, code):
pass
def newProperty(self,property):
baseDevice = property.getBaseDevice()
deviceName = baseDevice.getDeviceName()
if(property.getName()=="DRIVER_INFO"):
interface = baseDevice.getDriverInterface()
if(interface & PyIndi.BaseDevice.CCD_INTERFACE):
print("Found camera:" + deviceName)
# connect the server
indiclient=IndiClient()
indiclient.setServer("localhost",7624)
indiclient.connectServer()
# Let's take some pictures
ccd="Nikon DSLR DSC D5100 (PTP mode)"
device_ccd=indiclient.getDevice(ccd)
while not(device_ccd):
time.sleep(0.5)
device_ccd=indiclient.getDevice(ccd)
ccd_connect=device_ccd.getSwitch("CONNECTION")
while not(ccd_connect):
time.sleep(0.5)
ccd_connect=device_ccd.getSwitch("CONNECTION")
if not(device_ccd.isConnected()):
ccd_connect[0].s=PyIndi.ISS_ON # the "CONNECT" switch
ccd_connect[1].s=PyIndi.ISS_OFF # the "DISCONNECT" switch
indiclient.sendNewSwitch(ccd_connect)
ccd_exposure=device_ccd.getNumber("CCD_EXPOSURE")
# while not(ccd_exposure):
# time.sleep(0.5)
# ccd_exposure=device_ccd.getNumber("CCD_EXPOSURE")
# we should inform the indi server that we want to receive the
# "CCD1" blob from this device
indiclient.setBLOBMode(PyIndi.B_ALSO, ccd, "CCD1")
ccd_ccd1=device_ccd.getBLOB("CCD1")
# while not(ccd_ccd1):
# time.sleep(0.5)
# ccd_ccd1=device_ccd.getBLOB("CCD1")
ccd_exposure[0].value=1.0
indiclient.sendNewNumber(ccd_exposure)
ccd_dis_connect=device_ccd.getSwitch("DISCONNECTION")
while not(ccd_dis_connect):
time.sleep(0.5)
ccd_dis_connect=device_ccd.getSwitch("DISCONNECTION")
print("try disconnect")
print("disconnect!")