void ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int num) { ISInit(); for (int i = 0; i < cameraCount; i++) { FishCampCCD *camera = cameras[i]; if (dev == nullptr || !strcmp(dev, camera->name)) { camera->ISNewSwitch(dev, name, states, names, num); if (dev != nullptr) break; } } //This turns the LibFishcamp fcusb logging on and off along with the INDI Fishcamp file logging. if (!strcmp(name, "LOG_OUTPUT")) { if(INDI::Logger::ConfigurationS[1].s == ISS_ON) { fcUsb_setLogging(true); IDLog("Setting Starfish Driver File Log On\n"); } else { fcUsb_setLogging(false); IDLog("Setting Starfish Driver File Log Off\n"); } } }
bool NFocus::Connect() { int connectrc=0; char errorMsg[MAXRBUF]; if (isDebug()) IDLog("connecting to %s\n",PortT[0].text); if ( (connectrc = tty_connect(PortT[0].text, 9600, 8, 0, 1, &PortFD)) != TTY_OK) { tty_error_msg(connectrc, errorMsg, MAXRBUF); if (isDebug()) IDLog("Failed to connect o port %s. Error: %s", PortT[0].text, errorMsg); IDMessage(getDeviceName(), "Failed to connect to port %s. Error: %s", PortT[0].text, errorMsg); return false; } IDMessage(getDeviceName(), "Nfocus is online. Getting focus parameters..."); return true; }
void ISInit() { static bool isInit = false; if (!isInit) { // initialize the driver framework IDLog("About to call fcUsb_init()\n"); fcUsb_init(); IDLog("About to call set logging\n"); fcUsb_setLogging(false); IDLog("About to call find Cameras\n"); cameraCount = -1; cameraCount = fcUsb_FindCameras(); if(cameraCount == -1) { IDLog("Calling FindCameras again because at least 1 RAW camera was found\n"); cameraCount = fcUsb_FindCameras(); } IDLog("Found %d fishcamp cameras.\n", cameraCount); for (int i = 0; i < cameraCount; i++) cameras[i] = new FishCampCCD(i + 1); atexit(cleanup); isInit = true; } }
void MathPluginManagement::EnumeratePlugins() { dirent* de; DIR* dp; MathPluginFiles.clear(); MathPluginDisplayNames.clear(); errno = 0; dp = opendir( INDI_MATH_PLUGINS_DIRECTORY ); if (dp) { while (true) { void *Handle; std::string PluginPath(INDI_MATH_PLUGINS_DIRECTORY "/"); errno = 0; de = readdir( dp ); if (de == NULL) break; if (0 == strcmp(de->d_name, ".")) continue; if (0 == strcmp(de->d_name, "..")) continue; // Try to load the plugin PluginPath.append(de->d_name); Handle = dlopen(PluginPath.c_str(), RTLD_NOW); if (NULL == Handle) { IDLog("EnumeratePlugins - cannot load plugin %s error %s\n", PluginPath.c_str(), dlerror()); continue; } // Try to get the plugin display name typedef const char* GetDisplayName_t(); GetDisplayName_t* GetDisplayNamePtr = (GetDisplayName_t*)dlsym(Handle, "GetDisplayName"); if (NULL == GetDisplayNamePtr) { IDLog("EnumeratePlugins - cannot get plugin %s DisplayName error %s\n", PluginPath.c_str(), dlerror()); continue; } IDLog("EnumeratePlugins - found plugin %s\n", GetDisplayNamePtr()); MathPluginDisplayNames.push_back(GetDisplayNamePtr()); MathPluginFiles.push_back( PluginPath ); dlclose(Handle); } closedir( dp ); } else { IDLog("EnumeratePlugins - Failed to open %s error %s\n", INDI_MATH_PLUGINS_DIRECTORY, strerror(errno) ); } }
void ISInit() { static bool isInit = false; if (!isInit) { #ifdef __APPLE__ UploadFW(); #endif char camid[MAXINDIDEVICE]; bool allCameraInit = true; int ret = QHYCCD_ERROR; #ifndef USE_SIMULATION ret = InitQHYCCDResource(); if(ret != QHYCCD_SUCCESS) { IDLog("Init QHYCCD SDK failed (%d)\n", ret); return; } cameraCount = ScanQHYCCD(); #else cameraCount = 2; #endif for(int i = 0;i < cameraCount;i++) { memset(camid,'\0', MAXINDIDEVICE); #ifndef USE_SIMULATION ret = GetQHYCCDId(i,camid); #else ret = QHYCCD_SUCCESS; snprintf(camid, MAXINDIDEVICE, "Model %d", i+1); #endif if(ret == QHYCCD_SUCCESS) { cameras[i] = new QHYCCD(camid); } else { IDLog("#%d GetQHYCCDId error (%d)\n", i, ret); allCameraInit = false; break; } } if(cameraCount > 0 && allCameraInit) { atexit(cleanup); isInit = true; } } }
bool ClientAPIForAlignmentDatabase::InsertSyncPoint(unsigned int Offset, const AlignmentDatabaseEntry &CurrentValues) { // Wait for driver to initialise if neccessary WaitForDriverCompletion(); ISwitchVectorProperty * pAction = Action->getSwitch(); INumberVectorProperty * pMandatoryNumbers = MandatoryNumbers->getNumber(); INumberVectorProperty * pCurrentEntry = CurrentEntry->getNumber(); ISwitchVectorProperty * pCommit = Commit->getSwitch(); // Select the required action if (INSERT != IUFindOnSwitchIndex(pAction)) { // Request Insert mode IUResetSwitch(pAction); pAction->sp[INSERT].s = ISS_ON; SetDriverBusy(); BaseClient->sendNewSwitch(pAction); WaitForDriverCompletion(); if (IPS_OK != pAction->s) { IDLog("InsertSyncPoint - Bad Action switch state %s\n", pstateStr(pAction->s)); return false; } } // Send the offset pCurrentEntry->np[0].value = Offset; SetDriverBusy(); BaseClient->sendNewNumber(pCurrentEntry); WaitForDriverCompletion(); if (IPS_OK != pCurrentEntry->s) { IDLog("InsertSyncPoint - Bad Current Entry state %s\n", pstateStr(pCurrentEntry->s)); return false; } if (!SendEntryData(CurrentValues)) return false; // Commit the entry to the database IUResetSwitch(pCommit); pCommit->sp[0].s = ISS_ON; SetDriverBusy(); BaseClient->sendNewSwitch(pCommit); WaitForDriverCompletion(); if (IPS_OK != pCommit->s) { IDLog("InsertSyncPoint - Bad Commit switch state %s\n", pstateStr(pCommit->s)); return false; } return true; }
void ASI_EAF_ISInit() { static bool isInit = false; if (!isInit) { iAvailableFocusersCount = 0; iAvailableFocusersCount = EAFGetNum(); if (iAvailableFocusersCount > MAX_DEVICES) iAvailableFocusersCount = MAX_DEVICES; if (iAvailableFocusersCount <= 0) { IDLog("No ASI EAF detected."); } else { int iAvailableFocusersCount_ok = 0; for (int i = 0; i < iAvailableFocusersCount; i++) { int id; EAF_ERROR_CODE result = EAFGetID(i, &id); if (result != EAF_SUCCESS) { IDLog("ERROR: ASI EAF %d EAFGetID error %d.", i + 1, result); continue; } // Open device result = EAFOpen(id); if (result != EAF_SUCCESS) { IDLog("ERROR: ASI EAF %d Failed to open device %d.", i + 1, result); continue; } EAF_INFO info; result = EAFGetProperty(id, &info); if (result != EAF_SUCCESS) { IDLog("ERROR: ASI EAF %d EAFGetProperty error %d.", i + 1, result); continue; } EAFClose(id); focusers[i] = new ASIEAF(id, info.Name, info.MaxStep); iAvailableFocusersCount_ok++; } IDLog("%d ASI EAF attached out of %d detected.", iAvailableFocusersCount_ok, iAvailableFocusersCount); if (iAvailableFocusersCount == iAvailableFocusersCount_ok) isInit = true; } } }
bool ClientAPIForAlignmentDatabase::ReadIncrementSyncPoint(AlignmentDatabaseEntry &CurrentValues) { // Wait for driver to initialise if neccessary WaitForDriverCompletion(); ISwitchVectorProperty * pAction = Action->getSwitch(); INumberVectorProperty * pMandatoryNumbers = MandatoryNumbers->getNumber(); IBLOBVectorProperty * pBLOB = OptionalBinaryBlob->getBLOB(); INumberVectorProperty * pCurrentEntry = CurrentEntry->getNumber(); ISwitchVectorProperty * pCommit = Commit->getSwitch(); // Select the required action if (READ_INCREMENT != IUFindOnSwitchIndex(pAction)) { // Request Read Increment mode IUResetSwitch(pAction); pAction->sp[READ_INCREMENT].s = ISS_ON; SetDriverBusy(); BaseClient->sendNewSwitch(pAction); WaitForDriverCompletion(); if (IPS_OK != pAction->s) { IDLog("ReadIncrementSyncPoint - Bad Action switch state %s\n", pstateStr(pAction->s)); return false; } } // Commit the read increment IUResetSwitch(pCommit); pCommit->sp[0].s = ISS_ON; SetDriverBusy(); BaseClient->sendNewSwitch(pCommit); WaitForDriverCompletion(); if ((IPS_OK != pCommit->s) || (IPS_OK != pMandatoryNumbers->s) || (IPS_OK != pBLOB->s) || (IPS_OK != pCurrentEntry->s)) { IDLog("ReadIncrementSyncPoint - Bad Commit/Mandatory numbers/Blob/Current entry state %s %s %s %s\n", pstateStr(pCommit->s), pstateStr(pMandatoryNumbers->s), pstateStr(pBLOB->s), pstateStr(pCurrentEntry->s)); return false; } // Read the entry data CurrentValues.ObservationJulianDate = pMandatoryNumbers->np[ENTRY_OBSERVATION_JULIAN_DATE].value; CurrentValues.RightAscension = pMandatoryNumbers->np[ENTRY_RA].value; CurrentValues.Declination = pMandatoryNumbers->np[ENTRY_DEC].value; CurrentValues.TelescopeDirection.x = pMandatoryNumbers->np[ENTRY_VECTOR_X].value; CurrentValues.TelescopeDirection.y = pMandatoryNumbers->np[ENTRY_VECTOR_Y].value; CurrentValues.TelescopeDirection.z = pMandatoryNumbers->np[ENTRY_VECTOR_Z].value; return true; }
int NFocus::ReadResponse(char *buf, int nbytes, int timeout) { char nfocus_error[MAXRBUF]; int bytesRead = 0; int totalBytesRead = 0; int err_code; if (isDebug()) IDLog("##########################################\n") ; while (totalBytesRead < nbytes) { if ( (err_code = tty_read(PortFD, buf+totalBytesRead, nbytes-totalBytesRead, timeout, &bytesRead)) != TTY_OK) { tty_error_msg(err_code, nfocus_error, MAXRBUF); if (isDebug()) { IDLog("TTY error detected: %s\n", nfocus_error); IDMessage(getDeviceName(), "TTY error detected: %s\n", nfocus_error); } return -1; } if (isDebug()) IDLog("Bytes Read: %d\n", bytesRead); if (bytesRead < 0 ) { if (isDebug()) IDLog("Bytesread < 1\n"); return -1; } totalBytesRead += bytesRead; } tcflush(PortFD, TCIOFLUSH); if (isDebug()) { fprintf(stderr, "READ : (%s,%d), %d\n", buf, 9, totalBytesRead) ; fprintf(stderr, "READ : ") ; for(int i=0; i < 9; i++) { fprintf(stderr, "0x%2x ", (unsigned char)buf[i]) ; } fprintf(stderr, "\n") ; } return 9; }
int NFocus::SendCommand(char *rf_cmd) { int nbytes_written=0, nbytes_read=0, check_ret=0, err_code=0; char rf_cmd_cks[32],nfocus_error[MAXRBUF]; if (isDebug()) { fprintf(stderr, "strlen(rf_cmd) %ld\n", strlen(rf_cmd)) ; fprintf(stderr, "WRITE: ") ; for(int i=0; i < strlen(rf_cmd); i++) { fprintf(stderr, "0x%2x ", (unsigned char) rf_cmd[i]) ; } fprintf(stderr, "\n") ; } tcflush(PortFD, TCIOFLUSH); if ( (err_code = tty_write(PortFD, rf_cmd, strlen(rf_cmd)+1, &nbytes_written) != TTY_OK)) { tty_error_msg(err_code, nfocus_error, MAXRBUF); if (isDebug()) IDLog("TTY error detected: %s\n", nfocus_error); return -1; } return 0; }
IPState IpFocus::MoveFocuser(FocusDirection dir, int speed, uint16_t duration) { //TODO: calc and delegate to MoveAbsFocuser IDLog("RELMOVE speed: %i\n", speed); return IPS_OK; }
bool SynscanMount::Goto(double ra,double dec) { char str[20]; int n1,n2; int numread, bytesWritten, bytesRead; // not fleshed in yet tty_write(PortFD,"Ka",2, &bytesWritten); // test for an echo tty_read(PortFD,str,2,2, &bytesRead); // Read 2 bytes of response if(str[1] != '#') { // this is not a correct echo // so we are not talking to a mount properly return false; } // Ok, mount is alive and well // so, lets format up a goto command n1=ra*0x1000000/24; n2=dec*0x1000000/360; n1=n1<<8; n2=n2<<8; sprintf((char *)str,"r%08X,%08X",n1,n2); tty_write(PortFD,str,18, &bytesWritten); TrackState=SCOPE_SLEWING; numread=tty_read(PortFD,str,1,60, &bytesRead); if (bytesRead!=1||str[0]!='#') { if (isDebug()) IDLog("Timeout waiting for scope to complete slewing."); return false; } return true; }
IPState FocusSim::MoveAbsFocuser(uint32_t targetTicks) { if (targetTicks < FocusAbsPosN[0].min || targetTicks > FocusAbsPosN[0].max) { IDMessage(getDeviceName(), "Error, requested absolute position is out of range."); return IPS_ALERT; } double mid = (FocusAbsPosN[0].max - FocusAbsPosN[0].min)/2; IDMessage(getDeviceName() , "Focuser is moving to requested position..."); // Limit to +/- 10 from initTicks ticks = initTicks + (targetTicks - mid) / 5000.0; if (isDebug()) IDLog("Current ticks: %g\n", ticks); // simulate delay in motion as the focuser moves to the new position usleep( abs(targetTicks - FocusAbsPosN[0].value) * FOCUS_MOTION_DELAY); FocusAbsPosN[0].value = targetTicks; FWHMN[0].value = 0.5625*ticks*ticks + SeeingN[0].value; if (FWHMN[0].value < SeeingN[0].value) FWHMN[0].value = SeeingN[0].value; IDSetNumber(&FWHMNP, NULL); return IPS_OK; }
bool LX200Autostar::ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) { int index = 0; if (dev != nullptr && strcmp(dev, getDeviceName()) == 0) { // Focus Motion if (!strcmp(name, FocusMotionSP.name)) { // If speed is "halt" if (FocusSpeedN[0].value == 0) { FocusMotionSP.s = IPS_IDLE; IDSetSwitch(&FocusMotionSP, nullptr); return false; } int last_motion = IUFindOnSwitchIndex(&FocusMotionSP); if (IUUpdateSwitch(&FocusMotionSP, states, names, n) < 0) return false; index = IUFindOnSwitchIndex(&FocusMotionSP); // If same direction and we're busy, stop if (last_motion == index && FocusMotionSP.s == IPS_BUSY) { IUResetSwitch(&FocusMotionSP); FocusMotionSP.s = IPS_IDLE; setFocuserSpeedMode(PortFD, 0); IDSetSwitch(&FocusMotionSP, nullptr); return true; } if (!isSimulation() && setFocuserMotion(PortFD, index) < 0) { FocusMotionSP.s = IPS_ALERT; IDSetSwitch(&FocusMotionSP, "Error setting focuser speed."); return false; } FocusMotionSP.s = IPS_BUSY; // with a timer if (FocusTimerNP.np[0].value > 0) { FocusTimerNP.s = IPS_BUSY; if (isDebug()) IDLog("Starting Focus Timer BUSY\n"); IEAddTimer(50, LX200Generic::updateFocusHelper, this); } IDSetSwitch(&FocusMotionSP, nullptr); return true; } } return LX200Generic::ISNewSwitch(dev, name, states, names, n); }
MICCD::MICCD(int camId, bool eth) : FilterInterface(this) { cameraId = camId; isEth = eth; if (isEth) cameraHandle = gxccd_initialize_eth(cameraId); else cameraHandle = gxccd_initialize_usb(cameraId); if (!cameraHandle) IDLog("Error connecting MI camera!\n"); char sp[MAXINDINAME]; if (gxccd_get_string_parameter(cameraHandle, GSP_CAMERA_DESCRIPTION, sp, sizeof(sp)) < 0) { gxccd_get_last_error(cameraHandle, sp, sizeof(sp)); IDLog("Error getting MI camera info: %s.\n", sp); strncpy(name, "MI CCD", MAXINDIDEVICE); } else { // trim trailing spaces char *end = sp + strlen(sp) - 1; while (end > sp && isspace(*end)) end--; *(end + 1) = '\0'; snprintf(name, MAXINDINAME, "MI CCD %s", sp); IDLog("Detected camera: %s.\n", name); } gxccd_get_integer_parameter(cameraHandle, GIP_READ_MODES, &numReadModes); gxccd_get_integer_parameter(cameraHandle, GIP_FILTERS, &numFilters); gxccd_get_integer_parameter(cameraHandle, GIP_MAX_FAN, &maxFanValue); gxccd_get_integer_parameter(cameraHandle, GIP_MAX_WINDOW_HEATING, &maxHeatingValue); gxccd_release(cameraHandle); cameraHandle = nullptr; hasGain = false; useShutter = true; canDoPreflash = false; setDeviceName(name); setVersion(INDI_MI_VERSION_MAJOR, INDI_MI_VERSION_MINOR); }
int tty_nread_section(int fd, char *buf, int nsize, char stop_char, int timeout, int *nbytes_read) { #ifdef _WIN32 return TTY_ERRNO; #else if (fd == -1) return TTY_ERRNO; int bytesRead = 0; int err = TTY_OK; *nbytes_read = 0; uint8_t *read_char = 0; if (tty_debug) IDLog("%s: Request to read until stop char '%#02X' with %d timeout for fd %d\n", __FUNCTION__, stop_char, timeout, fd); for (;;) { if ((err = tty_timeout(fd, timeout))) return err; read_char = (uint8_t*)(buf + *nbytes_read); bytesRead = read(fd, read_char, 1); if (bytesRead < 0) return TTY_READ_ERROR; if (tty_debug) IDLog("%s: buffer[%d]=%#X (%c)\n", __FUNCTION__, (*nbytes_read), *read_char, *read_char); (*nbytes_read)++; if (*read_char == stop_char) return TTY_OK; else if (*nbytes_read >= nsize) return TTY_OVERFLOW; } return TTY_TIME_OUT; #endif }
bool SynscanMount::initProperties() { //if (isDebug()) IDLog("Synscan::init_properties\n"); //setDeviceName("Synscan"); INDI::Telescope::initProperties(); return true; }
bool CCDSim::ISSnoopDevice (XMLEle *root) { if (IUSnoopNumber(root,&FWHMNP)==0) { seeing = FWHMNP.np[0].value; if (isDebug()) IDLog("CCD Simulator: New FWHM value of %g\n", seeing); return true; } if (IUSnoopNumber(root,&ScopeParametersNP)==0) { focallength = ScopeParametersNP.np[1].value; guider_focallength = ScopeParametersNP.np[3].value; if (isDebug()) { IDLog("CCD Simulator: New focalLength value of %g\n", focallength); IDLog("CCD Simulator: New guider_focalLength value of %g\n", guider_focallength); } return true; } if(IUSnoopNumber(root,&EqPECNP)==0) { float newra,newdec; newra=EqPECN[0].value; newdec=EqPECN[1].value; if((newra != raPEC)||(newdec != decPEC)) { if (isDebug()) IDLog("raPEC %4.2f decPEC %4.2f Snooped raPEC %4.2f decPEC %4.2f\n",raPEC,decPEC,newra,newdec); raPEC=newra; decPEC=newdec; return true; } } return INDI::CCD::ISSnoopDevice(root); }
void INDI::BaseClientQt::listenINDI() { char buffer[MAXINDIBUF]; char errorMsg[MAXRBUF]; int err_code=0; XMLEle ** nodes; XMLEle * root; int inode=0; if (sConnected == false) return; while (client_socket.bytesAvailable() > 0) { qint64 readBytes = client_socket.read(buffer, MAXINDIBUF - 1); if ( readBytes > 0 ) buffer[ readBytes ] = '\0'; nodes=parseXMLChunk(lillp, buffer, readBytes, errorMsg); if (!nodes) { if (errorMsg[0]) { fprintf (stderr, "Bad XML from %s/%d: %s\n%s\n", cServer.c_str(), cPort, errorMsg, buffer); return; } return; } root=nodes[inode]; while (root) { if (verbose) prXMLEle(stderr, root, 0); if ( (err_code = dispatchCommand(root, errorMsg)) < 0) { // Silenty ignore property duplication errors if (err_code != INDI_PROPERTY_DUPLICATED) { IDLog("Dispatch command error(%d): %s\n", err_code, errorMsg); prXMLEle (stderr, root, 0); } } delXMLEle (root); // not yet, delete and continue inode++; root=nodes[inode]; } free(nodes); inode=0; } }
bool ClientAPIForAlignmentDatabase::AppendSyncPoint(const AlignmentDatabaseEntry &CurrentValues) { // Wait for driver to initialise if neccessary WaitForDriverCompletion(); ISwitchVectorProperty * pAction = Action->getSwitch(); ISwitchVectorProperty * pCommit = Commit->getSwitch(); if (APPEND != IUFindOnSwitchIndex(pAction)) { // Request Append mode IUResetSwitch(pAction); pAction->sp[APPEND].s = ISS_ON; SetDriverBusy(); BaseClient->sendNewSwitch(pAction); WaitForDriverCompletion(); if (IPS_OK != pAction->s) { IDLog("AppendSyncPoint - Bad Action switch state %s\n", pstateStr(pAction->s)); return false; } } if (!SendEntryData(CurrentValues)) return false; // Commit the entry to the database IUResetSwitch(pCommit); pCommit->sp[0].s = ISS_ON; SetDriverBusy(); BaseClient->sendNewSwitch(pCommit); WaitForDriverCompletion(); if (IPS_OK != pCommit->s) { IDLog("AppendSyncPoint - Bad Commit switch state %s\n", pstateStr(pCommit->s)); return false; } return true; }
/************************************************************************* ** Define Basic properties to clients. *************************************************************************/ void AAGCloudWatcher::ISGetProperties(const char *dev) { IDLog("ISGetProperties\n"); static int configLoaded = 0; // Ask the default driver first to send properties. INDI::DefaultDevice::ISGetProperties(dev); // If no configuration is load before, then load it now. if (configLoaded == 0) { loadConfig(); configLoaded = 1; } }
IPState FocusSim::MoveFocuser(FocusDirection dir, int speed, uint16_t duration) { double targetTicks = (speed * duration) / (FocusSpeedN[0].max * FocusTimerN[0].max); double plannedTicks=ticks; double plannedAbsPos=0; if (dir == FOCUS_INWARD) plannedTicks -= targetTicks; else plannedTicks += targetTicks; if (isDebug()) IDLog("Current ticks: %g - target Ticks: %g, plannedTicks %g\n", ticks, targetTicks, plannedTicks); plannedAbsPos = (plannedTicks - initTicks) * 5000 + (FocusAbsPosN[0].max - FocusAbsPosN[0].min)/2; if (plannedAbsPos < FocusAbsPosN[0].min || plannedAbsPos > FocusAbsPosN[0].max) { IDMessage(getDeviceName(), "Error, requested position is out of range."); return IPS_ALERT; } ticks = plannedTicks; if (isDebug()) IDLog("Current absolute position: %g, current ticks is %g\n", plannedAbsPos, ticks); FWHMN[0].value = 0.5625*ticks*ticks + SeeingN[0].value; FocusAbsPosN[0].value = plannedAbsPos; if (FWHMN[0].value < SeeingN[0].value) FWHMN[0].value = SeeingN[0].value; IDSetNumber(&FWHMNP, NULL); IDSetNumber(&FocusAbsPosNP, NULL); return IPS_OK; }
bool SynscanMount::Park() { char str[20]; int numread, bytesWritten, bytesRead; memset(str,0,3); tty_write(PortFD,"Ka",2, &bytesWritten); // test for an echo tty_read(PortFD,str,2,2, &bytesRead); // Read 2 bytes of response if(str[1] != '#') { // this is not a correct echo // so we are not talking to a mount properly return false; } // Now we stop tracking tty_write(PortFD,"T0",2, &bytesWritten); numread=tty_read(PortFD,str,1,60, &bytesRead); if (bytesRead!=1||str[0]!='#') { if (isDebug()) IDLog("Timeout waiting for scope to stop tracking."); return false; } //sprintf((char *)str,"b%08X,%08X",0x0,0x40000000); tty_write(PortFD,"B0000,4000",10, &bytesWritten); numread=tty_read(PortFD,str,1,60, &bytesRead); if (bytesRead!=1||str[0]!='#') { if (isDebug()) IDLog("Timeout waiting for scope to respond to park."); return false; } TrackState=SCOPE_PARKING; IDMessage(getDeviceName(),"Parking Telescope..."); return true; }
FishCampCCD::FishCampCCD(int CamNum) { cameraNum = CamNum; int rc = fcUsb_OpenCamera(cameraNum); IDLog("fcUsb_OpenCamera opening cam #%d, returns %d\n", cameraNum, rc); rc = fcUsb_cmd_getinfo(cameraNum, &camInfo); IDLog("fcUsb_cmd_getinfo opening cam #%d, returns %d\n", cameraNum, rc); strncpy(name, (char *)&camInfo.camNameStr, MAXINDINAME); IDLog("Cam #%d with name %s\n", cameraNum, name); setDeviceName(name); setVersion(FISHCAMP_VERSION_MAJOR, FISHCAMP_VERSION_MINOR); sim = false; }
void JoyStick::buttonEvent(int button_n, int value) { if (isConnected() == false) return; if (isDebug()) IDLog("buttonEvent[%d]: %s\n", button_n, value > 0 ? "On" : "Off"); ButtonSP.s = IPS_OK; ButtonS[button_n].s = (value == 0 )? ISS_OFF : ISS_ON; IDSetSwitch(&ButtonSP, NULL); }
bool ClientAPIForAlignmentDatabase::WaitForDriverCompletion() { int ReturnCode; ReturnCode = pthread_mutex_lock(&DriverActionCompleteMutex); while(!DriverActionComplete) { IDLog("WaitForDriverCompletion - Waiting\n"); ReturnCode = pthread_cond_wait(&DriverActionCompleteCondition, &DriverActionCompleteMutex); IDLog("WaitForDriverCompletion - Back from wait ReturnCode = %d\n", ReturnCode); if (ReturnCode) { ReturnCode = pthread_mutex_unlock(&DriverActionCompleteMutex); return false; } } IDLog("WaitForDriverCompletion - Finished waiting\n"); ReturnCode = pthread_mutex_unlock(&DriverActionCompleteMutex); if (ReturnCode) return false; else return true; }
bool QSICCD::UpdateCCDFrame(int x, int y, int w, int h) { char errmsg[ERRMSG_SIZE]; /* Add the X and Y offsets */ long x_1 = x / PrimaryCCD.getBinX(); long y_1 = y / PrimaryCCD.getBinY(); long x_2 = x_1 + (w / PrimaryCCD.getBinX()); long y_2 = y_1 + (h / PrimaryCCD.getBinY()); if (x_2 > PrimaryCCD.getXRes() / PrimaryCCD.getBinX()) { DEBUGF(INDI::Logger::DBG_ERROR, "Error: invalid width requested %ld", x_2); return false; } else if (y_2 > PrimaryCCD.getYRes() / PrimaryCCD.getBinY()) { DEBUGF(INDI::Logger::DBG_ERROR, "Error: invalid height request %ld", y_2); return false; } if (isDebug()) IDLog("The Final image area is (%ld, %ld), (%ld, %ld)\n", x_1, y_1, x_2, y_2); imageWidth = x_2 - x_1; imageHeight = y_2 - y_1; try { QSICam.put_StartX(x_1); QSICam.put_StartY(y_1); QSICam.put_NumX(imageWidth); QSICam.put_NumY(imageHeight); } catch (std::runtime_error err) { snprintf(errmsg, ERRMSG_SIZE, "Setting image area failed. %s.\n",err.what()); DEBUGF(INDI::Logger::DBG_ERROR, "Setting image area failed. %s.", err.what()); return false; } // Set UNBINNED coords PrimaryCCD.setFrame(x, y, w, h); int nbuf; nbuf=(imageWidth*imageHeight * PrimaryCCD.getBPP()/8); // this is pixel count nbuf+=512; // leave a little extra at the end PrimaryCCD.setFrameBufferSize(nbuf); return true; }
bool ClientAPIForAlignmentDatabase::SaveDatabase() { // Wait for driver to initialise if neccessary WaitForDriverCompletion(); ISwitchVectorProperty * pAction = Action->getSwitch(); ISwitchVectorProperty * pCommit = Commit->getSwitch(); // Select the required action if (SAVE_DATABASE != IUFindOnSwitchIndex(pAction)) { // Request Load Database mode IUResetSwitch(pAction); pAction->sp[SAVE_DATABASE].s = ISS_ON; SetDriverBusy(); BaseClient->sendNewSwitch(pAction); WaitForDriverCompletion(); if (IPS_OK != pAction->s) { IDLog("SaveDatabase - Bad Action switch state %s\n", pstateStr(pAction->s)); return false; } } // Commit the Save Database IUResetSwitch(pCommit); pCommit->sp[0].s = ISS_ON; SetDriverBusy(); BaseClient->sendNewSwitch(pCommit); WaitForDriverCompletion(); if (IPS_OK != pCommit->s) { IDLog("Save Database - Bad Commit state %s\n", pstateStr(pCommit->s)); return false; } return true; }
void INDI::BaseClientQt::processSocketError( QAbstractSocket::SocketError socketError ) { if (sConnected == false) return; // TODO Handle what happens on socket failure! INDI_UNUSED(socketError); IDLog("Socket Error: %s\n", client_socket.errorString().toLatin1().constData()); fprintf (stderr,"INDI server %s/%d disconnected.\n", cServer.c_str(), cPort); delLilXML(lillp); client_socket.close(); // Let client handle server disconnection serverDisconnected(-1); }
bool ClientAPIForAlignmentDatabase::SetDriverBusy() { int ReturnCode; ReturnCode = pthread_mutex_lock(&DriverActionCompleteMutex); if (ReturnCode) return false; DriverActionComplete = false; IDLog("SetDriverBusy\n"); ReturnCode = pthread_mutex_unlock(&DriverActionCompleteMutex); if (ReturnCode) return false; else return true; }