/************************************************************************************ * * ***********************************************************************************/ IPState ScopeDome::sendMove(double azDiff) { int rc; if (azDiff < 0) { uint16_t steps = (uint16_t)(-azDiff * stepsPerTurn / 360.0); LOGF_DEBUG("CCW (%d)", steps); steps = compensateInertia(steps); LOGF_DEBUG("CCW inertia (%d)", steps); if (steps == 0) return IPS_OK; rc = writeU16(CCWRotation, steps); } else { uint16_t steps = (uint16_t)(azDiff * stepsPerTurn / 360.0); LOGF_DEBUG("CW (%d)", steps); steps = compensateInertia(steps); LOGF_DEBUG("CW inertia (%d)", steps); if (steps == 0) return IPS_OK; rc = writeU16(CWRotation, steps); } if (rc != 0) { LOGF_ERROR("Error moving dome: %d", rc); } return IPS_BUSY; }
bool FishCampCCD::StartExposure(float duration) { PrimaryCCD.setExposureDuration(duration); ExposureRequest = duration; bool rc = false; LOGF_DEBUG("Exposure Time (s) is: %g", duration); // setup the exposure time in ms. rc = fcUsb_cmd_setIntegrationTime(cameraNum, (UInt32)(duration * 1000.0)); LOGF_DEBUG("fcUsb_cmd_setIntegrationTime returns %d", rc); rc = fcUsb_cmd_startExposure(cameraNum); LOGF_DEBUG("fcUsb_cmd_startExposure returns %d", rc); gettimeofday(&ExpStart, nullptr); LOGF_INFO("Taking a %g seconds frame...", ExposureRequest); InExposure = true; return (rc == 0); }
bool lacerta_mfoc::SetBacklash(double values[], char *names[], int n) { LOGF_DEBUG("-> BACKLASH_SETTINGS", 0); char MFOC_cmd[32] = ": B "; char MFOC_res[32] = {0}; int nbytes_read = 0; int nbytes_written = 0; int MFOC_tdir_measd = 0; int bl_int = 0; char bl_char[32] = {0}; char MFOC_res_type[32] = "0"; BacklashNP.s = IPS_OK; IUUpdateNumber(&BacklashNP, values, names, n); bl_int = BacklashN[0].value; sprintf(bl_char, "%d", bl_int); strcat(bl_char, " #"); strcat(MFOC_cmd, bl_char); tty_write_string(PortFD, MFOC_cmd, &nbytes_written); LOGF_DEBUG("CMD <%s>", MFOC_cmd); tty_write_string(PortFD, ": J #", &nbytes_written); tty_read_section(PortFD, MFOC_res, 0xD, FOCUSMFOC_TIMEOUT, &nbytes_read); sscanf (MFOC_res, "%s %d", MFOC_res_type, &MFOC_tdir_measd); LOGF_DEBUG("RES <%s>", MFOC_res); IDSetNumber(&BacklashNP, nullptr); return true; }
int Arduino::closePort() { if (strcmp(serialPort, "indi") == 0) return 0; // do not close port that we did not open int rv = 0; rv |= flushPort(); if (fd < 0) { LOGF_DEBUG("Connection to %s already closed", serialPort); rv |= -1; } else if (tcsetattr(fd, TCSAFLUSH, &oldterm) < 0) { LOGF_DEBUG("Arduino::closePort():tcsetattr():%s", strerror(errno)); rv |= -2; if (close(fd) < 0) { LOGF_DEBUG("Arduino::closePort():close():%s", strerror(errno)); rv |= -4; } else { fd = -1; } } return (rv); }
// Send a command to the mount. Return the number of bytes received or 0 if // case of error // commands are null terminated, replies end with /n int QFW::send_command(int fd, const char* cmd, char *resp) { int err; int nbytes = 0; char errmsg[MAXRBUF]; int cmd_len = strlen(cmd); char dmp[255]; dump(dmp, cmd); LOGF_DEBUG("CMD <%s>", dmp); tcflush(fd, TCIOFLUSH); if ((err = tty_write(fd, cmd, cmd_len, &nbytes)) != TTY_OK) { tty_error_msg(err, errmsg, MAXRBUF); LOGF_ERROR("Serial write error: %s", errmsg); return 0; } err = tty_read_section(fd, resp, '\n', QUANTUM_TIMEOUT, &nbytes); if (err) { tty_error_msg(err, errmsg, MAXRBUF); LOGF_ERROR("Serial read error: %s", errmsg); return 0; } resp[nbytes] = 0; dump(dmp, resp); LOGF_DEBUG("RES <%s>", dmp); return nbytes; }
bool ArmPlat::slpSendRxInt( char *command, int *rcode ) { int nbytes_wrrd = 0; int rc; char errstr[MAXRBUF]; char res[SLP_SEND_BUF_SIZE]={0}; LOGF_DEBUG("Tx [%s]", command); //tty_set_debug( 1 ); if ((rc = tty_write_string(PortFD, command, &nbytes_wrrd)) != TTY_OK) { tty_error_msg(rc, errstr, MAXRBUF); //IDLog( "ERROR Tx: <%s>\n", errstr ); LOGF_ERROR("Send error: %s.", errstr); return false; } if ((rc = tty_read_section(PortFD, res, '#', ArmPlat_TIMEOUT, &nbytes_wrrd)) != TTY_OK) { tty_error_msg(rc, errstr, MAXRBUF); //IDLog( "ERROR Rx: <%s> error msg <%s>\n", res, errstr ); LOGF_ERROR("Echo receiving error: %s.", errstr); return false; } LOGF_DEBUG("Rx [%s]", res); //if ( ( strstr( command, "getpos" ) == nullptr ) && ( strstr( command, "temps" ) == nullptr ) ) //IDLog( "Rx: <%s>\n", res ); return getIntResultCode( command, res, rcode ); }
IPState WeatherSafetyProxy::executeCurl() { CURL *curl_handle; CURLcode res; std::string readBuffer; curl_handle = curl_easy_init(); if (curl_handle) { curl_easy_setopt(curl_handle, CURLOPT_URL, UrlT[WSP_URL].text); curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, WSP_WriteCallback); curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, &readBuffer); curl_easy_setopt(curl_handle, CURLOPT_USERAGENT, "libcurl-agent/1.0"); LOGF_DEBUG("Call curl %s", UrlT[WSP_URL].text); res = curl_easy_perform(curl_handle); if (res != CURLE_OK) { LOGF_ERROR("curl_easy_perform failed with [%s]", curl_easy_strerror(res)); return IPS_ALERT; } curl_easy_cleanup(curl_handle); LOGF_DEBUG("Read %d bytes output [%s]", readBuffer.size(), readBuffer.c_str()); return parseSafetyJSON(readBuffer.c_str(), readBuffer.size()); } else { LOG_ERROR("curl_easy_init failed"); return IPS_ALERT; } }
IPState WeatherSafetyProxy::executeScript() { char *cmd = ScriptsT[WSP_SCRIPT].text; if (access(cmd, F_OK|X_OK) == -1) { LOGF_ERROR("Cannot use script [%s], check its existence and permissions", cmd); LastParseSuccess = false; return IPS_ALERT; } LOGF_DEBUG("Run script: %s", cmd); FILE *handle = popen(cmd, "r"); if (handle == nullptr) { LOGF_ERROR("Failed to run script [%s]", strerror(errno)); LastParseSuccess = false; return IPS_ALERT; } char buf[BUFSIZ]; size_t byte_count = fread(buf, 1, BUFSIZ - 1, handle); fclose(handle); buf[byte_count] = 0; if (byte_count == 0) { LOGF_ERROR("Got no output from script [%s]", cmd); LastParseSuccess = false; return IPS_ALERT; } LOGF_DEBUG("Read %d bytes output [%s]", byte_count, buf); return parseSafetyJSON(buf, byte_count); }
bool lacerta_mfoc::SetTempComp(double values[], char *names[], int n) { LOGF_INFO("-> TEMPCOMP_SETTINGS", 0); char MFOC_cmd[32] = ": D "; char MFOC_res[32] = {0}; int nbytes_read = 0; int nbytes_written = 0; int MFOC_tc_measd = 0; int tc_int = 0; char tc_char[32] = {0}; char MFOC_res_type[32] = "0"; TempCompNP.s = IPS_OK; IUUpdateNumber(&TempCompNP, values, names, n); tc_int = TempCompN[0].value; sprintf(tc_char, "%d", tc_int); strcat(tc_char, " #"); strcat(MFOC_cmd, tc_char); tty_write_string(PortFD, MFOC_cmd, &nbytes_written); LOGF_DEBUG("CMD <%s>", MFOC_cmd); tty_write_string(PortFD, ": U #", &nbytes_written); tty_read_section(PortFD, MFOC_res, 0xD, FOCUSMFOC_TIMEOUT, &nbytes_read); sscanf (MFOC_res, "%s %d", MFOC_res_type, &MFOC_tc_measd); LOGF_DEBUG("RES <%s>", MFOC_res); IDSetNumber(&TempCompNP, nullptr); return true; }
bool lacerta_mfoc::SetFocuserMaxPosition(uint32_t ticks) { char MFOC_cmd[32] = ": G "; char MFOC_res[32] = {0}; int nbytes_read = 0; int nbytes_written = 0; int MFOC_pm_measd = 0; char pm_char[32] = {0}; char MFOC_res_type[32] = "0"; sprintf(pm_char, "%d", ticks); strcat(pm_char, " #"); strcat(MFOC_cmd, pm_char); tty_write_string(PortFD, MFOC_cmd, &nbytes_written); LOGF_DEBUG("CMD <%s>", MFOC_cmd); tty_write_string(PortFD, ": O #", &nbytes_written); tty_read_section(PortFD, MFOC_res, 0xD, FOCUSMFOC_TIMEOUT, &nbytes_read); sscanf (MFOC_res, "%s %d", MFOC_res_type, &MFOC_pm_measd); LOGF_DEBUG("RES <%s>", MFOC_res); return true; }
bool SynscanDriver::sendCommand(const char * cmd, char * res, int cmd_len, int res_len) { int nbytes_written = 0, nbytes_read = 0, rc = -1; tcflush(PortFD, TCIOFLUSH); if (cmd_len > 0) { char hex_cmd[SYN_RES * 3] = {0}; hexDump(hex_cmd, cmd, cmd_len); LOGF_DEBUG("CMD <%s>", hex_cmd); rc = tty_write(PortFD, cmd, cmd_len, &nbytes_written); } else { LOGF_DEBUG("CMD <%s>", cmd); rc = tty_write_string(PortFD, cmd, &nbytes_written); } if (rc != TTY_OK) { char errstr[MAXRBUF] = {0}; tty_error_msg(rc, errstr, MAXRBUF); LOGF_ERROR("Serial write error: %s.", errstr); return false; } if (res == nullptr) return true; if (res_len > 0) rc = tty_read(PortFD, res, res_len, SYN_TIMEOUT, &nbytes_read); else rc = tty_nread_section(PortFD, res, SYN_RES, SYN_DEL, SYN_TIMEOUT, &nbytes_read); if (rc != TTY_OK) { char errstr[MAXRBUF] = {0}; tty_error_msg(rc, errstr, MAXRBUF); LOGF_ERROR("Serial read error: %s.", errstr); return false; } if (res_len > 0) { char hex_res[SYN_RES * 3] = {0}; hexDump(hex_res, res, res_len); LOGF_DEBUG("RES <%s>", hex_res); } else { LOGF_DEBUG("RES <%s>", res); } tcflush(PortFD, TCIOFLUSH); return true; }
int Arduino::sendUchar(const unsigned char data) { #ifdef DEBUG LOGF_DEBUG("Arduino::sendUchar sending: 0x%02x", data); #endif // DEBUG if (write(fd, &data, sizeof(char)) < 0) { LOGF_DEBUG("Arduino::sendUchar():write():%s", strerror(errno)); LOGF_DEBUG("during write 0x%02x (%c)", data, data); return (-1); } usleep(100); return (0); }
bool MoonLiteDRO::updateStepDelay() { int nbytes_written = 0, nbytes_read = 0, rc = -1; char errstr[MAXRBUF]; char resp[3]={0}; char cmd[DRO_CMD]={0}; short speed; if (m_ID == 1) strncpy(cmd, ":GD#", DRO_CMD); else strncpy(cmd, ":2GD#", DRO_CMD); LOGF_DEBUG("CMD <%s>", cmd); tcflush(PortFD, TCIOFLUSH); if ((rc = tty_write_string(PortFD, cmd, &nbytes_written)) != TTY_OK) { tty_error_msg(rc, errstr, MAXRBUF); LOGF_ERROR("updateStepDelay error: %s.", errstr); return false; } if ((rc = tty_read_section(PortFD, resp, '#', MOONLITEDRO_TIMEOUT, &nbytes_read)) != TTY_OK) { tty_error_msg(rc, errstr, MAXRBUF); LOGF_ERROR("updateStepDelay error: %s.", errstr); return false; } tcflush(PortFD, TCIOFLUSH); LOGF_DEBUG("RES <%s>", resp); rc = sscanf(resp, "%hX", &speed); if (rc > 0) { int focus_speed = -1; while (speed > 0) { speed >>= 1; focus_speed++; } StepDelayN[0].value = focus_speed; }
bool SynscanDriver::passThruCommand(int cmd, int target, int msgsize, int data, int numReturn) { char test[20] = {0}; int bytesRead, bytesWritten; char a, b, c; int tt = data; a = tt % 256; tt = tt >> 8; b = tt % 256; tt = tt >> 8; c = tt % 256; // format up a passthru command memset(test, 0, 20); test[0] = 80; // passhtru test[1] = msgsize; // set message size test[2] = target; // set the target test[3] = cmd; // set the command test[4] = c; // set data bytes test[5] = b; test[6] = a; test[7] = numReturn; LOGF_DEBUG("CMD <%s>", test); tty_write(PortFD, test, 8, &bytesWritten); memset(test, 0, 20); tty_read(PortFD, test, numReturn + 1, 2, &bytesRead); LOGF_DEBUG("RES <%s>", test); if (numReturn > 0) { int retval = 0; retval = test[0]; if (numReturn > 1) { retval = retval << 8; retval += test[1]; } if (numReturn > 2) { retval = retval << 8; retval += test[2]; } return retval; } return 0; }
bool ArmPlat::setTempSensorInUse( uint16_t sensor ) { LOGF_DEBUG("Temp sensor set to %d", sensor ); tempSensInUse = sensor; return true; }
bool TCFS::read_tcfs(char *response, bool silent) { int err_code = 0, nbytes_read = 0; char err_msg[TCFS_ERROR_BUFFER]; if (isSimulation()) { strncpy(response, "SIMULATION", TCFS_MAX_CMD); return true; } // Read until encountring a CR if ((err_code = tty_read_section(PortFD, response, 0x0D, 2, &nbytes_read)) != TTY_OK) { if (!silent) { tty_error_msg(err_code, err_msg, 32); LOGF_ERROR("TTY error detected: %s", err_msg); } return false; } // Remove LF & CR response[nbytes_read - 2] = '\0'; LOGF_DEBUG("RES <%s>", response); return true; }
bool TCFS::Handshake() { LOGF_DEBUG("%s %s",__FUNCTION__, me); if (isSimulation()) { LOG_INFO("TCF-S: Simulating connection."); currentPosition = simulated_position; return true; } char response[TCFS_MAX_CMD] = { 0 }; if(SetManualMode()) { dispatch_command(FWAKUP); read_tcfs(response); tcflush(PortFD, TCIOFLUSH); LOG_INFO("Successfully connected to TCF-S Focuser in Manual Mode."); // Enable temperature readout FocusTemperatureNP.s = IPS_OK; return true; } tcflush(PortFD, TCIOFLUSH); LOG_ERROR("Failed connection to TCF-S Focuser."); return false; }
bool MICCD::UpdateCCDFrame(int x, int y, int w, int h) { /* 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()) { LOGF_ERROR("Error: Requested width out of bounds %ld", x_2); return false; } else if (y_2 > PrimaryCCD.getYRes()) { LOGF_ERROR("Error: Requested height out of bounds %ld", y_2); return false; } LOGF_DEBUG("The Final image area is (%ld, %ld), (%ld, %ld)\n", x_1, y_1, x_2, y_2); int imageWidth = x_2 - x_1; int imageHeight = y_2 - y_1; // Set UNBINNED coords PrimaryCCD.setFrame(x, y, w, h); PrimaryCCD.setFrameBufferSize(imageWidth * imageHeight * PrimaryCCD.getBPP() / 8); return true; }
IPState ArmPlat::MoveRelFocuser(FocusDirection dir, uint32_t ticks) { //IDLog( "Rel focuser move %d %d\n", (int)dir, ticks ); if ( port == -1 ) return IPS_ALERT; int rc = -1; int realticks; char cmd[SLP_SEND_BUF_SIZE]={0}; if (dir == FOCUS_INWARD) realticks = -ticks; else realticks = ticks; LOGF_DEBUG("Rel move to %d", realticks ); sprintf(cmd, "!step gopr %d %d#", port, realticks ); if ( slpSendRxInt( cmd, &rc ) ) { if ( rc == 0 ) { isMoving = true; FocusRelPosN[0].value = ticks; FocusRelPosNP.s = IPS_BUSY; return IPS_BUSY; } } return IPS_ALERT; }
bool MICCD::StartExposure(float duration) { imageFrameType = PrimaryCCD.getFrameType(); useShutter = (imageFrameType == INDI::CCDChip::LIGHT_FRAME || imageFrameType == INDI::CCDChip::FLAT_FRAME); if (!isSimulation()) { // read modes in G2/G3/G4 cameras are in inverse order, we have to calculate correct value int mode, prm; gxccd_get_integer_parameter(cameraHandle, GIP_PREVIEW_READ_MODE, &prm); if (prm == 0) // preview mode == 0 means smaller G0/G1 cameras mode = IUFindOnSwitchIndex(&ReadModeSP); else mode = prm - IUFindOnSwitchIndex(&ReadModeSP); gxccd_set_read_mode(cameraHandle, mode); // send binned coords int x = PrimaryCCD.getSubX() / PrimaryCCD.getBinX(); int y = PrimaryCCD.getSubY() / PrimaryCCD.getBinY(); int w = PrimaryCCD.getSubW() / PrimaryCCD.getBinX(); int d = PrimaryCCD.getSubH() / PrimaryCCD.getBinY(); gxccd_start_exposure(cameraHandle, duration, useShutter, x, y, w, d); } ExposureRequest = duration; PrimaryCCD.setExposureDuration(duration); gettimeofday(&ExpStart, nullptr); InExposure = true; downloading = false; LOGF_DEBUG("Taking a %.3f seconds frame...", ExposureRequest); return true; }
bool ATIKCCD::Disconnect() { ImageState tState; LOGF_DEBUG("Closing %s...", name); stopTimerNS(); stopTimerWE(); RemoveTimer(genTimerID); genTimerID = -1; pthread_mutex_lock(&condMutex); tState = threadState; threadRequest = StateTerminate; pthread_cond_signal(&cv); pthread_mutex_unlock(&condMutex); pthread_join(imagingThread, nullptr); tState = StateNone; if (isSimulation() == false) { if (tState == StateExposure) ArtemisStopExposure(hCam); ArtemisDisconnect(hCam); } LOG_INFO("Camera is offline."); return true; }
IPState lacerta_mfoc::MoveAbsFocuser(uint32_t targetTicks) { char MFOC_cmd[32] = ": M "; char abs_pos_char[32] = {0}; int nbytes_written = 0; //int pos = GetAbsFocuserPosition(); sprintf(abs_pos_char, "%d", targetTicks); strcat(abs_pos_char, " #"); strcat(MFOC_cmd, abs_pos_char); tty_write_string(PortFD, MFOC_cmd, &nbytes_written); LOGF_DEBUG("CMD <%s>", MFOC_cmd); //Waiting makes no sense - will be immediatly interrupted by the ekos system... //int ticks = std::abs((int)(targetTicks - pos) * FOCUS_MOTION_DELAY); //LOGF_INFO("sleep for %d ms", ticks); //usleep(ticks + 5000); FocusAbsPosN[0].value = targetTicks; //only for debugging! Maybe there is a bug in the MFOC firmware command "Q #"! GetAbsFocuserPosition(); return IPS_OK; }
bool SynscanDriver::SetCurrentPark() { char res[SYN_RES] = {0}; // Get Current Az/Alt memset(res, 0, SYN_RES); if (!sendCommand("z", res)) return false; uint32_t n1 = 0, n2 = 0; sscanf(res, "%ux,%ux#", &n1, &n2); double az = static_cast<double>(n1) / 0x100000000 * 360.0; double al = static_cast<double>(n2) / 0x100000000 * 360.0; al = rangeDec(al); char AzStr[16], AltStr[16]; fs_sexa(AzStr, az, 2, 3600); fs_sexa(AltStr, al, 2, 3600); LOGF_DEBUG("Setting current parking position to coordinates Az (%s) Alt (%s)...", AzStr, AltStr); SetAxis1Park(az); SetAxis2Park(al); return true; }
bool SynscanDriver::Sync(double ra, double dec) { char cmd[SYN_RES] = {0}, res[SYN_RES] = {0}; TargetRA = ra; TargetDE = dec; if (isSimulation()) return true; // INDI is JNow. Synscan Controll uses J2000 Epoch ln_equ_posn epochPos { 0, 0 }, J2000Pos { 0, 0 }; epochPos.ra = ra * 15.0; epochPos.dec = dec; // Synscan accepts J2000 coordinates so we need to convert from JNow to J2000 ln_get_equ_prec2(&epochPos, ln_get_julian_from_sys(), JD2000, &J2000Pos); // Mount deals in J2000 coords. uint32_t n1 = J2000Pos.ra / 360 * 0x100000000; uint32_t n2 = J2000Pos.dec / 360 * 0x100000000; LOGF_DEBUG("Sync - JNow RA: %g JNow DE: %g J2000 RA: %g J2000 DE: %g", ra, dec, J2000Pos.ra / 15.0, J2000Pos.dec); snprintf(cmd, SYN_RES, "s%08X,%08X", n1, n2); return sendCommand(cmd, res, 18); }
bool lacerta_mfoc::Handshake() { char MFOC_cmd[32] = ": Q #"; char MFOC_res[32] = {0}; char MFOC_res_type[32] = "0"; int MFOC_pos_measd = 0; int nbytes_written = 0; int nbytes_read = 0; tty_write_string(PortFD, MFOC_cmd, &nbytes_written); LOGF_INFO("CMD <%s>", MFOC_cmd); tty_read_section(PortFD, MFOC_res, 0xD, FOCUSMFOC_TIMEOUT, &nbytes_read); LOGF_DEBUG("RES <%s>", MFOC_res_type); sscanf(MFOC_res, "%s %d", MFOC_res_type, &MFOC_pos_measd); if (MFOC_res_type[0] == 'P') { FocusAbsPosN[0].value = MFOC_pos_measd; FocusAbsPosNP.s = IPS_OK; return true; } return false; }
bool FishCampCCD::setGain(double gain) { int rc = fcUsb_cmd_setCameraGain(cameraNum, ((int)gain)); LOGF_DEBUG("fcUsb_cmd_setCameraGain returns %d", rc); return true; }
bool Paramount::Handshake() { if (isSimulation()) return true; int rc = 0, nbytes_written = 0, nbytes_read = 0; char pCMD[MAXRBUF]={0}, pRES[MAXRBUF]={0}; strncpy(pCMD, "/* Java Script */" "var Out;" "sky6RASCOMTele.ConnectAndDoNotUnpark();" "Out = sky6RASCOMTele.IsConnected;", MAXRBUF); LOGF_DEBUG("CMD: %s", pCMD); if ((rc = tty_write_string(PortFD, pCMD, &nbytes_written)) != TTY_OK) { LOG_ERROR("Error writing to TheSky6 TCP server."); return false; } // Should we read until we encounter string terminator? or what? if (static_cast<int>(rc == tty_read_section(PortFD, pRES, '\0', PARAMOUNT_TIMEOUT, &nbytes_read)) != TTY_OK) { LOG_ERROR("Error reading from TheSky6 TCP server."); return false; } LOGF_DEBUG("RES: %s", pRES); int isTelescopeConnected = -1; std::regex rgx(R"((\d+)\|(.+)\. Error = (\d+)\.)"); std::smatch match; std::string input(pRES); if (std::regex_search(input, match, rgx)) isTelescopeConnected = atoi(match.str(1).c_str()); if (isTelescopeConnected <= 0) { LOGF_ERROR("Error connecting to telescope: %s (%d).", match.str(1).c_str(), atoi(match.str(2).c_str())); return false; }
int Arduino::flushPort() { if (tcflush(fd, TCIFLUSH) < 0) { LOGF_DEBUG("Arduino::flushPort():tcflush():%s", strerror(errno)); return (-1); } return (0); }
bool QHYCFW2::SelectFilter(int f) { TargetFilter = f; char cmd[8] = {0}, res[8]={0}; int rc = -1, nbytes_written=0, nbytes_read=0; LOGF_DEBUG("CMD <%d>", TargetFilter-1); snprintf(cmd, 2, "%d", TargetFilter-1); if (isSimulation()) snprintf(res, 8, "%d", TargetFilter-1); else { if ((rc = tty_write_string(PortFD, cmd, &nbytes_written)) != TTY_OK) { char error_message[ERRMSG_SIZE]; tty_error_msg(rc, error_message, ERRMSG_SIZE); LOGF_ERROR("Sending command select filter failed: %s", error_message); return false; } if ((rc = tty_read(PortFD, res, 1, 30, &nbytes_read)) != TTY_OK) { char error_message[ERRMSG_SIZE]; tty_error_msg(rc, error_message, ERRMSG_SIZE); LOGF_ERROR("Reading select filter response failed: %s", error_message); return false; } LOGF_DEBUG("RES <%s>", res); } if (atoi(res)+1 == TargetFilter) { CurrentFilter = TargetFilter; SelectFilterDone(CurrentFilter); return true; } return false; }
bool ATIKCCD::StartExposure(float duration) { PrimaryCCD.setExposureDuration(duration); ExposureRequest = duration; // Camera needs to be in idle state to start exposure after previous abort int maxWaitCount = 1000; // 1000 * 0.1s = 100s while (ArtemisCameraState(hCam) != CAMERA_IDLE && --maxWaitCount > 0) { LOG_DEBUG("Waiting camera to be idle..."); usleep(100000); } if (maxWaitCount == 0) { LOG_ERROR("Camera not in idle state, can't start exposure"); return false; } LOGF_DEBUG("Start Exposure : %.3fs", duration); // if (m_CameraFlags & ARTEMIS_PROPERTIES_CAMERAFLAGS_HAS_SHUTTER) // { // if (PrimaryCCD.getFrameType() == INDI::CCDChip::DARK_FRAME || // PrimaryCCD.getFrameType() == INDI::CCDChip::BIAS_FRAME) // { // ArtemisCloseShutter(hCam); // } // else // { // ArtemisOpenShutter(hCam); // } // } ArtemisSetDarkMode(hCam, PrimaryCCD.getFrameType() == INDI::CCDChip::DARK_FRAME || PrimaryCCD.getFrameType() == INDI::CCDChip::BIAS_FRAME); int rc = ArtemisStartExposure(hCam, duration); if (rc != ARTEMIS_OK) { LOGF_ERROR("Failed to start exposure (%d).", rc); return false; } gettimeofday(&ExpStart, nullptr); if (ExposureRequest > VERBOSE_EXPOSURE) LOGF_INFO("Taking a %g seconds frame...", ExposureRequest); InExposure = true; pthread_mutex_lock(&condMutex); threadRequest = StateExposure; pthread_cond_signal(&cv); pthread_mutex_unlock(&condMutex); return true; }