Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
132 commits
Select commit Hold shift + click to select a range
ce9ff31
add autofetch command to camerad
mikelangmayr Aug 7, 2024
53dba41
start adding autofetch support
mikelangmayr Aug 7, 2024
0689112
find buffer variable
mikelangmayr Aug 8, 2024
e498cd7
Merge branch 'main' into feature_autofetch
Aug 9, 2024
5131c74
prototyping in progress
Aug 9, 2024
6afa165
prototyping in progress
mikelangmayr Aug 9, 2024
d7d621b
prototyping in progress
mikelangmayr Aug 9, 2024
428353f
prototyping in progress
mikelangmayr Aug 9, 2024
a89a39b
prototyping in progress
mikelangmayr Aug 9, 2024
e4bc048
prototyping in progress
mikelangmayr Aug 9, 2024
29bde85
prototyping in progress
mikelangmayr Aug 9, 2024
3c6fe8e
prototyping in progress
mikelangmayr Aug 12, 2024
6a572bc
prototyping in progress
mikelangmayr Aug 12, 2024
a1c56ce
prototyping in progress
mikelangmayr Aug 12, 2024
85a901a
prototyping in progress
mikelangmayr Aug 12, 2024
c1104fe
prototyping in progress
mikelangmayr Aug 12, 2024
2398b3f
prototyping in progress
mikelangmayr Aug 12, 2024
be4f325
prototyping in progress
mikelangmayr Aug 12, 2024
cdcf655
prototyping in progress
mikelangmayr Aug 12, 2024
a155039
prototyping in progress
mikelangmayr Aug 12, 2024
94cf692
prototyping in progress
mikelangmayr Aug 13, 2024
520e5ec
prototyping in progress
mikelangmayr Aug 13, 2024
ddb7f04
prototyping in progress
mikelangmayr Aug 13, 2024
d6c5987
Merge branch 'main' into feature_autofetch
mikelangmayr Aug 13, 2024
c79e2ec
prototyping in progress
mikelangmayr Aug 13, 2024
613c450
prototyping in progress
mikelangmayr Aug 13, 2024
248bb3d
prototyping in progress
mikelangmayr Aug 13, 2024
f1e0bec
prototyping in progress
mikelangmayr Aug 13, 2024
cf960ad
prototyping in progress
mikelangmayr Aug 13, 2024
18deaa5
prototyping in progress
mikelangmayr Aug 13, 2024
f918bf8
prototyping in progress
mikelangmayr Aug 13, 2024
eff0a25
prototyping in progress
mikelangmayr Aug 13, 2024
2d107fb
prototyping in progress
mikelangmayr Aug 13, 2024
7d31568
prototyping in progress
mikelangmayr Aug 13, 2024
781a8bf
prototyping in progress
mikelangmayr Aug 13, 2024
7b041c1
prototyping in progress
mikelangmayr Aug 13, 2024
6770e6e
prototyping in progress
mikelangmayr Aug 13, 2024
94274a2
prototyping in progress
mikelangmayr Aug 13, 2024
697ac39
prototyping in progress
mikelangmayr Aug 13, 2024
740d104
prototyping in progress
mikelangmayr Aug 13, 2024
3f743b0
prototyping in progress
mikelangmayr Aug 13, 2024
3650647
prototyping in progress
mikelangmayr Aug 14, 2024
a78314c
Merge branch 'main' into feature_autofetch
mikelangmayr Aug 14, 2024
7968ec3
prototyping in progress
mikelangmayr Aug 14, 2024
3951204
prototyping in progress
mikelangmayr Aug 14, 2024
4577ec3
prototyping in progress
mikelangmayr Aug 14, 2024
cbb0bc4
prototyping in progress
mikelangmayr Aug 14, 2024
24d5e14
prototyping in progress
mikelangmayr Aug 14, 2024
a320c6c
prototyping in progress
mikelangmayr Aug 14, 2024
fc8a80d
prototyping in progress
mikelangmayr Aug 14, 2024
ddc9f91
prototyping in progress
mikelangmayr Aug 14, 2024
73cfe58
prototyping in progress
mikelangmayr Aug 14, 2024
9a9dacd
prototyping in progress
mikelangmayr Aug 14, 2024
e9a938a
prototyping in progress
mikelangmayr Aug 14, 2024
9ec1151
prototyping in progress
mikelangmayr Aug 14, 2024
9118f5a
prototyping in progress
mikelangmayr Aug 14, 2024
426bfde
prototyping in progress
mikelangmayr Aug 14, 2024
343a208
prototyping in progress
mikelangmayr Aug 14, 2024
5d28209
prototyping in progress
mikelangmayr Aug 14, 2024
ef84493
prototyping in progress
mikelangmayr Aug 14, 2024
ab9c55f
prototyping in progress
mikelangmayr Aug 14, 2024
40cedbe
prototyping in progress
mikelangmayr Aug 14, 2024
dad57ec
prototyping in progress
mikelangmayr Aug 14, 2024
29f891b
prototyping in progress
mikelangmayr Aug 14, 2024
460b56a
prototyping in progress
mikelangmayr Aug 14, 2024
0dd949f
prototyping in progress
mikelangmayr Aug 15, 2024
a4797c2
prototyping in progress
mikelangmayr Aug 15, 2024
e49b189
prototyping in progress
mikelangmayr Aug 15, 2024
6de722c
prototyping in progress
mikelangmayr Aug 15, 2024
7ae3247
prototyping in progress
mikelangmayr Aug 15, 2024
54b792e
prototyping in progress
mikelangmayr Aug 15, 2024
adc0e67
prototyping in progress
mikelangmayr Aug 15, 2024
7ed5b43
prototyping in progress
mikelangmayr Aug 15, 2024
b555159
prototyping in progress
mikelangmayr Aug 15, 2024
251d771
prototyping in progress
mikelangmayr Aug 15, 2024
8f55582
prototyping in progress
mikelangmayr Aug 15, 2024
e3c788f
Merge branch 'main' into feature_autofetch
mikelangmayr Aug 16, 2024
f73c5fa
fixed merge conflicts
mikelangmayr Aug 16, 2024
b4a2945
Merge branch 'main' into feature_autofetch
mikelangmayr Aug 16, 2024
4972415
prototyping in progress
mikelangmayr Aug 16, 2024
9c557bb
prototyping in progress
mikelangmayr Aug 16, 2024
357820d
prototyping in progress
mikelangmayr Aug 16, 2024
fc8b922
prototyping in progress
mikelangmayr Aug 16, 2024
d72f6fb
prototyping in progress
mikelangmayr Aug 16, 2024
18a1c09
prototyping in progress
mikelangmayr Aug 16, 2024
44a858d
prototyping in progress
mikelangmayr Aug 16, 2024
8aac912
prototyping in progress
mikelangmayr Aug 16, 2024
85b8fdd
prototyping in progress
mikelangmayr Aug 16, 2024
57c33c9
move autofetch read to read_frame()
mikelangmayr Aug 16, 2024
363dfe7
move autofetch read to read_frame()
mikelangmayr Aug 16, 2024
247b76b
prototyping in progress
mikelangmayr Aug 16, 2024
9db406a
prototyping in progress
mikelangmayr Aug 16, 2024
1933ed4
prototyping in progress
mikelangmayr Aug 16, 2024
f72ff11
prototyping in progress
mikelangmayr Aug 16, 2024
1e578c5
remove custom make clean target
mikelangmayr Aug 16, 2024
f0be204
cleanup
mikelangmayr Aug 16, 2024
c0f8a6c
prototyping in progress
mikelangmayr Aug 19, 2024
a026db0
prototyping in progress
mikelangmayr Aug 19, 2024
dddaf89
remove logging all headers
mikelangmayr Aug 19, 2024
b92c6de
prototyping in progress
mikelangmayr Aug 19, 2024
61ac27b
prototyping in progress
mikelangmayr Aug 19, 2024
5ae49e9
prototyping in progress
mikelangmayr Aug 19, 2024
3df8014
prototyping in progress
mikelangmayr Aug 19, 2024
e9f8a8d
prototyping in progress
mikelangmayr Aug 19, 2024
aaf3582
prototyping in progress
mikelangmayr Aug 19, 2024
92e705f
prototyping in progress
mikelangmayr Aug 19, 2024
7dda939
prototyping in progress
mikelangmayr Aug 19, 2024
8dbddda
prototyping in progress
mikelangmayr Aug 19, 2024
eca3d15
prototyping in progress
mikelangmayr Aug 19, 2024
ff2bdde
prototyping in progress
mikelangmayr Aug 19, 2024
bcffb94
prototyping in progress
mikelangmayr Aug 19, 2024
9b12c6d
prototyping in progress
mikelangmayr Aug 19, 2024
b0df585
prototyping in progress
mikelangmayr Aug 19, 2024
4b82dd5
Merge branch 'main' into feature_autofetch
mikelangmayr Aug 20, 2024
e856196
prototyping in progress
mikelangmayr Aug 20, 2024
366b8b4
prototyping in progress
mikelangmayr Aug 20, 2024
3e11006
prototyping in progress
mikelangmayr Aug 20, 2024
94b4230
prototyping in progress
mikelangmayr Aug 20, 2024
2aa6f53
prototyping in progress
mikelangmayr Aug 20, 2024
7dc4fd8
prototyping in progress
mikelangmayr Aug 20, 2024
6bbd2f6
cleaup
mikelangmayr Aug 20, 2024
a9b82d0
cleaup
mikelangmayr Aug 20, 2024
a99c4d9
cleaup
mikelangmayr Aug 21, 2024
04efb46
prototyping in progress
mikelangmayr Aug 21, 2024
5ea9409
prototyping in progress
mikelangmayr Aug 21, 2024
6aceba5
prototyping in progress
mikelangmayr Aug 21, 2024
257aeba
prototyping in progress
mikelangmayr Aug 22, 2024
376d52f
cleaup
mikelangmayr Aug 22, 2024
f952259
Merge branch 'feature_autofetch' of github.com:CaltechOpticalObservat…
mikelangmayr Aug 22, 2024
14ca585
cleaup
mikelangmayr Aug 22, 2024
6f7ab57
cleaup
mikelangmayr Aug 22, 2024
bdb25c4
Merge branch 'main' into feature_autofetch
mikelangmayr Aug 22, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.idea
.vscode
cmake-build*
163 changes: 108 additions & 55 deletions camerad/archon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1022,14 +1022,13 @@ 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 {
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;

Expand Down Expand Up @@ -2261,9 +2260,14 @@ 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) {
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;
}
}

