Ejemplo n.º 1
0
/*
 * create or update the XImage using X shared memory
 * so that it has the given width and height and return TCL_OK if all
 * is TCL_OK.
 */
int ImageDisplay::updateShm(int width, int height)
{

    // use this to catch X errors
    ErrorHandler errorHandler(display_, verbose_);

    // create an XImage in shared memory
    xImage_ = XShmCreateImage(display_, visual_, depth_,
                              ZPixmap, NULL, &shmInfo_, width, height);
    if (!xImage_) {
#ifdef DEBUG
        if (verbose_)
            cout << "XShmCreateImage failed\n";
#endif
        return TCL_ERROR;
    }

    // allocate enough shared memory to hold the image
    // (plus a fudge factor to keep the X server on HP happy)
    shmInfo_.shmid = shmget(IPC_PRIVATE,
                            (xImage_->bytes_per_line * (height+1)),
                            IPC_CREAT | 0777);

    if (shmInfo_.shmid < 0) {
        XDestroyImage(xImage_);
        xImage_ = NULL;
#ifdef DEBUG
        if (verbose_) {
            perror("shmget failed for X shared memory");
        }
#endif
        return TCL_ERROR;
    }
    shmInfo_.shmaddr = (char *) shmat(shmInfo_.shmid, 0, 0);
    if (shmInfo_.shmaddr == ((char *) -1)) {
        XDestroyImage(xImage_);
        shmctl(shmInfo_.shmid, IPC_RMID, 0);
        shmdt(shmInfo_.shmaddr);
        xImage_ = NULL;
#ifdef DEBUG
        if (verbose_)
            perror("shmat failed for X shared memory");
#endif
        return TCL_ERROR;
    }

    xImage_->data = shmInfo_.shmaddr;
    shmInfo_.readOnly = False;
    XShmAttach(display_, &shmInfo_);

    // check for X errors
    if (errorHandler.errors()) {
        XShmDetach(display_, &shmInfo_);
        XDestroyImage(xImage_);
        shmctl(shmInfo_.shmid, IPC_RMID, 0);
        shmdt(shmInfo_.shmaddr);
        xImage_ = NULL;
#ifdef DEBUG
        if (verbose_)
            cout << "X shared memory error\n";
#endif
        return TCL_ERROR;
    }

    // this will cause the shared memory to be automatically deleted
    shmctl(shmInfo_.shmid, IPC_RMID, 0);

#ifdef XXXDEBUG
    if (verbose_)
        cout << "Sharing memory\n";
#endif
    return TCL_OK;
}
void RecursiveDescentParser::errorHandler(std::string errorMessage, Token tk, bool recoverable) {
	errorHandler(errorMessage, tk.getLineNum(), recoverable);
}
/**
 * Function representing the <st_factor_ident> prods
 */
