00001 #define USELIBRARY
00002
00003 #include <iostream>
00004
00005 #include "../TApi.h"
00006
00007 using namespace std;
00008
00009 int main () {
00010 TApi tapi;
00011
00012 tapi.initialiseAll(0);
00013
00014 bool cont = true;
00015
00016
00017 unsigned long echoData[2] = {0xDEADF00D,0};
00018
00019 tapi.createDebugPrimList();
00020
00021 const int ECHO = 0;
00022 const int R_ECHO = 100;
00023
00024 tapi.addDebugPrimList(4 + 2, 1, ECHO, R_ECHO, echoData);
00025
00026
00027
00028 cout << "ECHO3 sending standard primlist\n";
00029
00030 try {
00031 if(cont)
00032 tapi.sendDebugPrimList(0);
00033 } catch(...) {
00034 cout << "Exception sending echo primitive\n";
00035 cont = false;
00036 }
00037
00038 try {
00039 if(cont) {
00040 cerr << "Waiting for response from master\n";
00041 tapi.awaitResponse(0);
00042 cerr << "Done await response\n";
00043 }
00044 } catch(...) {
00045 cout << "Exception awaiting echo response\n";
00046 cont = false;
00047 }
00048
00049 unsigned long outLength;
00050
00051 unsigned long *outBody = tapi.getResponse(0, &outLength);
00052
00053
00054
00055 cout << "ECHO3 sending slave primlist\n";
00056
00057 try {
00059 if(cont)
00060 tapi.sendDebugSlavePrimList(0, 0, 1, 1);
00061 } catch(...) {
00062 cout << "Exception sending echo primitive\n";
00063 cont = false;
00064 }
00065
00066 try {
00067 if(cont) {
00068 cerr << "Going to await response\n";
00069 tapi.awaitResponse(0);
00070 cerr << "Done await response\n";
00071 }
00072 } catch(...) {
00073 cout << "Exception awaiting echo response\n";
00074 cont = false;
00075 }
00076
00077 delete [] outBody;
00078
00079 outBody = tapi.getResponse(0, &outLength);
00080
00081
00082 if(outBody) {
00083
00084 hex(cout);
00085 for (unsigned int i=0; i<outLength; i++) {
00086 cout.width(8);
00087 cout << outBody[i] << " ";
00088 if (0 == (i+1)%8) cout << endl;
00089 }
00090 if (0 != (outLength)%8) cout << endl;
00091 dec(cout);
00092
00093
00094
00095
00096 delete [] outBody;
00097 } else {
00098 cout << "Response was null\n";
00099 }
00100
00101 try {
00102 if(cont) {
00103 cerr << "Check text buffers...\n";
00104 tapi.awaitResponse(0, 1);
00105 cerr << "Done await response\n";
00106 }
00107 } catch(...) {
00108 cout << "Exception awaiting echo response\n";
00109 cont = false;
00110 }
00111
00112 tapi.shutdownAll();
00113 }
00114