From 0bed4e5a743821a877d80a46dc8442d3593414b4 Mon Sep 17 00:00:00 2001 From: David Hale Date: Wed, 26 Feb 2025 12:24:22 -0800 Subject: [PATCH] adds firmware checksum (md5) to FITS header --- camerad/archon.cpp | 12 +++++++----- utils/utilities.cpp | 7 +------ 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/camerad/archon.cpp b/camerad/archon.cpp index 0a691ad6..2637e0f5 100644 --- a/camerad/archon.cpp +++ b/camerad/archon.cpp @@ -1340,7 +1340,7 @@ namespace Archon { * */ long Interface::load_acf(std::string acffile) { - std::string function = "Archon::Interface::load_acf"; + const std::string function("Archon::Interface::load_acf"); std::stringstream message; std::fstream filestream; // I/O stream class std::string line; // the line read from the acffile @@ -1750,11 +1750,13 @@ namespace Archon { logwrite(function, "loaded Archon config file OK"); this->firmwareloaded = true; - // add to systemkeys keyword database + // add firmware filename and checksum to systemkeys keyword database // - std::stringstream keystr; - keystr << "FIRMWARE=" << acffile << "// controller firmware"; - this->systemkeys.addkey( keystr.str() ); + this->systemkeys.addkey( "FIRMWARE=" + acffile + "// controller firmware" ); + + std::string hash; + md5_file( acffile, hash ); + this->systemkeys.addkey( "FIRM_MD5=" + hash + "// MD5 checksum of firmware" ); } // If there was an Archon error then read the Archon error log diff --git a/utils/utilities.cpp b/utils/utilities.cpp index a4311ef5..b732fbf2 100644 --- a/utils/utilities.cpp +++ b/utils/utilities.cpp @@ -747,13 +747,9 @@ long md5_file(const std::string &filename, std::string &hash) { } instream.close(); - } catch (std::ifstream::failure &e) { - std::cerr << "md5_file( " << filename << " ): " << e.what() << "\n"; - hash = "ERROR"; - return 1; } catch (std::exception &e) { - std::cerr << "md5_file( " << filename << " ): " << e.what() << "\n"; + std::cerr << "ERROR md5_file( " << filename << " ): " << e.what() << "\n"; hash = "ERROR"; return 1; } @@ -772,7 +768,6 @@ long md5_file(const std::string &filename, std::string &hash) { return 0; } - /***** md5_file *************************************************************/