Index: trunk/MagicSoft/AMC/activemirrorcontrol/activemirrorcontrol/amcmotor.cpp
===================================================================
--- trunk/MagicSoft/AMC/activemirrorcontrol/activemirrorcontrol/amcmotor.cpp	(revision 4481)
+++ trunk/MagicSoft/AMC/activemirrorcontrol/activemirrorcontrol/amcmotor.cpp	(revision 4482)
@@ -34,5 +34,5 @@
 
 /** No descriptions */
-void AMCMotor::sendCommand(const QCString& p_sCommand, QCString& p_sResponse ) const
+void AMCMotor::sendCommand(const QCString& p_sCommand, QCString& p_sResponse, int p_iExpRes ) const
 {
 	char	buffer[256];	
@@ -58,5 +58,6 @@
 		{
       // sleep 30 ms to be sure to get the whole response
-	    usleep(30000);
+//	    usleep(30000);
+//			max = p_iExpRes + iNumEcho;
 			max = 255;
 		}
@@ -64,4 +65,5 @@
 			max = iNumEcho;
 //			max = NUM_ECHO;
+		usleep(10000);
 		int rlen = m_pPort->readBlock( buffer, max );
 		// set the end of the response string to a 0 char to
@@ -70,5 +72,15 @@
     rrlen = rlen;
 	}
-	
+
+/*	
+	if( p_sCommand.contains("B0") != 0 )
+  {
+		QString sResult, qsTemp;
+		for( int i=0; i< rrlen; i++)
+			sResult += qsTemp.sprintf(" %02X",(unsigned char) buffer[i]);		
+		qDebug( sResult );
+	}	
+*/
+
 	// Reset and unselect commands will not return any status
 	if( (p_sCommand == IDS_COMMAND_UNSELECT_BOX)
@@ -81,6 +93,6 @@
 			(buffer[rrlen-1] != '>') )
 	{
-    usleep(20000);
-		int rlen = m_pPort->readBlock( buffer+rrlen, 255 );
+//    usleep(20000);
+		int rlen = m_pPort->readBlock( buffer+rrlen, IDS_CMD_RES_INFO );
 		qDebug("Second iteration for info command. %d bytes", rlen);
 		buffer[rrlen+rlen] = 0;
@@ -150,5 +162,5 @@
 		// send the query command
 		sComm.sprintf( IDS_COMMAND_QUERY );
-		sendCommand( sComm, sResp2 );
+		sendCommand( sComm, sResp2, IDS_CMD_RES_QUERY );
 		
 		// The response should contain the error code in HEX plus '\r>'
@@ -187,5 +199,5 @@
 				// of the box are outside the range. Lets find out which.
 				sComm.sprintf( IDS_COMMAND_INFO );
-				sendCommand( sComm, sResp2 );
+				sendCommand( sComm, sResp2, IDS_CMD_RES_INFO );
 				
 				aErr.setCommand( p_sCommand + " - " + sComm );
@@ -236,6 +248,15 @@
 	QCString sComm, sResp;
 	
+	m_pPort->flush();
 	sComm.sprintf( IDS_COMMAND_BOX, p_iBox );
-	sendCommand( sComm, sResp );
+	try	
+	{
+		sendCommand( sComm, sResp, IDS_CMD_RES_BOX );
+	}
+	catch( AMCError& e)
+	{
+	}
+	sComm.sprintf( IDS_COMMAND_QUERY, p_iBox );
+	sendCommand( sComm, sResp, IDS_CMD_RES_QUERY );	
 }
 
@@ -247,5 +268,5 @@
 	
 	sComm.sprintf( IDS_COMMAND_DRIVER, p_iDriver-1 );
-	sendCommand( sComm, sResp );
+	sendCommand( sComm, sResp, IDS_CMD_RES_DRIVER );
 	m_iCurrDriver = p_iDriver;
 	return;
@@ -272,5 +293,5 @@
   qDebug("Sending kill command");	
 	sComm.sprintf( IDS_COMMAND_KILL );
-	sendCommand( sComm, sResp );
+	sendCommand( sComm, sResp, IDS_CMD_RES_KILL );
 	return;
 }
@@ -287,5 +308,5 @@
 	
 	sComm.sprintf( IDS_COMMAND_INFO );