void RecursiveDescentParser::st_factor_ident(TableEntry* te) {
	if(errorCondition) return;
	if(token == TK_LEFT_PARENTHESES) 
	{
#if DEBUG_PARSER
		std::cout << "<st_factor_ident> --> (<o_list>);\n";
#endif
		Token leftParen = token;
		token = scanner->getToken();
		ParamList* pList = o_list();
		
		if(te) {
			if(te->getEntryType()!=TableEntry::FUNCTION) {
				std::stringstream errorMsg;
				errorMsg << "'" << te->getName() << "' is not a function";
				errorHandler(errorMsg.str(), leftParen);
			} else {
				// now makes sure the lists match
				FunctionEntry* fe = (FunctionEntry*)te;
				if(pList) matchParameters(fe, pList, leftParen);
				
				iCode.threeAddressCode(TAC_PARAM, pList);
				iCode.threeAddressCode( 
						symTab.getNextAddress(), // throw away temporary
						TAC_CALL, 
						fe->getLabel(), 
						fe->getParamCount()
					);
			}
		} else {
			std::stringstream errorMsg;
			errorMsg << "Undeclared function";
			errorHandler(errorMsg.str(), leftParen);
		}
		
		match(TK_RIGHT_PARENTHESES);
		match(TK_SEMICOLON);
	} 
	else if(token == TK_LEFT_BRACKET || 
			token == TK_ASSIGNMENT) 
	{
#if DEBUG_PARSER		
		std::cout << "<st_factor_ident> --> <var_prime>=<exp>;\n";
#endif
		VariableEntry* vEntry = (VariableEntry*)te;
		Token startToken = token;
		
		attr varAttr  = var_prime(vEntry);
		match(TK_ASSIGNMENT);
		attr expAttr = exp();
		
		if(expAttr.type != varAttr.type) {
			std::stringstream errorMsg;
			errorMsg << "Type mismatch variable '" << vEntry->getName() << "'";
			errorHandler(errorMsg.str(), startToken);
		}
		
		if(varAttr.attrib == VA_ARRAY) {
			std::stringstream errorMsg;
			errorMsg << "Assignment error, array '" << vEntry->getName() << "' must be indexed.";
			errorHandler( errorMsg.str(), startToken );
		}
		
		if(vEntry->getAttribute() == VA_ARRAY) {
			//                       array addr                           value to assign   index
			iCode.threeAddressCode(vEntry->getAttr(), TAC_ASSIGN_TO_ADDRESS_AT, expAttr, varAttr);
		} else {
			iCode.threeAddressCode(vEntry->getAttr(), TAC_ASSIGN, expAttr);
		}
		
		match(TK_SEMICOLON);
	} 
	else 
	{
		errorHandler();
	}
}
/**
 * Function representing the <prim_prime> productions
 */
attr RecursiveDescentParser::prim_prime(TableEntry* pTabEntry) {
	attr retval;
	retval.type = T_ERROR;
	
	if(errorCondition) return retval;
	if(token == TK_LEFT_BRACKET) 
	{
#if DEBUG_PARSER
		std::cout << "<prim_prime> --> [<exp>]\n";
#endif
		token = scanner->getToken();
		
		retval = exp();
		retval.attrib = VA_SIMPLE;
		
		match(TK_RIGHT_BRACKET);
	}
	else if(token == TK_LEFT_PARENTHESES)
	{
#if DEBUG_PARSER
		std::cout << "<prim_prime> --> (<o_list>)\n";
#endif
		Token sToken = token;
		token = scanner->getToken();
		ParamList* pList = o_list();
		match(TK_RIGHT_PARENTHESES);

		if(pTabEntry && pTabEntry->getEntryType()==TableEntry::FUNCTION) {
			FunctionEntry* fe = (FunctionEntry*)pTabEntry;
			if(pList) {
				matchParameters(fe, pList, sToken);
			}
			retval.type = fe->getReturnType();
			retval.addr = symTab.getNextAddress();

			iCode.threeAddressCode(TAC_PARAM, pList);
			iCode.threeAddressCode(retval, TAC_CALL, fe->getLabel(), fe->getParamCount());
		}
		else {
			std::stringstream errorMsg;
			errorMsg << "'" << pTabEntry->getName() << "' is not a function";
			errorHandler(errorMsg.str(), sToken);
		}
	}
	else if( token == TK_ASTERISK || 
			token == TK_SLASH || 
			token == TK_PERCENT || 
			token == TK_PLUS ||
			token == TK_MINUS || 
			token == TK_RIGHT_PARENTHESES || 
			token == TK_RIGHT_BRACKET || 
			token == TK_SEMICOLON || 
			token == TK_LT || 
			token == TK_GT || 
			token == TK_LTE || 
			token == TK_GTE || 
			token == TK_EQUAL || 
			token == TK_NOT_EQ ) 
	{		
#if DEBUG_PARSER
		std::cout << "<prim_prime> --> e\n";
#endif
		retval = pTabEntry->getAttr();
	}
	else {
		errorHandler();
	}
	
	return retval;
}
/**
 * Functions representing the <st> productions
 */
