コード例 #1
0
ファイル: Dcm_Dsl.c プロジェクト: t8534/acore_repo
//
//	This function implements the requirement DCM139 when
// 	transition from one session to another.
//
static void changeDiagnosticSession(Dcm_DslRunTimeProtocolParametersType *runtime, Dcm_SesCtrlType newSession) {

	/** @req DCM139 */

	switch (runtime->sessionControl) {
	case DCM_DEFAULT_SESSION: // "default".
		/* to set the dsp buffer to default*/
		DspInit();
		break;

	case DCM_PROGRAMMING_SESSION:
	case DCM_EXTENDED_DIAGNOSTIC_SESSION:
	case DCM_SAFTEY_SYSTEM_DIAGNOSTIC_SESSION:
	case DCM_ALL_SESSION_LEVEL:
		runtime->securityLevel = DCM_SEC_LEV_LOCKED; // "0x00".
		break;

	default:
		DET_REPORTERROR(MODULE_ID_DCM, 0, DCM_CHANGE_DIAGNOSTIC_SESSION_ID, DCM_E_PARAM);
		DEBUG(DEBUG_MEDIUM, "Old session invalid");
		break;
	}

	switch (newSession) {
	case DCM_DEFAULT_SESSION: // "default".
	case DCM_PROGRAMMING_SESSION:
	case DCM_EXTENDED_DIAGNOSTIC_SESSION:
	case DCM_SAFTEY_SYSTEM_DIAGNOSTIC_SESSION:
	case DCM_ALL_SESSION_LEVEL:
		runtime->sessionControl = newSession;
		break;

	default:
		DET_REPORTERROR(MODULE_ID_DCM, 0, DCM_CHANGE_DIAGNOSTIC_SESSION_ID, DCM_E_PARAM);
		DEBUG(DEBUG_MEDIUM, "New session invalid");
		break;
	}
}
コード例 #2
0
ファイル: Dcm_Dsl.c プロジェクト: t8534/acore_repo
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
//	Implements 'void Dcm_MainFunction(void)' for DSL.
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void DslMain(void) {
	const Dcm_DslProtocolRowType *protocolRowEntry;
	const Dcm_DspSessionRowType *sessionRow = NULL;
	Dcm_DslRunTimeProtocolParametersType *runtime = NULL;

	protocolRowEntry = DCM_Config.Dsl->DslProtocol->DslProtocolRowList;
	while (protocolRowEntry->Arc_EOL == FALSE) {
		runtime = protocolRowEntry->DslRunTimeProtocolParameters;
		if (runtime != NULL) {
			// #### HANDLE THE TESTER PRESENT PRESENCE ####
			if (runtime->sessionControl != DCM_DEFAULT_SESSION) { // Timeout if tester present is lost.
				if( TRUE == runtime->S3ServerStarted ) {
					DECREMENT(runtime->S3ServerTimeoutCount);
					if (runtime->S3ServerTimeoutCount == 0) {
						changeDiagnosticSession(runtime, DCM_DEFAULT_SESSION); /** @req DCM140 */
						runtime->protocolStarted = FALSE;
						if( (NULL != DcmDslRunTimeData.activeProtocol) &&
								(protocolRowEntry->DslProtocolID == DcmDslRunTimeData.activeProtocol->DslProtocolID) ) {
							DcmDslRunTimeData.activeProtocol = NULL;
						}
						if( (NULL != DcmDslRunTimeData.preemptingProtocol)
								&& (protocolRowEntry->DslProtocolID == DcmDslRunTimeData.preemptingProtocol->DslProtocolID) ) {
							DcmDslRunTimeData.preemptingProtocol = NULL;
						}
					}
				}
			}
			switch (runtime->externalTxBufferStatus) { // #### TX buffer state. ####
			case NOT_IN_USE:
				DEBUG( DEBUG_MEDIUM, "state NOT_IN_USE!\n");
				break;
			case PROVIDED_TO_DSD: {
				DECREMENT(runtime->stateTimeoutCount);
				if (runtime->stateTimeoutCount == 0) {
					sessionRow = getActiveSessionRow(runtime);
					runtime->stateTimeoutCount = DCM_CONVERT_MS_TO_MAIN_CYCLES(sessionRow->DspSessionP2StarServerMax); /* Reinitiate timer, see 9.2.2. */
					if (DCM_Config.Dsl->DslDiagResp != NULL) {
						if (DCM_Config.Dsl->DslDiagResp->DslDiagRespForceRespPendEn == TRUE) {
							if (runtime->responsePendingCount != 0) {
								sendResponse(protocolRowEntry, DCM_E_RESPONSEPENDING);  /** @req DCM024 */
								DECREMENT( runtime->responsePendingCount );
							} else {
								DspCancelPendingRequests();
								sendResponse(protocolRowEntry, DCM_E_GENERALREJECT); /** @req DCM120 */
								releaseExternalRxTxBuffers(protocolRowEntry, runtime);
							}
						} else {
							DEBUG( DEBUG_MEDIUM, "Not configured to send response pending, now sending general reject!\n");
							DspCancelPendingRequests();
							sendResponse(protocolRowEntry, DCM_E_GENERALREJECT);
							releaseExternalRxTxBuffers(protocolRowEntry, runtime);
						}
					}
				}
				break;
			}
			case DSD_PENDING_RESPONSE_SIGNALED:
				// The DSD has signaled to DSL that the diagnostic response is available in the Tx buffer.
				// Make sure that response pending or general reject have not been issued,
				// if so we can not transmit to PduR because we would not know from where
				// the Tx confirmation resides later.
				DEBUG( DEBUG_MEDIUM, "state DSD_PENDING_RESPONSE_SIGNALED!\n");
				if (runtime->localTxBuffer.status == NOT_IN_USE) { // Make sure that no TxConfirm could be sent by the local buffer and mixed up with this transmission.
					const Dcm_DslProtocolRxType *protocolRx = NULL;
					const Dcm_DslMainConnectionType *mainConnection = NULL;
					const Dcm_DslConnectionType *connection = NULL;
					const Dcm_DslProtocolRowType *protocolRow = NULL;
					Std_ReturnType transmitResult;

					if (findRxPduIdParentConfigurationLeafs(runtime->diagReqestRxPduId, &protocolRx, &mainConnection, &connection, &protocolRow, &runtime)) {
						const PduIdType txPduId = mainConnection->DslProtocolTx->DcmDslProtocolTxPduId;
						DEBUG( DEBUG_MEDIUM, "runtime->externalTxBufferStatus enter state DCM_TRANSMIT_SIGNALED.\n" );
						runtime->externalTxBufferStatus = DCM_TRANSMIT_SIGNALED;
						transmitResult = PduR_DcmTransmit(txPduId, &runtime->diagnosticResponseFromDsd); /** @req DCM237 *//* Will trigger PduR (CanTP) to call DslProvideTxBuffer(). */
						if (transmitResult != E_OK) {
							// TODO: What to do here?
							releaseExternalRxTxBuffers(protocolRow, runtime);
						}
					} else {
						DEBUG( DEBUG_MEDIUM, "***** WARNING, THIS IS UNEXPECTED !!! ********.\n" );
						const PduIdType txPduId = protocolRowEntry->DslConnection->DslMainConnection->DslProtocolTx->DcmDslProtocolTxPduId;
						DEBUG( DEBUG_MEDIUM, "runtime->externalTxBufferStatus enter state DSD_PENDING_RESPONSE_SIGNALED.\n", txPduId);
						runtime->externalTxBufferStatus = DCM_TRANSMIT_SIGNALED;
						DEBUG( DEBUG_MEDIUM, "Calling PduR_DcmTransmit with txPduId = %d from DslMain\n", txPduId);
						transmitResult = PduR_DcmTransmit(txPduId, &runtime->diagnosticResponseFromDsd); /** @req DCM237 *//* Will trigger PduR (CanTP) to call DslProvideTxBuffer(). */
						if (transmitResult != E_OK) {
							// TODO: What to do here?
							releaseExternalRxTxBuffers(protocolRow, runtime);
						}
					}
				}
				break;
			case DCM_TRANSMIT_SIGNALED:
				DEBUG( DEBUG_MEDIUM, "state DSD_PENDING_RESPONSE_SIGNALED!\n");
				break;
			case PROVIDED_TO_PDUR: // The valid data is being transmitted by TP-layer.
				DEBUG( DEBUG_MEDIUM, "state DSD_PENDING_RESPONSE_SIGNALED!\n");
				break;
			case PREEMPT_TRANSMIT_NRC: /* preemption has happened,send NRC 0x21 to OBD tester */
//				DEBUG( DEBUG_MEDIUM, "state PREEMPT_TRANSMIT_NRC!\n");
				if (TRUE == PreemptionNotProcessingDone){
					if( !BusyRepeatSent ) {
						/*sent NRC 0x21 till timeout or processing done*/
						sendResponse(protocolRowEntry, DCM_E_BUSYREPEATREQUEST);
						BusyRepeatSent = TRUE;
					}

					/*decrease preempt timeout count*/					
					DECREMENT(runtime->preemptTimeoutCount);
//					DEBUG( DEBUG_MEDIUM, "runtime->preemptTimeoutCount = %x\n",runtime->preemptTimeoutCount);
					/*if processing done is finished,clear the flag*/
//					DEBUG( DEBUG_MEDIUM, "DcmDslRunTimeData.activeProtocol->DslRunTimeProtocolParameters->externalTxBufferStatus = %x\n",DcmDslRunTimeData.activeProtocol->DslRunTimeProtocolParameters->externalTxBufferStatus);
					if (DcmDslRunTimeData.activeProtocol->DslRunTimeProtocolParameters->externalTxBufferStatus == NOT_IN_USE){
						/*if processing done is finished,clear the flag*/
						PreemptionNotProcessingDone = FALSE;
						/*close the preempted protocol*/
						DcmDslRunTimeData.activeProtocol->DslRunTimeProtocolParameters->protocolStarted = FALSE;
						/*remove the active protocol and waiting for second OBD request*/
						DcmDslRunTimeData.activeProtocol = NULL;
						/*release current protocol buffer*/
						releaseExternalRxTxBuffers(protocolRowEntry, runtime);
						DcmDslRunTimeData.preemptingProtocol = NULL;
					}
					else if(runtime->preemptTimeoutCount == 0){
						/*if preempt timeout,clear the flag*/
						PreemptionNotProcessingDone = FALSE;
						/*close the preempted protocol*/
						DcmDslRunTimeData.activeProtocol->DslRunTimeProtocolParameters->protocolStarted = FALSE;
						/*release the extrnal Rx and Tx buffters of the preempted protocol*/
						releaseExternalRxTxBuffers(DcmDslRunTimeData.activeProtocol, DcmDslRunTimeData.activeProtocol->DslRunTimeProtocolParameters);
						/*remove the active protocol and waiting for second OBD request*/
						DcmDslRunTimeData.activeProtocol = NULL;
						/*release the extrnal Rx and Tx buffters of the preempting protocol*/
						releaseExternalRxTxBuffers(protocolRowEntry, runtime);
						DcmDslRunTimeData.preemptingProtocol = NULL;
						/*initialize DSP*/
						DspInit();
					}
					else
					{
					}																															
				}
				break;
			default:
				break;
			}
		}
		protocolRowEntry++;
	}
}
コード例 #3
0
ファイル: AudioPlayer.cpp プロジェクト: hihua/hihuacode
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow, MAINWND* main_wnd)
{  		
	DWORD style = WS_OVERLAPPEDWINDOW;
	style ^= WS_MAXIMIZEBOX;
	style ^= WS_SIZEBOX;

	main_wnd->inst = hInstance;
	main_wnd->hWnd = CreateWindowEx(WS_EX_ACCEPTFILES, main_wnd->szWindowClass, main_wnd->szTitle, style, CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);
		
	if (!main_wnd->hWnd)
		return FALSE;

	Gdiplus::GdiplusStartupInput gdiInput;
	Gdiplus::GdiplusStartup(&main_wnd->gdiToken, &gdiInput, NULL);
		
	main_wnd->spectrumline = TRUE;
	main_cdrom = GetCDROM();
	Gdiplus::GdiplusStartupInput startupInput;	
	Gdiplus::GdiplusStartup(&gditoken, &startupInput, NULL);
	
	RECT rect = {0};		
	GetClientRect(main_wnd->hWnd, &rect);	
	LONG height = 0;
	LONG width = BANDCOUNT * (BANDWIDTH + BANDSPACE) + 10;
			
	rect.right = width;
	rect.bottom = 38;
	CLOCKINFO* clockinfo = ClockInfoInit(&rect, main_wnd);
	if (clockinfo == NULL)
		return FALSE;

	clockinfo->status = &playerstatus;
	clockinfo->player = &player;

	rect.top = rect.bottom;
	rect.bottom = rect.top + 80;	
	SPECTRUM* spectrum = SpectrumInit(&rect, main_wnd);
	if (spectrum == NULL)
		return FALSE;
	
	spectrum->status = &playerstatus;
	spectrum->player = &player;
	
	rect.top = rect.bottom + 1;
	rect.bottom = rect.top + 20;
	main_wnd->hTrack = CreateWindow(TRACKBAR_CLASS, _T(""), WS_CHILD | WS_VISIBLE | TBS_BOTH | TBS_NOTICKS, rect.left, rect.top, rect.right - rect.left - 6, rect.bottom - rect.top, main_wnd->hWnd, NULL, hInstance, NULL);
	if (main_wnd->hTrack == NULL)
		return FALSE;

	SendMessage(main_wnd->hTrack, TBM_SETRANGE, (WPARAM)FALSE, (LPARAM)MAKELONG(0, TRACK_PROGRESS));
	SendMessage(main_wnd->hTrack, TBM_SETLINESIZE, (WPARAM)FALSE, (LPARAM)5);
	SendMessage(main_wnd->hTrack, TBM_SETPAGESIZE, (WPARAM)FALSE, (LPARAM)5);
	TrackEnable(FALSE);
		
	height += rect.bottom;
	rect.top = rect.bottom + 1;
	rect.bottom = rect.top + 300;	
	if (!SongListInit(&rect, main_wnd))
		return FALSE;

	LYRICWND* lyric_wnd = LyricInit(main_wnd);
	if (lyric_wnd == NULL)
		return FALSE;

	lyric_wnd->status = &playerstatus;
	lyric_wnd->player = &player;

	LYRICSEARCH* lyric_search = LyricSearchInit(main_wnd);
	if (lyric_search == NULL)
		return FALSE;

	lyric_search->status = &playerstatus;
	lyric_search->player = &player;

	height += rect.bottom - rect.top;
	GetClientRect(main_wnd->hWnd, &rect);
	LONG bottom = rect.bottom - rect.top;
	GetWindowRect(main_wnd->hWnd, &rect);
	rect.left = 0;
	rect.right = width;
	bottom = rect.bottom - rect.top - bottom;
	SetWindowPos(main_wnd->hWnd, NULL, 0, 0, rect.right - rect.left, height + bottom, SWP_NOMOVE);
	
	if (!DspInit(main_wnd))
		return FALSE;

	if (!DxSoundInit(&main_wnd->hWnd))
	{
		MessageBox(main_wnd->hWnd, L"³õʼ»¯DirectSound´íÎó", L"´íÎó", MB_ICONERROR);
		return FALSE;
	}
	
	avcodec_register_all();   
	av_register_all();
	
	main_wnd->handle = CreateEvent(NULL, TRUE, FALSE, NULL);
	main_wnd->thread = CreateThread(NULL, 0, MainThread, main_wnd, 0, &main_wnd->thread_id);
	
	ShowWindow(main_wnd->hWnd, nCmdShow);
	UpdateWindow(main_wnd->hWnd);
	
	return TRUE;
}