int main() { HANDLE hDevice = GetDeviceViaInterface((LPGUID)&GUID_DEVINTERFACE_SDIO_DEVICE,0); if (hDevice == INVALID_HANDLE_VALUE) { printf("Failed to obtain file handle to device: " "%s with Win32 error code: %d\n", "MyWDMDevice", GetLastError() ); return 1; } EnableInt(hDevice); Sleep(2000); DWORD dwRead; ReadFile(hDevice,buffer,BUFFER_SIZE,&dwRead,NULL); printf("read %x\n",dwRead); DisableInt(hDevice); CloseHandle(hDevice); return 0; }
void Ventilation (void) { register int flagvvm = 0; register int ncol, nlin, escala, y0, y1, y2; int y_ini0, y_ini1; int cor; float far *apt; float far *aptaux; register float flux, sum_flux; float sum[4]; #ifdef BYPASS_VVM int step = 0; int offset = 0; #endif BYPASS_VVM LeData (); getviewsettings (&vp); VentVolMax = sum_flux = 0.0; NumeroSinal = 0; escala = DELTA_Y(14); coluna = DELTA_X( 6); y0 = y_ini0 = DELTA_Y(74); y2 = y1 = y_ini1 = DELTA_Y(90); apt = inicVVM1; aptaux = inicVVM1Int; Atendeu = FALSE; sum[0] = sum[1] = sum[2] = sum[3] = 0.0; LinBaseVVM1 = LinBaseVVM2 =0.0; #ifndef BYPASS_HADWARE #ifndef BYPASS_VVM IniAquisition(); EnableInt(); #endif BYPASS_VVM #endif BYPASS_HADWARE do { #ifndef BYPASS_VVM DisableInt(); #endif BYPASS_VVM Help = kbhit() && (ESC == getch()); #ifndef BYPASS_VVM EnableInt(); #endif BYPASS_VVM if (Help) Abortou = TRUE; else { #ifndef BYPASS_VVM while(!Atendeu); Sinal -= (int)Zero; #else BYPASS_VVM Sinal = 14; #endif BYPASS_VVM Atendeu = FALSE; } } while( (abs(Sinal) < 10) && (!Abortou) ); if (!Abortou) { #ifdef GRAVACAO_DE_DADOS fprintf ( PDados, "\n\n\t %%%%%%%%%%% VENTVOL: %%%%%%%%%%%"); #endif GRAVACAO_DE_DADOS do { #ifndef BYPASS_VVM DisableInt(); #endif BYPASS_VVM Help = kbhit() && (ESC == getch()); #ifndef BYPASS_VVM EnableInt(); #endif BYPASS_VVM if (Help) Abortou = TRUE; else { #ifndef BYPASS_VVM while(!Atendeu); *aptaux = flux = (Sinal > Zero) ? VDxFluxo ( Sinal , GanhoExp ): VDxFluxo ( Sinal , GanhoIns ); #else BYPASS_VVM /* ----------------------------- */ /* Simulacao de um Alcaponamento */ /* ----------------------------- */ if (!(NumeroSinal % 15)) { offset = -1; } else { offset = 0; } if ( NumeroSinal > 1200 ) { offset = -2; } if ( NumeroSinal > 1300 ) { offset = 0; } *aptaux = flux = 10 * cos ( (M_PI * step++) /60) + offset; #endif BYPASS_VVM #ifdef GRAVACAO_DE_DADOS fprintf ( PDados, "\n\t%04X", Sinal); #endif GRAVACAO_DE_DADOS if (*aptaux > 0.0) { VentVolMax += flux / SampleRatio; flagvvm = 1; } #ifdef VVM_ALCAP_ sum_flux += flux / SampleRatio; sum[0] = (.01 * sum_flux) + (.19 * sum[1]) + (.30 * sum[2]) + (.50 * sum[3]); sum[3] = sum[2]; sum[2] = sum[1]; sum[1] = sum[0]; /* --------------------------- */ /* Calculo das Linhas de Base */ /* para obtencao do valor do */ /* volume Alcaponado. */ /* */ /* Convecionou-se: */ /* LBASE1 -> Volume Medio Entre*/ /* 2 e 3 segundos. */ /* */ /* LBASE2 -> Volume Medio Entre*/ /* 10 e 11 segundos. */ /* */ /* Volume Acapondado Extrapola-*/ /* do a um minuto sera a dife- */ /* das das linhas de Base vezes*/ /* 7.5 (que e'60/8) */ /* --------------------------- */ if ( (NumeroSinal >= 200) && (NumeroSinal < 400) ) /* ------- */ /* LBASE_1 */ /* ------- */ { LinBaseVVM1 += sum[0]; } else if ( (NumeroSinal >= 2000) && (NumeroSinal < 2200) ) /* ------- */ /* LBASE_2 */ /* ------- */ { LinBaseVVM2 += sum[0]; } #else VVM_ALCAP_ sum_flux = sum_flux; y_ini1 = y_ini1; y0 = y0; y1 = y1; y2 = y2; #endif VVM_ALCAP_ if (flagvvm) { *apt = VentVolMax; /* --------------------------- */ /* Um ponto chega a cada 5ms */ /* Totalizando 2400 ptos em 12s*/ /* Os 12s medem DELTA_X(88), */ /* logo a coluna atual depende */ /* de NumSinal segundo a formu-*/ /* la abaixo: */ /* --------------------------- */ ncol = (int) ( (((long) NumeroSinal) * DELTA_X(88))/2400 + DELTA_X( 6) ); if ( ncol != coluna ) { cor = getcolor(); /* -------------------------- */ /* Tracado do Volume Expirado */ /* -------------------------- */ nlin = (int) ((y_ini0 - (((long) escala ) * VentVolMax)/10)); moveto(coluna, y0); lineto( coluna, nlin ); y0 = nlin; #ifdef VVM_ALCAP_ setcolor (bea_color[ 7]); /* ----------------------------- */ /* Tracado do Volume (Invertido) */ /* ----------------------------- */ nlin = (int) ((y_ini1 + (((long) escala ) * (sum_flux))/2)); moveto(coluna, y1); lineto( coluna, nlin ); y1 = nlin; setcolor (bea_color[11]); /* -------------------------------------------------- */ /* Tracado Valor Medio Filtrado do Volume (Invertido) */ /* -------------------------------------------------- */ nlin = (int) ((y_ini1 + (((long) escala ) * (sum[0]))/2)); moveto(coluna, y2); lineto( coluna, nlin ); y2 = nlin; #endif VVM_ALCAP_ setcolor (cor); coluna = ncol; } ++NumeroSinal; } ++apt; ++aptaux; Atendeu = FALSE; } } while ( (NumeroSinal != NUMMAXPONTOSINF-1) && (coluna != DELTA_X(88) + DELTA_X( 6)) && (!Abortou) ); #ifndef BYPASS_VVM DisableInt(); #endif BYPASS_VVM for (; apt<inicVVM1+NUMMAXPONTOSINF; apt++) { *apt = FIM_1; } *aptaux = END; *(aptaux+1) = TempAmb; *(aptaux+2) = UmidRel; *(aptaux+3) = PresBar; if (!Abortou) { if (FlagIntegridade) ReCalcula(); CalculaParamVVM(); CalculaVVMpercent(); outtextxy(DELTA_X(25) , DELTA_Y( 5), "Param Teorico Calculado %"); cor = getcolor(); setcolor(bea_color[15]); gprintf (DELTA_X(25) , DELTA_Y( 6) + CharH, "VVM %6.2f %6.2f %4.0f", VentVolMaxteorico, VentVolMax, (VentVolMaxpercent+0.5)); #ifdef VVM_ALCAP_ gprintf (DELTA_X(25) , DELTA_Y( 7) + 2 * CharH, "ALCAP -- %7.2f - ", VolAlcaponado); #endif VVM_ALCAP_ setcolor(cor); if (teste1VVM) { teste2VVM = TRUE; teste1VVM = FALSE; } else teste1VVM = TRUE; } } #ifndef BYPASS_VVM else DisableInt(); #endif BYPASS_VVM } /* Ventilation */