-	sendCommand( sComm, sResp );
+	sendCommand( sComm, sResp, IDS_CMD_RES_INFO );
 	sscanf( (const char*) sResp,
 			"T=%d\rH=%d\rI=%d\rV=%d\rS=%d\rL=%d\r",
@@ -306,5 +327,5 @@
 	
 	sComm.sprintf( IDS_COMMAND_FREQUENCY_READ );
-	sendCommand( sComm, sResp );
+	sendCommand( sComm, sResp, IDS_CMD_RES_FREQUENCY_READ );
 	
 	int iFrequency;
@@ -320,5 +341,5 @@
 	
 	sComm.sprintf( IDS_COMMAND_FREQUENCY_WRITE, p_iFreq );
-	sendCommand( sComm, sResp );
+	sendCommand( sComm, sResp, IDS_CMD_RES_FREQUENCY_WRITE );
 	m_iCurrFreq = p_iFreq;
 
@@ -332,5 +353,5 @@
 	
 	sComm.sprintf( IDS_COMMAND_WORKING_READ );
-	sendCommand( sComm, sResp );
+	sendCommand( sComm, sResp, IDS_CMD_RES_WORKING_READ );
 	
 	int iCurrent;
@@ -345,5 +366,5 @@
 	
 	sComm.sprintf( IDS_COMMAND_WORKING_WRITE, p_iCurrent );
-	sendCommand( sComm, sResp );
+	sendCommand( sComm, sResp, IDS_CMD_RES_WORKING_WRITE );
 
 	return;	
@@ -356,5 +377,5 @@
 	
 	sComm.sprintf( IDS_COMMAND_HOLDING_READ );
-	sendCommand( sComm, sResp );
+	sendCommand( sComm, sResp, IDS_CMD_RES_HOLDING_READ );
 	
 	int iCurrent;
@@ -369,5 +390,5 @@
 	
 	sComm.sprintf( IDS_COMMAND_HOLDING_WRITE, p_iCurrent );
-	sendCommand( sComm, sResp );
+	sendCommand( sComm, sResp, IDS_CMD_RES_HOLDING_READ );
 
 	return;	
@@ -383,5 +404,5 @@
 	else
 		sComm.sprintf( IDS_COMMAND_LASER_OFF );
-	sendCommand( sComm, sResp );
+	sendCommand( sComm, sResp, IDS_CMD_RES_LASER_ON );
 
 	return;	
@@ -401,5 +422,5 @@
 	else
 		sComm.sprintf( IDS_COMMAND_POWER_OFF );
-	sendCommand( sComm, sResp );
+	sendCommand( sComm, sResp, IDS_CMD_RES_POWER_ON );
 
 	return;	
@@ -412,5 +433,5 @@
 	
 	sComm.sprintf( IDS_COMMAND_CENTER );
-	sendCommand( sComm, sResp );
+	sendCommand( sComm, sResp, IDS_CMD_RES_CENTER );
 
 	return;	
@@ -426,5 +447,5 @@
 	
 	sComm.sprintf( IDS_COMMAND_MOVE, p_iX, p_iY );
-	sendCommand( sComm, sResp );
+	sendCommand( sComm, sResp, IDS_CMD_RES_MOVE );
 
 	return;	
@@ -480,5 +501,5 @@
 			throw aErr;
 		}
-		sendCommand( sComm, sResp );
+		sendCommand( sComm, sResp, IDS_CMD_RES_QUERY );
 		if( sResp[0] != '@' )
 		{
@@ -514,5 +535,5 @@
 	
 	sComm.sprintf( IDS_COMMAND_UNSELECT_BOX );
-	sendCommand( sComm, sResp );
+	sendCommand( sComm, sResp, IDS_CMD_RES_UNSELECT_BOX );
 
 	return;	
@@ -525,5 +546,5 @@
 	
 	sComm.sprintf( IDS_COMMAND_RESET );
-	sendCommand( sComm, sResp );
+	sendCommand( sComm, sResp, IDS_CMD_RES_RESET );
 
 	return;	
@@ -536,6 +557,6 @@
 	
 	sComm.sprintf( IDS_COMMAND_DRIVER_RESET );
-	sendCommand( sComm, sResp );
-
-	return;	
-}
+	sendCommand( sComm, sResp, IDS_CMD_RES_DRIVER_RESET );
+
+	return;	
+}
Index: trunk/MagicSoft/AMC/activemirrorcontrol/activemirrorcontrol/amcmotor.h
===================================================================
--- trunk/MagicSoft/AMC/activemirrorcontrol/activemirrorcontrol/amcmotor.h	(revision 4481)
+++ trunk/MagicSoft/AMC/activemirrorcontrol/activemirrorcontrol/amcmotor.h	(revision 4482)
@@ -122,5 +122,5 @@
 private: // Private methods
   /** No descriptions */
-  void sendCommand(const QCString& p_sCommand, QCString& p_sResponse ) const;
+  void sendCommand(const QCString& p_sCommand, QCString& p_sResponse, int p_iExpRes ) const;
 
 private: // Private attributes
