Ejemplo n.º 1
0
PUBLIC void* rt_UploadServer(void *arg )
{
    int_T numSampTimes;
    numSampTimes = *((int_T *)arg);
    printf ("numSampTimes in rt_UploadServer is %d\n", numSampTimes);
    for(;;) {
        rt_UploadServerWork(numSampTimes);
    }
} /* end rt_UploadServer */
Ejemplo n.º 2
0
void rtExtModeOneStep(RTWExtModeInfo *ei,
                      int_T          numSampTimes,
                      boolean_T      *stopReqPtr)
{
    /*
     * In a multi-tasking environment, this would be removed from the base rate
     * and called as a "background" task.
     */
    if (modelStatus != TARGET_STATUS_PAUSED) {
        rt_PktServerWork(ei,numSampTimes,stopReqPtr);
#ifndef EXTMODE_DISABLESIGNALMONITORING
        rt_UploadServerWork(numSampTimes);
#endif
    }
}
Ejemplo n.º 3
0
/* Function ====================================================================
 * Pause the process (w/o hogging the cpu) until receive step packet (which
 * means the startModel flag moves to true) or until we are no longer
 * in the paused state.  The packet/upload server must continue to process
 * events (otherwise the host would not be able to communicate with the target).
 */
void rtExtModePauseIfNeeded(RTWExtModeInfo *ei,
                            int_T          numSampTimes,
                            boolean_T      *stopReqPtr)
{
    while((modelStatus == TARGET_STATUS_PAUSED) && 
          !startModel && !(*stopReqPtr)) {
        rt_ExtModeSleep(0L, 375000L);
        rt_PktServerWork(ei,numSampTimes,stopReqPtr);
#ifndef EXTMODE_DISABLESIGNALMONITORING
        rt_UploadServerWork(numSampTimes);
#endif
    }
    startModel = FALSE; /* reset to FALSE - if we were stepped we want to
                         *                  stop again next time we get
                         *                  back here.
                         */
} /* end rtExtModePauseIfNeeded */
Ejemplo n.º 4
0
// This task is run at priority level 1, essentially a background
// task. 
void rtExtModeOneStep(UArg arg0, ExtStepArgs *arg1)
{
    // Process external mode packets and upload data
    //TSK_prolog( TSK_self() );
    RTWExtModeInfo *ei = arg1->ei;
    int_T numSampTimes = arg1->numSampTimes;
    boolean_T *stopReqPtr = arg1->stopReqPtr;
    while (extmodeSimStatus != EXTMODE_STOPPED) {
        rt_PktServerWork(ei, numSampTimes, stopReqPtr);
        rt_UploadServerWork(numSampTimes);
    }
    rt_ExtModeShutdown(numSampTimes);
    //TSK_epilog( TSK_self() );
    
    /* TODO: */ 
    Clock_delete( &rt_task_handle );
    rt_TermModel();
    
    // Signal completion of Pkt / Upload server work
    Semaphore_post(extStartStopSem);
}
Ejemplo n.º 5
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 */
Ejemplo n.º 6
0
/* Function ====================================================================
 * Pause the process (w/o hogging the cpu) until receive start packet
 * from the host.  The packet/upload server must continue to process
 * events (otherwise the host would not be able to communicate with the target).
 */
void rtExtModeWaitForStartPkt(RTWExtModeInfo *ei,
                              int_T          numSampTimes,
                              boolean_T      *stopReqPtr)
{
    /*
     * Pause until receive model start packet.
     */
    if (ExtWaitForStartPkt()) {
        while(!startModel && !(*stopReqPtr)) {
            rt_ExtModeSleep(0L, 375000L);
            rt_PktServerWork(ei,numSampTimes,stopReqPtr);
#ifndef EXTMODE_DISABLESIGNALMONITORING
            rt_UploadServerWork(numSampTimes);
#endif
        }
    }
    if (modelStatus != TARGET_STATUS_PAUSED) {
        modelStatus = TARGET_STATUS_RUNNING;
    } else {
        /* leave in pause mode */
    }
}
Ejemplo n.º 7
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 */
Ejemplo n.º 8
0
PUBLIC boolean_T rt_UploadServer(SimStruct *S)
{
    for(;;) {
        if (rt_UploadServerWork(S) == EXT_ERROR) return(EXT_ERROR);
    }
} /* end rt_UploadServer */
PUBLIC void rt_UploadServer(int_T numSampTimes)
{
    for(;;) {
        rt_UploadServerWork(numSampTimes);
    }
} /* end rt_UploadServer */