Changeset 4482 for trunk/MagicSoft


Ignore:
Timestamp:
08/04/04 16:36:29 (20 years ago)
Author:
merck
Message:
MMerck: Added code to check for correct length of response. Was disabled as AMC boards return different length depending on used compiler version.
Location:
trunk/MagicSoft/AMC/activemirrorcontrol/activemirrorcontrol
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/AMC/activemirrorcontrol/activemirrorcontrol/amcmotor.cpp

    r3401 r4482  
    3434
    3535/** No descriptions */
    36 void AMCMotor::sendCommand(const QCString& p_sCommand, QCString& p_sResponse ) const
     36void AMCMotor::sendCommand(const QCString& p_sCommand, QCString& p_sResponse, int p_iExpRes ) const
    3737{
    3838        char    buffer[256];   
     
    5858                {
    5959      // sleep 30 ms to be sure to get the whole response
    60             usleep(30000);
     60//          usleep(30000);
     61//                      max = p_iExpRes + iNumEcho;
    6162                        max = 255;
    6263                }
     
    6465                        max = iNumEcho;
    6566//                      max = NUM_ECHO;
     67                usleep(10000);
    6668                int rlen = m_pPort->readBlock( buffer, max );
    6769                // set the end of the response string to a 0 char to
     
    7072    rrlen = rlen;
    7173        }
    72        
     74
     75/*     
     76        if( p_sCommand.contains("B0") != 0 )
     77  {
     78                QString sResult, qsTemp;
     79                for( int i=0; i< rrlen; i++)
     80                        sResult += qsTemp.sprintf(" %02X",(unsigned char) buffer[i]);           
     81                qDebug( sResult );
     82        }       
     83*/
     84
    7385        // Reset and unselect commands will not return any status
    7486        if( (p_sCommand == IDS_COMMAND_UNSELECT_BOX)
     
    8193                        (buffer[rrlen-1] != '>') )
    8294        {
    83     usleep(20000);
    84                 int rlen = m_pPort->readBlock( buffer+rrlen, 255 );
     95//    usleep(20000);
     96                int rlen = m_pPort->readBlock( buffer+rrlen, IDS_CMD_RES_INFO );
    8597                qDebug("Second iteration for info command. %d bytes", rlen);
    8698                buffer[rrlen+rlen] = 0;
     
    150162                // send the query command
    151163                sComm.sprintf( IDS_COMMAND_QUERY );
    152                 sendCommand( sComm, sResp2 );
     164                sendCommand( sComm, sResp2, IDS_CMD_RES_QUERY );
    153165               
    154166                // The response should contain the error code in HEX plus '\r>'
     
    187199                                // of the box are outside the range. Lets find out which.
    188200                                sComm.sprintf( IDS_COMMAND_INFO );
    189                                 sendCommand( sComm, sResp2 );
     201                                sendCommand( sComm, sResp2, IDS_CMD_RES_INFO );
    190202                               
    191203                                aErr.setCommand( p_sCommand + " - " + sComm );
     
    236248        QCString sComm, sResp;
    237249       
     250        m_pPort->flush();
    238251        sComm.sprintf( IDS_COMMAND_BOX, p_iBox );
    239         sendCommand( sComm, sResp );
     252        try     
     253        {
     254                sendCommand( sComm, sResp, IDS_CMD_RES_BOX );
     255        }
     256        catch( AMCError& e)
     257        {
     258        }
     259        sComm.sprintf( IDS_COMMAND_QUERY, p_iBox );
     260        sendCommand( sComm, sResp, IDS_CMD_RES_QUERY );
    240261}
    241262
     
    247268       
    248269        sComm.sprintf( IDS_COMMAND_DRIVER, p_iDriver-1 );
    249         sendCommand( sComm, sResp );
     270        sendCommand( sComm, sResp, IDS_CMD_RES_DRIVER );
    250271        m_iCurrDriver = p_iDriver;
    251272        return;
     
    272293  qDebug("Sending kill command");       
    273294        sComm.sprintf( IDS_COMMAND_KILL );
    274         sendCommand( sComm, sResp );
     295        sendCommand( sComm, sResp, IDS_CMD_RES_KILL );
    275296        return;
    276297}
     
    287308       
    288309        sComm.sprintf( IDS_COMMAND_INFO );
    289         sendCommand( sComm, sResp );
     310        sendCommand( sComm, sResp, IDS_CMD_RES_INFO );
    290311        sscanf( (const char*) sResp,
    291312                        "T=%d\rH=%d\rI=%d\rV=%d\rS=%d\rL=%d\r",
     
    306327       
    307328        sComm.sprintf( IDS_COMMAND_FREQUENCY_READ );
    308         sendCommand( sComm, sResp );
     329        sendCommand( sComm, sResp, IDS_CMD_RES_FREQUENCY_READ );
    309330       
    310331        int iFrequency;
     
    320341       
    321342        sComm.sprintf( IDS_COMMAND_FREQUENCY_WRITE, p_iFreq );
    322         sendCommand( sComm, sResp );
     343        sendCommand( sComm, sResp, IDS_CMD_RES_FREQUENCY_WRITE );
    323344        m_iCurrFreq = p_iFreq;
    324345
     
    332353       
    333354        sComm.sprintf( IDS_COMMAND_WORKING_READ );
    334         sendCommand( sComm, sResp );
     355        sendCommand( sComm, sResp, IDS_CMD_RES_WORKING_READ );
    335356       
    336357        int iCurrent;
     
    345366       
    346367        sComm.sprintf( IDS_COMMAND_WORKING_WRITE, p_iCurrent );
    347         sendCommand( sComm, sResp );
     368        sendCommand( sComm, sResp, IDS_CMD_RES_WORKING_WRITE );
    348369
    349370        return;
     
    356377       
    357378        sComm.sprintf( IDS_COMMAND_HOLDING_READ );
    358         sendCommand( sComm, sResp );
     379        sendCommand( sComm, sResp, IDS_CMD_RES_HOLDING_READ );
    359380       
    360381        int iCurrent;
     
    369390       
    370391        sComm.sprintf( IDS_COMMAND_HOLDING_WRITE, p_iCurrent );
    371         sendCommand( sComm, sResp );
     392        sendCommand( sComm, sResp, IDS_CMD_RES_HOLDING_READ );
    372393
    373394        return;
     
    383404        else
    384405                sComm.sprintf( IDS_COMMAND_LASER_OFF );
    385         sendCommand( sComm, sResp );
     406        sendCommand( sComm, sResp, IDS_CMD_RES_LASER_ON );
    386407
    387408        return;
     
    401422        else
    402423                sComm.sprintf( IDS_COMMAND_POWER_OFF );
    403         sendCommand( sComm, sResp );
     424        sendCommand( sComm, sResp, IDS_CMD_RES_POWER_ON );
    404425
    405426        return;
     
    412433       
    413434        sComm.sprintf( IDS_COMMAND_CENTER );
    414         sendCommand( sComm, sResp );
     435        sendCommand( sComm, sResp, IDS_CMD_RES_CENTER );
    415436
    416437        return;
     
    426447       
    427448        sComm.sprintf( IDS_COMMAND_MOVE, p_iX, p_iY );
    428         sendCommand( sComm, sResp );
     449        sendCommand( sComm, sResp, IDS_CMD_RES_MOVE );
    429450
    430451        return;
     
    480501                        throw aErr;
    481502                }
    482                 sendCommand( sComm, sResp );
     503                sendCommand( sComm, sResp, IDS_CMD_RES_QUERY );
    483504                if( sResp[0] != '@' )
    484505                {
     
    514535       
    515536        sComm.sprintf( IDS_COMMAND_UNSELECT_BOX );
    516         sendCommand( sComm, sResp );
     537        sendCommand( sComm, sResp, IDS_CMD_RES_UNSELECT_BOX );
    517538
    518539        return;
     
    525546       
    526547        sComm.sprintf( IDS_COMMAND_RESET );
    527         sendCommand( sComm, sResp );
     548        sendCommand( sComm, sResp, IDS_CMD_RES_RESET );
    528549
    529550        return;
     
    536557       
    537558        sComm.sprintf( IDS_COMMAND_DRIVER_RESET );
    538         sendCommand( sComm, sResp );
    539 
    540         return;
    541 }
     559        sendCommand( sComm, sResp, IDS_CMD_RES_DRIVER_RESET );
     560
     561        return;
     562}
  • trunk/MagicSoft/AMC/activemirrorcontrol/activemirrorcontrol/amcmotor.h

    r3401 r4482  
    122122private: // Private methods
    123123  /** No descriptions */
    124   void sendCommand(const QCString& p_sCommand, QCString& p_sResponse ) const;
     124  void sendCommand(const QCString& p_sCommand, QCString& p_sResponse, int p_iExpRes ) const;
    125125
    126126private: // Private attributes
Note: See TracChangeset for help on using the changeset viewer.