// First Tokenize breaks the single, continuous reply string into vector of individual strings,
Expand Down Expand Up @@ -2622,10 +2626,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;
Expand Down Expand Up @@ -2793,14 +2800,14 @@ namespace Archon {
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
Expand Down Expand Up @@ -2831,7 +2838,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
Expand Down Expand Up @@ -2995,11 +3002,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.
Expand Down Expand Up @@ -3035,13 +3045,16 @@ 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 ) {
logwrite( function, "ERROR: fetching Archon buffer" );
return error;
// 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!
//
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
Expand All @@ -3050,23 +3063,25 @@ namespace Archon {
totalbytesread = 0;
std::cerr << "reading bytes: ";
for (block=0; block<bufblocks; block++) {

// Are there data to read?
if ( (retval=this->archon.Poll()) <= 0) {
if (retval==0) {
// Disable polling in autofetch mode
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
Expand All @@ -3087,14 +3102,36 @@ namespace Archon {
if ( error != NO_ERROR ) break; // needed to also break out of for loop on error

// Check message header
//
SNPRINTF(check, "<%02X:", this->msgref)
if (this->is_autofetch) {
sprintf(check, "<XF:");
} else {
SNPRINTF(check, "<%02X:", this->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() );
error = ERROR;
break; // break out of for loop
}

// Read autofetch header
if (this->is_autofetch) {
if (strncmp(header, "<SFA", 4) == 0) {
logwrite( function, "AUTOFETCH HEADER: FOUND" );
std::string autofetch_header_str;
retval = this->archon.Read(autofetch_header_str, '\n');

// Read next header
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() );
Expand Down Expand Up @@ -3794,7 +3831,6 @@ namespace Archon {
return ERROR;
}
}

// If nseq_in is not supplied then set nseq to 1.
// Add any pre-exposures onto the number of sequences.
//
Expand Down Expand Up @@ -3824,7 +3860,10 @@ namespace Archon {
//
this->camera_info.extension = 0;

error = this->get_frame_status(); // TODO is this needed here?
// Don't send get_frame_status in autofetch mode
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" );
Expand Down Expand Up @@ -5271,9 +5310,19 @@ namespace Archon {
// The last frame was recorded before the readout was triggered in get_frame().
//
while (!done && !this->abort) {

if ( this->camera_info.exposure_time.is_longexposure() ) std::this_thread::sleep_for( std::chrono::microseconds( 10 ) );
error = this->get_frame_status();

// Don't run get_frame status in autofetch mode
if (this->is_autofetch) {
// 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;
}
} else {
error = this->get_frame_status();
}

if (error == ERROR) {
done = true;
Expand Down Expand Up @@ -5317,14 +5366,18 @@ namespace Archon {
// After exiting while loop, one update to ensure accurate ASYNC message
// reporting of LINECOUNT.
//
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 ) {
Expand Down
7 changes: 7 additions & 0 deletions camerad/camerad.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -755,6 +755,13 @@ 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( " ");
}
}
else if ( cmd == "fetchlog" ) {
ret = server.fetchlog();
}
Expand Down