00001
00002
00003
00004
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;
00021 const long numSlaves=4;
00022 long numWords;
00023 long dspStart;
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
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
00065 RCCVmeInterface *vme1 = new RCCVmeInterface();
00066
00067
00068 RodModule* rod0 = new RodModule(baseAddress, mapSize, *vme1, numSlaves);
00069
00070
00071
00072 for (int ibuf=0; ibuf<4; ibuf++) {
00073 dspStart = txtAddress[ibuf];
00074
00075
00076 unsigned long * buffer = new unsigned long[numWords];
00077 rod0->mdspBlockRead(dspStart, buffer, numWords);
00078
00079
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
00135 delete rod0;
00136 delete vme1;
00137
00138 return 0;
00139 }
00140
00141