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

TextPeek.cxx

00001 
00002 // It does NOT initialize the ROD!! This program is intended to be 
00003 // a diagnostic used to examine buffer 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 #include "RodDspAddresses.h"
00013 
00014 #include "RCCVmeInterface.h"
00015 
00016 int main(int argc, char *argv[]) {
00017 
00018 using namespace SctPixelRod;
00019 
00020   const unsigned long mapSize=0xc00040;         // Map size
00021   const long numSlaves=4;                       // Number of slaves
00022   long numWords;                                // Number of words to dump
00023   long dspStart;                                // Address limits to dump
00024   unsigned long txtAddress[4] = {ERR_BUFF_BASE, INFO_BUFF_BASE, \
00025           DIAG_BUFF_BASE, XFER_BUFF_BASE};
00026   void* genPtr;
00027   char* textBuff;
00028   
00029   std::string fileName(""), option;
00030   int slot = -1;
00031   unsigned long baseAddress;
00032 
00033   if (argc > 1) {
00034     for (int i=1; i<argc; i++) {
00035       option = argv[i];
00036       if (option[0] != '-') break;
00037       switch (option[1]) {
00038         case 's': {
00039           slot = atoi(option.substr(2).c_str());
00040           break;
00041         }
00042         default: {
00043           break;
00044         }
00045       }
00046     }
00047   }
00048 
00049 // Prompt for slot number
00050   if (slot < 0 ) {
00051     cout << "Enter slot number (decimal):"; 
00052     cin >> slot;
00053     while ((slot < 1) || (slot > 21)) {
00054       cout << "Slot number out or range [1:21], re-enter: ";
00055       cin >> slot;
00056     }
00057   }
00058   baseAddress = slot << 24;
00059   
00060   cout << "Number of characters to dump (decimal): ";
00061   cin >> numWords;
00062   numWords = (numWords+3)/4;
00063 
00064 // Create VME interface
00065   RCCVmeInterface *vme1 = new RCCVmeInterface();
00066   
00067 // Create RodModule but do not initialize it
00068   RodModule* rod0 = new RodModule(baseAddress, mapSize, *vme1, numSlaves);
00069 
00070 // get starting address and number of bytes to read
00071 
00072   for (int ibuf=0; ibuf<4; ibuf++) {
00073     dspStart = txtAddress[ibuf];
00074   
00075 // create buffer and read data
00076     unsigned long * buffer = new unsigned long[numWords];
00077     rod0->mdspBlockRead(dspStart, buffer, numWords);
00078   
00079 // output the data and delete the buffer
00080     switch(ibuf) {
00081       case 0: cout << endl << "Hexadecimal dump of ERR buffer:" << endl;
00082               break;
00083       case 1: cout << endl << "Hexadecimal dump of INFO buffer:" << endl;
00084               break;
00085       case 2: cout << endl << "Hexadecimal dump of DIAG buffer:" << endl;
00086               break;
00087       case 4: cout << endl << "Hexadecimal dump of XFER buffer:" << endl;
00088               break;
00089       }
00090     hex(cout);
00091     cout.fill('0');
00092     for (int i=0; i<numWords; i+=8) {
00093       cout.width(8);
00094       cout << buffer[i]   << ' ';
00095       cout.width(8);
00096       cout << buffer[i+1] << ' ';
00097       cout.width(8);
00098       cout << buffer[i+2] << ' ';
00099       cout.width(8);
00100       cout << buffer[i+3] << ' ';
00101       cout.width(8);
00102       cout << buffer[i+4] << ' ';
00103       cout.width(8);
00104       cout << buffer[i+5] << ' ';
00105       cout.width(8);
00106       cout << buffer[i+6] << ' ';
00107       cout.width(8);
00108       cout << buffer[i+7] << endl;
00109     }
00110     dec(cout);
00111     cout.fill(' ');
00112     genPtr = static_cast<void*>(buffer);
00113     textBuff = static_cast<char*>(genPtr);
00114     switch(ibuf) {
00115       case 0: cout << endl << "ASCII dump of ERR buffer:" << endl;
00116               break;
00117       case 1: cout << endl << "ASCII dump of INFO buffer:" << endl;
00118               break;
00119       case 2: cout << endl << "ASCII dump of DIAG buffer:" << endl;
00120               break;
00121       case 4: cout << endl << "ASCII dump of XFER buffer:" << endl;
00122               break;
00123       }
00124       for (int itext = 0; itext< 4*numWords; itext++) {
00125         if ((textBuff[itext]<' ') || (textBuff[itext] > '~')) textBuff[itext] = '.';
00126         cout << textBuff[itext];
00127         if ((itext+1)%64 == 0) cout << endl;
00128       }
00129       cout << endl;
00130         
00131     delete [] buffer;
00132     }
00133     
00134 // Clean up before exiting
00135   delete rod0;
00136   delete vme1;
00137 
00138   return 0;  
00139 }
00140 
00141 

Generated on Thu Dec 15 21:14:41 2005 for SCT DAQ/DCS Software - C++ by doxygen 1.3.5