예제 #1
0
/* Function: DisconnectFromHost ================================================
 * Abstract:
 *  Disconnect from the host.
 */
PRIVATE void DisconnectFromHost(bool sendFinalUpload, int_T numSampTimes)
{
    int i;

    for (i=0; i<NUM_UPINFOS; i++) {
        if (sendFinalUpload) {
            UploadPrepareForFinalFlush(i);
            UploadServerWork(i, numSampTimes);
            UploadLogInfoTerm(i, numSampTimes);
        }
    }
    
    connected       = FALSE;
    commInitialized = FALSE;
    
    ExtCloseConnection(extUD);
} /* end DisconnectFromHost */
예제 #2
0
파일: ext_qnx_svr.c 프로젝트: kyak/qnx_ert
/* Function: ExtModeShutdown ==================================================
 * Abstract:
 *  Called when target program terminates to enable cleanup of external 
 *  mode for a given upInfo.
 */
PRIVATE void ExtModeShutdown(int32_T upInfoIdx, int_T numSampTimes)
{
    /*
     * Make sure buffers are flushed so that the final points get to
     * host (this is important for the case of the target reaching tfinal
     * while data uploading is in progress).
     */
    UploadPrepareForFinalFlush(upInfoIdx);
    UploadServerWork(upInfoIdx, numSampTimes);

    UploadLogInfoTerm(upInfoIdx, numSampTimes);

    if (pktBuf != NULL) {
        free(pktBuf);
        pktBuf = NULL;
    }

} /* end ExtModeShutdown */
예제 #3
0
파일: ext_qnx_svr.c 프로젝트: kyak/qnx_ert
/* Function: DisconnectFromHost ================================================
 * Abstract:
 *  Disconnect from the host.
 */
PRIVATE void DisconnectFromHost(int_T numSampTimes)
{
    int i;

    for (i=0; i<NUM_UPINFOS; i++) {
        UploadPrepareForFinalFlush(i);

#if defined(QNX_OS)
        /*
         * UploadPrepareForFinalFlush() has already called semGive(uploadSem)
         * two times.  Now the server thread will wait until the upload thread
         * has processed all of the data in the buffers for the final upload
         * and exhausted the uploadSem semaphores.  If the server thread
         * attempts to call UploadServerWork() while the upload thread is in
         * the middle of processing the buffers, the target code may crash
         * with a NULL pointer exception (the buffers are destroyed after
         * calling UploadLogInfoTerm).
         */
#if 0
        while(semTake(uploadSem, NO_WAIT) != ERROR) {
            semGive(uploadSem);
            taskDelay(1000);
        }
#endif
       while (sem_trywait(uploadSem) == 0) {
          sem_post(uploadSem);
          sched_yield();
          
       }
       
      
#else
        UploadServerWork(i, numSampTimes);
#endif

        UploadLogInfoTerm(i, numSampTimes);
    }
    
    connected       = FALSE;
    commInitialized = FALSE;
    
    ExtCloseConnection(extUD);
} /* end DisconnectFromHost */
예제 #4
0
/* Function: rt_ExtModeShutdown ================================================
 * Abstract:
 *  Called when target program terminates to enable cleanup of external 
 *  mode.
 */
PUBLIC boolean_T rt_ExtModeShutdown(SimStruct *S)
{
    boolean_T error = EXT_NO_ERROR;

    /*
     * Make sure buffers are flushed so that the final points get to
     * host (this is important for the case of the target reaching tfinal
     * while data is uploading is in progress).
     */
    UploadPrepareForFinalFlush();
    rt_UploadServerWork(S);
    
    UploadLogInfoTerm();
    if (msgBuf != NULL) free(msgBuf);
    
    if (connected) {
        error = SendMsgToHost(EXT_MODEL_SHUTDOWN, 0, NULL);
        if (error != EXT_NO_ERROR) {
            fprintf(stderr,
                "\nError sending 'EXT_MODEL_SHUTDOWN' message to host.\n");
        }
        connected = FALSE;
        commInitialized = FALSE;
        modelStatus = TARGET_STATUS_WAITING_TO_START;        
    }

    ExtShutDown(extUD);
    ExtUserDataDestroy(extUD);

    /* For internal Mathworks testing only */
#ifdef TMW_GRT_TESTING
# ifdef WIN32
    (void)system("del /f batmarker");
# else
    (void)system("rm -f batmarker");
# endif
#endif
        
    return(error);
} /* end rt_ExtModeShutdown */
/* Function: DisconnectFromHost ================================================
 * Abstract:
 *  Disconnect from the host.
 */
PRIVATE void DisconnectFromHost(int_T numSampTimes)
{
    int i;

    for (i=0; i<NUM_UPINFOS; i++) {
        UploadPrepareForFinalFlush(i);

#if defined(VXWORKS)
        /*
         * UploadPrepareForFinalFlush() has already called semGive(uploadSem)
         * two times.  Now the server thread will wait until the upload thread
         * has processed all of the data in the buffers for the final upload
         * and exhausted the uploadSem semaphores.  If the server thread
         * attempts to call UploadServerWork() while the upload thread is in
         * the middle of processing the buffers, the target code may crash
         * with a NULL pointer exception (the buffers are destroyed after
         * calling UploadLogInfoTerm).
         */
        while(semTake(uploadSem, NO_WAIT) != ERROR) {
            semGive(uploadSem);
            taskDelay(1000);
        }
#else
#ifndef EXTMODE_DISABLESIGNALMONITORING
        if (host_upstatus_is_uploading) {
            UploadServerWork(i, numSampTimes);
        }
#endif
#endif

        UploadLogInfoTerm(i, numSampTimes);
    }
    
    connected       = false;
    commInitialized = false;
    
    ExtCloseConnection(extUD);
} /* end DisconnectFromHost */
예제 #6
0
/* Function: DisconnectFromHost ================================================
 * Abstract:
 *  Disconnect from the host.
 */
PRIVATE void DisconnectFromHost(SimStruct *S)
{
    UploadPrepareForFinalFlush();
#ifdef VXWORKS
    /*
     * Patch by Gopal Santhanam 5/24/2002 (for VXWORKS) We
     * were having problems in RTAI in that the semaphore
     * signaled in UploadPrepareForFinalFlush was taken up by
     * the upload server task.  This meant that the subsequent
     * call to rt_UploadServerWork in this function would
     * block indefinitely!
     */
    semGive(uploadSem);
#endif
    rt_UploadServerWork(S);
    
    UploadLogInfoTerm();

    connected       = FALSE;
    commInitialized = FALSE;

    ExtCloseConnection(extUD);
} /* end DisconnectFromHost */