Exemplo n.º 1
0
void rtExtModeCheckInit(int_T numSampTimes)
{
    UNUSED_PARAMETER(numSampTimes);
    if (rt_ExtModeInit() != EXT_NO_ERROR){
#ifndef EXTMODE_DISABLEPRINTF            
            printf("Error calling rt_ExtModeInit!\n");
#endif
    }
}
Exemplo n.º 2
0
void rtExtModeTornadoStartup(RTWExtModeInfo *ei,
                             int_T          numSampTimes,
                             boolean_T      *stopReqPtr,
                             int_T          priority,
                             int32_T        stack_size,
                             SEM_ID         startStopSem)
{
    uploadSem = semBCreate(SEM_Q_PRIORITY, SEM_EMPTY);
    commSem   = semBCreate(SEM_Q_PRIORITY, SEM_FULL);
    pktSem    = semBCreate(SEM_Q_PRIORITY, SEM_FULL);

    rt_ExtModeInit();

    extern_pkt_tid = taskSpawn("tExternPkt",
        priority+(numSampTimes), VX_FP_TASK, stack_size, (FUNCPTR)rt_PktServer, 
        (int_T) ei, (int_T) numSampTimes, (int_T) stopReqPtr, 0, 0, 0, 0, 0, 0, 0);
    if (extern_pkt_tid == ERROR) {
#ifndef EXTMODE_DISABLEPRINTF
        printf("handle taskpawn error");
#endif
    }

    extern_upload_tid = taskSpawn("tExternUpload",
        priority+(numSampTimes)+1,VX_FP_TASK, stack_size,(FUNCPTR)rt_UploadServer,
        (int_T) numSampTimes, 0, 0, 0, 0, 0, 0, 0, 0, 0);
    if (extern_upload_tid == ERROR) {
#ifndef EXTMODE_DISABLEPRINTF
        printf("handle taskpawn error");
#endif
    }

    /*
     * Pause until receive model start packet - if external mode.
     * Make sure the external mode tasks are running so that 
     * we are listening for commands from the host.
     */
    if (ExtWaitForStartPkt()) {
#ifndef EXTMODE_DISABLEPRINTF
        printf("\nWaiting for start packet from host.\n");
#endif
        semTake(startStopSem, WAIT_FOREVER);
    }
    modelStatus = TARGET_STATUS_RUNNING;
}
Exemplo n.º 3
0
// External mode startup function
void rtExtModeC6000Startup( RTWExtModeInfo *ei,
                            int_T          numSampTimes,
                            boolean_T      *stopReqPtr)
{
    Task_Params attr;
    Task_Params_init(&attr);
    Semaphore_Params sem_params; 
    Semaphore_Params_init(&sem_params);

    sem_params.mode = ti_sysbios_knl_Semaphore_Mode_BINARY; 
  
    sExtStepArgs.ei = ei;
    sExtStepArgs.numSampTimes = numSampTimes;
    sExtStepArgs.stopReqPtr = stopReqPtr;
    attr.arg1 = (UArg) &sExtStepArgs;

    // Set external mode state to 
    extmodeSimStatus = EXTMODE_STARTUP;

	// Initialize semaphores used for external mode
	// communication
    uploadSem = Semaphore_create(1, &sem_params, NULL);
    extStartStopSem = Semaphore_create(1, NULL, NULL);

    // Pause until Ethernet network initialization completes
    //waitNetworkStartup();
    extmodeSimStatus = EXTMODE_NET_INITIALIZED;

    // Initialize user data structure
    rtExtModeInitUD();
    rt_ExtModeInit();

    // Create external mode task
    attr.priority = 1;
    attr.stack = (Ptr) &stack_pkt_tid[0];
    attr.stackSize = EXT_MODE_TSK_STACK_SIZE;
    extern_pkt_tid = Task_create( (Task_FuncPtr) rtExtModeOneStep,
        &attr, NULL );
    if (extern_pkt_tid == NULL) 
    {
        printf("handle taskpawn error");
    }

 
    /*
     * Pause until receive model start packet - if external mode.
     * Make sure the external mode tasks are running so that 
     * we are listening for commands from the host.
     */
    extmodeSimStatus = EXTMODE_WAITING_START_PACKET;
    modelStatus      = TARGET_STATUS_WAITING_TO_START;
    if (ExtWaitForStartPkt()) 
    {
        printf("\nWaiting for start packet from host.\n");
        // rt_PktServerWork() function posts a semaphore when
        // it receives start packet from host
        // this function in turn runs as part of rt_PktServer task
        //Semaphore_pend(extStartStopSem, BIOS_WAIT_FOREVER);
        while (rt_PktServerWork(ei, numSampTimes, stopReqPtr) != EXT_MODEL_START)
        {
        };
    }
    modelStatus      = TARGET_STATUS_RUNNING;
    extmodeSimStatus = EXTMODE_RUNNING;
}
Exemplo n.º 4
0
void rtExtModeCheckInit(int_T numSampTimes)
{
    UNUSED_PARAMETER(numSampTimes);
    if (rt_ExtModeInit() != EXT_NO_ERROR) exit(EXIT_FAILURE);
}