/* Function: rt_ExtModeShutdown ================================================ * Abstract: * Called when target program terminates to enable cleanup of external * mode. */ PUBLIC boolean_T rt_ExtModeShutdown(int_T numSampTimes) { int i; boolean_T error = EXT_NO_ERROR; for (i=0; i<NUM_UPINFOS; i++) { ExtModeShutdown(i, numSampTimes); } if (commInitialized) { error = SendPktToHost(EXT_MODEL_SHUTDOWN, 0, NULL); if (error != EXT_NO_ERROR) { fprintf(stderr, "\nError sending EXT_MODEL_SHUTDOWN packet to host.\n"); } commInitialized = FALSE; } if (connected) { connected = FALSE; modelStatus = TARGET_STATUS_WAITING_TO_START; } ExtShutDown(extUD); ExtUserDataDestroy(extUD); rtExtModeTestingRemoveBatMarker(); return(error); } /* end rt_ExtModeShutdown */
/* 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 */