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

MdspPeek.cxx

00001 
00002 // It does NOT initialize the ROD!! This program is intended to be 
00003 // a diagnostic used to examine memory contents after another
00004 // program, e.g. EchoTest or LedTest, has run.
00005 
00006 #include <iostream>
00007 using namespace std;
00008 
00009 #include <ctype.h>
00010 
00011 #include "RodModule.h"
00012 
00013 #include "RCCVmeInterface.h"
00014 
00015 int main(int argc, char *argv[]) {
00016 
00017 using namespace SctPixelRod;
00018 
00019   const unsigned long mapSize=0xc00040;         // Map size
00020   const long numSlaves=4;                       // Number of slaves
00021   long numWords;                                // Number of words to dump
00022   long dspStart;                                // Address limits to dump
00023   char response;                                // Y/n response
00024   void* genPtr;
00025   char* textBuff;
00026   std::string fileName(""), option;
00027   int slot = -1;
00028   unsigned long baseAddress;
00029 
00030   if (argc > 1) {
00031     for (int i=1; i<argc; i++) {
00032       option = argv[i];
00033       if (option[0] != '-') break;
00034       switch (option[1]) {
00035         case 's': {
00036           slot = atoi(option.substr(2).c_str());
00037           break;
00038         }
00039         default: {
00040           break;
00041         }
00042       }
00043     }
00044   }
00045 
00046 // Prompt for slot number
00047   if (slot < 0 ) {
00048     cout << "Enter slot number (decimal):"; 
00049     cin >> slot;
00050     while ((slot < 1) || (slot > 21)) {
00051       cout << "Slot number out or range [1:21], re-enter: ";
00052       cin >> slot;
00053     }
00054   }
00055   baseAddress = slot << 24;
00056 
00057 // Create VME interface
00058   RCCVmeInterface *vme1 = new RCCVmeInterface();
00059   
00060 // Create RodModule but do not initialize it
00061   RodModule* rod0 = new RodModule(baseAddress, mapSize, *vme1, numSlaves);
00062 
00063 // get starting address and number of bytes to read
00064 
00065   do {
00066     hex(cin);
00067     cout << "Starting address (hex, without leading 0x): ";
00068     cin >> dspStart;
00069     cout << "Number of 32-bit words (hex, without leading 0x): ";
00070     cin >> numWords;
00071     dec(cin);
00072   
00073 // create buffer and read data
00074     unsigned long * buffer = new unsigned long[numWords];
00075     rod0->mdspBlockRead(dspStart, buffer, numWords);
00076   
00077 // output the data and delete the buffer
00078     hex(cout);
00079     cout.fill('0');
00080     for (int i=0; i<numWords; i+=8) {
00081       cout.width(8);
00082       cout << buffer[i]   << ' ';
00083       cout.width(8);
00084       cout << buffer[i+1] << ' ';
00085       cout.width(8);
00086       cout << buffer[i+2] << ' ';
00087       cout.width(8);
00088       cout << buffer[i+3] << ' ';
00089       cout.width(8);
00090       cout << buffer[i+4] << ' ';
00091       cout.width(8);
00092       cout << buffer[i+5] << ' ';
00093       cout.width(8);
00094       cout << buffer[i+6] << ' ';
00095       cout.width(8);
00096       cout << buffer[i+7] << endl;
00097     }
00098     dec(cout);
00099 // Display as text also
00100     cout.fill(' ');
00101     genPtr = static_cast<void*>(buffer);
00102     textBuff = static_cast<char*>(genPtr);
00103     cout << endl << "ASCII dump :" << endl;
00104     for (int itext = 0; itext< 4*numWords; itext++) {
00105       if ((textBuff[itext]<' ') || (textBuff[itext] > '~')) textBuff[itext] = '.';
00106         cout << textBuff[itext];
00107       if ((itext+1)%64 == 0) cout << endl;
00108     }
00109     cout << endl;
00110     delete [] buffer;
00111     
00112 // do another?
00113     cout << "Do another? [Y/n]: ";
00114     cin >> response;
00115   } while (response != 'n');
00116 
00117 // Clean up before exiting
00118   delete rod0;
00119   delete vme1;
00120 
00121   return 0;  
00122 }
00123 
00124 

Generated on Fri Sep 16 18:01:53 2005 for SCT DAQ/DCS Software - C++ by doxygen 1.3.5