From ce9ff31009a76c1a14bc7616c3329e9e0121b107 Mon Sep 17 00:00:00 2001 From: Michael Langmayr Date: Wed, 7 Aug 2024 10:47:44 -0700 Subject: [PATCH 001/124] add autofetch command to camerad --- camerad/camerad.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/camerad/camerad.cpp b/camerad/camerad.cpp index c3431205..d7e51cd8 100644 --- a/camerad/camerad.cpp +++ b/camerad/camerad.cpp @@ -755,6 +755,14 @@ void doit(Network::TcpSocket sock) { } else if (cmd == "trigin") { ret = server.trigin(args); } + else + if (cmd=="autofetch") { + ret = server.autofetch(args, retstring); + if (!retstring.empty()) { + sock.Write(retstring); + sock.Write( " "); + } + } #endif else if (cmd == "expose") { ret = server.expose(args); From 53dba41a153eaa48fccfe7548b5e38d9d17ecaaa Mon Sep 17 00:00:00 2001 From: Michael Langmayr Date: Wed, 7 Aug 2024 15:33:47 -0700 Subject: [PATCH 002/124] start adding autofetch support --- CMakeLists.txt | 10 ++++++++++ camerad/archon.cpp | 19 +++++++++++++++++-- camerad/archon.h | 2 +- 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5623581b..40cf9657 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -52,3 +52,13 @@ add_subdirectory(${PROJECT_BASE_DIR}/common) add_subdirectory(${PROJECT_BASE_DIR}/camerad) add_subdirectory(${PROJECT_BASE_DIR}/emulator) add_subdirectory(${PROJECT_BASE_DIR}/tests EXCLUDE_FROM_ALL) + +## Custom clean target +#add_custom_target(custom_clean +# COMMAND ${CMAKE_COMMAND} -P ${CMAKE_BINARY_DIR}/cmake_clean.cmake +# COMMAND ${CMAKE_COMMAND} -E rm -Rf ${CMAKE_BINARY_DIR} +# COMMENT "Custom clean steps" +#) + +# Make the custom clean target depend on the default clean target +#add_dependencies(custom_clean clean) diff --git a/camerad/archon.cpp b/camerad/archon.cpp index 8e6cef22..2f8d2bad 100644 --- a/camerad/archon.cpp +++ b/camerad/archon.cpp @@ -5041,7 +5041,7 @@ namespace Archon { * This function polls the Archon frame status until a new frame is ready. * */ - long Interface::wait_for_readout() { + long Interface::wait_for_readout(bool is_autofetch) { std::string function = "Archon::Interface::wait_for_readout"; std::stringstream message; long error = NO_ERROR; @@ -5075,7 +5075,22 @@ namespace Archon { while (!done && !this->abort) { if (this->is_longexposure) usleep( 10000 ); // reduces polling frequency - error = this->get_frame_status(); + + int retval; + char buffer[4096]; + char header[13]; + + if (!is_autofetch) { + error = this->get_frame_status(); + } else { + retval = this->archon.Read(header, 12); + message.str(""); message << "code " << retval << " reading Archon frame header: " << header; + + if (strncmp(header, " Date: Thu, 8 Aug 2024 11:40:21 -0700 Subject: [PATCH 003/124] find buffer variable --- camerad/archon.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/camerad/archon.cpp b/camerad/archon.cpp index 2f8d2bad..ee697115 100644 --- a/camerad/archon.cpp +++ b/camerad/archon.cpp @@ -5078,16 +5078,17 @@ namespace Archon { int retval; char buffer[4096]; - char header[13]; + char header[25]; if (!is_autofetch) { error = this->get_frame_status(); } else { - retval = this->archon.Read(header, 12); + retval = this->archon.Read(header, 24); message.str(""); message << "code " << retval << " reading Archon frame header: " << header; if (strncmp(header, " Date: Fri, 9 Aug 2024 14:26:14 -0700 Subject: [PATCH 004/124] prototyping in progress --- .gitignore | 1 + camerad/archon.cpp | 13 +++++++------ camerad/archon.h | 2 +- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index 706fd07f..5ac6ccdc 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ .idea .vscode +cmake-build* \ No newline at end of file diff --git a/camerad/archon.cpp b/camerad/archon.cpp index ee697115..46831b8d 100644 --- a/camerad/archon.cpp +++ b/camerad/archon.cpp @@ -5041,7 +5041,7 @@ namespace Archon { * This function polls the Archon frame status until a new frame is ready. * */ - long Interface::wait_for_readout(bool is_autofetch) { + long Interface::wait_for_readout() { std::string function = "Archon::Interface::wait_for_readout"; std::stringstream message; long error = NO_ERROR; @@ -5078,15 +5078,16 @@ namespace Archon { int retval; char buffer[4096]; - char header[25]; + // char header[25]; - if (!is_autofetch) { + if (!this->is_autofetch) { error = this->get_frame_status(); } else { - retval = this->archon.Read(header, 24); - message.str(""); message << "code " << retval << " reading Archon frame header: " << header; + logwrite( function, "AUTOFETCH MODE" ); + retval = this->archon.Read(buffer, 2048); + message.str(""); message << "code " << retval << " reading Archon frame header: " << buffer; - if (strncmp(header, " Date: Fri, 9 Aug 2024 14:49:22 -0700 Subject: [PATCH 005/124] prototyping in progress --- camerad/archon.cpp | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/camerad/archon.cpp b/camerad/archon.cpp index 46831b8d..282c2b87 100644 --- a/camerad/archon.cpp +++ b/camerad/archon.cpp @@ -822,6 +822,10 @@ namespace Archon { // log the command as long as it's not a STATUS, TIMER, WCONFIG or FRAME command // + if(this->is_autofetch) { + logwrite( function, "AUTOFETCH IS ON"); + } + if ( (cmd.compare(0,7,"WCONFIG") != 0) && (cmd.compare(0,5,"TIMER") != 0) && (cmd.compare(0,6,"STATUS") != 0) && @@ -897,13 +901,18 @@ namespace Archon { this->camera.log_error( function, message.str() ); } else if (reply.compare(0, 3, check)!=0) { // First 3 bytes of reply must equal checksum else reply doesn't belong to command - error = ERROR; - // std::string hdr = reply; - try { + if (this->is_autofetch) { + logwrite( function, "auto fetch mode"); + error = NO_ERROR; + } else { + error = ERROR; + // std::string hdr = reply; + try { scmd.erase(scmd.find('\n'), 1); - } catch(...) { } - message.str(""); message << "command-reply mismatch for command: " + scmd + ": expected " + check + " but received " + reply ; - this->camera.log_error( function, message.str() ); + } catch(...) { } + message.str(""); message << "command-reply mismatch for command: " + scmd + ": expected " + check + " but received " + reply ; + this->camera.log_error( function, message.str() ); + } } else { // command and reply are a matched pair error = NO_ERROR; From d7d621b20c74891699e00f568f5dd51bde3e451e Mon Sep 17 00:00:00 2001 From: Michael Langmayr Date: Fri, 9 Aug 2024 15:13:06 -0700 Subject: [PATCH 006/124] prototyping in progress --- camerad/archon.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/camerad/archon.cpp b/camerad/archon.cpp index 282c2b87..f1328151 100644 --- a/camerad/archon.cpp +++ b/camerad/archon.cpp @@ -5094,11 +5094,18 @@ namespace Archon { } else { logwrite( function, "AUTOFETCH MODE" ); retval = this->archon.Read(buffer, 2048); - message.str(""); message << "code " << retval << " reading Archon frame header: " << buffer; + std::string buffer_str(buffer); + size_t pos = buffer_str.find(" Date: Fri, 9 Aug 2024 15:28:39 -0700 Subject: [PATCH 007/124] prototyping in progress --- camerad/archon.cpp | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/camerad/archon.cpp b/camerad/archon.cpp index f1328151..7ad29433 100644 --- a/camerad/archon.cpp +++ b/camerad/archon.cpp @@ -822,10 +822,6 @@ namespace Archon { // log the command as long as it's not a STATUS, TIMER, WCONFIG or FRAME command // - if(this->is_autofetch) { - logwrite( function, "AUTOFETCH IS ON"); - } - if ( (cmd.compare(0,7,"WCONFIG") != 0) && (cmd.compare(0,5,"TIMER") != 0) && (cmd.compare(0,6,"STATUS") != 0) && @@ -5092,14 +5088,12 @@ namespace Archon { if (!this->is_autofetch) { error = this->get_frame_status(); } else { - logwrite( function, "AUTOFETCH MODE" ); - retval = this->archon.Read(buffer, 2048); + logwrite( function, " READ IN AUTOFETCH MODE" ); + retval = this->archon.Read(buffer, 4096); std::string buffer_str(buffer); - size_t pos = buffer_str.find(" Date: Fri, 9 Aug 2024 15:46:17 -0700 Subject: [PATCH 008/124] prototyping in progress --- camerad/archon.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/camerad/archon.cpp b/camerad/archon.cpp index 7ad29433..3b12e1d8 100644 --- a/camerad/archon.cpp +++ b/camerad/archon.cpp @@ -5082,24 +5082,26 @@ namespace Archon { if (this->is_longexposure) usleep( 10000 ); // reduces polling frequency int retval; - char buffer[4096]; + char buffer[20]; // char header[25]; if (!this->is_autofetch) { error = this->get_frame_status(); } else { logwrite( function, " READ IN AUTOFETCH MODE" ); - retval = this->archon.Read(buffer, 4096); + retval = this->archon.Read(buffer, 20); std::string buffer_str(buffer); const size_t pos = buffer_str.find(" Date: Fri, 9 Aug 2024 15:49:38 -0700 Subject: [PATCH 009/124] prototyping in progress --- camerad/archon.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/camerad/archon.cpp b/camerad/archon.cpp index 3b12e1d8..58efd7c7 100644 --- a/camerad/archon.cpp +++ b/camerad/archon.cpp @@ -5099,6 +5099,8 @@ namespace Archon { logwrite( function, "READ AUTOFETCH HEADER!" ); logwrite( function, message.str() ); + this->frame.index = std::stoi(buffer_str.substr(13, 1)); + done = true; error = NO_ERROR; break; From 29bde853a3b2cb15c7b6a84e452150ec06ffe64d Mon Sep 17 00:00:00 2001 From: Michael Langmayr Date: Fri, 9 Aug 2024 16:10:00 -0700 Subject: [PATCH 010/124] prototyping in progress --- camerad/archon.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/camerad/archon.cpp b/camerad/archon.cpp index 58efd7c7..43c4e180 100644 --- a/camerad/archon.cpp +++ b/camerad/archon.cpp @@ -5091,15 +5091,16 @@ namespace Archon { logwrite( function, " READ IN AUTOFETCH MODE" ); retval = this->archon.Read(buffer, 20); std::string buffer_str(buffer); - const size_t pos = buffer_str.find("frame.index = std::stoi(buffer_str.substr(13, 1)); + this->frame.index = frame_index; + currentframe = this->frame.bufframen[this->frame.index]; done = true; error = NO_ERROR; From 3c6fe8e86f3c72292357a9b2318d8ce172b9c05b Mon Sep 17 00:00:00 2001 From: Michael Langmayr Date: Mon, 12 Aug 2024 08:53:29 -0700 Subject: [PATCH 011/124] prototyping in progress --- camerad/archon.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/camerad/archon.cpp b/camerad/archon.cpp index 43c4e180..e36a245e 100644 --- a/camerad/archon.cpp +++ b/camerad/archon.cpp @@ -5100,11 +5100,11 @@ namespace Archon { logwrite( function, message.str() ); this->frame.index = frame_index; - currentframe = this->frame.bufframen[this->frame.index]; + // currentframe = this->frame.bufframen[this->frame.index]; - done = true; - error = NO_ERROR; - break; + //done = true; + //error = NO_ERROR; + //break; } } @@ -5128,6 +5128,8 @@ namespace Archon { break; } + logwrite( function, "GET CURRENT FRAME" ); + // get current frame number and check the status of its buffer currentframe = this->frame.bufframen[this->frame.index]; if ( (currentframe != this->lastframe) && (this->frame.bufcomplete[this->frame.index]==1) ) { From 6a572bc9aefa51268e87862683b8d84893ed81ce Mon Sep 17 00:00:00 2001 From: Michael Langmayr Date: Mon, 12 Aug 2024 09:54:12 -0700 Subject: [PATCH 012/124] prototyping in progress --- camerad/archon.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/camerad/archon.cpp b/camerad/archon.cpp index e36a245e..b15b3cd0 100644 --- a/camerad/archon.cpp +++ b/camerad/archon.cpp @@ -16,6 +16,7 @@ #include #include #include +#include namespace Archon { @@ -5091,20 +5092,19 @@ namespace Archon { logwrite( function, " READ IN AUTOFETCH MODE" ); retval = this->archon.Read(buffer, 20); std::string buffer_str(buffer); - // const size_t pos = buffer_str.find("frame.index = frame_index; - // currentframe = this->frame.bufframen[this->frame.index]; - - //done = true; - //error = NO_ERROR; - //break; + } else { + logwrite( function, "NO AUTOFETCH HEADER FOUND! IDLING FOR 3 SECONDS..." ); + std::this_thread::sleep_for(std::chrono::seconds(3)); } } From a1c56ce8c7cfd9449932e8592950f563238f3dff Mon Sep 17 00:00:00 2001 From: Michael Langmayr Date: Mon, 12 Aug 2024 15:19:24 -0700 Subject: [PATCH 013/124] prototyping in progress --- camerad/archon.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/camerad/archon.cpp b/camerad/archon.cpp index b15b3cd0..de7dadaa 100644 --- a/camerad/archon.cpp +++ b/camerad/archon.cpp @@ -5094,13 +5094,11 @@ namespace Archon { std::string buffer_str(buffer); if (strncmp(buffer, "frame.index = frame_index; } else { logwrite( function, "NO AUTOFETCH HEADER FOUND! IDLING FOR 3 SECONDS..." ); From 85a901ab884fe7392293d1de191d8e564299bf77 Mon Sep 17 00:00:00 2001 From: Michael Langmayr Date: Mon, 12 Aug 2024 15:42:41 -0700 Subject: [PATCH 014/124] prototyping in progress --- camerad/archon.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/camerad/archon.cpp b/camerad/archon.cpp index de7dadaa..5c7d1f04 100644 --- a/camerad/archon.cpp +++ b/camerad/archon.cpp @@ -900,7 +900,7 @@ namespace Archon { } else if (reply.compare(0, 3, check)!=0) { // First 3 bytes of reply must equal checksum else reply doesn't belong to command if (this->is_autofetch) { logwrite( function, "auto fetch mode"); - error = NO_ERROR; + // error = NO_ERROR; } else { error = ERROR; // std::string hdr = reply; From c1104fe1f92759354b2882611c09f3162a51bfdc Mon Sep 17 00:00:00 2001 From: Michael Langmayr Date: Mon, 12 Aug 2024 15:55:29 -0700 Subject: [PATCH 015/124] prototyping in progress --- camerad/archon.cpp | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/camerad/archon.cpp b/camerad/archon.cpp index 5c7d1f04..842862cf 100644 --- a/camerad/archon.cpp +++ b/camerad/archon.cpp @@ -898,10 +898,6 @@ namespace Archon { this->camera.log_error( function, message.str() ); } else if (reply.compare(0, 3, check)!=0) { // First 3 bytes of reply must equal checksum else reply doesn't belong to command - if (this->is_autofetch) { - logwrite( function, "auto fetch mode"); - // error = NO_ERROR; - } else { error = ERROR; // std::string hdr = reply; try { @@ -909,8 +905,6 @@ namespace Archon { } catch(...) { } message.str(""); message << "command-reply mismatch for command: " + scmd + ": expected " + check + " but received " + reply ; this->camera.log_error( function, message.str() ); - } - } else { // command and reply are a matched pair error = NO_ERROR; @@ -5079,12 +5073,10 @@ namespace Archon { // The last frame was recorded before the readout was triggered in get_frame(). // while (!done && !this->abort) { - if (this->is_longexposure) usleep( 10000 ); // reduces polling frequency int retval; char buffer[20]; - // char header[25]; if (!this->is_autofetch) { error = this->get_frame_status(); @@ -5098,11 +5090,15 @@ namespace Archon { const int frame_index = std::stoi(buffer_str.substr(13, 1)); logwrite( function, message.str() ); - logwrite( function, "SET FRAME INDEX TO: " + std::to_string(frame_index) ); - this->frame.index = frame_index; + if (this->frame.index != frame_index) { + logwrite( function, "SET FRAME INDEX TO: " + std::to_string(frame_index) ); + this->frame.index = frame_index; + } } else { - logwrite( function, "NO AUTOFETCH HEADER FOUND! IDLING FOR 3 SECONDS..." ); - std::this_thread::sleep_for(std::chrono::seconds(3)); + logwrite( function, "NO AUTOFETCH HEADER FOUND!" ); + // std::this_thread::sleep_for(std::chrono::seconds(3)); + + error = this->get_frame_status(); } } From 2398b3f56a1873edbf84182e8cf22750925e28ac Mon Sep 17 00:00:00 2001 From: Michael Langmayr Date: Mon, 12 Aug 2024 16:02:53 -0700 Subject: [PATCH 016/124] prototyping in progress --- camerad/archon.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/camerad/archon.cpp b/camerad/archon.cpp index 842862cf..e5386c7d 100644 --- a/camerad/archon.cpp +++ b/camerad/archon.cpp @@ -2135,9 +2135,12 @@ namespace Archon { // send FRAME command to get frame buffer status // - if ( (error = this->archon_cmd(FRAME, reply)) ) { - if ( error == ERROR ) logwrite( function, "ERROR: sending FRAME command" ); // don't log here if BUSY - return error; + + if (!this->is_autofetch) { + if ( (error = this->archon_cmd(FRAME, reply)) ) { + if ( error == ERROR ) logwrite( function, "ERROR: sending FRAME command" ); // don't log here if BUSY + return error; + } } // First Tokenize breaks the single, continuous reply string into vector of individual strings, From be4f3253b4ba5aafdf73d288b90531450ba1864c Mon Sep 17 00:00:00 2001 From: Michael Langmayr Date: Mon, 12 Aug 2024 16:11:29 -0700 Subject: [PATCH 017/124] prototyping in progress --- camerad/archon.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/camerad/archon.cpp b/camerad/archon.cpp index e5386c7d..e58767fb 100644 --- a/camerad/archon.cpp +++ b/camerad/archon.cpp @@ -2141,6 +2141,8 @@ namespace Archon { if ( error == ERROR ) logwrite( function, "ERROR: sending FRAME command" ); // don't log here if BUSY return error; } + } else { + logwrite( function, "get_frame_status: AUTOFETCH ON, not sending FRAME command"); } // First Tokenize breaks the single, continuous reply string into vector of individual strings, From cdcf6558fa458e8089ea0fd77761eb71a47092a6 Mon Sep 17 00:00:00 2001 From: Michael Langmayr Date: Mon, 12 Aug 2024 16:46:57 -0700 Subject: [PATCH 018/124] prototyping in progress --- camerad/archon.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/camerad/archon.cpp b/camerad/archon.cpp index e58767fb..be21349d 100644 --- a/camerad/archon.cpp +++ b/camerad/archon.cpp @@ -2814,6 +2814,9 @@ namespace Archon { long Interface::read_frame(Camera::frame_type_t frame_type) { std::string function = "Archon::Interface::read_frame"; std::stringstream message; + + logwrite( function, "READ FRAME" ); + int retval; int bufready; char check[5], header[5]; @@ -5100,8 +5103,8 @@ namespace Archon { this->frame.index = frame_index; } } else { - logwrite( function, "NO AUTOFETCH HEADER FOUND!" ); - // std::this_thread::sleep_for(std::chrono::seconds(3)); + logwrite( function, "NO AUTOFETCH HEADER FOUND! SLEEP 3 seconds..." ); + std::this_thread::sleep_for(std::chrono::seconds(3)); error = this->get_frame_status(); } From a1550393808bf7b9e896c4735edb13b7902e032f Mon Sep 17 00:00:00 2001 From: Michael Langmayr Date: Mon, 12 Aug 2024 16:52:23 -0700 Subject: [PATCH 019/124] prototyping in progress --- camerad/archon.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/camerad/archon.cpp b/camerad/archon.cpp index be21349d..b9afc78e 100644 --- a/camerad/archon.cpp +++ b/camerad/archon.cpp @@ -2537,6 +2537,8 @@ namespace Archon { std::stringstream message; long error = NO_ERROR; + logwrite( function, "READ FRAME" ); + if ( ! this->modeselected ) { this->camera.log_error( function, "no mode selected" ); return ERROR; @@ -2815,7 +2817,7 @@ namespace Archon { std::string function = "Archon::Interface::read_frame"; std::stringstream message; - logwrite( function, "READ FRAME" ); + logwrite( function, "READ FRAME WITH FRAME TYPE" ); int retval; int bufready; From 94cf692e00b28041504e7331bff8772887546691 Mon Sep 17 00:00:00 2001 From: Michael Langmayr Date: Tue, 13 Aug 2024 08:45:39 -0700 Subject: [PATCH 020/124] prototyping in progress --- camerad/archon.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/camerad/archon.cpp b/camerad/archon.cpp index b9afc78e..5607bc95 100644 --- a/camerad/archon.cpp +++ b/camerad/archon.cpp @@ -3569,6 +3569,8 @@ namespace Archon { std::string mode = this->camera_info.current_observing_mode; // local copy for convenience + logwrite( function, "RUN EXPOSE: " + nseq_in ); + if ( ! this->modeselected ) { this->camera.log_error( function, "no mode selected" ); return ERROR; From 520e5ecc05588b8ac174e855d0b0f6f892f582b5 Mon Sep 17 00:00:00 2001 From: Michael Langmayr Date: Tue, 13 Aug 2024 08:51:23 -0700 Subject: [PATCH 021/124] prototyping in progress --- camerad/archon.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/camerad/archon.cpp b/camerad/archon.cpp index 5607bc95..e208da78 100644 --- a/camerad/archon.cpp +++ b/camerad/archon.cpp @@ -2474,6 +2474,8 @@ namespace Archon { uint64_t maxoffset = this->frame.bufbase[this->frame.index]; uint64_t maxaddr = maxoffset + maxblocks; + logwrite( function, "FETCH"); + if ( bufaddr > maxaddr ) { message.str(""); message << "fetch Archon buffer requested address 0x" << std::hex << bufaddr << " exceeds 0x" << maxaddr; this->camera.log_error( function, message.str() ); @@ -2638,6 +2640,8 @@ namespace Archon { long error = ERROR; int num_detect = this->modemap[this->camera_info.current_observing_mode].geometry.num_detect; + logwrite( function, "H READ FRAME"); + // Archon buffer number of the last frame read into memory // Archon frame index is 1 biased so add 1 here bufready = this->frame.index + 1; @@ -5088,13 +5092,13 @@ namespace Archon { if (this->is_longexposure) usleep( 10000 ); // reduces polling frequency int retval; - char buffer[20]; + char buffer[1024]; if (!this->is_autofetch) { error = this->get_frame_status(); } else { logwrite( function, " READ IN AUTOFETCH MODE" ); - retval = this->archon.Read(buffer, 20); + retval = this->archon.Read(buffer, 1024); std::string buffer_str(buffer); if (strncmp(buffer, " Date: Tue, 13 Aug 2024 08:56:20 -0700 Subject: [PATCH 022/124] prototyping in progress --- camerad/archon.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/camerad/archon.cpp b/camerad/archon.cpp index e208da78..1b3ee909 100644 --- a/camerad/archon.cpp +++ b/camerad/archon.cpp @@ -5111,10 +5111,11 @@ namespace Archon { this->frame.index = frame_index; } } else { - logwrite( function, "NO AUTOFETCH HEADER FOUND! SLEEP 3 seconds..." ); + logwrite( function, "NO AUTOFETCH HEADER FOUND! SLEEP 3 seconds..."); + logwrite( function, "BUFFER: " + buffer_str ); std::this_thread::sleep_for(std::chrono::seconds(3)); - error = this->get_frame_status(); + //error = this->get_frame_status(); } } From c79e2ec780ae314dda0323c0d36b15e292d9f634 Mon Sep 17 00:00:00 2001 From: Michael Langmayr Date: Tue, 13 Aug 2024 13:04:09 -0700 Subject: [PATCH 023/124] prototyping in progress --- camerad/archon.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/camerad/archon.cpp b/camerad/archon.cpp index 1b3ee909..a504e511 100644 --- a/camerad/archon.cpp +++ b/camerad/archon.cpp @@ -5112,7 +5112,7 @@ namespace Archon { } } else { logwrite( function, "NO AUTOFETCH HEADER FOUND! SLEEP 3 seconds..."); - logwrite( function, "BUFFER: " + buffer_str ); + logwrite( function, "BUFFER: " + buffer_str.substr(0, 100) ); std::this_thread::sleep_for(std::chrono::seconds(3)); //error = this->get_frame_status(); From 613c4504a9928127ab96942212e28955ed3ec276 Mon Sep 17 00:00:00 2001 From: Michael Langmayr Date: Tue, 13 Aug 2024 13:10:36 -0700 Subject: [PATCH 024/124] prototyping in progress --- camerad/archon.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/camerad/archon.cpp b/camerad/archon.cpp index a504e511..ddb3f6c8 100644 --- a/camerad/archon.cpp +++ b/camerad/archon.cpp @@ -5177,6 +5177,8 @@ namespace Archon { // After exiting while loop, one update to ensure accurate ASYNC message // reporting of LINECOUNT. // + logwrite( function, "EXITED WHILE LOOP" ); + if ( error == NO_ERROR ) { error = this->get_frame_status(); if ( error != NO_ERROR ) { From 248bb3dddeb53509d7888b6d10a26a4a6ff5e6c9 Mon Sep 17 00:00:00 2001 From: Michael Langmayr Date: Tue, 13 Aug 2024 13:18:56 -0700 Subject: [PATCH 025/124] prototyping in progress --- camerad/archon.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/camerad/archon.cpp b/camerad/archon.cpp index ddb3f6c8..f3a8464f 100644 --- a/camerad/archon.cpp +++ b/camerad/archon.cpp @@ -5101,8 +5101,11 @@ namespace Archon { retval = this->archon.Read(buffer, 1024); std::string buffer_str(buffer); + size_t autofetchEnd = buffer_str.find('>'); + if (strncmp(buffer, "get_frame_status(); From f1e0becbfb066c45b22ba0b6f251ddec24511cda Mon Sep 17 00:00:00 2001 From: Michael Langmayr Date: Tue, 13 Aug 2024 13:22:51 -0700 Subject: [PATCH 026/124] prototyping in progress --- camerad/archon.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/camerad/archon.cpp b/camerad/archon.cpp index f3a8464f..87d9edc8 100644 --- a/camerad/archon.cpp +++ b/camerad/archon.cpp @@ -5092,13 +5092,13 @@ namespace Archon { if (this->is_longexposure) usleep( 10000 ); // reduces polling frequency int retval; - char buffer[1024]; + char buffer[2048]; if (!this->is_autofetch) { error = this->get_frame_status(); } else { logwrite( function, " READ IN AUTOFETCH MODE" ); - retval = this->archon.Read(buffer, 1024); + retval = this->archon.Read(buffer, 2048); std::string buffer_str(buffer); size_t autofetchEnd = buffer_str.find('>'); From cf960ad09e51ce5379628572768080bd34e9081e Mon Sep 17 00:00:00 2001 From: Michael Langmayr Date: Tue, 13 Aug 2024 13:25:53 -0700 Subject: [PATCH 027/124] prototyping in progress --- camerad/archon.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/camerad/archon.cpp b/camerad/archon.cpp index 87d9edc8..90ac2ff5 100644 --- a/camerad/archon.cpp +++ b/camerad/archon.cpp @@ -5101,7 +5101,7 @@ namespace Archon { retval = this->archon.Read(buffer, 2048); std::string buffer_str(buffer); - size_t autofetchEnd = buffer_str.find('>'); + size_t autofetchEnd = buffer_str.find(" Date: Tue, 13 Aug 2024 13:34:11 -0700 Subject: [PATCH 028/124] prototyping in progress --- camerad/archon.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/camerad/archon.cpp b/camerad/archon.cpp index 90ac2ff5..b87c2d35 100644 --- a/camerad/archon.cpp +++ b/camerad/archon.cpp @@ -5092,13 +5092,13 @@ namespace Archon { if (this->is_longexposure) usleep( 10000 ); // reduces polling frequency int retval; - char buffer[2048]; + char buffer[1266]; if (!this->is_autofetch) { error = this->get_frame_status(); } else { logwrite( function, " READ IN AUTOFETCH MODE" ); - retval = this->archon.Read(buffer, 2048); + retval = this->archon.Read(buffer, 1266); std::string buffer_str(buffer); size_t autofetchEnd = buffer_str.find("frame.index != frame_index) { @@ -5115,7 +5115,7 @@ namespace Archon { } } else { logwrite( function, "NO AUTOFETCH HEADER FOUND! SLEEP 3 seconds..."); - logwrite( function, "BUFFER: " + buffer_str.substr(0, autofetchEnd) ); + logwrite( function, "BUFFER: " + buffer_str.substr(0, 100) ); std::this_thread::sleep_for(std::chrono::seconds(3)); //error = this->get_frame_status(); From f918bf86d4f69f24a2d6a7696f993b60e645b209 Mon Sep 17 00:00:00 2001 From: Michael Langmayr Date: Tue, 13 Aug 2024 13:39:43 -0700 Subject: [PATCH 029/124] prototyping in progress --- camerad/archon.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/camerad/archon.cpp b/camerad/archon.cpp index b87c2d35..f74c50b3 100644 --- a/camerad/archon.cpp +++ b/camerad/archon.cpp @@ -5098,7 +5098,7 @@ namespace Archon { error = this->get_frame_status(); } else { logwrite( function, " READ IN AUTOFETCH MODE" ); - retval = this->archon.Read(buffer, 1266); + retval = this->archon.Read(buffer, 1264); std::string buffer_str(buffer); size_t autofetchEnd = buffer_str.find("frame.index != frame_index) { logwrite( function, "SET FRAME INDEX TO: " + std::to_string(frame_index) ); this->frame.index = frame_index; } + } else if(strncmp(buffer, "get_frame_status(); From eff0a25534745944a2e049744a8f403582c49090 Mon Sep 17 00:00:00 2001 From: Michael Langmayr Date: Tue, 13 Aug 2024 13:47:58 -0700 Subject: [PATCH 030/124] prototyping in progress --- camerad/archon.cpp | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/camerad/archon.cpp b/camerad/archon.cpp index f74c50b3..dffeae80 100644 --- a/camerad/archon.cpp +++ b/camerad/archon.cpp @@ -5097,17 +5097,16 @@ namespace Archon { if (!this->is_autofetch) { error = this->get_frame_status(); } else { - logwrite( function, " READ IN AUTOFETCH MODE" ); - retval = this->archon.Read(buffer, 1264); + logwrite( function, "READ IN AUTOFETCH MODE" ); + retval = this->archon.Read(buffer, 20); std::string buffer_str(buffer); - size_t autofetchEnd = buffer_str.find("archon.Read(buffer, 1244); if (this->frame.index != frame_index) { logwrite( function, "SET FRAME INDEX TO: " + std::to_string(frame_index) ); @@ -5115,12 +5114,12 @@ namespace Archon { } } else if(strncmp(buffer, "get_frame_status(); + // read rest of buffer frame + retval = this->archon.Read(buffer, 1004); + } else { + logwrite( function, "NO AUTOFETCH OR XF HEADER FOUND!"); + logwrite( function, "BUFFER CONTENT: " + buffer_str ); } } From 2d107fb226213aba88c3d088684ff0b06d00793b Mon Sep 17 00:00:00 2001 From: Michael Langmayr Date: Tue, 13 Aug 2024 13:52:04 -0700 Subject: [PATCH 031/124] prototyping in progress --- camerad/archon.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/camerad/archon.cpp b/camerad/archon.cpp index dffeae80..f97f0a76 100644 --- a/camerad/archon.cpp +++ b/camerad/archon.cpp @@ -5106,7 +5106,7 @@ namespace Archon { const int frame_index = std::stoi(buffer_str.substr(13, 1)); // read rest of buffer frame - retval = this->archon.Read(buffer, 1244); + retval = this->archon.Read(buffer, 1246); if (this->frame.index != frame_index) { logwrite( function, "SET FRAME INDEX TO: " + std::to_string(frame_index) ); @@ -5119,7 +5119,7 @@ namespace Archon { retval = this->archon.Read(buffer, 1004); } else { logwrite( function, "NO AUTOFETCH OR XF HEADER FOUND!"); - logwrite( function, "BUFFER CONTENT: " + buffer_str ); + logwrite( function, "BUFFER CONTENT: " + buffer_str.substr(0, 100) + "..." ); } } From 7d31568c0d45a459c02c2fab0262cc8ba7ffdc51 Mon Sep 17 00:00:00 2001 From: Michael Langmayr Date: Tue, 13 Aug 2024 13:56:40 -0700 Subject: [PATCH 032/124] prototyping in progress --- camerad/archon.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/camerad/archon.cpp b/camerad/archon.cpp index f97f0a76..40843357 100644 --- a/camerad/archon.cpp +++ b/camerad/archon.cpp @@ -5092,16 +5092,17 @@ namespace Archon { if (this->is_longexposure) usleep( 10000 ); // reduces polling frequency int retval; + char header[20]; char buffer[1266]; if (!this->is_autofetch) { error = this->get_frame_status(); } else { logwrite( function, "READ IN AUTOFETCH MODE" ); - retval = this->archon.Read(buffer, 20); - std::string buffer_str(buffer); + retval = this->archon.Read(header, 20); + std::string buffer_str(header); - if (strncmp(buffer, "archon.Read(buffer, 1004); } else { logwrite( function, "NO AUTOFETCH OR XF HEADER FOUND!"); - logwrite( function, "BUFFER CONTENT: " + buffer_str.substr(0, 100) + "..." ); + // logwrite( function, "BUFFER CONTENT: " + buffer_str.substr(0, 100) + "..." ); } } From 781a8bf63380828526eb051c4703bdd4f6b1c6d2 Mon Sep 17 00:00:00 2001 From: Michael Langmayr Date: Tue, 13 Aug 2024 15:10:53 -0700 Subject: [PATCH 033/124] prototyping in progress --- camerad/archon.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/camerad/archon.cpp b/camerad/archon.cpp index 40843357..8169b03b 100644 --- a/camerad/archon.cpp +++ b/camerad/archon.cpp @@ -5119,7 +5119,9 @@ namespace Archon { // read rest of buffer frame retval = this->archon.Read(buffer, 1004); } else { - logwrite( function, "NO AUTOFETCH OR XF HEADER FOUND!"); + logwrite( function, "NO AUTOFETCH OR XF HEADER FOUND! SLEEP 3 SECONDS..."); + std::this_thread::sleep_for(std::chrono::seconds(3)); + // logwrite( function, "BUFFER CONTENT: " + buffer_str.substr(0, 100) + "..." ); } } From 7b041c1610373264e9424a09f0d92d84e195a295 Mon Sep 17 00:00:00 2001 From: Michael Langmayr Date: Tue, 13 Aug 2024 15:34:09 -0700 Subject: [PATCH 034/124] prototyping in progress --- camerad/archon.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/camerad/archon.cpp b/camerad/archon.cpp index 8169b03b..35bba2f5 100644 --- a/camerad/archon.cpp +++ b/camerad/archon.cpp @@ -5100,24 +5100,26 @@ namespace Archon { } else { logwrite( function, "READ IN AUTOFETCH MODE" ); retval = this->archon.Read(header, 20); - std::string buffer_str(header); + std::string header_str(header); if (strncmp(header, "archon.Read(buffer, 1246); + std::string buffer_str(buffer); if (this->frame.index != frame_index) { logwrite( function, "SET FRAME INDEX TO: " + std::to_string(frame_index) ); this->frame.index = frame_index; } - } else if(strncmp(buffer, "archon.Read(buffer, 1004); + std::string buffer_str(buffer); } else { logwrite( function, "NO AUTOFETCH OR XF HEADER FOUND! SLEEP 3 SECONDS..."); std::this_thread::sleep_for(std::chrono::seconds(3)); From 6770e6efcf77734b0eac89a151552e41258b5b26 Mon Sep 17 00:00:00 2001 From: Michael Langmayr Date: Tue, 13 Aug 2024 15:44:17 -0700 Subject: [PATCH 035/124] prototyping in progress --- camerad/archon.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/camerad/archon.cpp b/camerad/archon.cpp index 35bba2f5..3c83abc6 100644 --- a/camerad/archon.cpp +++ b/camerad/archon.cpp @@ -5093,7 +5093,7 @@ namespace Archon { int retval; char header[20]; - char buffer[1266]; + char buffer[1264]; if (!this->is_autofetch) { error = this->get_frame_status(); @@ -5107,7 +5107,7 @@ namespace Archon { const int frame_index = std::stoi(header_str.substr(13, 1)); // read rest of buffer frame - retval = this->archon.Read(buffer, 1246); + retval = this->archon.Read(buffer, 1244); std::string buffer_str(buffer); if (this->frame.index != frame_index) { @@ -5124,7 +5124,7 @@ namespace Archon { logwrite( function, "NO AUTOFETCH OR XF HEADER FOUND! SLEEP 3 SECONDS..."); std::this_thread::sleep_for(std::chrono::seconds(3)); - // logwrite( function, "BUFFER CONTENT: " + buffer_str.substr(0, 100) + "..." ); + logwrite( function, "BUFFER CONTENT: " + header_str + "..." ); } } From 94274a2c2c7fcf35299015d466b43c7ff1456897 Mon Sep 17 00:00:00 2001 From: Michael Langmayr Date: Tue, 13 Aug 2024 15:48:52 -0700 Subject: [PATCH 036/124] prototyping in progress --- camerad/archon.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/camerad/archon.cpp b/camerad/archon.cpp index 3c83abc6..17bfe480 100644 --- a/camerad/archon.cpp +++ b/camerad/archon.cpp @@ -5118,7 +5118,7 @@ namespace Archon { logwrite( function, "FOUND XF HEADER"); // read rest of buffer frame - retval = this->archon.Read(buffer, 1004); + retval = this->archon.Read(buffer, 1244); std::string buffer_str(buffer); } else { logwrite( function, "NO AUTOFETCH OR XF HEADER FOUND! SLEEP 3 SECONDS..."); From 697ac3904ea63789d7d974862f1a572be74c9f2b Mon Sep 17 00:00:00 2001 From: Michael Langmayr Date: Tue, 13 Aug 2024 16:00:35 -0700 Subject: [PATCH 037/124] prototyping in progress --- camerad/archon.cpp | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/camerad/archon.cpp b/camerad/archon.cpp index 17bfe480..b10ab1a1 100644 --- a/camerad/archon.cpp +++ b/camerad/archon.cpp @@ -5114,17 +5114,33 @@ namespace Archon { logwrite( function, "SET FRAME INDEX TO: " + std::to_string(frame_index) ); this->frame.index = frame_index; } + + if (int x = buffer_str.find("archon.Read(buffer, 1244); + retval = this->archon.Read(buffer, 1024); std::string buffer_str(buffer); + + if (int x = buffer_str.find("archon.Read(buffer, 1024); + std::string buffer_str(buffer); + + if (int x = buffer_str.find(" Date: Tue, 13 Aug 2024 16:08:59 -0700 Subject: [PATCH 038/124] prototyping in progress --- camerad/archon.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/camerad/archon.cpp b/camerad/archon.cpp index b10ab1a1..78a352e6 100644 --- a/camerad/archon.cpp +++ b/camerad/archon.cpp @@ -5115,7 +5115,8 @@ namespace Archon { this->frame.index = frame_index; } - if (int x = buffer_str.find("archon.Read(buffer, 1024); std::string buffer_str(buffer); - if (int x = buffer_str.find("archon.Read(buffer, 1024); std::string buffer_str(buffer); - if (int x = buffer_str.find(" Date: Tue, 13 Aug 2024 16:14:33 -0700 Subject: [PATCH 039/124] prototyping in progress --- camerad/archon.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/camerad/archon.cpp b/camerad/archon.cpp index 78a352e6..6edfc180 100644 --- a/camerad/archon.cpp +++ b/camerad/archon.cpp @@ -5123,7 +5123,7 @@ namespace Archon { logwrite( function, "FOUND XF HEADER"); // read rest of buffer frame - retval = this->archon.Read(buffer, 1024); + retval = this->archon.Read(buffer, 1008); std::string buffer_str(buffer); int x = buffer_str.find("archon.Read(buffer, 1024); + retval = this->archon.Read(buffer, 1008); std::string buffer_str(buffer); int x = buffer_str.find(" Date: Wed, 14 Aug 2024 11:27:57 -0700 Subject: [PATCH 040/124] prototyping in progress --- camerad/archon.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/camerad/archon.cpp b/camerad/archon.cpp index 6edfc180..6661df49 100644 --- a/camerad/archon.cpp +++ b/camerad/archon.cpp @@ -5130,6 +5130,8 @@ namespace Archon { if (x != std::string::npos) { logwrite( function, "FOUND Date: Wed, 14 Aug 2024 13:38:05 -0700 Subject: [PATCH 041/124] prototyping in progress --- camerad/archon.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/camerad/archon.cpp b/camerad/archon.cpp index 3d30b552..bf640d2d 100644 --- a/camerad/archon.cpp +++ b/camerad/archon.cpp @@ -1128,6 +1128,8 @@ namespace Archon { std::stringstream scmd; long error = NO_ERROR; + logwrite( function, "PREP PARAMETER: " + paramname ); + // Prepare to apply it to the system -- will be loaded on next EXTLOAD signal // scmd << "FASTPREPPARAM " << paramname << " " << value; From 395120442f085114a8b7ae3273d72e9df66d3734 Mon Sep 17 00:00:00 2001 From: Michael Langmayr Date: Wed, 14 Aug 2024 13:46:20 -0700 Subject: [PATCH 042/124] prototyping in progress --- camerad/archon.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/camerad/archon.cpp b/camerad/archon.cpp index bf640d2d..f85ec724 100644 --- a/camerad/archon.cpp +++ b/camerad/archon.cpp @@ -5322,7 +5322,10 @@ namespace Archon { // If the frame isn't done by the predicted time then // enough time has passed to trigger a timeout error. // + + logwrite( function, "CHECKING FROM TIMEOUT"); if (clock_now > clock_timeout) { + logwrite( function, "TIMED OUT"); done = true; error = ERROR; message.str(""); message << "timeout waiting for new frame exceeded " << waittime << ". lastframe = " << this->lastframe; From 4577ec3829f69e4c6db471ce3e0e715aa376e517 Mon Sep 17 00:00:00 2001 From: Michael Langmayr Date: Wed, 14 Aug 2024 13:52:29 -0700 Subject: [PATCH 043/124] prototyping in progress --- camerad/archon.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/camerad/archon.cpp b/camerad/archon.cpp index f85ec724..fac25159 100644 --- a/camerad/archon.cpp +++ b/camerad/archon.cpp @@ -5241,10 +5241,14 @@ namespace Archon { logwrite( function, "READ IN AUTOFETCH MODE" ); retval = this->archon.Read(header, 20); std::string header_str(header); + if (retval <= 0) { + this->camera.log_error( function, "reading Archon" ); + break; + } if (strncmp(header, "archon.Read(buffer, 1244); @@ -5323,7 +5327,7 @@ namespace Archon { // enough time has passed to trigger a timeout error. // - logwrite( function, "CHECKING FROM TIMEOUT"); + logwrite( function, "CHECKING FOR TIMEOUT"); if (clock_now > clock_timeout) { logwrite( function, "TIMED OUT"); done = true; From cbb0bc48086052b59594e4e57185b17d59ee8465 Mon Sep 17 00:00:00 2001 From: Michael Langmayr Date: Wed, 14 Aug 2024 14:07:21 -0700 Subject: [PATCH 044/124] prototyping in progress --- camerad/archon.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/camerad/archon.cpp b/camerad/archon.cpp index fac25159..5ffb5568 100644 --- a/camerad/archon.cpp +++ b/camerad/archon.cpp @@ -5248,7 +5248,7 @@ namespace Archon { if (strncmp(header, "archon.Read(buffer, 1244); @@ -5259,7 +5259,7 @@ namespace Archon { this->frame.index = frame_index; } - int x = buffer_str.find("archon.Read(buffer, 1008); std::string buffer_str(buffer); - int x = buffer_str.find("archon.Read(buffer, 1008); std::string buffer_str(buffer); - int x = buffer_str.find("frame.bufframen[this->frame.index]; - if ( (currentframe != this->lastframe) && (this->frame.bufcomplete[this->frame.index]==1) ) { - done = true; - error = NO_ERROR; - break; + if (!this->is_autofetch) { + // get current frame number and check the status of its buffer + currentframe = this->frame.bufframen[this->frame.index]; + if ( (currentframe != this->lastframe) && (this->frame.bufcomplete[this->frame.index]==1) ) { + done = true; + error = NO_ERROR; + break; + } } // If the frame isn't done by the predicted time then // enough time has passed to trigger a timeout error. // - logwrite( function, "CHECKING FOR TIMEOUT"); if (clock_now > clock_timeout) { - logwrite( function, "TIMED OUT"); done = true; error = ERROR; message.str(""); message << "timeout waiting for new frame exceeded " << waittime << ". lastframe = " << this->lastframe; From 24d5e14fba3a64836de478a93a91dddb853cbd5e Mon Sep 17 00:00:00 2001 From: Michael Langmayr Date: Wed, 14 Aug 2024 14:13:27 -0700 Subject: [PATCH 045/124] prototyping in progress --- camerad/archon.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/camerad/archon.cpp b/camerad/archon.cpp index 5ffb5568..8f5556a5 100644 --- a/camerad/archon.cpp +++ b/camerad/archon.cpp @@ -5274,8 +5274,6 @@ namespace Archon { if (x != std::string::npos) { logwrite( function, "FOUND Date: Wed, 14 Aug 2024 14:29:09 -0700 Subject: [PATCH 046/124] prototyping in progress --- camerad/archon.cpp | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/camerad/archon.cpp b/camerad/archon.cpp index 8f5556a5..5bee1293 100644 --- a/camerad/archon.cpp +++ b/camerad/archon.cpp @@ -5245,6 +5245,7 @@ namespace Archon { this->camera.log_error( function, "reading Archon" ); break; } + logwrite( function, "READING HEADER DONE" ); if (strncmp(header, "is_autofetch) { - // get current frame number and check the status of its buffer - currentframe = this->frame.bufframen[this->frame.index]; - if ( (currentframe != this->lastframe) && (this->frame.bufcomplete[this->frame.index]==1) ) { - done = true; - error = NO_ERROR; - break; - } + // get current frame number and check the status of its buffer + currentframe = this->frame.bufframen[this->frame.index]; + if ( (currentframe != this->lastframe) && (this->frame.bufcomplete[this->frame.index]==1) ) { + done = true; + error = NO_ERROR; + break; } // If the frame isn't done by the predicted time then // enough time has passed to trigger a timeout error. // - logwrite( function, "CHECKING FOR TIMEOUT"); if (clock_now > clock_timeout) { done = true; error = ERROR; From fc8a80dc1ebe646c1204d37b38190e6543260db6 Mon Sep 17 00:00:00 2001 From: Michael Langmayr Date: Wed, 14 Aug 2024 14:35:39 -0700 Subject: [PATCH 047/124] prototyping in progress --- utils/network.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/utils/network.cpp b/utils/network.cpp index 2b049b84..b91fb1cd 100644 --- a/utils/network.cpp +++ b/utils/network.cpp @@ -884,6 +884,8 @@ namespace Network { char buf[2]; memset(buf,'\0',2); + logwrite( function, "Reading from socket"); + // get the time now for timeout purposes // std::chrono::steady_clock::time_point tstart = std::chrono::steady_clock::now(); @@ -910,6 +912,7 @@ namespace Network { auto elapsed = std::chrono::duration_cast(tnow - tstart).count(); + logwrite( function, "POLLTIMEOUT: " + POLLTIMEOUT); if ( elapsed > POLLTIMEOUT ) { message << "ERROR: timeout waiting for data on fd " << this->fd; logwrite( function, message.str() ); From ddc9f9181f7ad671c0cf65ff375d7bded34f2848 Mon Sep 17 00:00:00 2001 From: Michael Langmayr Date: Wed, 14 Aug 2024 14:43:09 -0700 Subject: [PATCH 048/124] prototyping in progress --- camerad/archon.cpp | 84 ++++++++++++++++++++++++---------------------- 1 file changed, 44 insertions(+), 40 deletions(-) diff --git a/camerad/archon.cpp b/camerad/archon.cpp index 5bee1293..5c3e34c4 100644 --- a/camerad/archon.cpp +++ b/camerad/archon.cpp @@ -5239,56 +5239,60 @@ namespace Archon { error = this->get_frame_status(); } else { logwrite( function, "READ IN AUTOFETCH MODE" ); - retval = this->archon.Read(header, 20); - std::string header_str(header); - if (retval <= 0) { - this->camera.log_error( function, "reading Archon" ); - break; - } - logwrite( function, "READING HEADER DONE" ); + if (this->archon.Bytes_ready() > 0) { + retval = this->archon.Read(header, 20); + std::string header_str(header); + if (retval <= 0) { + this->camera.log_error( function, "reading Archon" ); + break; + } + logwrite( function, "READING HEADER DONE" ); - if (strncmp(header, "archon.Read(buffer, 1244); - std::string buffer_str(buffer); + // read rest of buffer frame + retval = this->archon.Read(buffer, 1244); + std::string buffer_str(buffer); - if (this->frame.index != frame_index) { - logwrite( function, "SET FRAME INDEX TO: " + std::to_string(frame_index) ); - this->frame.index = frame_index; - } + if (this->frame.index != frame_index) { + logwrite( function, "SET FRAME INDEX TO: " + std::to_string(frame_index) ); + this->frame.index = frame_index; + } - long unsigned int x = buffer_str.find("archon.Read(buffer, 1008); - std::string buffer_str(buffer); + // read rest of buffer frame + retval = this->archon.Read(buffer, 1008); + std::string buffer_str(buffer); - long unsigned int x = buffer_str.find("archon.Read(buffer, 1008); - std::string buffer_str(buffer); + // read rest of buffer frame + retval = this->archon.Read(buffer, 1008); + std::string buffer_str(buffer); - long unsigned int x = buffer_str.find(" Date: Wed, 14 Aug 2024 14:44:14 -0700 Subject: [PATCH 049/124] prototyping in progress --- camerad/archon.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/camerad/archon.cpp b/camerad/archon.cpp index 5c3e34c4..d428ae57 100644 --- a/camerad/archon.cpp +++ b/camerad/archon.cpp @@ -5293,7 +5293,7 @@ namespace Archon { logwrite( function, "Nothing to read on socket" ); break; } - + } // If Archon is busy then ignore it, keep trying for up to ~ 3 second // (300 attempts, ~10000us between attempts) From 9a9dacd5e1b29543bf6ce25d63ed7820901c7fe9 Mon Sep 17 00:00:00 2001 From: Michael Langmayr Date: Wed, 14 Aug 2024 14:50:02 -0700 Subject: [PATCH 050/124] prototyping in progress --- camerad/archon.cpp | 1 - utils/network.cpp | 3 --- 2 files changed, 4 deletions(-) diff --git a/camerad/archon.cpp b/camerad/archon.cpp index d428ae57..686a00f8 100644 --- a/camerad/archon.cpp +++ b/camerad/archon.cpp @@ -5291,7 +5291,6 @@ namespace Archon { } } else { logwrite( function, "Nothing to read on socket" ); - break; } } diff --git a/utils/network.cpp b/utils/network.cpp index b91fb1cd..2b049b84 100644 --- a/utils/network.cpp +++ b/utils/network.cpp @@ -884,8 +884,6 @@ namespace Network { char buf[2]; memset(buf,'\0',2); - logwrite( function, "Reading from socket"); - // get the time now for timeout purposes // std::chrono::steady_clock::time_point tstart = std::chrono::steady_clock::now(); @@ -912,7 +910,6 @@ namespace Network { auto elapsed = std::chrono::duration_cast(tnow - tstart).count(); - logwrite( function, "POLLTIMEOUT: " + POLLTIMEOUT); if ( elapsed > POLLTIMEOUT ) { message << "ERROR: timeout waiting for data on fd " << this->fd; logwrite( function, message.str() ); From e9a938afbdbd59e3139a3c690b20d2a21b8ccf9e Mon Sep 17 00:00:00 2001 From: Michael Langmayr Date: Wed, 14 Aug 2024 14:55:14 -0700 Subject: [PATCH 051/124] prototyping in progress --- camerad/archon.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/camerad/archon.cpp b/camerad/archon.cpp index 686a00f8..bcd3a790 100644 --- a/camerad/archon.cpp +++ b/camerad/archon.cpp @@ -5240,6 +5240,8 @@ namespace Archon { } else { logwrite( function, "READ IN AUTOFETCH MODE" ); if (this->archon.Bytes_ready() > 0) { + std::this_thread::sleep_for(std::chrono::seconds(1)); + retval = this->archon.Read(header, 20); std::string header_str(header); if (retval <= 0) { @@ -5291,6 +5293,7 @@ namespace Archon { } } else { logwrite( function, "Nothing to read on socket" ); + break; } } From 9ec1151f890f24e3f22d77672863b7fad99759ea Mon Sep 17 00:00:00 2001 From: Michael Langmayr Date: Wed, 14 Aug 2024 14:58:02 -0700 Subject: [PATCH 052/124] prototyping in progress --- camerad/archon.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/camerad/archon.cpp b/camerad/archon.cpp index bcd3a790..c37111e1 100644 --- a/camerad/archon.cpp +++ b/camerad/archon.cpp @@ -5239,9 +5239,9 @@ namespace Archon { error = this->get_frame_status(); } else { logwrite( function, "READ IN AUTOFETCH MODE" ); - if (this->archon.Bytes_ready() > 0) { - std::this_thread::sleep_for(std::chrono::seconds(1)); + std::this_thread::sleep_for(std::chrono::seconds(1)); + if (this->archon.Bytes_ready() > 0) { retval = this->archon.Read(header, 20); std::string header_str(header); if (retval <= 0) { From 9118f5a12642f91b85509e8a327b446c40d8fde6 Mon Sep 17 00:00:00 2001 From: Michael Langmayr Date: Wed, 14 Aug 2024 15:02:17 -0700 Subject: [PATCH 053/124] prototyping in progress --- camerad/archon.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/camerad/archon.cpp b/camerad/archon.cpp index c37111e1..867da90a 100644 --- a/camerad/archon.cpp +++ b/camerad/archon.cpp @@ -5239,7 +5239,8 @@ namespace Archon { error = this->get_frame_status(); } else { logwrite( function, "READ IN AUTOFETCH MODE" ); - std::this_thread::sleep_for(std::chrono::seconds(1)); + logwrite( function, "Bytes ready on socket: " + std::to_string(this->archon.Bytes_ready())); + std::this_thread::sleep_for(std::chrono::seconds(3)); if (this->archon.Bytes_ready() > 0) { retval = this->archon.Read(header, 20); From 426bfde4147f9045e2cb700671b5b19a389bccd4 Mon Sep 17 00:00:00 2001 From: Michael Langmayr Date: Wed, 14 Aug 2024 15:08:04 -0700 Subject: [PATCH 054/124] prototyping in progress --- camerad/archon.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/camerad/archon.cpp b/camerad/archon.cpp index 867da90a..b0a0537e 100644 --- a/camerad/archon.cpp +++ b/camerad/archon.cpp @@ -5240,7 +5240,7 @@ namespace Archon { } else { logwrite( function, "READ IN AUTOFETCH MODE" ); logwrite( function, "Bytes ready on socket: " + std::to_string(this->archon.Bytes_ready())); - std::this_thread::sleep_for(std::chrono::seconds(3)); + std::this_thread::sleep_for(std::chrono::seconds(2)); if (this->archon.Bytes_ready() > 0) { retval = this->archon.Read(header, 20); From 343a208f0081942bdb9007c7c42a8c191749998e Mon Sep 17 00:00:00 2001 From: Michael Langmayr Date: Wed, 14 Aug 2024 15:15:49 -0700 Subject: [PATCH 055/124] prototyping in progress --- camerad/archon.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/camerad/archon.cpp b/camerad/archon.cpp index b0a0537e..2e44d945 100644 --- a/camerad/archon.cpp +++ b/camerad/archon.cpp @@ -5240,7 +5240,6 @@ namespace Archon { } else { logwrite( function, "READ IN AUTOFETCH MODE" ); logwrite( function, "Bytes ready on socket: " + std::to_string(this->archon.Bytes_ready())); - std::this_thread::sleep_for(std::chrono::seconds(2)); if (this->archon.Bytes_ready() > 0) { retval = this->archon.Read(header, 20); @@ -5254,11 +5253,14 @@ namespace Archon { if (strncmp(header, "frame.bufframen[this->frame.index]; // read rest of buffer frame retval = this->archon.Read(buffer, 1244); std::string buffer_str(buffer); + logwrite( function, "AUTOFETCH HEADER: " + header_str + buffer_str); + if (this->frame.index != frame_index) { logwrite( function, "SET FRAME INDEX TO: " + std::to_string(frame_index) ); this->frame.index = frame_index; @@ -5294,7 +5296,6 @@ namespace Archon { } } else { logwrite( function, "Nothing to read on socket" ); - break; } } From 5d28209a6738b7c2c3e87239a2a5221417c74ed6 Mon Sep 17 00:00:00 2001 From: Michael Langmayr Date: Wed, 14 Aug 2024 15:24:34 -0700 Subject: [PATCH 056/124] prototyping in progress --- camerad/archon.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/camerad/archon.cpp b/camerad/archon.cpp index 2e44d945..e2407cea 100644 --- a/camerad/archon.cpp +++ b/camerad/archon.cpp @@ -5296,6 +5296,8 @@ namespace Archon { } } else { logwrite( function, "Nothing to read on socket" ); + std::this_thread::sleep_for(std::chrono::milliseconds(500)); + continue; } } From ef84493b00d929e3e7363853d841f9718899942b Mon Sep 17 00:00:00 2001 From: Michael Langmayr Date: Wed, 14 Aug 2024 15:32:15 -0700 Subject: [PATCH 057/124] prototyping in progress --- camerad/archon.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/camerad/archon.cpp b/camerad/archon.cpp index e2407cea..c79a16d6 100644 --- a/camerad/archon.cpp +++ b/camerad/archon.cpp @@ -5261,6 +5261,9 @@ namespace Archon { logwrite( function, "AUTOFETCH HEADER: " + header_str + buffer_str); + // stop after printing the autofetch header + break; + if (this->frame.index != frame_index) { logwrite( function, "SET FRAME INDEX TO: " + std::to_string(frame_index) ); this->frame.index = frame_index; From ab9c55f7f4bf5d6dc88dc8bf8d463bb0f73bb7bb Mon Sep 17 00:00:00 2001 From: Michael Langmayr Date: Wed, 14 Aug 2024 15:37:10 -0700 Subject: [PATCH 058/124] prototyping in progress --- camerad/archon.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/camerad/archon.cpp b/camerad/archon.cpp index c79a16d6..e4ffa61a 100644 --- a/camerad/archon.cpp +++ b/camerad/archon.cpp @@ -5225,6 +5225,8 @@ namespace Archon { double clock_now = get_clock_time(); // get_clock_time returns seconds double clock_timeout = clock_now + waittime/1000.; // must receive frame by this time + unsigned int xf_package_counter = 0; + // Poll frame status until current frame is not the last frame and the buffer is ready to read. // The last frame was recorded before the readout was triggered in get_frame(). // @@ -5262,7 +5264,7 @@ namespace Archon { logwrite( function, "AUTOFETCH HEADER: " + header_str + buffer_str); // stop after printing the autofetch header - break; + //break; if (this->frame.index != frame_index) { logwrite( function, "SET FRAME INDEX TO: " + std::to_string(frame_index) ); @@ -5276,6 +5278,9 @@ namespace Archon { } else if(strncmp(header, "archon.Read(buffer, 1008); std::string buffer_str(buffer); @@ -5298,7 +5303,7 @@ namespace Archon { } } } else { - logwrite( function, "Nothing to read on socket" ); + logwrite( function, "Nothing to read on socket, xf counter: " + std::to_string(xf_package_counter) ); std::this_thread::sleep_for(std::chrono::milliseconds(500)); continue; } From 40cedbe7530f4ef517c5ea175ba70f5921fc6ea8 Mon Sep 17 00:00:00 2001 From: Michael Langmayr Date: Wed, 14 Aug 2024 15:40:57 -0700 Subject: [PATCH 059/124] prototyping in progress --- camerad/archon.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/camerad/archon.cpp b/camerad/archon.cpp index e4ffa61a..8703ce84 100644 --- a/camerad/archon.cpp +++ b/camerad/archon.cpp @@ -5264,7 +5264,7 @@ namespace Archon { logwrite( function, "AUTOFETCH HEADER: " + header_str + buffer_str); // stop after printing the autofetch header - //break; + break; if (this->frame.index != frame_index) { logwrite( function, "SET FRAME INDEX TO: " + std::to_string(frame_index) ); From dad57ecf5e5ddf368073e6209fce439ee0fbdef3 Mon Sep 17 00:00:00 2001 From: Michael Langmayr Date: Wed, 14 Aug 2024 15:46:51 -0700 Subject: [PATCH 060/124] prototyping in progress --- camerad/archon.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/camerad/archon.cpp b/camerad/archon.cpp index 8703ce84..3faa854e 100644 --- a/camerad/archon.cpp +++ b/camerad/archon.cpp @@ -5244,6 +5244,9 @@ namespace Archon { logwrite( function, "Bytes ready on socket: " + std::to_string(this->archon.Bytes_ready())); if (this->archon.Bytes_ready() > 0) { + logwrite( function, "+Bytes ready on socket: " + std::to_string(this->archon.Bytes_ready())); + break; + retval = this->archon.Read(header, 20); std::string header_str(header); if (retval <= 0) { From 29f891b80fade81c35e9b22d8a76e31d5d9ad9c8 Mon Sep 17 00:00:00 2001 From: Michael Langmayr Date: Wed, 14 Aug 2024 15:57:40 -0700 Subject: [PATCH 061/124] prototyping in progress --- camerad/archon.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/camerad/archon.cpp b/camerad/archon.cpp index 3faa854e..e759f782 100644 --- a/camerad/archon.cpp +++ b/camerad/archon.cpp @@ -5226,6 +5226,7 @@ namespace Archon { double clock_timeout = clock_now + waittime/1000.; // must receive frame by this time unsigned int xf_package_counter = 0; + bool found_autofetch_header = false; // Poll frame status until current frame is not the last frame and the buffer is ready to read. // The last frame was recorded before the readout was triggered in get_frame(). @@ -5257,6 +5258,7 @@ namespace Archon { if (strncmp(header, "frame.bufframen[this->frame.index]; @@ -5267,7 +5269,7 @@ namespace Archon { logwrite( function, "AUTOFETCH HEADER: " + header_str + buffer_str); // stop after printing the autofetch header - break; + // break; if (this->frame.index != frame_index) { logwrite( function, "SET FRAME INDEX TO: " + std::to_string(frame_index) ); @@ -5308,6 +5310,9 @@ namespace Archon { } else { logwrite( function, "Nothing to read on socket, xf counter: " + std::to_string(xf_package_counter) ); std::this_thread::sleep_for(std::chrono::milliseconds(500)); + if (found_autofetch_header) { + done = true; + } continue; } } From 460b56a98f9d5f48b4ab0e7801c29d99423d0292 Mon Sep 17 00:00:00 2001 From: Michael Langmayr Date: Wed, 14 Aug 2024 16:00:42 -0700 Subject: [PATCH 062/124] prototyping in progress --- camerad/archon.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/camerad/archon.cpp b/camerad/archon.cpp index e759f782..e6d9249d 100644 --- a/camerad/archon.cpp +++ b/camerad/archon.cpp @@ -5245,9 +5245,6 @@ namespace Archon { logwrite( function, "Bytes ready on socket: " + std::to_string(this->archon.Bytes_ready())); if (this->archon.Bytes_ready() > 0) { - logwrite( function, "+Bytes ready on socket: " + std::to_string(this->archon.Bytes_ready())); - break; - retval = this->archon.Read(header, 20); std::string header_str(header); if (retval <= 0) { From 0dd949f333ac826286a72f5c2387c1a48d90732e Mon Sep 17 00:00:00 2001 From: Michael Langmayr Date: Thu, 15 Aug 2024 13:54:12 -0700 Subject: [PATCH 063/124] prototyping in progress --- camerad/archon.cpp | 186 +++++++++++++++++++++++++-------------------- 1 file changed, 104 insertions(+), 82 deletions(-) diff --git a/camerad/archon.cpp b/camerad/archon.cpp index e6d9249d..28778b13 100644 --- a/camerad/archon.cpp +++ b/camerad/archon.cpp @@ -2820,7 +2820,7 @@ namespace Archon { // Wait for a block+header Bytes to be available // (but don't wait more than 1 second -- this should be tens of microseconds or less) // - auto start = std::chrono::steady_clock::now(); // start a timer now + auto start = std::chrono::steady_clock::now(); // start a timer now while ( this->archon.Bytes_ready() < (BLOCK_LEN+4) ) { auto now = std::chrono::steady_clock::now(); // check the time again @@ -3978,13 +3978,111 @@ namespace Archon { return error; } - error = read_frame(); // then read the frame buffer to host (and write file) when frame ready. - if ( error != NO_ERROR ) { - logwrite( function, "ERROR: reading frame buffer" ); - this->fits_file.close_file(this->camera.writekeys_when == "after", this->camera_info ); - return error; + if (this->is_autofetch) { + int retval; + // int bufready; + // char check[5]; + char header[12]; + char *ptr_image; + int bytesread, totalbytesread, toread; + // uint64_t bufaddr; + // unsigned int block, bufblocks=0; + unsigned int xf_package_counter = 0; + bool found_autofetch_header = false; + + bytesread = 0; + ptr_image = this->image_data; + totalbytesread = 0; + // Read the frame contents + // + if (this->archon.Bytes_ready() > 0) { + char buffer[1264]; + + int retval = this->archon.Read(header, 12); + std::string header_str(header); + if (retval <= 0) { + this->camera.log_error( function, "reading Archon" ); + break; + } + logwrite( function, "READING HEADER DONE" ); + + if (strncmp(header, "archon.Read(buffer, 1252); + std::string buffer_str(buffer); + + logwrite( function, "AUTOFETCH HEADER: " + header_str + buffer_str); + + // stop after printing the autofetch header + break; + + // if (this->frame.index != frame_index) { + // logwrite( function, "SET FRAME INDEX TO: " + std::to_string(frame_index) ); + // this->frame.index = frame_index; + // } + + long unsigned int x = buffer_str.find("archon.Read(buffer, 1016); + std::string buffer_str(buffer); + + long unsigned int x = buffer_str.find("archon.Read(buffer, 1016); + std::string buffer_str(buffer); + + long unsigned int x = buffer_str.find("archon.Read(ptr_image, (size_t)toread)) > 0 ) { + bytesread += retval; // this will get zeroed after each block + totalbytesread += retval; // this won't (used only for info purposes) + std::cerr << std::setw(10) << totalbytesread << "\b\b\b\b\b\b\b\b\b\b"; + ptr_image += retval; // advance pointer + } + } while (bytesread < BLOCK_LEN); + + } else { + error = read_frame(); // then read the frame buffer to host (and write file) when frame ready. + if ( error != NO_ERROR ) { + logwrite( function, "ERROR: reading frame buffer" ); + this->fits_file.close_file(this->camera.writekeys_when == "after", this->camera_info ); + return error; + } + } + + + // For non-sequence multiple exposures, including cubeamps, close the fits file here // if ( !this->camera.datacube() || this->camera.cubeamps() ) { // Error or not, close the file. @@ -5225,93 +5323,17 @@ namespace Archon { double clock_now = get_clock_time(); // get_clock_time returns seconds double clock_timeout = clock_now + waittime/1000.; // must receive frame by this time - unsigned int xf_package_counter = 0; - bool found_autofetch_header = false; - // Poll frame status until current frame is not the last frame and the buffer is ready to read. // The last frame was recorded before the readout was triggered in get_frame(). // while (!done && !this->abort) { if (this->is_longexposure) usleep( 10000 ); // reduces polling frequency - int retval; - char header[20]; - char buffer[1264]; - if (!this->is_autofetch) { error = this->get_frame_status(); } else { logwrite( function, "READ IN AUTOFETCH MODE" ); logwrite( function, "Bytes ready on socket: " + std::to_string(this->archon.Bytes_ready())); - - if (this->archon.Bytes_ready() > 0) { - retval = this->archon.Read(header, 20); - std::string header_str(header); - if (retval <= 0) { - this->camera.log_error( function, "reading Archon" ); - break; - } - logwrite( function, "READING HEADER DONE" ); - - if (strncmp(header, "frame.bufframen[this->frame.index]; - - // read rest of buffer frame - retval = this->archon.Read(buffer, 1244); - std::string buffer_str(buffer); - - logwrite( function, "AUTOFETCH HEADER: " + header_str + buffer_str); - - // stop after printing the autofetch header - // break; - - if (this->frame.index != frame_index) { - logwrite( function, "SET FRAME INDEX TO: " + std::to_string(frame_index) ); - this->frame.index = frame_index; - } - - long unsigned int x = buffer_str.find("archon.Read(buffer, 1008); - std::string buffer_str(buffer); - - long unsigned int x = buffer_str.find("archon.Read(buffer, 1008); - std::string buffer_str(buffer); - - long unsigned int x = buffer_str.find(" Date: Thu, 15 Aug 2024 14:27:51 -0700 Subject: [PATCH 064/124] prototyping in progress --- camerad/archon.cpp | 131 +++++++++++++++++++++++---------------------- 1 file changed, 68 insertions(+), 63 deletions(-) diff --git a/camerad/archon.cpp b/camerad/archon.cpp index 28778b13..936685af 100644 --- a/camerad/archon.cpp +++ b/camerad/archon.cpp @@ -3982,7 +3982,8 @@ namespace Archon { int retval; // int bufready; // char check[5]; - char header[12]; + char autofetch_header[248]; + char header[4]; char *ptr_image; int bytesread, totalbytesread, toread; // uint64_t bufaddr; @@ -3996,81 +3997,87 @@ namespace Archon { // Read the frame contents // if (this->archon.Bytes_ready() > 0) { - char buffer[1264]; + char buffer[1024]; - int retval = this->archon.Read(header, 12); - std::string header_str(header); - if (retval <= 0) { - this->camera.log_error( function, "reading Archon" ); - break; - } - logwrite( function, "READING HEADER DONE" ); + int retval = this->archon.Read(header, 4); + std::string header_str(header); + if (retval <= 0) { + this->camera.log_error( function, "reading Archon" ); + break; + } + logwrite( function, "READING HEADER DONE" ); - if (strncmp(header, "archon.Read(buffer, 1252); - std::string buffer_str(buffer); + // Read rest of autofetch header + retval = this->archon.Read(autofetch_header, 244); + std::string autofetch_header_str(autofetch_header); - logwrite( function, "AUTOFETCH HEADER: " + header_str + buffer_str); + // read rest of buffer frame + retval = this->archon.Read(buffer, 1016); + std::string buffer_str(buffer); - // stop after printing the autofetch header - break; + logwrite( function, "AUTOFETCH HEADER: " + header_str); + logwrite( function, "AUTOFETCH HEADER: " + autofetch_header_str); - // if (this->frame.index != frame_index) { - // logwrite( function, "SET FRAME INDEX TO: " + std::to_string(frame_index) ); - // this->frame.index = frame_index; - // } + // stop after printing the autofetch header + break; - long unsigned int x = buffer_str.find("frame.index != frame_index) { + // logwrite( function, "SET FRAME INDEX TO: " + std::to_string(frame_index) ); + // this->frame.index = frame_index; + // } - // increase xf counter - xf_package_counter++; + unsigned int x; + if (x != std::string::npos) { + x = buffer_str.find("archon.Read(buffer, 1016); - std::string buffer_str(buffer); + // increase xf counter + xf_package_counter++; - long unsigned int x = buffer_str.find("archon.Read(buffer, 1016); + std::string buffer_str(buffer); + + long unsigned int x = buffer_str.find("archon.Read(buffer, 1016); - std::string buffer_str(buffer); + // read rest of buffer frame + retval = this->archon.Read(buffer, 1016); + std::string buffer_str(buffer); - long unsigned int x = buffer_str.find("archon.Read(ptr_image, (size_t)toread)) > 0 ) { - bytesread += retval; // this will get zeroed after each block - totalbytesread += retval; // this won't (used only for info purposes) - std::cerr << std::setw(10) << totalbytesread << "\b\b\b\b\b\b\b\b\b\b"; - ptr_image += retval; // advance pointer - } - } while (bytesread < BLOCK_LEN); + do { + toread = BLOCK_LEN - bytesread; + if ( (retval=this->archon.Read(ptr_image, (size_t)toread)) > 0 ) { + bytesread += retval; // this will get zeroed after each block + totalbytesread += retval; // this won't (used only for info purposes) + std::cerr << std::setw(10) << totalbytesread << "\b\b\b\b\b\b\b\b\b\b"; + ptr_image += retval; // advance pointer + } + } while (bytesread < BLOCK_LEN); } else { error = read_frame(); // then read the frame buffer to host (and write file) when frame ready. @@ -4081,8 +4088,6 @@ namespace Archon { } } - - // For non-sequence multiple exposures, including cubeamps, close the fits file here // if ( !this->camera.datacube() || this->camera.cubeamps() ) { // Error or not, close the file. From e49b1892fbb611345c38c72e4061022754b89d0b Mon Sep 17 00:00:00 2001 From: Michael Langmayr Date: Thu, 15 Aug 2024 14:32:15 -0700 Subject: [PATCH 065/124] prototyping in progress --- camerad/archon.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/camerad/archon.cpp b/camerad/archon.cpp index 936685af..d2607c66 100644 --- a/camerad/archon.cpp +++ b/camerad/archon.cpp @@ -5339,6 +5339,7 @@ namespace Archon { } else { logwrite( function, "READ IN AUTOFETCH MODE" ); logwrite( function, "Bytes ready on socket: " + std::to_string(this->archon.Bytes_ready())); + break; } // If Archon is busy then ignore it, keep trying for up to ~ 3 second @@ -5360,8 +5361,6 @@ namespace Archon { break; } - logwrite( function, "GET CURRENT FRAME" ); - // get current frame number and check the status of its buffer currentframe = this->frame.bufframen[this->frame.index]; if ( (currentframe != this->lastframe) && (this->frame.bufcomplete[this->frame.index]==1) ) { From 6de722c6ca984e28a30bcfdff38821dd87284f10 Mon Sep 17 00:00:00 2001 From: Michael Langmayr Date: Thu, 15 Aug 2024 14:37:11 -0700 Subject: [PATCH 066/124] prototyping in progress --- camerad/archon.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/camerad/archon.cpp b/camerad/archon.cpp index d2607c66..065c2ac9 100644 --- a/camerad/archon.cpp +++ b/camerad/archon.cpp @@ -3979,6 +3979,9 @@ namespace Archon { } if (this->is_autofetch) { + logwrite( function, "AUTOFETCH READ FRAME"); + std::this_thread::sleep_for(std::chrono::seconds(2)); + int retval; // int bufready; // char check[5]; From 7ae324736bd9fb9dacf2e566aebc53cdc6bbbf9d Mon Sep 17 00:00:00 2001 From: Michael Langmayr Date: Thu, 15 Aug 2024 14:42:15 -0700 Subject: [PATCH 067/124] prototyping in progress --- camerad/archon.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/camerad/archon.cpp b/camerad/archon.cpp index 065c2ac9..72fbade2 100644 --- a/camerad/archon.cpp +++ b/camerad/archon.cpp @@ -4027,7 +4027,7 @@ namespace Archon { logwrite( function, "AUTOFETCH HEADER: " + autofetch_header_str); // stop after printing the autofetch header - break; + // break; // if (this->frame.index != frame_index) { // logwrite( function, "SET FRAME INDEX TO: " + std::to_string(frame_index) ); From 54b792ebfa81b403061506a3cf96517844b560a0 Mon Sep 17 00:00:00 2001 From: Michael Langmayr Date: Thu, 15 Aug 2024 14:47:47 -0700 Subject: [PATCH 068/124] prototyping in progress --- camerad/archon.cpp | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/camerad/archon.cpp b/camerad/archon.cpp index 72fbade2..ddb7130b 100644 --- a/camerad/archon.cpp +++ b/camerad/archon.cpp @@ -4016,11 +4016,11 @@ namespace Archon { // const int frame_index = std::stoi(header_str.substr(13, 1)); // Read rest of autofetch header - retval = this->archon.Read(autofetch_header, 244); + retval = this->archon.Read(autofetch_header, 236); std::string autofetch_header_str(autofetch_header); // read rest of buffer frame - retval = this->archon.Read(buffer, 1016); + retval = this->archon.Read(buffer, 1024); std::string buffer_str(buffer); logwrite( function, "AUTOFETCH HEADER: " + header_str); @@ -4046,7 +4046,7 @@ namespace Archon { xf_package_counter++; // read rest of buffer frame - retval = this->archon.Read(buffer, 1016); + retval = this->archon.Read(buffer, 1024); std::string buffer_str(buffer); long unsigned int x = buffer_str.find("archon.Read(buffer, 1016); + retval = this->archon.Read(buffer, 1024); std::string buffer_str(buffer); long unsigned int x = buffer_str.find("archon.Read(ptr_image, (size_t)toread)) > 0 ) { - bytesread += retval; // this will get zeroed after each block - totalbytesread += retval; // this won't (used only for info purposes) - std::cerr << std::setw(10) << totalbytesread << "\b\b\b\b\b\b\b\b\b\b"; - ptr_image += retval; // advance pointer - } - } while (bytesread < BLOCK_LEN); + // do { + // toread = BLOCK_LEN - bytesread; + // if ( (retval=this->archon.Read(ptr_image, (size_t)toread)) > 0 ) { + // bytesread += retval; // this will get zeroed after each block + // totalbytesread += retval; // this won't (used only for info purposes) + // std::cerr << std::setw(10) << totalbytesread << "\b\b\b\b\b\b\b\b\b\b"; + // ptr_image += retval; // advance pointer + // } + // } while (bytesread < BLOCK_LEN); } else { error = read_frame(); // then read the frame buffer to host (and write file) when frame ready. From adc0e67cf6fed58769692e1c2372f8f1381718b8 Mon Sep 17 00:00:00 2001 From: Michael Langmayr Date: Thu, 15 Aug 2024 14:53:21 -0700 Subject: [PATCH 069/124] prototyping in progress --- camerad/archon.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/camerad/archon.cpp b/camerad/archon.cpp index ddb7130b..e12fc5f5 100644 --- a/camerad/archon.cpp +++ b/camerad/archon.cpp @@ -3985,7 +3985,7 @@ namespace Archon { int retval; // int bufready; // char check[5]; - char autofetch_header[248]; + char autofetch_header[300]; char header[4]; char *ptr_image; int bytesread, totalbytesread, toread; @@ -4016,7 +4016,7 @@ namespace Archon { // const int frame_index = std::stoi(header_str.substr(13, 1)); // Read rest of autofetch header - retval = this->archon.Read(autofetch_header, 236); + retval = this->archon.Read(autofetch_header, 300); std::string autofetch_header_str(autofetch_header); // read rest of buffer frame @@ -4034,7 +4034,7 @@ namespace Archon { // this->frame.index = frame_index; // } - unsigned int x; + long unsigned int x; if (x != std::string::npos) { x = buffer_str.find(" Date: Thu, 15 Aug 2024 14:59:03 -0700 Subject: [PATCH 070/124] prototyping in progress --- camerad/archon.cpp | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/camerad/archon.cpp b/camerad/archon.cpp index e12fc5f5..d033dbb1 100644 --- a/camerad/archon.cpp +++ b/camerad/archon.cpp @@ -4016,7 +4016,7 @@ namespace Archon { // const int frame_index = std::stoi(header_str.substr(13, 1)); // Read rest of autofetch header - retval = this->archon.Read(autofetch_header, 300); + retval = this->archon.Read(autofetch_header, 600); std::string autofetch_header_str(autofetch_header); // read rest of buffer frame @@ -4029,11 +4029,6 @@ namespace Archon { // stop after printing the autofetch header // break; - // if (this->frame.index != frame_index) { - // logwrite( function, "SET FRAME INDEX TO: " + std::to_string(frame_index) ); - // this->frame.index = frame_index; - // } - long unsigned int x; if (x != std::string::npos) { x = buffer_str.find(" Date: Thu, 15 Aug 2024 15:02:46 -0700 Subject: [PATCH 071/124] prototyping in progress --- camerad/archon.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/camerad/archon.cpp b/camerad/archon.cpp index d033dbb1..c04d2e68 100644 --- a/camerad/archon.cpp +++ b/camerad/archon.cpp @@ -4016,7 +4016,7 @@ namespace Archon { // const int frame_index = std::stoi(header_str.substr(13, 1)); // Read rest of autofetch header - retval = this->archon.Read(autofetch_header, 600); + retval = this->archon.Read(autofetch_header, 1000); std::string autofetch_header_str(autofetch_header); // read rest of buffer frame From 251d771879e7e1055a39d2e5eeda6617a89fca5c Mon Sep 17 00:00:00 2001 From: Michael Langmayr Date: Thu, 15 Aug 2024 15:10:01 -0700 Subject: [PATCH 072/124] prototyping in progress --- camerad/archon.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/camerad/archon.cpp b/camerad/archon.cpp index c04d2e68..4f534e0d 100644 --- a/camerad/archon.cpp +++ b/camerad/archon.cpp @@ -4016,7 +4016,7 @@ namespace Archon { // const int frame_index = std::stoi(header_str.substr(13, 1)); // Read rest of autofetch header - retval = this->archon.Read(autofetch_header, 1000); + retval = this->archon.Read(autofetch_header, 1260); std::string autofetch_header_str(autofetch_header); // read rest of buffer frame From 8f5558223fc5dbcfe6ad7a60170aa32d5bfd7272 Mon Sep 17 00:00:00 2001 From: Michael Langmayr Date: Thu, 15 Aug 2024 15:17:54 -0700 Subject: [PATCH 073/124] prototyping in progress --- camerad/archon.cpp | 45 +++++++++++++++++++++++++++------------------ 1 file changed, 27 insertions(+), 18 deletions(-) diff --git a/camerad/archon.cpp b/camerad/archon.cpp index 4f534e0d..e4333b72 100644 --- a/camerad/archon.cpp +++ b/camerad/archon.cpp @@ -4019,9 +4019,9 @@ namespace Archon { retval = this->archon.Read(autofetch_header, 1260); std::string autofetch_header_str(autofetch_header); - // read rest of buffer frame - retval = this->archon.Read(buffer, 1024); - std::string buffer_str(buffer); + // // read rest of buffer frame + // retval = this->archon.Read(buffer, 1024); + // std::string buffer_str(buffer); logwrite( function, "AUTOFETCH HEADER: " + header_str); logwrite( function, "AUTOFETCH HEADER: " + autofetch_header_str); @@ -4029,11 +4029,30 @@ namespace Archon { // stop after printing the autofetch header // break; - long unsigned int x; - if (x != std::string::npos) { - x = buffer_str.find("archon.Bytes_ready(); + this->archon.Read(header, 4); + if(strncmp(header, "archon.Read(ptr_image, 1024); + ptr_image += 1; + } + if ( (retval=this->archon.Read(ptr_image, (size_t)toread)) > 0 ) { + bytesread += retval; // this will get zeroed after each block + totalbytesread += retval; // this won't (used only for info purposes) + std::cerr << std::setw(10) << totalbytesread << "\b\b\b\b\b\b\b\b\b\b"; + ptr_image += retval; // advance pointer + } + } while (toread > BLOCK_LEN); + + } else if(strncmp(header, "archon.Read(ptr_image, (size_t)toread)) > 0 ) { - // bytesread += retval; // this will get zeroed after each block - // totalbytesread += retval; // this won't (used only for info purposes) - // std::cerr << std::setw(10) << totalbytesread << "\b\b\b\b\b\b\b\b\b\b"; - // ptr_image += retval; // advance pointer - // } - // } while (bytesread < BLOCK_LEN); - } else { error = read_frame(); // then read the frame buffer to host (and write file) when frame ready. if ( error != NO_ERROR ) { From f73c5fac0519aafe1bf42b3bd4dda5e92420a99c Mon Sep 17 00:00:00 2001 From: Michael Langmayr Date: Fri, 16 Aug 2024 09:28:01 -0700 Subject: [PATCH 074/124] fixed merge conflicts --- camerad/camerad.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/camerad/camerad.cpp b/camerad/camerad.cpp index d764f16b..d3579f53 100644 --- a/camerad/camerad.cpp +++ b/camerad/camerad.cpp @@ -755,13 +755,13 @@ void doit(Network::TcpSocket sock) { } else if (cmd == "trigin") { ret = server.trigin(args); } - else - if (cmd=="autofetch") { + else if (cmd=="autofetch") { ret = server.autofetch(args, retstring); if (!retstring.empty()) { sock.Write(retstring); sock.Write( " "); } + } else if ( cmd == "fetchlog" ) { ret = server.fetchlog(); } From 497241519aa5edd53057f6a962854d240e365359 Mon Sep 17 00:00:00 2001 From: Michael Langmayr Date: Fri, 16 Aug 2024 10:24:01 -0700 Subject: [PATCH 075/124] prototyping in progress --- camerad/archon.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/camerad/archon.cpp b/camerad/archon.cpp index aa6fb865..84ef9281 100644 --- a/camerad/archon.cpp +++ b/camerad/archon.cpp @@ -4061,12 +4061,14 @@ namespace Archon { do { toread = this->archon.Bytes_ready(); + logwrite( function, "bytes remaining to read: " + toread); + this->archon.Read(header, 4); if(strncmp(header, "archon.Read(ptr_image, 1024); - ptr_image += 1; + // this->archon.Read(ptr_image, 1024); + // ptr_image += 1; } if ( (retval=this->archon.Read(ptr_image, (size_t)toread)) > 0 ) { bytesread += retval; // this will get zeroed after each block From 9c557bbd59da451f52e2614cb92da0d477707297 Mon Sep 17 00:00:00 2001 From: Michael Langmayr Date: Fri, 16 Aug 2024 10:28:04 -0700 Subject: [PATCH 076/124] prototyping in progress --- camerad/archon.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/camerad/archon.cpp b/camerad/archon.cpp index 84ef9281..76da3d42 100644 --- a/camerad/archon.cpp +++ b/camerad/archon.cpp @@ -4067,15 +4067,15 @@ namespace Archon { if(strncmp(header, "archon.Read(ptr_image, 1024); - // ptr_image += 1; - } - if ( (retval=this->archon.Read(ptr_image, (size_t)toread)) > 0 ) { - bytesread += retval; // this will get zeroed after each block - totalbytesread += retval; // this won't (used only for info purposes) - std::cerr << std::setw(10) << totalbytesread << "\b\b\b\b\b\b\b\b\b\b"; - ptr_image += retval; // advance pointer + this->archon.Read(ptr_image, 1024); + ptr_image += 1; } + // if ( (retval=this->archon.Read(ptr_image, (size_t)toread)) > 0 ) { + // bytesread += retval; // this will get zeroed after each block + // totalbytesread += retval; // this won't (used only for info purposes) + // std::cerr << std::setw(10) << totalbytesread << "\b\b\b\b\b\b\b\b\b\b"; + // ptr_image += retval; // advance pointer + // } } while (toread > BLOCK_LEN); From 357820dffb1a3d9581e78928b5cfa9fa69cf1934 Mon Sep 17 00:00:00 2001 From: Michael Langmayr Date: Fri, 16 Aug 2024 10:33:39 -0700 Subject: [PATCH 077/124] prototyping in progress --- camerad/archon.cpp | 52 +++++++++++++++++++++++----------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/camerad/archon.cpp b/camerad/archon.cpp index 76da3d42..a7e0ea94 100644 --- a/camerad/archon.cpp +++ b/camerad/archon.cpp @@ -4079,32 +4079,32 @@ namespace Archon { } while (toread > BLOCK_LEN); - } else if(strncmp(header, "archon.Read(buffer, 1024); - std::string buffer_str(buffer); - - long unsigned int x = buffer_str.find("archon.Read(buffer, 1024); - std::string buffer_str(buffer); - - long unsigned int x = buffer_str.find("archon.Read(buffer, 1024); + // std::string buffer_str(buffer); + // + // long unsigned int x = buffer_str.find("archon.Read(buffer, 1024); + // std::string buffer_str(buffer); + // + // long unsigned int x = buffer_str.find(" Date: Fri, 16 Aug 2024 10:40:18 -0700 Subject: [PATCH 078/124] prototyping in progress --- camerad/archon.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/camerad/archon.cpp b/camerad/archon.cpp index a7e0ea94..886873ca 100644 --- a/camerad/archon.cpp +++ b/camerad/archon.cpp @@ -4023,7 +4023,7 @@ namespace Archon { totalbytesread = 0; // Read the frame contents // - if (this->archon.Bytes_ready() > 0) { + if ((toread = this->archon.Bytes_ready()) > 0) { char buffer[1024]; int retval = this->archon.Read(header, 4); @@ -4067,7 +4067,7 @@ namespace Archon { if(strncmp(header, "archon.Read(ptr_image, 1024); + this->archon.Read(ptr_image, 1016); ptr_image += 1; } // if ( (retval=this->archon.Read(ptr_image, (size_t)toread)) > 0 ) { From d72f6fb65d3b13803f3e364de6110d34960d86da Mon Sep 17 00:00:00 2001 From: Michael Langmayr Date: Fri, 16 Aug 2024 10:42:27 -0700 Subject: [PATCH 079/124] prototyping in progress --- camerad/archon.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/camerad/archon.cpp b/camerad/archon.cpp index 886873ca..007c5e1c 100644 --- a/camerad/archon.cpp +++ b/camerad/archon.cpp @@ -4012,7 +4012,8 @@ namespace Archon { char autofetch_header[300]; char header[4]; char *ptr_image; - int bytesread, totalbytesread, toread; + int bytesread, totalbytesread; + int toread; // uint64_t bufaddr; // unsigned int block, bufblocks=0; unsigned int xf_package_counter = 0; @@ -4026,7 +4027,7 @@ namespace Archon { if ((toread = this->archon.Bytes_ready()) > 0) { char buffer[1024]; - int retval = this->archon.Read(header, 4); + retval = this->archon.Read(header, 4); std::string header_str(header); if (retval <= 0) { this->camera.log_error( function, "reading Archon" ); From 18a1c0976d61f97f535a5df90135292ede581b23 Mon Sep 17 00:00:00 2001 From: Michael Langmayr Date: Fri, 16 Aug 2024 10:44:20 -0700 Subject: [PATCH 080/124] prototyping in progress --- camerad/archon.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/camerad/archon.cpp b/camerad/archon.cpp index 007c5e1c..51cca705 100644 --- a/camerad/archon.cpp +++ b/camerad/archon.cpp @@ -4064,12 +4064,12 @@ namespace Archon { toread = this->archon.Bytes_ready(); logwrite( function, "bytes remaining to read: " + toread); - this->archon.Read(header, 4); + this->archon.Read(header, 1024); if(strncmp(header, "archon.Read(ptr_image, 1016); - ptr_image += 1; + // this->archon.Read(ptr_image, 1016); + // ptr_image += 1; } // if ( (retval=this->archon.Read(ptr_image, (size_t)toread)) > 0 ) { // bytesread += retval; // this will get zeroed after each block From 44a858dee7d9179d47b95ed0751ca9a6bc3ee63e Mon Sep 17 00:00:00 2001 From: Michael Langmayr Date: Fri, 16 Aug 2024 10:49:22 -0700 Subject: [PATCH 081/124] prototyping in progress --- camerad/archon.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/camerad/archon.cpp b/camerad/archon.cpp index 51cca705..96439bf8 100644 --- a/camerad/archon.cpp +++ b/camerad/archon.cpp @@ -4064,7 +4064,7 @@ namespace Archon { toread = this->archon.Bytes_ready(); logwrite( function, "bytes remaining to read: " + toread); - this->archon.Read(header, 1024); + this->archon.Read(header, 1028); if(strncmp(header, " Date: Fri, 16 Aug 2024 10:55:41 -0700 Subject: [PATCH 082/124] prototyping in progress --- camerad/archon.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/camerad/archon.cpp b/camerad/archon.cpp index 96439bf8..7e9c07be 100644 --- a/camerad/archon.cpp +++ b/camerad/archon.cpp @@ -4064,12 +4064,12 @@ namespace Archon { toread = this->archon.Bytes_ready(); logwrite( function, "bytes remaining to read: " + toread); - this->archon.Read(header, 1028); - if(strncmp(header, "archon.Read(header, 4); + if(strncmp(header, "archon.Read(ptr_image, 1016); - // ptr_image += 1; + this->archon.Read(ptr_image, 1024); + ptr_image += 1; } // if ( (retval=this->archon.Read(ptr_image, (size_t)toread)) > 0 ) { // bytesread += retval; // this will get zeroed after each block @@ -4077,7 +4077,7 @@ namespace Archon { // std::cerr << std::setw(10) << totalbytesread << "\b\b\b\b\b\b\b\b\b\b"; // ptr_image += retval; // advance pointer // } - } while (toread > BLOCK_LEN); + } while (toread > 1024); // } else if(strncmp(header, " Date: Fri, 16 Aug 2024 11:01:24 -0700 Subject: [PATCH 083/124] prototyping in progress --- camerad/archon.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/camerad/archon.cpp b/camerad/archon.cpp index 7e9c07be..7ec9818a 100644 --- a/camerad/archon.cpp +++ b/camerad/archon.cpp @@ -4065,7 +4065,7 @@ namespace Archon { logwrite( function, "bytes remaining to read: " + toread); this->archon.Read(header, 4); - if(strncmp(header, "archon.Read(ptr_image, 1024); From 57c33c9f883467a1bec5fb0f5d4a0d14c9642ca6 Mon Sep 17 00:00:00 2001 From: Michael Langmayr Date: Fri, 16 Aug 2024 11:23:33 -0700 Subject: [PATCH 084/124] move autofetch read to read_frame() --- camerad/archon.cpp | 237 ++++++++++++++++++++++----------------------- 1 file changed, 118 insertions(+), 119 deletions(-) diff --git a/camerad/archon.cpp b/camerad/archon.cpp index 7ec9818a..8315c802 100644 --- a/camerad/archon.cpp +++ b/camerad/archon.cpp @@ -2701,7 +2701,119 @@ namespace Archon { } else { // IMAGE, or IMAGE+RAW // datacube was already set = true in the expose function - error = this->read_frame(Camera::FRAME_IMAGE); // read image frame + if (this->is_autofetch) { + logwrite( function, "AUTOFETCH READ FRAME"); + std::this_thread::sleep_for(std::chrono::seconds(2)); + + int retval; + // int bufready; + // char check[5]; + char autofetch_header[300]; + char header[4]; + char *ptr_image; + int bytesread, totalbytesread; + int toread; + // uint64_t bufaddr; + // unsigned int block, bufblocks=0; + unsigned int xf_package_counter = 0; + bool found_autofetch_header = false; + + bytesread = 0; + ptr_image = this->image_data; + totalbytesread = 0; + // Read the frame contents + // + if ((toread = this->archon.Bytes_ready()) > 0) { + char buffer[1024]; + + retval = this->archon.Read(header, 4); + std::string header_str(header); + if (retval <= 0) { + this->camera.log_error( function, "reading Archon" ); + } + logwrite( function, "READING HEADER DONE" ); + + if (strncmp(header, "archon.Read(autofetch_header, 1260); + std::string autofetch_header_str(autofetch_header); + + // // read rest of buffer frame + // retval = this->archon.Read(buffer, 1024); + // std::string buffer_str(buffer); + + logwrite( function, "AUTOFETCH HEADER: " + header_str); + logwrite( function, "AUTOFETCH HEADER: " + autofetch_header_str); + + // stop after printing the autofetch header + // break; + + // long unsigned int x; + // if (x != std::string::npos) { + // x = buffer_str.find("archon.Bytes_ready(); + logwrite( function, "bytes remaining to read: " + toread); + + this->archon.Read(header, 4); + if(strncmp(header, "archon.Read(ptr_image, 1024); + ptr_image += 1; + } + // if ( (retval=this->archon.Read(ptr_image, (size_t)toread)) > 0 ) { + // bytesread += retval; // this will get zeroed after each block + // totalbytesread += retval; // this won't (used only for info purposes) + // std::cerr << std::setw(10) << totalbytesread << "\b\b\b\b\b\b\b\b\b\b"; + // ptr_image += retval; // advance pointer + // } + } while (toread > 1024); + + + // } else if(strncmp(header, "archon.Read(buffer, 1024); + // std::string buffer_str(buffer); + // + // long unsigned int x = buffer_str.find("archon.Read(buffer, 1024); + // std::string buffer_str(buffer); + // + // long unsigned int x = buffer_str.find("read_frame(Camera::FRAME_IMAGE); + } + // read image frame if ( error != NO_ERROR ) { logwrite( function, "ERROR: reading image frame" ); return error; } error = this->write_frame(); // write image frame if ( error != NO_ERROR ) { logwrite( function, "ERROR: writing image frame" ); return error; } @@ -4002,124 +4114,11 @@ namespace Archon { return error; } - if (this->is_autofetch) { - logwrite( function, "AUTOFETCH READ FRAME"); - std::this_thread::sleep_for(std::chrono::seconds(2)); - - int retval; - // int bufready; - // char check[5]; - char autofetch_header[300]; - char header[4]; - char *ptr_image; - int bytesread, totalbytesread; - int toread; - // uint64_t bufaddr; - // unsigned int block, bufblocks=0; - unsigned int xf_package_counter = 0; - bool found_autofetch_header = false; - - bytesread = 0; - ptr_image = this->image_data; - totalbytesread = 0; - // Read the frame contents - // - if ((toread = this->archon.Bytes_ready()) > 0) { - char buffer[1024]; - - retval = this->archon.Read(header, 4); - std::string header_str(header); - if (retval <= 0) { - this->camera.log_error( function, "reading Archon" ); - break; - } - logwrite( function, "READING HEADER DONE" ); - - if (strncmp(header, "archon.Read(autofetch_header, 1260); - std::string autofetch_header_str(autofetch_header); - - // // read rest of buffer frame - // retval = this->archon.Read(buffer, 1024); - // std::string buffer_str(buffer); - - logwrite( function, "AUTOFETCH HEADER: " + header_str); - logwrite( function, "AUTOFETCH HEADER: " + autofetch_header_str); - - // stop after printing the autofetch header - // break; - - // long unsigned int x; - // if (x != std::string::npos) { - // x = buffer_str.find("archon.Bytes_ready(); - logwrite( function, "bytes remaining to read: " + toread); - - this->archon.Read(header, 4); - if(strncmp(header, "archon.Read(ptr_image, 1024); - ptr_image += 1; - } - // if ( (retval=this->archon.Read(ptr_image, (size_t)toread)) > 0 ) { - // bytesread += retval; // this will get zeroed after each block - // totalbytesread += retval; // this won't (used only for info purposes) - // std::cerr << std::setw(10) << totalbytesread << "\b\b\b\b\b\b\b\b\b\b"; - // ptr_image += retval; // advance pointer - // } - } while (toread > 1024); - - - // } else if(strncmp(header, "archon.Read(buffer, 1024); - // std::string buffer_str(buffer); - // - // long unsigned int x = buffer_str.find("archon.Read(buffer, 1024); - // std::string buffer_str(buffer); - // - // long unsigned int x = buffer_str.find("fits_file.close_file(this->camera.writekeys_when == "after", this->camera_info ); - return error; - } + error = read_frame(); // then read the frame buffer to host (and write file) when frame ready. + if ( error != NO_ERROR ) { + logwrite( function, "ERROR: reading frame buffer" ); + this->fits_file.close_file(this->camera.writekeys_when == "after", this->camera_info ); + return error; } // For non-sequence multiple exposures, including cubeamps, close the fits file here From 363dfe7b51c3e0ba14b05697cdee6de7deb3e352 Mon Sep 17 00:00:00 2001 From: Michael Langmayr Date: Fri, 16 Aug 2024 14:09:16 -0700 Subject: [PATCH 085/124] move autofetch read to read_frame() --- camerad/archon.cpp | 184 +++++++++++++++++---------------------------- 1 file changed, 69 insertions(+), 115 deletions(-) diff --git a/camerad/archon.cpp b/camerad/archon.cpp index 8315c802..d7b1d999 100644 --- a/camerad/archon.cpp +++ b/camerad/archon.cpp @@ -2701,118 +2701,69 @@ namespace Archon { } else { // IMAGE, or IMAGE+RAW // datacube was already set = true in the expose function - if (this->is_autofetch) { - logwrite( function, "AUTOFETCH READ FRAME"); - std::this_thread::sleep_for(std::chrono::seconds(2)); - - int retval; - // int bufready; - // char check[5]; - char autofetch_header[300]; - char header[4]; - char *ptr_image; - int bytesread, totalbytesread; - int toread; - // uint64_t bufaddr; - // unsigned int block, bufblocks=0; - unsigned int xf_package_counter = 0; - bool found_autofetch_header = false; - - bytesread = 0; - ptr_image = this->image_data; - totalbytesread = 0; - // Read the frame contents - // - if ((toread = this->archon.Bytes_ready()) > 0) { - char buffer[1024]; - - retval = this->archon.Read(header, 4); - std::string header_str(header); - if (retval <= 0) { - this->camera.log_error( function, "reading Archon" ); - } - logwrite( function, "READING HEADER DONE" ); - - if (strncmp(header, "archon.Read(autofetch_header, 1260); - std::string autofetch_header_str(autofetch_header); - - // // read rest of buffer frame - // retval = this->archon.Read(buffer, 1024); - // std::string buffer_str(buffer); - - logwrite( function, "AUTOFETCH HEADER: " + header_str); - logwrite( function, "AUTOFETCH HEADER: " + autofetch_header_str); - - // stop after printing the autofetch header - // break; - - // long unsigned int x; - // if (x != std::string::npos) { - // x = buffer_str.find("archon.Bytes_ready(); - logwrite( function, "bytes remaining to read: " + toread); - - this->archon.Read(header, 4); - if(strncmp(header, "archon.Read(ptr_image, 1024); - ptr_image += 1; - } - // if ( (retval=this->archon.Read(ptr_image, (size_t)toread)) > 0 ) { - // bytesread += retval; // this will get zeroed after each block - // totalbytesread += retval; // this won't (used only for info purposes) - // std::cerr << std::setw(10) << totalbytesread << "\b\b\b\b\b\b\b\b\b\b"; - // ptr_image += retval; // advance pointer - // } - } while (toread > 1024); - - - // } else if(strncmp(header, "archon.Read(buffer, 1024); - // std::string buffer_str(buffer); - // - // long unsigned int x = buffer_str.find("archon.Read(buffer, 1024); - // std::string buffer_str(buffer); - // - // long unsigned int x = buffer_str.find("is_autofetch) { + // logwrite( function, "AUTOFETCH READ FRAME"); + // std::this_thread::sleep_for(std::chrono::seconds(2)); + // + // int retval; + // char autofetch_header[300]; + // char header[4]; + // char *ptr_image; + // int bytesread, totalbytesread; + // int toread; + // unsigned int xf_package_counter = 0; + // + // bytesread = 0; + // ptr_image = this->image_data; + // totalbytesread = 0; + // // Read the frame contents + // // + // if ((toread = this->archon.Bytes_ready()) > 0) { + // char buffer[1024]; + // + // retval = this->archon.Read(header, 4); + // std::string header_str(header); + // if (retval <= 0) { + // this->camera.log_error( function, "reading Archon" ); + // } + // + // if (strncmp(header, "archon.Read(autofetch_header, 1260); + // std::string autofetch_header_str(autofetch_header); + // + // logwrite( function, "AUTOFETCH HEADER: " + header_str); + // logwrite( function, "AUTOFETCH HEADER: " + autofetch_header_str); + // + // do { + // toread = this->archon.Bytes_ready(); + // logwrite( function, "bytes remaining to read: " + toread); + // + // this->archon.Read(header, 4); + // if(strncmp(header, "archon.Read(ptr_image, 1024); + // ptr_image += 1; + // } + // // if ( (retval=this->archon.Read(ptr_image, (size_t)toread)) > 0 ) { + // // bytesread += retval; // this will get zeroed after each block + // // totalbytesread += retval; // this won't (used only for info purposes) + // // std::cerr << std::setw(10) << totalbytesread << "\b\b\b\b\b\b\b\b\b\b"; + // // ptr_image += retval; // advance pointer + // // } + // } while (toread > 1028); + // } + // } else { + // logwrite( function, "Nothing to read on socket, xf counter: " + std::to_string(xf_package_counter) ); + // std::this_thread::sleep_for(std::chrono::milliseconds(500)); + // // continue; + // } + // } else { error = this->read_frame(Camera::FRAME_IMAGE); - } + // } // read image frame if ( error != NO_ERROR ) { logwrite( function, "ERROR: reading image frame" ); return error; } error = this->write_frame(); // write image frame @@ -3166,12 +3117,15 @@ namespace Archon { // send the FETCH command. // This will take the archon_busy semaphore, but not release it -- must release in this function! // - error = this->fetch(bufaddr, bufblocks); - if ( error != NO_ERROR ) { - logwrite( function, "ERROR: fetching Archon buffer" ); - return error; + if (!this->is_autofetch) { + error = this->fetch(bufaddr, bufblocks); + if ( error != NO_ERROR ) { + logwrite( function, "ERROR: fetching Archon buffer" ); + return error; + } } + // Read the data from the connected socket into memory, one block at a time // ptr_image = this->image_data; From 247b76b438b4ed602920c59d2518d5af788ea0f3 Mon Sep 17 00:00:00 2001 From: Michael Langmayr Date: Fri, 16 Aug 2024 14:22:21 -0700 Subject: [PATCH 086/124] prototyping in progress --- camerad/archon.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/camerad/archon.cpp b/camerad/archon.cpp index d7b1d999..da97b3b9 100644 --- a/camerad/archon.cpp +++ b/camerad/archon.cpp @@ -3123,6 +3123,8 @@ namespace Archon { logwrite( function, "ERROR: fetching Archon buffer" ); return error; } + } else { + logwrite( function, "READ FRAME AUTOFETCH"); } From 9db406af5c1de3c073264657654c8842a7f2c4ce Mon Sep 17 00:00:00 2001 From: Michael Langmayr Date: Fri, 16 Aug 2024 14:29:45 -0700 Subject: [PATCH 087/124] prototyping in progress --- camerad/archon.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/camerad/archon.cpp b/camerad/archon.cpp index da97b3b9..1320fa96 100644 --- a/camerad/archon.cpp +++ b/camerad/archon.cpp @@ -3125,6 +3125,17 @@ namespace Archon { } } else { logwrite( function, "READ FRAME AUTOFETCH"); + + // Read autofetch header + char autofetch_header[1264]; + + retval = this->archon.Read(autofetch_header, 1264); + if (strncmp(autofetch_header, " Date: Fri, 16 Aug 2024 14:33:23 -0700 Subject: [PATCH 088/124] prototyping in progress --- camerad/archon.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/camerad/archon.cpp b/camerad/archon.cpp index 1320fa96..4d11bf67 100644 --- a/camerad/archon.cpp +++ b/camerad/archon.cpp @@ -3138,7 +3138,6 @@ namespace Archon { } } - // Read the data from the connected socket into memory, one block at a time // ptr_image = this->image_data; @@ -3146,22 +3145,24 @@ namespace Archon { std::cerr << "reading bytes: "; for (block=0; blockarchon.Poll()) <= 0) { - if (retval==0) { + if (!this->is_autofetch) { + // Are there data to read? + if ( (retval=this->archon.Poll()) <= 0) { + if (retval==0) { message.str(""); message << "Poll timeout waiting for Archon frame data"; error = ERROR; - } // TODO should error=TIMEOUT? + } // TODO should error=TIMEOUT? - if (retval<0) { + if (retval<0) { message.str(""); message << "Poll error waiting for Archon frame data"; error = ERROR; - } + } - if ( error != NO_ERROR ) this->camera.log_error( function, message.str() ); - break; // breaks out of for loop + if ( error != NO_ERROR ) this->camera.log_error( function, message.str() ); + break; // breaks out of for loop + } } // Wait for a block+header Bytes to be available From f72ff1107c6c99302d4e4e2a4a08b066a19bf819 Mon Sep 17 00:00:00 2001 From: Michael Langmayr Date: Fri, 16 Aug 2024 14:47:24 -0700 Subject: [PATCH 089/124] prototyping in progress --- camerad/archon.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/camerad/archon.cpp b/camerad/archon.cpp index 4d11bf67..4a723df0 100644 --- a/camerad/archon.cpp +++ b/camerad/archon.cpp @@ -3191,6 +3191,9 @@ namespace Archon { error = ERROR; break; // break out of for loop } + + logwrite(function, "check: " + std::string(check) + ", header: " + header); + if (header[0] == '?') { // Archon retured an error message.str(""); message << "Archon returned \'?\' reading " << (frame_type==Camera::FRAME_RAW?"raw ":"image ") << " data"; this->camera.log_error( function, message.str() ); From 1e578c544d9aa70ee1fdfdf91c854131d18b5b22 Mon Sep 17 00:00:00 2001 From: Michael Langmayr Date: Fri, 16 Aug 2024 14:56:57 -0700 Subject: [PATCH 090/124] remove custom make clean target --- CMakeLists.txt | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5a8c84f2..9bc6f933 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -64,13 +64,3 @@ add_subdirectory(${PROJECT_BASE_DIR}/common) add_subdirectory(${PROJECT_BASE_DIR}/camerad) add_subdirectory(${PROJECT_BASE_DIR}/emulator) add_subdirectory(${PROJECT_BASE_DIR}/tests EXCLUDE_FROM_ALL) - -## Custom clean target -#add_custom_target(custom_clean -# COMMAND ${CMAKE_COMMAND} -P ${CMAKE_BINARY_DIR}/cmake_clean.cmake -# COMMAND ${CMAKE_COMMAND} -E rm -Rf ${CMAKE_BINARY_DIR} -# COMMENT "Custom clean steps" -#) - -# Make the custom clean target depend on the default clean target -#add_dependencies(custom_clean clean) From f0be204c82c233c3dde6ea77285cf92e10a812ef Mon Sep 17 00:00:00 2001 From: Michael Langmayr Date: Fri, 16 Aug 2024 14:57:57 -0700 Subject: [PATCH 091/124] cleanup --- .gitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitignore b/.gitignore index 5ac6ccdc..706fd07f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,2 @@ .idea .vscode -cmake-build* \ No newline at end of file From c0f8a6cf2d1ab608ed2f269db59157965fe665c5 Mon Sep 17 00:00:00 2001 From: Michael Langmayr Date: Mon, 19 Aug 2024 08:36:57 -0700 Subject: [PATCH 092/124] prototyping in progress --- camerad/archon.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/camerad/archon.cpp b/camerad/archon.cpp index 4a723df0..eb1683ce 100644 --- a/camerad/archon.cpp +++ b/camerad/archon.cpp @@ -3133,7 +3133,6 @@ namespace Archon { if (strncmp(autofetch_header, "msgref) + // SNPRINTF(check, "<%02X:", this->msgref) + sprintf(check, "archon.Read(header, 4)) != 4 ) { message.str(""); message << "code " << retval << " reading Archon frame header"; this->camera.log_error( function, message.str() ); From a026db093113dc6c9a43f6160a6c147658c445dc Mon Sep 17 00:00:00 2001 From: Michael Langmayr Date: Mon, 19 Aug 2024 08:43:32 -0700 Subject: [PATCH 093/124] prototyping in progress --- camerad/archon.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/camerad/archon.cpp b/camerad/archon.cpp index eb1683ce..e870cda1 100644 --- a/camerad/archon.cpp +++ b/camerad/archon.cpp @@ -3183,8 +3183,12 @@ namespace Archon { // Check message header // - // SNPRINTF(check, "<%02X:", this->msgref) - sprintf(check, "is_autofetch) { + sprintf(check, "msgref); + } + if ( (retval=this->archon.Read(header, 4)) != 4 ) { message.str(""); message << "code " << retval << " reading Archon frame header"; this->camera.log_error( function, message.str() ); From dddaf8970f0e963339356a1dc39d107d778fd0d0 Mon Sep 17 00:00:00 2001 From: Michael Langmayr Date: Mon, 19 Aug 2024 10:52:26 -0700 Subject: [PATCH 094/124] remove logging all headers --- camerad/archon.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/camerad/archon.cpp b/camerad/archon.cpp index e870cda1..879c4cc2 100644 --- a/camerad/archon.cpp +++ b/camerad/archon.cpp @@ -3124,7 +3124,7 @@ namespace Archon { return error; } } else { - logwrite( function, "READ FRAME AUTOFETCH"); + logwrite( function, "READ FRAME: AUTOFETCH MODE"); // Read autofetch header char autofetch_header[1264]; @@ -3143,7 +3143,6 @@ namespace Archon { totalbytesread = 0; std::cerr << "reading bytes: "; for (block=0; blockis_autofetch) { // Are there data to read? if ( (retval=this->archon.Poll()) <= 0) { @@ -3196,8 +3195,6 @@ namespace Archon { break; // break out of for loop } - logwrite(function, "check: " + std::string(check) + ", header: " + header); - if (header[0] == '?') { // Archon retured an error message.str(""); message << "Archon returned \'?\' reading " << (frame_type==Camera::FRAME_RAW?"raw ":"image ") << " data"; this->camera.log_error( function, message.str() ); From b92c6defe8448aa507edf3ba640bf03dc80b686a Mon Sep 17 00:00:00 2001 From: Michael Langmayr Date: Mon, 19 Aug 2024 10:58:03 -0700 Subject: [PATCH 095/124] prototyping in progress --- camerad/archon.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/camerad/archon.cpp b/camerad/archon.cpp index 879c4cc2..f7d76a57 100644 --- a/camerad/archon.cpp +++ b/camerad/archon.cpp @@ -3925,15 +3925,19 @@ namespace Archon { } this->lastframe = this->frame.bufframen[this->frame.index]; // save the last frame number acquired (wait_for_readout will need this) - // initiate the exposure here - // - error = this->prep_parameter(this->exposeparam, nseqstr); - if (error == NO_ERROR) error = this->load_parameter(this->exposeparam, nseqstr); - if ( error != NO_ERROR ) { - logwrite( function, "ERROR: could not initiate exposure" ); - return error; + // disable prep parameters in autofetch mode + if (!this->is_autofetch) { + // initiate the exposure here + // + error = this->prep_parameter(this->exposeparam, nseqstr); + if (error == NO_ERROR) error = this->load_parameter(this->exposeparam, nseqstr); + if ( error != NO_ERROR ) { + logwrite( function, "ERROR: could not initiate exposure" ); + return error; + } } + // get system time and Archon's timer after exposure starts // start_timer is used to determine when the exposure has ended, in wait_for_exposure() // From 61ac27b875e8d8ba023b291566f461b7a12555fd Mon Sep 17 00:00:00 2001 From: Michael Langmayr Date: Mon, 19 Aug 2024 11:01:30 -0700 Subject: [PATCH 096/124] prototyping in progress --- camerad/archon.cpp | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/camerad/archon.cpp b/camerad/archon.cpp index f7d76a57..568a0f37 100644 --- a/camerad/archon.cpp +++ b/camerad/archon.cpp @@ -3925,16 +3925,13 @@ namespace Archon { } this->lastframe = this->frame.bufframen[this->frame.index]; // save the last frame number acquired (wait_for_readout will need this) - // disable prep parameters in autofetch mode - if (!this->is_autofetch) { - // initiate the exposure here - // - error = this->prep_parameter(this->exposeparam, nseqstr); - if (error == NO_ERROR) error = this->load_parameter(this->exposeparam, nseqstr); - if ( error != NO_ERROR ) { - logwrite( function, "ERROR: could not initiate exposure" ); - return error; - } + // initiate the exposure here + // + error = this->prep_parameter(this->exposeparam, nseqstr); + if (error == NO_ERROR) error = this->load_parameter(this->exposeparam, nseqstr); + if ( error != NO_ERROR ) { + logwrite( function, "ERROR: could not initiate exposure" ); + return error; } From 5ae49e937e710964b49f00aa07e98bad07ee1c96 Mon Sep 17 00:00:00 2001 From: Michael Langmayr Date: Mon, 19 Aug 2024 11:20:24 -0700 Subject: [PATCH 097/124] prototyping in progress --- camerad/archon.cpp | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/camerad/archon.cpp b/camerad/archon.cpp index 568a0f37..d354ad04 100644 --- a/camerad/archon.cpp +++ b/camerad/archon.cpp @@ -2631,10 +2631,13 @@ namespace Archon { return ERROR; } - if (this->archon_cmd(scmd) == ERROR) { - logwrite( function, "ERROR: sending FETCH command. Aborting read." ); - this->archon_cmd(UNLOCK); // unlock all buffers - return ERROR; + // disable sending fetch command in autofetch mode + if (!this->is_autofetch) { + if (this->archon_cmd(scmd) == ERROR) { + logwrite( function, "ERROR: sending FETCH command. Aborting read." ); + this->archon_cmd(UNLOCK); // unlock all buffers + return ERROR; + } } message.str(""); message << "reading " << (this->camera_info.frame_type==Camera::FRAME_RAW?"raw":"image") << " with " << scmd; @@ -2868,15 +2871,14 @@ namespace Archon { << "0x" << std::uppercase << std::hex << bufblocks << " blocks from bufaddr=0x" << bufaddr; logwrite(function, message.str()); - if (!this->is_autofetch) { - // send the FETCH command. - // This will take the archon_busy semaphore, but not release it -- must release in this function! - // - error = this->fetch(bufaddr, bufblocks); - if (error != NO_ERROR) { - logwrite(function, "ERROR: fetching Archon buffer"); - return error; - } + + // send the FETCH command. + // This will take the archon_busy semaphore, but not release it -- must release in this function! + // + error = this->fetch(bufaddr, bufblocks); + if (error != NO_ERROR) { + logwrite(function, "ERROR: fetching Archon buffer"); + return error; } // Read the data from the connected socket into memory, one block at a time From 3df801498148f2eb0f09d39febe94687955a91a5 Mon Sep 17 00:00:00 2001 From: Michael Langmayr Date: Mon, 19 Aug 2024 12:51:07 -0700 Subject: [PATCH 098/124] prototyping in progress --- camerad/archon.cpp | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/camerad/archon.cpp b/camerad/archon.cpp index d354ad04..71fd5f8b 100644 --- a/camerad/archon.cpp +++ b/camerad/archon.cpp @@ -3116,27 +3116,15 @@ namespace Archon { << "0x" << std::uppercase << std::hex << bufblocks << " blocks from bufaddr=0x" << bufaddr; logwrite(function, message.str()); - // send the FETCH command. - // This will take the archon_busy semaphore, but not release it -- must release in this function! - // if (!this->is_autofetch) { + // send the FETCH command. + // This will take the archon_busy semaphore, but not release it -- must release in this function! + // error = this->fetch(bufaddr, bufblocks); if ( error != NO_ERROR ) { logwrite( function, "ERROR: fetching Archon buffer" ); return error; } - } else { - logwrite( function, "READ FRAME: AUTOFETCH MODE"); - - // Read autofetch header - char autofetch_header[1264]; - - retval = this->archon.Read(autofetch_header, 1264); - if (strncmp(autofetch_header, "is_autofetch) { sprintf(check, "msgref) + " with: msgref); } @@ -3197,6 +3186,23 @@ namespace Archon { break; // break out of for loop } + + + if (this->is_autofetch) { + // Read autofetch header + char autofetch_header[1260]; + + logwrite( function, "READ FRAME: AUTOFETCH MODE"); + + if (strncmp(header, "archon.Read(autofetch_header, 1260); + std::string autofetch_header_str(autofetch_header); + logwrite( function, "AUTOFETCH HEADER: " + autofetch_header_str); + } + } + + if (header[0] == '?') { // Archon retured an error message.str(""); message << "Archon returned \'?\' reading " << (frame_type==Camera::FRAME_RAW?"raw ":"image ") << " data"; this->camera.log_error( function, message.str() ); From e9f8a8d21f3f76c37dd6bd293c8e9b7aa93f02e4 Mon Sep 17 00:00:00 2001 From: Michael Langmayr Date: Mon, 19 Aug 2024 13:04:26 -0700 Subject: [PATCH 099/124] prototyping in progress --- camerad/archon.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/camerad/archon.cpp b/camerad/archon.cpp index 71fd5f8b..254b78f3 100644 --- a/camerad/archon.cpp +++ b/camerad/archon.cpp @@ -3186,8 +3186,6 @@ namespace Archon { break; // break out of for loop } - - if (this->is_autofetch) { // Read autofetch header char autofetch_header[1260]; @@ -5351,9 +5349,9 @@ namespace Archon { if (!this->is_autofetch) { error = this->get_frame_status(); } else { - logwrite( function, "READ IN AUTOFETCH MODE" ); - logwrite( function, "Bytes ready on socket: " + std::to_string(this->archon.Bytes_ready())); - break; + // logwrite( function, "READ IN AUTOFETCH MODE" ); + // logwrite( function, "Bytes ready on socket: " + std::to_string(this->archon.Bytes_ready())); + // break; } // If Archon is busy then ignore it, keep trying for up to ~ 3 second From aaf358228175d443e99598ebae436522513274f4 Mon Sep 17 00:00:00 2001 From: Michael Langmayr Date: Mon, 19 Aug 2024 13:08:34 -0700 Subject: [PATCH 100/124] prototyping in progress --- camerad/archon.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/camerad/archon.cpp b/camerad/archon.cpp index 254b78f3..7a434638 100644 --- a/camerad/archon.cpp +++ b/camerad/archon.cpp @@ -5347,11 +5347,14 @@ namespace Archon { if (this->is_longexposure) usleep( 10000 ); // reduces polling frequency if (!this->is_autofetch) { - error = this->get_frame_status(); + logwrite( function, "READ IN AUTOFETCH MODE" ); + logwrite( function, "Bytes ready on socket: " + std::to_string(this->archon.Bytes_ready())); + if (this->archon.Bytes_ready() > 0) { + done = true; + break; + } } else { - // logwrite( function, "READ IN AUTOFETCH MODE" ); - // logwrite( function, "Bytes ready on socket: " + std::to_string(this->archon.Bytes_ready())); - // break; + error = this->get_frame_status(); } // If Archon is busy then ignore it, keep trying for up to ~ 3 second From 92e705f7a57aed0de707e142fd6e5f5e66f41d36 Mon Sep 17 00:00:00 2001 From: Michael Langmayr Date: Mon, 19 Aug 2024 13:11:30 -0700 Subject: [PATCH 101/124] prototyping in progress --- camerad/archon.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/camerad/archon.cpp b/camerad/archon.cpp index 7a434638..ce61c654 100644 --- a/camerad/archon.cpp +++ b/camerad/archon.cpp @@ -5346,7 +5346,7 @@ namespace Archon { while (!done && !this->abort) { if (this->is_longexposure) usleep( 10000 ); // reduces polling frequency - if (!this->is_autofetch) { + if (this->is_autofetch) { logwrite( function, "READ IN AUTOFETCH MODE" ); logwrite( function, "Bytes ready on socket: " + std::to_string(this->archon.Bytes_ready())); if (this->archon.Bytes_ready() > 0) { From 7dda939fbda10fd832c28d37b5320753e9936612 Mon Sep 17 00:00:00 2001 From: Michael Langmayr Date: Mon, 19 Aug 2024 13:16:21 -0700 Subject: [PATCH 102/124] prototyping in progress --- camerad/archon.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/camerad/archon.cpp b/camerad/archon.cpp index ce61c654..e58d7901 100644 --- a/camerad/archon.cpp +++ b/camerad/archon.cpp @@ -5414,16 +5414,20 @@ namespace Archon { // logwrite( function, "EXITED WHILE LOOP" ); - if ( error == NO_ERROR ) { - error = this->get_frame_status(); - if ( error != NO_ERROR ) { - logwrite( function, "ERROR: unable to get frame status" ); - return error; + // don't run get_frame_status() in autofetch mode + if (!this->is_autofetch) { + if ( error == NO_ERROR ) { + error = this->get_frame_status(); + if ( error != NO_ERROR ) { + logwrite( function, "ERROR: unable to get frame status" ); + return error; + } + message.str(""); message << "LINECOUNT:" << this->frame.buflines[ this->frame.index ]; + this->camera.async.enqueue( message.str() ); } - message.str(""); message << "LINECOUNT:" << this->frame.buflines[ this->frame.index ]; - this->camera.async.enqueue( message.str() ); } + if ( error != NO_ERROR ) { return error; } From 8dbddda4844b9c4b9ae409e427eb1dfa03c87ee8 Mon Sep 17 00:00:00 2001 From: Michael Langmayr Date: Mon, 19 Aug 2024 13:20:35 -0700 Subject: [PATCH 103/124] prototyping in progress --- camerad/archon.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/camerad/archon.cpp b/camerad/archon.cpp index e58d7901..ebf1ad44 100644 --- a/camerad/archon.cpp +++ b/camerad/archon.cpp @@ -3076,11 +3076,14 @@ namespace Archon { << " data from Archon controller buffer " << bufready << " frame " << this->frame.frame; logwrite(function, message.str()); - // Lock the frame buffer before reading it - // - if ( this->lock_buffer(bufready) == ERROR) { + // don't lock frame buffer in autofetch mode + if (!this->is_autofetch) { + // Lock the frame buffer before reading it + // + if ( this->lock_buffer(bufready) == ERROR) { logwrite( function, "ERROR locking frame buffer" ); return (ERROR); + } } // Send the FETCH command to read the memory buffer from the Archon backplane. From eca3d15f6778e03572329fad348a2e06365f0b33 Mon Sep 17 00:00:00 2001 From: Michael Langmayr Date: Mon, 19 Aug 2024 13:25:18 -0700 Subject: [PATCH 104/124] prototyping in progress --- camerad/archon.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/camerad/archon.cpp b/camerad/archon.cpp index ebf1ad44..042bc004 100644 --- a/camerad/archon.cpp +++ b/camerad/archon.cpp @@ -3200,6 +3200,9 @@ namespace Archon { retval = this->archon.Read(autofetch_header, 1260); std::string autofetch_header_str(autofetch_header); logwrite( function, "AUTOFETCH HEADER: " + autofetch_header_str); + + // Read next header + this->archon.Read(header, 4); } } From ff2bddef5602d13de578c00efa2fbf5fdece5e97 Mon Sep 17 00:00:00 2001 From: Michael Langmayr Date: Mon, 19 Aug 2024 13:36:31 -0700 Subject: [PATCH 105/124] prototyping in progress --- camerad/archon.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/camerad/archon.cpp b/camerad/archon.cpp index 042bc004..b2c56311 100644 --- a/camerad/archon.cpp +++ b/camerad/archon.cpp @@ -3837,7 +3837,7 @@ namespace Archon { std::string mode = this->camera_info.current_observing_mode; // local copy for convenience - logwrite( function, "RUN EXPOSE: " + nseq_in ); + logwrite( function, "RUN EXPOSE" ); if ( ! this->modeselected ) { this->camera.log_error( function, "no mode selected" ); @@ -3929,7 +3929,9 @@ namespace Archon { // this->camera_info.extension = 0; - error = this->get_frame_status(); // TODO is this needed here? + if (!this->is_autofetch) { + error = this->get_frame_status(); // TODO is this needed here? + } if (error != NO_ERROR) { logwrite( function, "ERROR: unable to get frame status" ); From bcffb943f03413534c1d4d0edbb7ad04028528e1 Mon Sep 17 00:00:00 2001 From: Michael Langmayr Date: Mon, 19 Aug 2024 13:43:47 -0700 Subject: [PATCH 106/124] prototyping in progress --- camerad/archon.cpp | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/camerad/archon.cpp b/camerad/archon.cpp index b2c56311..9b12f7d3 100644 --- a/camerad/archon.cpp +++ b/camerad/archon.cpp @@ -3175,12 +3175,7 @@ namespace Archon { // Check message header // - if (this->is_autofetch) { - sprintf(check, "msgref) + " with: msgref); - } + SNPRINTF(check, "<%02X:", this->msgref); if ( (retval=this->archon.Read(header, 4)) != 4 ) { message.str(""); message << "code " << retval << " reading Archon frame header"; @@ -3199,7 +3194,10 @@ namespace Archon { logwrite( function, "AUTOFETCH HEADER FOUND!" ); retval = this->archon.Read(autofetch_header, 1260); std::string autofetch_header_str(autofetch_header); - logwrite( function, "AUTOFETCH HEADER: " + autofetch_header_str); + logwrite( function, "AUTOFETCH HEADER: " + std::string(header) + autofetch_header_str); + + logwrite( function, "replaced header: " + std::to_string(this->msgref) + " with: archon.Read(header, 4); @@ -5355,8 +5353,7 @@ namespace Archon { if (this->is_longexposure) usleep( 10000 ); // reduces polling frequency if (this->is_autofetch) { - logwrite( function, "READ IN AUTOFETCH MODE" ); - logwrite( function, "Bytes ready on socket: " + std::to_string(this->archon.Bytes_ready())); + logwrite( function, "AUTOFETCH MODE: Bytes ready on socket: " + std::to_string(this->archon.Bytes_ready())); if (this->archon.Bytes_ready() > 0) { done = true; break; From 9b12c6d2adfaf3ab0ed3e14655419ad6d0c01d6d Mon Sep 17 00:00:00 2001 From: Michael Langmayr Date: Mon, 19 Aug 2024 13:51:38 -0700 Subject: [PATCH 107/124] prototyping in progress --- camerad/archon.cpp | 81 +++++++--------------------------------------- 1 file changed, 11 insertions(+), 70 deletions(-) diff --git a/camerad/archon.cpp b/camerad/archon.cpp index 9b12f7d3..554969b5 100644 --- a/camerad/archon.cpp +++ b/camerad/archon.cpp @@ -2702,72 +2702,11 @@ namespace Archon { } } else { - // IMAGE, or IMAGE+RAW - // datacube was already set = true in the expose function - // if (this->is_autofetch) { - // logwrite( function, "AUTOFETCH READ FRAME"); - // std::this_thread::sleep_for(std::chrono::seconds(2)); - // - // int retval; - // char autofetch_header[300]; - // char header[4]; - // char *ptr_image; - // int bytesread, totalbytesread; - // int toread; - // unsigned int xf_package_counter = 0; - // - // bytesread = 0; - // ptr_image = this->image_data; - // totalbytesread = 0; - // // Read the frame contents - // // - // if ((toread = this->archon.Bytes_ready()) > 0) { - // char buffer[1024]; - // - // retval = this->archon.Read(header, 4); - // std::string header_str(header); - // if (retval <= 0) { - // this->camera.log_error( function, "reading Archon" ); - // } - // - // if (strncmp(header, "archon.Read(autofetch_header, 1260); - // std::string autofetch_header_str(autofetch_header); - // - // logwrite( function, "AUTOFETCH HEADER: " + header_str); - // logwrite( function, "AUTOFETCH HEADER: " + autofetch_header_str); - // - // do { - // toread = this->archon.Bytes_ready(); - // logwrite( function, "bytes remaining to read: " + toread); - // - // this->archon.Read(header, 4); - // if(strncmp(header, "archon.Read(ptr_image, 1024); - // ptr_image += 1; - // } - // // if ( (retval=this->archon.Read(ptr_image, (size_t)toread)) > 0 ) { - // // bytesread += retval; // this will get zeroed after each block - // // totalbytesread += retval; // this won't (used only for info purposes) - // // std::cerr << std::setw(10) << totalbytesread << "\b\b\b\b\b\b\b\b\b\b"; - // // ptr_image += retval; // advance pointer - // // } - // } while (toread > 1028); - // } - // } else { - // logwrite( function, "Nothing to read on socket, xf counter: " + std::to_string(xf_package_counter) ); - // std::this_thread::sleep_for(std::chrono::milliseconds(500)); - // // continue; - // } - // } else { - error = this->read_frame(Camera::FRAME_IMAGE); - // } - // read image frame + // IMAGE, or IMAGE+RAW + // datacube was already set = true in the expose function + error = this->read_frame(Camera::FRAME_IMAGE); + + // read image frame if ( error != NO_ERROR ) { logwrite( function, "ERROR: reading image frame" ); return error; } error = this->write_frame(); // write image frame if ( error != NO_ERROR ) { logwrite( function, "ERROR: writing image frame" ); return error; } @@ -3175,7 +3114,12 @@ namespace Archon { // Check message header // - SNPRINTF(check, "<%02X:", this->msgref); + if (this->is_autofetch) { + logwrite( function, "replaced header: " + std::to_string(this->msgref) + " with: msgref); + } if ( (retval=this->archon.Read(header, 4)) != 4 ) { message.str(""); message << "code " << retval << " reading Archon frame header"; @@ -3196,9 +3140,6 @@ namespace Archon { std::string autofetch_header_str(autofetch_header); logwrite( function, "AUTOFETCH HEADER: " + std::string(header) + autofetch_header_str); - logwrite( function, "replaced header: " + std::to_string(this->msgref) + " with: archon.Read(header, 4); } From b0df585c9a632fcc6b92a2b7012ed89e2b2f6167 Mon Sep 17 00:00:00 2001 From: Michael Langmayr Date: Mon, 19 Aug 2024 13:56:54 -0700 Subject: [PATCH 108/124] prototyping in progress --- camerad/archon.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/camerad/archon.cpp b/camerad/archon.cpp index 554969b5..0e9fee06 100644 --- a/camerad/archon.cpp +++ b/camerad/archon.cpp @@ -3153,13 +3153,14 @@ namespace Archon { error = ERROR; break; // break out of for loop - } else if (strncmp(header, check, 4) != 0) { - message.str(""); message << "Archon command-reply mismatch reading " << (frame_type==Camera::FRAME_RAW?"raw ":"image ") - << " data. header=" << header << " check=" << check; - this->camera.log_error( function, message.str() ); - error = ERROR; - break; // break out of for loop } + // else if (strncmp(header, check, 4) != 0) { + // message.str(""); message << "Archon command-reply mismatch reading " << (frame_type==Camera::FRAME_RAW?"raw ":"image ") + // << " data. header=" << header << " check=" << check; + // this->camera.log_error( function, message.str() ); + // error = ERROR; + // break; // break out of for loop + // } // Read the frame contents // From e856196d8b6bf07f533f8b27ebbdd6101e46d69e Mon Sep 17 00:00:00 2001 From: Michael Langmayr Date: Tue, 20 Aug 2024 10:48:16 -0700 Subject: [PATCH 109/124] prototyping in progress --- camerad/archon.cpp | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/camerad/archon.cpp b/camerad/archon.cpp index 0e9fee06..b0315fd0 100644 --- a/camerad/archon.cpp +++ b/camerad/archon.cpp @@ -2670,8 +2670,6 @@ namespace Archon { std::stringstream message; long error = NO_ERROR; - logwrite( function, "READ FRAME" ); - if ( ! this->modeselected ) { this->camera.log_error( function, "no mode selected" ); return ERROR; @@ -3154,13 +3152,13 @@ namespace Archon { break; // break out of for loop } - // else if (strncmp(header, check, 4) != 0) { - // message.str(""); message << "Archon command-reply mismatch reading " << (frame_type==Camera::FRAME_RAW?"raw ":"image ") - // << " data. header=" << header << " check=" << check; - // this->camera.log_error( function, message.str() ); - // error = ERROR; - // break; // break out of for loop - // } + else if (strncmp(header, check, 4) != 0) { + message.str(""); message << "Archon command-reply mismatch reading " << (frame_type==Camera::FRAME_RAW?"raw ":"image ") + << " data. header=" << header << " check=" << check; + this->camera.log_error( function, message.str() ); + error = ERROR; + break; // break out of for loop + } // Read the frame contents // From 366b8b4be6860e5689a5b6ab61c4c9367b7441fd Mon Sep 17 00:00:00 2001 From: Michael Langmayr Date: Tue, 20 Aug 2024 10:54:30 -0700 Subject: [PATCH 110/124] prototyping in progress --- camerad/archon.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/camerad/archon.cpp b/camerad/archon.cpp index b0315fd0..f0d56ecf 100644 --- a/camerad/archon.cpp +++ b/camerad/archon.cpp @@ -3153,9 +3153,11 @@ namespace Archon { } else if (strncmp(header, check, 4) != 0) { + char buffer[1000]; message.str(""); message << "Archon command-reply mismatch reading " << (frame_type==Camera::FRAME_RAW?"raw ":"image ") << " data. header=" << header << " check=" << check; - this->camera.log_error( function, message.str() ); + this->archon.Read(buffer, 1000); + this->camera.log_error( function, message.str() + " : " + buffer ); error = ERROR; break; // break out of for loop } From 3e1100663f9bf11f5a12cc897faee1c801caec77 Mon Sep 17 00:00:00 2001 From: Michael Langmayr Date: Tue, 20 Aug 2024 10:58:00 -0700 Subject: [PATCH 111/124] prototyping in progress --- camerad/archon.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/camerad/archon.cpp b/camerad/archon.cpp index f0d56ecf..9c092543 100644 --- a/camerad/archon.cpp +++ b/camerad/archon.cpp @@ -3134,7 +3134,7 @@ namespace Archon { if (strncmp(header, "archon.Read(autofetch_header, 1260); + retval = this->archon.Read(autofetch_header, 1264); std::string autofetch_header_str(autofetch_header); logwrite( function, "AUTOFETCH HEADER: " + std::string(header) + autofetch_header_str); From 94b4230e6c2ce6980aa025fc870dd0842e9997a5 Mon Sep 17 00:00:00 2001 From: Michael Langmayr Date: Tue, 20 Aug 2024 11:00:28 -0700 Subject: [PATCH 112/124] prototyping in progress --- camerad/archon.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/camerad/archon.cpp b/camerad/archon.cpp index 9c092543..63040512 100644 --- a/camerad/archon.cpp +++ b/camerad/archon.cpp @@ -3134,7 +3134,7 @@ namespace Archon { if (strncmp(header, "archon.Read(autofetch_header, 1264); + retval = this->archon.Read(autofetch_header, 1268); std::string autofetch_header_str(autofetch_header); logwrite( function, "AUTOFETCH HEADER: " + std::string(header) + autofetch_header_str); From 2aa6f5367af4688b5ce18e12c118edcdb86ca04e Mon Sep 17 00:00:00 2001 From: Michael Langmayr Date: Tue, 20 Aug 2024 14:31:16 -0700 Subject: [PATCH 113/124] prototyping in progress --- camerad/archon.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/camerad/archon.cpp b/camerad/archon.cpp index 63040512..0365b917 100644 --- a/camerad/archon.cpp +++ b/camerad/archon.cpp @@ -3134,7 +3134,7 @@ namespace Archon { if (strncmp(header, "archon.Read(autofetch_header, 1268); + retval = this->archon.Read(autofetch_header, '\n'); std::string autofetch_header_str(autofetch_header); logwrite( function, "AUTOFETCH HEADER: " + std::string(header) + autofetch_header_str); From 7dc4fd8b575d3ab3db1a8fda548deab810428e1e Mon Sep 17 00:00:00 2001 From: Michael Langmayr Date: Tue, 20 Aug 2024 14:42:42 -0700 Subject: [PATCH 114/124] prototyping in progress --- camerad/archon.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/camerad/archon.cpp b/camerad/archon.cpp index 0365b917..e189f76a 100644 --- a/camerad/archon.cpp +++ b/camerad/archon.cpp @@ -3134,8 +3134,9 @@ namespace Archon { if (strncmp(header, "archon.Read(autofetch_header, '\n'); - std::string autofetch_header_str(autofetch_header); + std::string autofetch_header_str; + retval = this->archon.Read(autofetch_header_str, '\n'); + // autofetch_header_str(autofetch_header); logwrite( function, "AUTOFETCH HEADER: " + std::string(header) + autofetch_header_str); // Read next header From 6bbd2f6e1967ee2c33a0478186a64d6dbffcd2b1 Mon Sep 17 00:00:00 2001 From: Michael Langmayr Date: Tue, 20 Aug 2024 15:07:25 -0700 Subject: [PATCH 115/124] cleaup --- camerad/archon.cpp | 52 ++++++++++++++++------------------------------ 1 file changed, 18 insertions(+), 34 deletions(-) diff --git a/camerad/archon.cpp b/camerad/archon.cpp index e189f76a..c1fb0d31 100644 --- a/camerad/archon.cpp +++ b/camerad/archon.cpp @@ -16,7 +16,6 @@ #include #include #include -#include namespace Archon { @@ -1143,8 +1142,6 @@ namespace Archon { std::stringstream scmd; long error = NO_ERROR; - logwrite( function, "PREP PARAMETER: " + paramname ); - // Prepare to apply it to the system -- will be loaded on next EXTLOAD signal // scmd << "FASTPREPPARAM " << paramname << " " << value; @@ -2264,13 +2261,13 @@ namespace Archon { // send FRAME command to get frame buffer status // - if (!this->is_autofetch) { + if (this->is_autofetch) { + logwrite( function, "AUTOFETCH MODE: not sending FRAME command"); + } else { if ( (error = this->archon_cmd(FRAME, reply)) ) { if ( error == ERROR ) logwrite( function, "ERROR: sending FRAME command" ); // don't log here if BUSY return error; } - } else { - logwrite( function, "get_frame_status: AUTOFETCH ON, not sending FRAME command"); } // First Tokenize breaks the single, continuous reply string into vector of individual strings, @@ -2602,8 +2599,6 @@ namespace Archon { uint64_t maxoffset = this->frame.bufbase[this->frame.index]; uint64_t maxaddr = maxoffset + maxblocks; - logwrite( function, "FETCH"); - if ( bufaddr > maxaddr ) { message.str(""); message << "fetch Archon buffer requested address 0x" << std::hex << bufaddr << " exceeds 0x" << maxaddr; this->camera.log_error( function, message.str() ); @@ -2771,8 +2766,6 @@ namespace Archon { long error = ERROR; int num_detect = this->modemap[this->camera_info.current_observing_mode].geometry.num_detect; - logwrite( function, "H READ FRAME"); - // Archon buffer number of the last frame read into memory // Archon frame index is 1 biased so add 1 here bufready = this->frame.index + 1; @@ -2950,9 +2943,6 @@ namespace Archon { long Interface::read_frame(Camera::frame_type_t frame_type) { std::string function = "Archon::Interface::read_frame"; std::stringstream message; - - logwrite( function, "READ FRAME WITH FRAME TYPE" ); - int retval; int bufready; char check[5], header[5]; @@ -3073,6 +3063,7 @@ namespace Archon { totalbytesread = 0; std::cerr << "reading bytes: "; for (block=0; blockis_autofetch) { // Are there data to read? if ( (retval=this->archon.Poll()) <= 0) { @@ -3111,7 +3102,6 @@ namespace Archon { if ( error != NO_ERROR ) break; // needed to also break out of for loop on error // Check message header - // if (this->is_autofetch) { logwrite( function, "replaced header: " + std::to_string(this->msgref) + " with: is_autofetch) { - // Read autofetch header - char autofetch_header[1260]; - - logwrite( function, "READ FRAME: AUTOFETCH MODE"); - if (strncmp(header, "archon.Read(autofetch_header_str, '\n'); - // autofetch_header_str(autofetch_header); - logwrite( function, "AUTOFETCH HEADER: " + std::string(header) + autofetch_header_str); // Read next header - this->archon.Read(header, 4); + if ( (retval=this->archon.Read(header, 4)) != 4 ) { + message.str(""); message << "code " << retval << " reading Archon frame header"; + this->camera.log_error( function, message.str() ); + error = ERROR; + break; // break out of for loop + } } } - if (header[0] == '?') { // Archon retured an error message.str(""); message << "Archon returned \'?\' reading " << (frame_type==Camera::FRAME_RAW?"raw ":"image ") << " data"; this->camera.log_error( function, message.str() ); @@ -3152,13 +3140,10 @@ namespace Archon { error = ERROR; break; // break out of for loop - } - else if (strncmp(header, check, 4) != 0) { - char buffer[1000]; + } else if (strncmp(header, check, 4) != 0) { message.str(""); message << "Archon command-reply mismatch reading " << (frame_type==Camera::FRAME_RAW?"raw ":"image ") << " data. header=" << header << " check=" << check; - this->archon.Read(buffer, 1000); - this->camera.log_error( function, message.str() + " : " + buffer ); + this->camera.log_error( function, message.str() ); error = ERROR; break; // break out of for loop } @@ -3778,8 +3763,6 @@ namespace Archon { std::string mode = this->camera_info.current_observing_mode; // local copy for convenience - logwrite( function, "RUN EXPOSE" ); - if ( ! this->modeselected ) { this->camera.log_error( function, "no mode selected" ); return ERROR; @@ -3870,6 +3853,7 @@ namespace Archon { // this->camera_info.extension = 0; + // Don't send get_frame_status in autofetch mode if (!this->is_autofetch) { error = this->get_frame_status(); // TODO is this needed here? } @@ -3889,7 +3873,6 @@ namespace Archon { return error; } - // get system time and Archon's timer after exposure starts // start_timer is used to determine when the exposure has ended, in wait_for_exposure() // @@ -5295,9 +5278,11 @@ namespace Archon { while (!done && !this->abort) { if (this->is_longexposure) usleep( 10000 ); // reduces polling frequency + // Don't run get_frame status in autofetch mode if (this->is_autofetch) { - logwrite( function, "AUTOFETCH MODE: Bytes ready on socket: " + std::to_string(this->archon.Bytes_ready())); + // Check if data is ready on socket if (this->archon.Bytes_ready() > 0) { + logwrite( function, "AUTOFETCH MODE: Bytes ready on socket: " + std::to_string(this->archon.Bytes_ready())); done = true; break; } @@ -5360,7 +5345,6 @@ namespace Archon { // After exiting while loop, one update to ensure accurate ASYNC message // reporting of LINECOUNT. // - logwrite( function, "EXITED WHILE LOOP" ); // don't run get_frame_status() in autofetch mode if (!this->is_autofetch) { From a9b82d035e69521d8aeb8e17bcf7d77af24e3f5e Mon Sep 17 00:00:00 2001 From: Michael Langmayr Date: Tue, 20 Aug 2024 15:44:47 -0700 Subject: [PATCH 116/124] cleaup --- camerad/archon.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/camerad/archon.cpp b/camerad/archon.cpp index c1fb0d31..f76e07b9 100644 --- a/camerad/archon.cpp +++ b/camerad/archon.cpp @@ -2801,7 +2801,6 @@ namespace Archon { << "0x" << std::uppercase << std::hex << bufblocks << " blocks from bufaddr=0x" << bufaddr; logwrite(function, message.str()); - // send the FETCH command. // This will take the archon_busy semaphore, but not release it -- must release in this function! // From a99c4d9df65f868cb985a2116dc9e3f9f19a2fe3 Mon Sep 17 00:00:00 2001 From: Michael Langmayr Date: Wed, 21 Aug 2024 08:59:31 -0700 Subject: [PATCH 117/124] cleaup --- camerad/archon.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/camerad/archon.cpp b/camerad/archon.cpp index f76e07b9..059e1a4c 100644 --- a/camerad/archon.cpp +++ b/camerad/archon.cpp @@ -3045,6 +3045,7 @@ namespace Archon { << "0x" << std::uppercase << std::hex << bufblocks << " blocks from bufaddr=0x" << bufaddr; logwrite(function, message.str()); + // Dont't send fetch command in autofetch mode if (!this->is_autofetch) { // send the FETCH command. // This will take the archon_busy semaphore, but not release it -- must release in this function! @@ -3062,7 +3063,7 @@ namespace Archon { totalbytesread = 0; std::cerr << "reading bytes: "; for (block=0; blockis_autofetch) { // Are there data to read? if ( (retval=this->archon.Poll()) <= 0) { From 04efb4692f430265f85c5b01da725cc57196bb6b Mon Sep 17 00:00:00 2001 From: Michael Langmayr Date: Wed, 21 Aug 2024 12:38:52 -0700 Subject: [PATCH 118/124] prototyping in progress --- camerad/archon.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/camerad/archon.cpp b/camerad/archon.cpp index 059e1a4c..33df8c6c 100644 --- a/camerad/archon.cpp +++ b/camerad/archon.cpp @@ -4545,6 +4545,8 @@ namespace Archon { std::string mode = this->camera_info.current_observing_mode; // local copy for convenience + logwrite( function, "H Expose"); + if ( ! this->modeselected ) { this->camera.log_error( function, "no mode selected" ); return ERROR; From 5ea9409636bd77fa914c938d7ca112d82ace039c Mon Sep 17 00:00:00 2001 From: Michael Langmayr Date: Wed, 21 Aug 2024 12:58:07 -0700 Subject: [PATCH 119/124] prototyping in progress --- camerad/archon.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/camerad/archon.cpp b/camerad/archon.cpp index 33df8c6c..b0811da8 100644 --- a/camerad/archon.cpp +++ b/camerad/archon.cpp @@ -3763,6 +3763,8 @@ namespace Archon { std::string mode = this->camera_info.current_observing_mode; // local copy for convenience + logwrite( function, "EXPOSE"); + if ( ! this->modeselected ) { this->camera.log_error( function, "no mode selected" ); return ERROR; @@ -3864,6 +3866,8 @@ namespace Archon { } this->lastframe = this->frame.bufframen[this->frame.index]; // save the last frame number acquired (wait_for_readout will need this) + logwrite( function, "PREP PRARAMETERS"); + // initiate the exposure here // error = this->prep_parameter(this->exposeparam, nseqstr); @@ -3873,6 +3877,8 @@ namespace Archon { return error; } + logwrite( function, "PREP PRARAMETERS: DONE"); + // get system time and Archon's timer after exposure starts // start_timer is used to determine when the exposure has ended, in wait_for_exposure() // From 6aceba52bc72dca54f7bcc8d1495f91069a80083 Mon Sep 17 00:00:00 2001 From: Michael Langmayr Date: Wed, 21 Aug 2024 13:06:08 -0700 Subject: [PATCH 120/124] prototyping in progress --- camerad/archon.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/camerad/archon.cpp b/camerad/archon.cpp index b0811da8..2bf952eb 100644 --- a/camerad/archon.cpp +++ b/camerad/archon.cpp @@ -3826,6 +3826,7 @@ namespace Archon { if ( this->longexposure( lexp, retval ) != NO_ERROR ) { logwrite( function, "ERROR: setting longexposure" ); return ERROR; } } + logwrite( function, "SEQUENCE NUMBERS"); // If nseq_in is not supplied then set nseq to 1. // Add any pre-exposures onto the number of sequences. // @@ -3855,6 +3856,8 @@ namespace Archon { // this->camera_info.extension = 0; + logwrite( function, "NOT GETTING FRAME STATUS"); + // Don't send get_frame_status in autofetch mode if (!this->is_autofetch) { error = this->get_frame_status(); // TODO is this needed here? From 257aeba38fc7a7e48b798902ec661035719a5b1b Mon Sep 17 00:00:00 2001 From: Michael Langmayr Date: Thu, 22 Aug 2024 10:24:37 -0700 Subject: [PATCH 121/124] prototyping in progress --- camerad/archon.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/camerad/archon.cpp b/camerad/archon.cpp index 2bf952eb..f823dd6d 100644 --- a/camerad/archon.cpp +++ b/camerad/archon.cpp @@ -3103,7 +3103,6 @@ namespace Archon { // Check message header if (this->is_autofetch) { - logwrite( function, "replaced header: " + std::to_string(this->msgref) + " with: msgref); From 376d52fc915aba6e64b9977e6758d153f6c453b6 Mon Sep 17 00:00:00 2001 From: Michael Langmayr Date: Thu, 22 Aug 2024 14:33:27 -0700 Subject: [PATCH 122/124] cleaup --- .gitignore | 1 + camerad/archon.cpp | 13 ------------- 2 files changed, 1 insertion(+), 13 deletions(-) diff --git a/.gitignore b/.gitignore index 706fd07f..f096120f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ .idea .vscode +cmake-build* diff --git a/camerad/archon.cpp b/camerad/archon.cpp index 2bf952eb..08c494e0 100644 --- a/camerad/archon.cpp +++ b/camerad/archon.cpp @@ -3763,8 +3763,6 @@ namespace Archon { std::string mode = this->camera_info.current_observing_mode; // local copy for convenience - logwrite( function, "EXPOSE"); - if ( ! this->modeselected ) { this->camera.log_error( function, "no mode selected" ); return ERROR; @@ -3825,8 +3823,6 @@ namespace Archon { std::string retval; if ( this->longexposure( lexp, retval ) != NO_ERROR ) { logwrite( function, "ERROR: setting longexposure" ); return ERROR; } } - - logwrite( function, "SEQUENCE NUMBERS"); // If nseq_in is not supplied then set nseq to 1. // Add any pre-exposures onto the number of sequences. // @@ -3856,8 +3852,6 @@ namespace Archon { // this->camera_info.extension = 0; - logwrite( function, "NOT GETTING FRAME STATUS"); - // Don't send get_frame_status in autofetch mode if (!this->is_autofetch) { error = this->get_frame_status(); // TODO is this needed here? @@ -3869,8 +3863,6 @@ namespace Archon { } this->lastframe = this->frame.bufframen[this->frame.index]; // save the last frame number acquired (wait_for_readout will need this) - logwrite( function, "PREP PRARAMETERS"); - // initiate the exposure here // error = this->prep_parameter(this->exposeparam, nseqstr); @@ -3880,8 +3872,6 @@ namespace Archon { return error; } - logwrite( function, "PREP PRARAMETERS: DONE"); - // get system time and Archon's timer after exposure starts // start_timer is used to determine when the exposure has ended, in wait_for_exposure() // @@ -4554,8 +4544,6 @@ namespace Archon { std::string mode = this->camera_info.current_observing_mode; // local copy for convenience - logwrite( function, "H Expose"); - if ( ! this->modeselected ) { this->camera.log_error( function, "no mode selected" ); return ERROR; @@ -5370,7 +5358,6 @@ namespace Archon { } } - if ( error != NO_ERROR ) { return error; } From 14ca5850704a1e76d17d366a2fe07b49780d38fa Mon Sep 17 00:00:00 2001 From: Michael Langmayr Date: Thu, 22 Aug 2024 14:35:25 -0700 Subject: [PATCH 123/124] cleaup --- camerad/archon.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/camerad/archon.cpp b/camerad/archon.cpp index a431eeff..940771f4 100644 --- a/camerad/archon.cpp +++ b/camerad/archon.cpp @@ -2801,13 +2801,15 @@ namespace Archon { << "0x" << std::uppercase << std::hex << bufblocks << " blocks from bufaddr=0x" << bufaddr; logwrite(function, message.str()); - // send the FETCH command. - // This will take the archon_busy semaphore, but not release it -- must release in this function! - // - error = this->fetch(bufaddr, bufblocks); - if (error != NO_ERROR) { + if (!this->is_autofetch) { + // send the FETCH command. + // This will take the archon_busy semaphore, but not release it -- must release in this function! + // + error = this->fetch(bufaddr, bufblocks); + if (error != NO_ERROR) { logwrite(function, "ERROR: fetching Archon buffer"); return error; + } } // Read the data from the connected socket into memory, one block at a time From 6f7ab57b90aea155ebc7e408a7d768952799e62c Mon Sep 17 00:00:00 2001 From: Michael Langmayr Date: Thu, 22 Aug 2024 14:37:12 -0700 Subject: [PATCH 124/124] cleaup --- camerad/archon.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/camerad/archon.cpp b/camerad/archon.cpp index 940771f4..073210b5 100644 --- a/camerad/archon.cpp +++ b/camerad/archon.cpp @@ -2695,11 +2695,9 @@ namespace Archon { } } else { - // IMAGE, or IMAGE+RAW - // datacube was already set = true in the expose function - error = this->read_frame(Camera::FRAME_IMAGE); - - // read image frame + // IMAGE, or IMAGE+RAW + // datacube was already set = true in the expose function + error = this->read_frame(Camera::FRAME_IMAGE); // read image frame if ( error != NO_ERROR ) { logwrite( function, "ERROR: reading image frame" ); return error; } error = this->write_frame(); // write image frame if ( error != NO_ERROR ) { logwrite( function, "ERROR: writing image frame" ); return error; }