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;
00015 const long numSlaves=4;
00016 long numWords;
00017 long dspStart, dspEnd;
00018 char 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
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
00052 RCCVmeInterface *vme1 = new RCCVmeInterface();
00053
00054
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
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
00079 unsigned long * buffer = new unsigned long[numWords];
00080 rod0->mdspBlockRead(dspStart, buffer, numWords);
00081
00082
00083
00084
00085
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
00102 cout << "Do another? [Y/n]: ";
00103 cin >> response;
00104 } while (response != 'n');
00105
00106
00107 delete rod0;
00108 delete vme1;
00109
00110 return 0;
00111 }
00112
00113