void RecursiveDescentParser::st() {
	if(token == TK_SEMICOLON) 
	{
#if DEBUG_PARSER
		std::cout << "<st> --> ;\n";
#endif
		token = scanner->getToken();
	} 
	else if(token == TK_LEFT_BRACE) 
	{
#if DEBUG_PARSER
		std::cout << "<st> --> <comp_st>\n";
#endif
		comp_st();
	}
	else if(token == TK_IF) 
	{
#if DEBUG_PARSER
		std::cout << "<st> --> if<log_exp><st>else<st>\n";
#endif
		token = scanner->getToken();
		
		attr logExp = log_exp();
		
		std::string lbl1 = iCode.getNextLabel();
		iCode.threeAddressCode(TAC_IF_FALSE, logExp, lbl1);

		st();
		
		std::string lbl2 = iCode.getNextLabel();
		iCode.threeAddressCode(TAC_GOTO, lbl2);
		
		match(TK_ELSE);
		
		iCode.threeAddressCode(lbl1);
		
		st();
		
		iCode.threeAddressCode(lbl2);
	} 
	else if(token == TK_WHILE) 
	{
#if DEBUG_PARSER
		std::cout << "<st> --> while<log_exp><st>\n";
#endif
		token = scanner->getToken();
		
		std::string lbl1 = iCode.getNextLabel();
		iCode.threeAddressCode(lbl1);
		std::string lbl2 = iCode.getNextLabel();
		
		attr cond = log_exp();
		
		iCode.threeAddressCode(TAC_IF_FALSE, cond, lbl2);
		
		st();
		
		iCode.threeAddressCode(TAC_GOTO, lbl1);
		iCode.threeAddressCode(lbl2);
	}
	else if(token == TK_RETURN) 
	{
#if DEBUG_PARSER
		std::cout << "<st> --> return(<exp>);\n";
#endif
		Token sToken = token;
		token = scanner->getToken();
		
		match(TK_LEFT_PARENTHESES);
		attr expAttr = exp(); 

		const FunctionEntry* fe = symTab.getCurrentFunction();
		if(expAttr.type != fe->getReturnType() && fe->getReturnType() != T_VOID) {
			std::stringstream ss;
			ss << "Type Mismatch, function '" << fe->getName() << "' must return ";
			if(fe->getReturnType() == T_INT) ss << "an integer";
			if(fe->getReturnType() == T_CHAR) ss << "a character";
			errorHandler(ss.str(), sToken);
		}
		
		match(TK_RIGHT_PARENTHESES);
		match(TK_SEMICOLON);
		iCode.threeAddressCode(TAC_SAVE_RET_VAL, expAttr);
		iCode.threeAddressCode(TAC_GOTO, currentReturnLabel);
	}
	else if(token == TK_SCANF) 
	{
#if DEBUG_PARSER
		std::cout << "<st> --> scanf<i_list>;\n";
#endif

		token = scanner->getToken();
		ParamList* pList = i_list();
		match(TK_SEMICOLON);
		
		iCode.threeAddressCode(TAC_READ, pList);
	}
	else if(token == TK_PRINTF) 
	{
#if DEBUG_PARSER
		std::cout << "<st> --> printf<o_list>;\n";
#endif

		token = scanner->getToken();
		ParamList* pList = o_list();
		match(TK_SEMICOLON);
		
		iCode.threeAddressCode(TAC_WRITE, pList);
	}
	else if(token == TK_IDENTIFIER) 
	{
#if DEBUG_PARSER
		std::cout << "<st> --> i<st_factor_ident>\n";
#endif
		TableEntry* te=NULL;
		if(!symTab.search(token, te)) {
			errorHandler("Undefined identifier", token);
		}
		token = scanner->getToken();
		st_factor_ident(te);
	}
	else if(token == TK_INT)  
	{
#if DEBUG_PARSER
		std::cout << "<st> --> int i <st_factor_type>\n";
#endif
		token = scanner->getToken();
		if(token!=TK_IDENTIFIER) {
			errorHandler();
		}		
		if(symTab.search(token) ) {
			std::stringstream msg;
			msg << "Duplicate variable declaration '" << token.getValue() << "'";
			errorHandler(msg.str(), token);
		} 
		
		VariableEntry* vEntry = new VariableEntry();
		vEntry->setType(T_INT);
		vEntry->setName( token.getValue() );
		//std::string varName = token.getValue();
		
		
		token = scanner->getToken();
		st_factor_type(vEntry);
		
		//symTab.insert(varName, vEntry);
	}
	else if(token == TK_CHAR) 
	{
#if DEBUG_PARSER
		std::cout << "<st> --> char i <st_factor_type>\n";
#endif
		token = scanner->getToken();
		if(token!=TK_IDENTIFIER) {
			errorHandler();
		}

		if(symTab.search(token)) {
			// aready declared in this scope
			std::stringstream msg;
			msg << "Duplicate variable declaration '" << token.getValue() << "'";
			errorHandler(msg.str(), token);
		}

		VariableEntry* vEntry = new VariableEntry();
		vEntry->setType(T_CHAR);
		vEntry->setName( token.getValue() );
		//std::string varName = token.getValue();
		
		token = scanner->getToken();
		st_factor_type(vEntry);
		
		//symTab.insert(varName, vEntry);
	}
	else 
	{
		errorHandler();
	}
	
	if(errorCondition) {
		while(token!=TK_EOF) {
			token = scanner->getToken();
			if(token==TK_RIGHT_BRACE) {
				errorCondition=false;
				break;
			}
			if(token==TK_SEMICOLON) {
				errorCondition=false;
				token = scanner->getToken();
				break;
			}
		}
	}
}
Ejemplo n.º 6
0
void setup() {
#ifdef DEBUG
  printf("Config Starting \n");
#endif

  ANTUART = fopen("/dev/uart_0", "r+");
  //ANTUART = open("/dev/uart_0" ,O_NONBLOCK | O_RDWR);
  if(ANTUART){;}else{
    #ifdef DEBUG
    printf("Cannot open ANTUART");
    #endif
  }


//  if(alt_timestamp_start() <= 0){
//    printf("Timestamp init no working \n");
//  }

  #ifdef DEBUG
  printf("Ticks Per Second: %i \n", alt_timestamp_freq());
  #endif

  //alt_avalon_timer_sc_init (0x04011040, 2, 2, 1);

  // Reset
  sendPacket(MESG_SYSTEM_RESET_ID, 1, 0);
  if (checkReturn() == 0) errorHandler(errDefault);
  delay(1000);

  // Assign Channel
  //   Channel: 0
  //   Channel Type: for Receive Channel
  //   Network Number: 0 for Public Network
  sendPacket(MESG_ASSIGN_CHANNEL_ID, 3, ANT_CHAN, 0, ANT_NET);
  if (checkReturn() == 0) errorHandler(errDefault);

  // Set Channel ID
  //   Channel Number: 0
  //   Device Number LSB: 0 for a slave to match any device
  //   Device Number MSB: 0 for a slave to match any device
  //   Device Type: bit 7 0 for pairing request bit 6..0 for device type
  //   Transmission Type: 0 to match any transmission type
  sendPacket(MESG_CHANNEL_ID_ID, 5, ANT_CHAN, 0, 0, ANT_DEVICETYPE, 0);
  if (checkReturn() == 0) errorHandler(errDefault);

  // Set Network Key
  //   Network Number
  //   Key
  sendPacket(MESG_NETWORK_KEY_ID, 9, ANT_NET, antNetKey[0], antNetKey[1], antNetKey[2], antNetKey[3], antNetKey[4], antNetKey[5], antNetKey[6], antNetKey[7]);
  if (checkReturn() == 0) errorHandler(errDefault);

  // Set Channel Search Timeout
  //   Channel
  //   Timeout: time for timeout in 2.5 sec increments
  sendPacket(MESG_CHANNEL_SEARCH_TIMEOUT_ID, 2, ANT_CHAN, ANT_TIMEOUT);
  if (checkReturn() == 0) errorHandler(errDefault);

  //ANT_send(1+2, MESG_CHANNEL_RADIO_FREQ_ID, CHAN0, FREQ);
  // Set Channel RF Frequency
  //   Channel
  //   Frequency = 2400 MHz + (FREQ * 1 MHz) (See page 59 of ANT MPaU) 0x39 = 2457 MHz
  sendPacket(MESG_CHANNEL_RADIO_FREQ_ID, 2, ANT_CHAN, ANT_FREQ);
  if (checkReturn() == 0) errorHandler(errDefault);

  // Set Channel Period
  sendPacket(MESG_CHANNEL_MESG_PERIOD_ID, 3, ANT_CHAN, (ANT_PERIOD & 0x00FF), ((ANT_PERIOD & 0xFF00) >> 8));
  if (checkReturn() == 0) errorHandler(errDefault);

  //Open Channel
  sendPacket(MESG_OPEN_CHANNEL_ID, 1, ANT_CHAN);
  if (checkReturn() == 0) errorHandler(errDefault);

  #ifdef DEBUG
  printf("Config Done");
  #endif
}
/**
 * Function representing the <prim> productions
 */
