void ISInit() { static bool isInit = false; if (isInit) return; for (int i = 0; i < MAX_DEVICES; ++i) cameras[i] = nullptr; #if !defined(USE_SIMULATION) int ret = InitQHYCCDResource(); if (ret != QHYCCD_SUCCESS) { IDLog("Init QHYCCD SDK failed (%d)\n", ret); isInit = true; return; } #endif #if defined(OSX_EMBEDED_MODE) char firmwarePath[128]; sprintf(firmwarePath, "%s/Contents/Resources", getenv("INDIPREFIX")); OSXInitQHYCCDFirmware(firmwarePath); #elif defined(__APPLE__) char firmwarePath[128] = "/usr/local/lib/qhy"; if (getenv("QHY_FIRMWARE_DIR") != NULL) strncpy(firmwarePath, getenv("QHY_FIRMWARE_DIR"), 128); OSXInitQHYCCDFirmware(firmwarePath); #endif std::vector<std::string> devices = GetDevicesIDs(); cameraCount = (int)devices.size(); for (int i = 0; i < cameraCount; i++) { cameras[i] = new QHYCCD(devices[i].c_str()); } if (cameraCount > 0) { atexit(QhyCCDCleanup); isInit = true; } }
int main(void) { char path[1024] = "The Path to your firmware Directroy"; /* for example: firmware dirctory path is /opt/phd2_qhy/tmp/firmware path = "/opt/phd2_qhy/tmp/"; */ InitQHYCCDResource(); /* remember you should put the .HEX and .IMG files to firmware folder before run this sample */ OSXInitQHYCCDFirmware(path); ReleaseQHYCCDResource(); }
static bool QHYSDKInit() { if (s_qhySdkInitDone) return false; uint32_t ret; if ((ret = InitQHYCCDResource()) != 0) { Debug.Write(wxString::Format("InitQHYCCDResource failed: %d\n", (int)ret)); return true; } #if defined (__APPLE__) wxFileName exeFile(wxStandardPaths::Get().GetExecutablePath()); wxString exePath(exeFile.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR)); const wxWX2MBbuf tmp_buf = wxConvCurrent->cWX2MB(exePath); const char *temp = (const char *)tmp_buf; size_t const len = strlen(temp) + 1; char *destImgPath = new char[len]; memcpy(destImgPath, temp, len); if ((ret = OSXInitQHYCCDFirmware(destImgPath)) != 0) { Debug.Write(wxString::Format("OSXInitQHYCCDFirmware(%s) failed: %d\n", destImgPath, (int)ret)); delete[] destImgPath; return true; } delete[] destImgPath; // lzr from QHY says that it is important to wait 5s for firmware download to complete WorkerThread::MilliSleep(5000); #endif s_qhySdkInitDone = true; return false; }