/* Function: rt_UploadServerWork =============================================== * Abstract: * Wrapper function that calls UploadServerWork once for each upInfo */ PUBLIC void rt_UploadServerWork(int_T numSampTimes) { int i; for (i=0; i<NUM_UPINFOS; i++) { UploadServerWork(i, numSampTimes); } } /* end rt_UploadServerWork */
/* 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 */
/* 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 */
/* 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 */
/* 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 */