Skip to content

Commit 339f9e6

Browse files
adds firmware checksum (md5) to FITS header (#51)
1 parent 86c3a6b commit 339f9e6

2 files changed

Lines changed: 8 additions & 11 deletions

File tree

camerad/archon.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1350,7 +1350,7 @@ namespace Archon {
13501350
*
13511351
*/
13521352
long Interface::load_acf(std::string acffile) {
1353-
std::string function = "Archon::Interface::load_acf";
1353+
const std::string function("Archon::Interface::load_acf");
13541354
std::stringstream message;
13551355
std::fstream filestream; // I/O stream class
13561356
std::string line; // the line read from the acffile
@@ -1760,11 +1760,13 @@ namespace Archon {
17601760
logwrite(function, "loaded Archon config file OK");
17611761
this->firmwareloaded = true;
17621762

1763-
// add to systemkeys keyword database
1763+
// add firmware filename and checksum to systemkeys keyword database
17641764
//
1765-
std::stringstream keystr;
1766-
keystr << "FIRMWARE=" << acffile << "// controller firmware";
1767-
this->systemkeys.addkey( keystr.str() );
1765+
this->systemkeys.addkey( "FIRMWARE=" + acffile + "// controller firmware" );
1766+
1767+
std::string hash;
1768+
md5_file( acffile, hash );
1769+
this->systemkeys.addkey( "FIRM_MD5=" + hash + "// MD5 checksum of firmware" );
17681770
}
17691771

17701772
// If there was an Archon error then read the Archon error log

utils/utilities.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -747,13 +747,9 @@ long md5_file(const std::string &filename, std::string &hash) {
747747
}
748748

749749
instream.close();
750-
} catch (std::ifstream::failure &e) {
751-
std::cerr << "md5_file( " << filename << " ): " << e.what() << "\n";
752-
hash = "ERROR";
753-
return 1;
754750
}
755751
catch (std::exception &e) {
756-
std::cerr << "md5_file( " << filename << " ): " << e.what() << "\n";
752+
std::cerr << "ERROR md5_file( " << filename << " ): " << e.what() << "\n";
757753
hash = "ERROR";
758754
return 1;
759755
}
@@ -772,7 +768,6 @@ long md5_file(const std::string &filename, std::string &hash) {
772768

773769
return 0;
774770
}
775-
776771
/***** md5_file *************************************************************/
777772

778773

0 commit comments

Comments
 (0)