1313// /
1414// / \author Kostas Alexopoulos ([email protected] )1515
16- #include " unordered_map"
17- #include " ReadoutCard/ChannelFactory.h"
18- #include " ReadoutCard/Parameters.h"
16+ #include " ReadoutCard/FirmwareChecker.h"
17+ #include " ExceptionInternal.h"
1918
2019namespace AliceO2
2120{
2221namespace roc
2322{
2423
25- inline std::unordered_map<std::string, std::string> compatibleFirmwareList ({ { " 20190911-150139-3f5e11b3" , " CRU v3.3.0" },
26- { " 20190718-120712-4c8e6c48" , " CRU v3.2.0" },
27- { " 0.0:2000-0-0" , " CRORC alpha" } });
24+ FirmwareChecker::FirmwareChecker () : mCompatibleFirmwareList ({ { " 20191014-115705-51882687" , " v3.4.0" },
25+ { " 20190911-150139-3f5e11b3" , " v3.3.0" },
26+ { " 20190718-120712-4c8e6c48" , " v3.2.0" },
27+ { " 0.0:2000-0-0" , " alpha" } })
28+ {
29+ }
30+
31+ FirmwareChecker::~FirmwareChecker ()
32+ {
33+ }
34+
35+ std::string FirmwareChecker::resolveFirmwareTag (std::string firmware)
36+ {
37+ if (mCompatibleFirmwareList .find (firmware) != mCompatibleFirmwareList .end ()) {
38+ return mCompatibleFirmwareList .at (firmware);
39+ } else {
40+ return firmware;
41+ }
42+ }
2843
29- inline std::string getFirmwareCompatibilityList ()
44+ std::string FirmwareChecker:: getFirmwareCompatibilityList ()
3045{
3146 std::string fwStrings;
32- for (auto fwString : compatibleFirmwareList ) {
47+ for (auto fwString : mCompatibleFirmwareList ) {
3348 fwStrings += " \n " + fwString.second + " - " + fwString.first ;
3449 }
3550 return fwStrings;
3651}
3752
38- inline void checkFirmwareCompatibilityWrapped (std::shared_ptr<BarInterface> bar2)
53+ void FirmwareChecker:: checkFirmwareCompatibilityWrapped (std::shared_ptr<BarInterface> bar2)
3954{
4055 auto firmware = bar2->getFirmwareInfo ().value_or (" " );
4156 auto serial = bar2->getSerial ().value_or (-1 );
42- if (compatibleFirmwareList .find (firmware) == compatibleFirmwareList .end ()) {
57+ if (mCompatibleFirmwareList .find (firmware) == mCompatibleFirmwareList .end ()) {
4358 BOOST_THROW_EXCEPTION (Exception () << ErrorInfo::Message (
4459 std::string (" Firmware compatibility check failed.\n " ) +
4560 std::string (" Serial: " + std::to_string (serial) + " \n " ) +
@@ -49,13 +64,13 @@ inline void checkFirmwareCompatibilityWrapped(std::shared_ptr<BarInterface> bar2
4964 }
5065}
5166
52- inline void checkFirmwareCompatibility (Parameters params)
67+ void FirmwareChecker:: checkFirmwareCompatibility (Parameters params)
5368{
5469 auto bar2 = ChannelFactory ().getBar (params);
5570 checkFirmwareCompatibilityWrapped (bar2);
5671}
5772
58- inline void checkFirmwareCompatibility (Parameters::CardIdType cardId)
73+ void FirmwareChecker:: checkFirmwareCompatibility (Parameters::CardIdType cardId)
5974{
6075 auto params = Parameters::makeParameters (cardId, 2 ); // access bar2 to check the firmware release
6176 auto bar2 = ChannelFactory ().getBar (params);
0 commit comments