00001
00002
00003
00004
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;
00020 const long numSlaves=4;
00021 long numWords;
00022 long dspStart;
00023 char response;
00024 long dspNumber=-2;
00025
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 case 'v': {
00040 dspNumber = atoi(option.substr(2).c_str());
00041 break;
00042 }
00043 default: {
00044 break;
00045 }
00046 }
00047 }
00048 }
00049
00050
00051 if (slot < 0 ) {
00052 cout << "Enter slot number (decimal):";
00053 cin >> slot;
00054 while ((slot < 1) || (slot > 21)) {
00055 cout << "Slot number out or range [1:21], re-enter: ";
00056 cin >> slot;
00057 }
00058 }
00059 baseAddress = slot << 24;
00060
00061
00062 RCCVmeInterface *vme1 = new RCCVmeInterface();
00063
00064
00065 RodModule* rod0 = new RodModule(baseAddress, mapSize, *vme1, numSlaves);
00066
00067
00068
00069 do {
00070 if (dspNumber < -1 ) {
00071 cout << "Enter DSP number (-1:3):";
00072 cin >> dspNumber;
00073 while ((dspNumber < -1) || (dspNumber > 3)) {
00074 cout << "DSP number out or range [-1:3], re-enter: ";
00075 cin >> dspNumber;
00076 }
00077 }
00078
00079 hex(cin);
00080 cout << "Starting address (hex, without leading 0x): ";
00081 cin >> dspStart;
00082 cout << "Number of 32-bit words (hex, without leading 0x): ";
00083 cin >> numWords;
00084 dec(cin);
00085
00086
00087 unsigned long * buffer = new unsigned long[numWords];
00088
00089 if (dspNumber == -1) {
00090 rod0->mdspBlockRead(dspStart, buffer, numWords);
00091 }
00092 else {
00093 rod0->slvBlockRead(dspStart, buffer, numWords, dspNumber);
00094 }
00095
00096
00097 hex(cout);
00098 cout.fill('0');
00099 for (int i=0; i<numWords; i+=8) {
00100 cout.width(8);
00101 cout << buffer[i] << ' ';
00102 cout.width(8);
00103 cout << buffer[i+1] << ' ';
00104 cout.width(8);
00105 cout << buffer[i+2] << ' ';
00106 cout.width(8);
00107 cout << buffer[i+3] << ' ';
00108 cout.width(8);
00109 cout << buffer[i+4] << ' ';
00110 cout.width(8);
00111 cout << buffer[i+5] << ' ';
00112 cout.width(8);
00113 cout << buffer[i+6] << ' ';
00114 cout.width(8);
00115 cout << buffer[i+7] << endl;
00116 }
00117 dec(cout);
00118 cout.fill(' ');
00119 delete [] buffer;
00120
00121
00122 cout << "Do another? [Y/n]: ";
00123 cin >> response;
00124 } while (response != 'n');
00125
00126
00127 delete rod0;
00128 delete vme1;
00129
00130 return 0;
00131 }
00132
00133