attr RecursiveDescentParser::prim() {
	attr retVal, ident, primP;
	retVal.type = T_ERROR;
	
	if(errorCondition) return retVal;
	
	if(token == TK_IDENTIFIER) 
	{
#if DEBUG_PARSER
		std::cout << "<prim> --> i<prim_prime>\n";
#endif
		TableEntry* tEntry;
		if(!symTab.search(token, tEntry)) {
			std::stringstream ss;
			ss << "Unknown identifier " << token.getValue(); 
			errorHandler(ss.str(), token);
			errorCondition = true;
			return retVal;
		} else {
			retVal = ident = tEntry->getAttr();
		}
		token = scanner->getToken();
		primP = prim_prime( tEntry );

		if(ident.attrib == VA_ARRAY && primP.attrib == VA_SIMPLE)
		{
			retVal.addr = symTab.getNextAddress();
			retVal.attrib = VA_SIMPLE;
			retVal.param = false; // weird
			iCode.threeAddressCode(retVal, TAC_ADDRESS_OF, ident, primP );
		}
		else if(tEntry->getEntryType()==TableEntry::FUNCTION) {
			retVal.addr = primP.addr;
		}
	} 
	else if(token == TK_NUM) 
	{
#if DEBUG_PARSER
		std::cout << "<prim> --> n\n";
#endif
		retVal.addr = symTab.getNextAddress();
		retVal.attrib = VA_SIMPLE;
		retVal.type = T_INT;
		
		std::string val = token.getValue();
		int litTabIndex = litTab.insert(atoi(val.c_str()));
		iCode.threeAddressCode(retVal, TAC_NUM_CONST, litTabIndex);
		
		token = scanner->getToken();
	}
	else if(token == TK_CHAR_CONST) 
	{
#if DEBUG_PARSER
		std::cout << "<prim> --> 'c'\n";
#endif
		retVal.addr = symTab.getNextAddress();
		retVal.attrib = VA_SIMPLE;
		retVal.type = T_CHAR;
		
		std::string val = token.getValue();
		int litTabIndex = litTab.insert(val[1]);
		iCode.threeAddressCode(retVal, TAC_CHAR_CONST, litTabIndex);
		
		token = scanner->getToken();		
	}
	else if(token == TK_LEFT_PARENTHESES) 
	{
#if DEBUG_PARSER
		std::cout << "<prim> --> (<exp>)\n";
#endif
		token = scanner->getToken();
		retVal = exp();
		match(TK_RIGHT_PARENTHESES);
	}
	else
	{
		errorHandler();
	}
	
	return retVal;
}
Ejemplo n.º 8
0
void		CRiInterface::RiError(int c,int s,const char *m) {
	if (errorHandler != NULL) {
		errorHandler(c,s,m);
	}
}
Ejemplo n.º 9
0
int main(void)
{
    int f,f2,nread,i;
    int pfd[2], pfd2[2];
    char buffer[BUFFSIZE], *str;

    if(pipe(pfd)==-1) {
        errorHandler("pipe");
    }

    if((f=fork())==-1) {
        errorHandler("fork 1");
    } else if(f == 0) {
        /*child 1*/
        if(pipe(pfd2)==-1) {
            errorHandler("pipe 2");
        }
        if((f2=fork())==-1) {
            errorHandler("fork 2");
        } else if(f2 == 0) {
            /*child 2*/
            close(pfd[0]);
            close(pfd[1]);
            close(pfd2[0]);
            for(i=0;i<10;++i) {
                str = int2CharPt(i);
                if(write(pfd2[1], str, BUFFSIZE)==-1) {
                    errorHandler("write 2");
                } else {
                    /*printf("-child 2 writing: %s\n", str);*/
                }
            }
        } else {
            /*child 1*/
            close(pfd[0]);
            close(pfd2[1]);
            while((nread=read(pfd2[0], buffer, BUFFSIZE))>0) {
                buffer[nread] = 0;
                /*printf("child 1 read data %d [%s]\n", nread, buffer);*/
                str = int2CharPt(charPt2int(buffer)*5);
                /*printf("---attempting to send [%s]\n", str);*/
                if(write(pfd[1], str, BUFFSIZE)==-1) {
                    errorHandler("child 1 write");
                }
            }
            if(nread==-1) {
                errorHandler("read child 1");
            }
            /*
            str = "patrollin patrolling hehe";
            printf("-child 1 writing %s\n", str);
            if(write(pfd[1], str, BUFFSIZE)==-1) {
                errorHandler("write");
            }
            */
        }
    } else {
        /*parent*/
        close(pfd[1]);
        while((nread=read(pfd[0], buffer, BUFFSIZE))>0) {
            buffer[nread] = 0;
            /*printf("parent read data: %d [%s]\n", nread, buffer);*/
            printf("%s,", buffer);
        }
        if(nread==-1) {
            errorHandler("read");
        }
        printf("\n");
    }

    return 0;
}
Ejemplo n.º 10
0
ProjectLangstatsModel::ProjectLangstatsModel(QObject *parent) :
    QAbstractListModel(parent)
{
    connect(&sAPI, SIGNAL(gotAllProjectLangStats(QVariantMap)), this, SLOT(populate(QVariantMap)));
    connect(&sAPI, SIGNAL(gotAllProjectLangStatsError(QString)), this, SLOT(errorHandler(QString)));
}
Ejemplo n.º 11
0
int main(int argc, char *argv[])
{
FILE *fIn, *fOut, *fTmp;
char filename[32],buffer[33],name[]="data",title[33];
unsigned int i, j, k, NFILES, NCOLS, NROWS;
double data;

if(argc == 2 && strcmp(argv[1],"-h") == 0){
    printf("\n\nCall as:\n\n\t./break filename nFiles nCols nRows\n\n");
    printf("Breaks a data file into several. Useful when calculations for ");
    printf("several planes\nin Z are done and need to be stored in ");
    printf("independent files with only the X\nand Y information.\n\n");
    printf("Takes the filename to break as input 1 and the number of files ");
    printf("to produce as\ninput 2, followed by the number of columns to ");
    printf("read in the original file and\nthe number of rows in each of the ");
    printf("output data files. The files are saved as\n'data1, data2,...' and");
    printf(" saves columns (X,Y,Z,T).\n\n");
    exit(0);
}
else if(argc != 5){
    printf("\n\nCorrect symtax is: ./break filename nFiles nCols nRows\n");
    errorHandler("Type './break -h' for help.\n");
}

/* INITIALIZATION */
fIn = fopen(argv[1],"r");
NFILES = atoi(argv[2]);
NCOLS = atoi(argv[3]);
NROWS = atoi(argv[4]);

for(i = 1; i <= NFILES; i++)
{
    sprintf(buffer,"%d",i);
    strcpy(filename,name);
    strcat(filename,buffer);
    fOut = fopen(filename,"w");
    if(i>1) fTmp = fopen("data1","r");
    for(j = 0; j <= NROWS; j++){
        if(i == 1 && j == 0){
            for(k = 0; k < NCOLS; k++){
                fscanf(fIn,"%s",&title);
                fprintf(fOut,"%s    ",title);
            }
        }else if(!j){
            for(k = 0; k < NCOLS; k++){
                fscanf(fTmp,"%s",&title);
                fprintf(fOut,"%s    ",title);
            }
        }else{
            for(k = 0; k < NCOLS; k++){
                fscanf(fIn,"%le",&data);
                fprintf(fOut,"%le   ",data);
            }
        }
        fprintf(fOut,"\n");
    }
    fclose(fOut);
    if(i>1) fclose(fTmp);
}
fclose(fIn);

return 1;
}
int main2()
{
	//Tracker			tracker(10000);
	CSystem			PCIBird;
	CSensor			*pSensor;
	CXmtr			*pXmtr;
	int				errorCode;
	int				i;
	int				sensorID;
	short			id;
	int				records = 10000;
	double			rate = 255.0f;

	printf("\n\n");
	printf("ATC3DG Timing Test Application\n");

	//////////////////////////////////////////////////////////////////////////////
	//////////////////////////////////////////////////////////////////////////////
	//////////////////////////////////////////////////////////////////////////////
	//
	// Initialize the PCIBIRD driver and DLL
	//
	// It is always necessary to first initialize the PCIBird "system". By
	// "system" we mean the set of PCIBird cards installed in the PC. All cards
	// will be initialized by a single call to InitializeBIRDSystem(). This
	// call will first invoke a hardware reset of each board. If at any time 
	// during operation of the system an unrecoverable error occurs then the 
	// first course of action should be to attempt to Recall InitializeBIRDSystem()
	// if this doesn't restore normal operating conditions there is probably a
	// permanent failure - contact tech support.
	// A call to InitializeBIRDSystem() does not return any information.
	//
	printf("Initializing ATC3DG system...\n");
	errorCode = InitializeBIRDSystem();
	if(errorCode!=BIRD_ERROR_SUCCESS) 
	{
		errorHandler(errorCode);
		exit(1);
	}

	//////////////////////////////////////////////////////////////////////////////
	//////////////////////////////////////////////////////////////////////////////
	//////////////////////////////////////////////////////////////////////////////
	//
	// GET SYSTEM CONFIGURATION
	//
	// In order to get information about the system we have to make a call to
	// GetBIRDSystemConfiguration(). This call will fill a fixed size structure
	// containing amongst other things the number of boards detected and the
	// number of sensors and transmitters the system can support (Note: This
	// does not mean that all sensors and transmitters that can be supported
	// are physically attached)
	//
	errorCode = GetBIRDSystemConfiguration(&PCIBird.m_config);
	if(errorCode!=BIRD_ERROR_SUCCESS) errorHandler(errorCode);

	//////////////////////////////////////////////////////////////////////////////
	//////////////////////////////////////////////////////////////////////////////
	//////////////////////////////////////////////////////////////////////////////
	//
	// GET SENSOR CONFIGURATION
	//
	// Having determined how many sensors can be supported we can dynamically
	// allocate storage for the information about each sensor.
	// This information is acquired through a call to GetSensorConfiguration()
	// This call will fill a fixed size structure containing amongst other things
	// a status which indicates whether a physical sensor is attached to this
	// sensor port or not.
	//
	pSensor = new CSensor[PCIBird.m_config.numberSensors];
	for(i=0;i<PCIBird.m_config.numberSensors;i++)
	{
		errorCode = GetSensorConfiguration(i, &(pSensor+i)->m_config);
		if(errorCode!=BIRD_ERROR_SUCCESS) errorHandler(errorCode);
	}

	//////////////////////////////////////////////////////////////////////////////
	//////////////////////////////////////////////////////////////////////////////
	//////////////////////////////////////////////////////////////////////////////
	//
	// GET TRANSMITTER CONFIGURATION
	//
	// The call to GetTransmitterConfiguration() performs a similar task to the 
	// GetSensorConfiguration() call. It also returns a status in the filled
	// structure which indicates whether a transmitter is attached to this
	// port or not. In a single transmitter system it is only necessary to 
	// find where that transmitter is in order to turn it on and use it.
	//
	pXmtr = new CXmtr[PCIBird.m_config.numberTransmitters];
	for(i=0;i<PCIBird.m_config.numberTransmitters;i++)
	{
		errorCode = GetTransmitterConfiguration(i, &(pXmtr+i)->m_config);
		if(errorCode!=BIRD_ERROR_SUCCESS) errorHandler(errorCode);
	}

	//
	// Set the measurement rate
	//
	errorCode = SetSystemParameter(MEASUREMENT_RATE, &rate, sizeof(rate));
	if(errorCode!=BIRD_ERROR_SUCCESS) errorHandler(errorCode);

	//
	//////////////////////////////////////////////////////////////////////////////
	//////////////////////////////////////////////////////////////////////////////
	//////////////////////////////////////////////////////////////////////////////
	//
	// Search for the first attached transmitter and turn it on
	//
	for(id=0;id<PCIBird.m_config.numberTransmitters;id++)
	{
		if((pXmtr+id)->m_config.attached)
		{
			// Transmitter selection is a system function.
			// Using the SELECT_TRANSMITTER parameter we send the id of the
			// transmitter that we want to run with the SetSystemParameter() call
			errorCode = SetSystemParameter(SELECT_TRANSMITTER, &id, sizeof(id));
			if(errorCode!=BIRD_ERROR_SUCCESS) errorHandler(errorCode);
			break;
		}
	}

	//////////////////////////////////////////////////////////////////////////////
	//////////////////////////////////////////////////////////////////////////////
	//////////////////////////////////////////////////////////////////////////////
	//
	// Collect data from all birds
	// Loop through all sensors and get a data record if the sensor is attached.
	// Print result to screen
	// Note: The default data format is DOUBLE_POSITION_ANGLES. We can use this
	// format without first setting it.
	// 
	//
	DOUBLE_POSITION_ANGLES_TIME_Q_RECORD record[8*4], *pRecord = record;

	// Set the data format type for each attached sensor.
	for(i=0;i<PCIBird.m_config.numberSensors;i++)
	{
		DATA_FORMAT_TYPE type = DOUBLE_POSITION_ANGLES_TIME_Q;
		errorCode = SetSensorParameter(i,DATA_FORMAT,&type,sizeof(type));
		if(errorCode!=BIRD_ERROR_SUCCESS) errorHandler(errorCode);
	}

	// collect as many records as specified in the records var
	printf("Collecting %d data records at %3.2fhz...\n", records, rate*3.0);
	for(i=0;i<records;i++)
	{
		errorCode = GetSynchronousRecord(ALL_SENSORS, pRecord, sizeof(record[0]) * PCIBird.m_config.numberSensors);
		if(errorCode!=BIRD_ERROR_SUCCESS) 
		{
			errorHandler(errorCode);
		}

		// Get a snap shot of the PC's time
		time_t currentTime;
		time(&currentTime);

		// Some user IO, every 500 records print a progress indication
		if( !(i % 500)) 
			printf( ".");

		// scan the sensors and request a record if the sensor is physically attached
		for(sensorID=0;sensorID<PCIBird.m_config.numberSensors;sensorID++)
		{
			// get the status of the last data record
			// only report the data if everything is okay
			unsigned int status = GetSensorStatus( sensorID);

			if( status == VALID_STATUS)
			{
				// save output to buffer
				sprintf(output[i][sensorID], "[%d] 0x%04x %8.3f %8.3f %8.3f: %8.2f %8.2f %8.2f %8.4f\n",
					sensorID,
					status,
					record[sensorID].x,
					record[sensorID].y,
					record[sensorID].z,
					record[sensorID].a,
					record[sensorID].e,
					record[sensorID].r,
					record[sensorID].time
					);
			}  
		}
	}

	printf("\nSaving results to 'GetSynchronousRecord.dat'..\n");

	FILE *fp = fopen( "GetSynchronousRecord.dat", "w");
	for(i=0;i<records;i++)
		for(sensorID=0;sensorID<PCIBird.m_config.numberSensors;sensorID++)
			fprintf( fp, output[i][sensorID]);
	fclose( fp);
	printf("Complete...\n");

	//////////////////////////////////////////////////////////////////////////////
	//////////////////////////////////////////////////////////////////////////////
	//////////////////////////////////////////////////////////////////////////////
	//
	// Turn off the transmitter before exiting
	// We turn off the transmitter by "selecting" a transmitter with an id of "-1"
	//
	id = -1;
	errorCode = SetSystemParameter(SELECT_TRANSMITTER, &id, sizeof(id));
	if(errorCode!=BIRD_ERROR_SUCCESS) errorHandler(errorCode);

	//////////////////////////////////////////////////////////////////////////////
	//////////////////////////////////////////////////////////////////////////////
	//////////////////////////////////////////////////////////////////////////////
	//
	//  Free memory allocations before exiting
	//
	delete[] pSensor;
	delete[] pXmtr;

	return 0;
}