Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Globals | Related Pages

MdspDump.cxx

00001 #include <iostream>
00002 using namespace std;
00003 
00004 #include <ctype.h>
00005 
00006 #include "RodModule.h"
00007 
00008 #include "RCCVmeInterface.h"
00009 
00010 int main(int argc, char *argv[]) {
00011 
00012 using namespace SctPixelRod;
00013 
00014   const unsigned long mapSize=0xc00040;         // Map size
00015   const long numSlaves=4;                       // Number of slaves
00016   long numWords;                                // Number of words to dump
00017   long dspStart, dspEnd;                        // Address limits to dump
00018   char response;                                // Y/n response
00019   
00020   std::string fileName(""), option;
00021   int slot = -1;
00022   unsigned long baseAddress;
00023 
00024   if (argc > 1) {
00025     for (int i=1; i<argc; i++) {
00026       option = argv[i];
00027       if (option[0] != '-') break;
00028       switch (option[1]) {
00029         case 's': {
00030           slot = atoi(option.substr(2).c_str());
00031           break;
00032         }
00033         default: {
00034           break;
00035         }
00036       }
00037     }
00038   }
00039 
00040 // Prompt for slot number
00041   if (slot < 0 ) {
00042     cout << "Enter slot number (decimal):"; 
00043     cin >> slot;
00044     while ((slot < 1) || (slot > 21)) {
00045       cout << "Slot number out or range [1:21], re-enter: ";
00046       cin >> slot;
00047     }
00048   }
00049   baseAddress = slot << 24;
00050 
00051 // Create VME interface
00052   RCCVmeInterface *vme1 = new RCCVmeInterface();
00053   
00054 // Create RodModule and initialize it
00055   RodModule* rod0 = new RodModule(baseAddress, mapSize, *vme1, numSlaves);
00056   try{
00057     rod0->initialize();
00058   }
00059   catch (HpiException *h) {
00060     hex(cout);
00061     cout << h->getDescriptor() << '\n';
00062     cout << "calcAddr: " << h->getCalcAddr() << ", readAddr: " << 
00063             h->getReadAddr() << '\n';
00064     dec(cout);
00065   };
00066 
00067 // get starting address and number of bytes to read
00068 
00069   do {
00070     hex(cin);
00071     cout << "Starting address (hex, without leading 0x): ";
00072     cin >> dspStart;
00073     cout << "Ending address (hex, without leading 0x): ";
00074     cin >> dspEnd;
00075     dec(cin);
00076     numWords = (dspEnd +1 - dspStart)/4;
00077   
00078 // create buffer and read data
00079     unsigned long * buffer = new unsigned long[numWords];
00080     rod0->mdspBlockRead(dspStart, buffer, numWords);
00081   
00082 // output the data and delete the buffer
00083 // Do this is in a slightly more sophisticated way, so that part
00084 // lines are printed sensibly.
00085 // JCH. 12 Sep 2003.
00086 //
00087     hex(cout);
00088     cout.fill('0');
00089     for (int i=0; i<numWords; i+=8) {
00090       int limit = i<(numWords-7) ? 8 : numWords%8;
00091       for(int j=0; j<limit; j++) {
00092         cout.width(8);
00093         cout << buffer[i+j]   << ' ';
00094       }
00095       cout << endl;
00096     }
00097     dec(cout);
00098     cout.fill(' ');
00099     delete [] buffer;
00100     
00101 // do another?
00102     cout << "Do another? [Y/n]: ";
00103     cin >> response;
00104   } while (response != 'n');
00105 
00106 // Clean up before exiting
00107   delete rod0;
00108   delete vme1;
00109 
00110   return 0;  
00111 }
00112 
00113 

Generated on Fri Dec 16 19:38:12 2005 for SCT DAQ/DCS Software - C++ by doxygen 1.3.5