/* Downloads the image from the CCD. */ int MICCD::grabImage() { unsigned char *image = (unsigned char *) PrimaryCCD.getFrameBuffer(); if (isSimulation()) { int height = PrimaryCCD.getSubH() / PrimaryCCD.getBinY(); int width = PrimaryCCD.getSubW() / PrimaryCCD.getBinX(); uint16_t *buffer = (uint16_t *) image; for (int i = 0; i < height; i++) for (int j = 0; j < width; j++) buffer[i * width + j] = rand() % UINT16_MAX; } else { int ret = 0; if (gxccd_read_image(cameraHandle, image, PrimaryCCD.getFrameBufferSize()) < 0) { char errorStr[MAX_ERROR_LEN]; gxccd_get_last_error(cameraHandle, errorStr, sizeof(errorStr)); DEBUGF(INDI::Logger::DBG_ERROR, "Error getting image: %s.", errorStr); } } if (ExposureRequest > POLLMS * 5) DEBUG(INDI::Logger::DBG_SESSION, "Download complete."); downloading = false; ExposureComplete(&PrimaryCCD); return 0; }
/* Downloads the image from the CCD. */ int MICCD::grabImage() { std::unique_lock<std::mutex> guard(ccdBufferLock); int ret = 0; unsigned char *image = (unsigned char *)PrimaryCCD.getFrameBuffer(); int width = PrimaryCCD.getSubW() / PrimaryCCD.getBinX(); int height = PrimaryCCD.getSubH() / PrimaryCCD.getBinY(); if (isSimulation()) { uint16_t *buffer = (uint16_t *)image; for (int i = 0; i < height; i++) for (int j = 0; j < width; j++) buffer[i * width + j] = rand() % UINT16_MAX; } else { ret = gxccd_read_image(cameraHandle, image, PrimaryCCD.getFrameBufferSize()); if (ret < 0) { char errorStr[MAX_ERROR_LEN]; gxccd_get_last_error(cameraHandle, errorStr, sizeof(errorStr)); LOGF_ERROR("Error getting image: %s.", errorStr); } else { mirror_image(image, width, height); } } guard.unlock(); if (ExposureRequest > POLLMS * 5 && !ret) LOG_INFO("Download complete."); downloading = false; ExposureComplete(&PrimaryCCD); return ret; }