//! A quick utility to read a ROD's serial number register and do a sanity check. #include using namespace std; #include #include "RodModule.h" #include "RodStatus.h" #include "primParams.h" #include "RCCVmeInterface.h" #include "parameters.h" using namespace SctPixelRod; bool checkSlot(int slot, RCCVmeInterface *vme, bool printit) { bool rval=false; if ((slot < 1) || (slot > 21)) { return rval; } unsigned long baseAddress = slot << 24; RodModule *rod; // Create VME interface try { // cout << "Creating ROD module\n"; rod = new RodModule(baseAddress, mapSize, *vme, numSlaves); rod->initialize(false); // cout << "Creating ROD status\n"; RodStatus rodStatus(*rod); rval = rodStatus.isSane(); if (rval) cout << rodStatus; } catch (...) { rval = false; // some exception occured } // delete rod; // return rval; } bool checkSlotOld(int slot, bool printit) { bool rval=false; if ((slot < 1) || (slot > 21)) { return rval; } unsigned long baseAddress = slot << 24; RCCVmeInterface *vme; RodModule *rod; // Create VME interface try { // cout << "Creating VME interface\n"; vme = new RCCVmeInterface(); // cout << "Creating ROD module\n"; rod = new RodModule(baseAddress, mapSize, *vme, numSlaves); rod->initialize(false); // cout << "Creating ROD status\n"; RodStatus rodStatus(*rod); rval = rodStatus.isSane(); if (rval) cout << rodStatus; } catch (...) { rval = false; // some exception occured } // delete rod; delete vme; // return rval; } int main(int argc, char *argv[]) { int slot = -1; bool foundAny=false; bool rval; // cout << "Creating VME interface\n"; RCCVmeInterface *vme = new RCCVmeInterface(); cout << "Searching for a sane ROD..." << endl; for ( slot=1; slot<22; slot++ ) { rval = checkSlot(slot,vme,true); // cout << "Slot: " << slot << " " << rval << endl; if (rval) { cout << "Found a ROD in slot " << slot << endl; foundAny = true; } } if (!foundAny) cout << "Sorry, no sane RODs found!" << endl; delete vme; return 0; }