| |
/*Bezeichnung:Prüfprogramm in C **Beschreibung:Die Karte wird gesucht. */ #define pci_product_id 0x0015
#define port1h 0x3bc #define port1 0x378 #define port2 0x278
#include <dos.h> #include <time.h>
#define y_hi 10 #define y_lo 15
unsigned char feldo[81],feldu[81]; int delay_wert=0;
unsigned int port;
clock_t ptime; clock_t checktime;
unsigned char lpt_version; unsigned char isa_version; unsigned char pci_version; main()
{ int i; int count; int auswahl;
cls(); do { printf("Welche Version des CLOCK-77 Moduls ist installiert ?\n"); printf("1 - CLOCK77/LPT\n"); printf("2 - CLOCK77/ISA\n"); printf("3 - CLOCK77/PCI\n"); scanf("%d",&auswahl); } while(auswahl!=1 && auswahl!=2 && auswahl!=3); if(auswahl==1) lpt_version=1; else lpt_version=0; if(auswahl==2) isa_version=1; else isa_version=0; if(auswahl==3) pci_version=1; else pci_version=0;
if(isa_version) port=0x1d0;
if(lpt_version) { do { printf("Bitte wählen Sie die Adresse des Ports an dem\n "); printf("Sie die CLOCK77 Uhr angeschlossen haben\n"); printf("1. LPT1:(hex 378)\n"); printf("2. LPT2:(hex 278)\n"); printf("3. Hercules LPT1:(hex 3bc)\n"); /* printf("4. User definiert \n");*/
printf("Bitte treffen Sie Ihre Auswahl: "); scanf("%d",&auswahl); } while(auswahl<1 && auswahl>4);
if(auswahl==1) port=port1; if(auswahl==2) port=port2; if(auswahl==3) port=port1h; /* if(auswahl==1) port=port1;*/
}
if(!test_ob_da()) { printf("Karte konnte nicht gefunden werden\n"); exit(0); }
if(lpt_version) outp(port,0x80); /*Spannungsversorgungsbit*/
feldo[80]=feldu[80]=0; for (i=0;i!=80;i++) {feldo[i]=' ';feldu[i]=' ';} checktime=clock(); cls();
show_oscilloscope(); getch(); empfang(); }
/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ empfang() { int stu,min,tag,mon,jahr; int i; int ret;
char buff[100]; int counter;
printf("\n"); printf("\n"); printf("Uhrenemfang wird gestartet\n");
counter=0; while(!kbhit() && counter<58) { ret=clock77_get_empfangswert(); printf("%d",ret); if(ret==-1) counter=0; buff[counter]=ret; ++counter; }
ret=clock77_get_empfangswert(); ret=clock77_get_empfangswert();
printf("%c",7); if(counter>57) { min=buff[21]+buff[22]*2+buff[23]*4+buff[24]*8+buff[25]*10+buff[26]*20+buff[27]*40; stu=buff[29]+buff[30]*2+buff[31]*4+buff[32]*8+buff[33]*10+buff[34]*20; tag=buff[36]+buff[37]*2+buff[38]*4+buff[39]*8+buff[40]*10+buff[41]*20; mon=buff[45]+buff[46]*2+buff[47]*4+buff[48]*8+buff[49]*10; jahr=buff[50]+buff[51]*2+buff[52]*4+buff[53]*8+buff[54]*10+buff[55]*20+buff[56]*40+buff[57]*80+1900; printf("\n"); printf("%d.%d.%d %d:%d\n",tag,mon,jahr,stu,min); } } /*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ /*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/
clock77_get_empfangswert() { int high,low;
high=0; low=0; /*Normalzustand ist high*/ while(clock77_get_bit()==0);
while(clock77_get_bit()==1) {++high;delay_1ms();} if(high<1100) while(clock77_get_bit()==0) {++low;delay_1ms();}
/*printf("high=%d low=%d\n",high,low);*/ if(high>1050) return(-1); if(low<120) return(0); else return(1);
/*Return: 0 bei lowzeit<120ms 1 bei lowzeit>120ms -1 bei highzeit>1,2 sekunden (Start des Uhrenempfangs */ } /*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ /*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ /*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ /*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ show_oscilloscope() { int count; do {
count=0; /*Zeit-Anfang*/ checktime=clock(); do { ptime=clock();
pprint(ptime); ++count;
} while(ptime<(checktime+1000));
/*1 sekunde vergangen*/ if(count<20) delay_wert-=25; if(count>20) delay_wert+=20; if(count>40) delay_wert+=30; if(count>60) delay_wert+=40; if(count>100) delay_wert+=50; if(count>200) delay_wert+=80;
gotoxy(0,23);printf("Messungen pro sekunde =%d ",count); printf("port=%x ",port);
} while(!kbhit()); } /*main*/ /*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ pprint(ptime) { int x; int j;
for(x=0;x!=79;++x) feldo[x]=feldo[x+1]; /* nach links verschieben*/ for(x=0;x!=79;++x) feldu[x]=feldu[x+1]; /* nach links verschieben*/
if(clock77_get_bit()==0) {feldo[79]=' ';feldu[79]='Ä';} else {feldo[79]='Ä';feldu[79]=' ';}
gotoxy(0,y_hi);printf("%s",feldo); gotoxy(0,y_lo);printf("%s",feldu); /*gotoxy(0,22);printf("%d- delay=%d- %d--",ptime,delay_wert,okdelay_wert);*/
delay(delay_wert); } /*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ clock77_get_bit() { int ret;
if(lpt_version) { if(inp(port+1)&128) ret=1; else ret=0; } if(isa_version) { /*PC-Karten-Version*/ if(inp(port+1)&1) ret=1; else ret=0; }
if(pci_version) { /*PCI-Karten-Version*/ if(inp(port)&1) ret=1; else ret=0; } return(ret); } /*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/ /*return-wert: 0=nicht ok 1=ok */
test_ob_da() { int wert;
if(lpt_version) { /*TEST fuer die LPT-Version*/ outp(port,0x00);printf("%d ",inp(port+1)&0x20); outp(port,0x40);printf("%d ",inp(port+1)&0x20); outp(port,0x00);printf("%d ",inp(port+1)&0x20);
outp(port,0x00);if((inp(port+1)&0x20)!=0) return(0); /*muß 0 sein*/ outp(port,0x40);if((inp(port+1)&0x20)!=0x20) return(0); /*muß 32 sein*/ outp(port,0x00);if((inp(port+1)&0x20)!=0) return(0); /*muß 0 sein*/ } if(isa_version) { /*TEST fuer die ISA-Karten Version*/ printf("inp(port+4)=%x\n",inp(port+4)); printf("inp(port+8)=%x\n",inp(port+8)); if((inp(port+4)&1)!=0) return(0); /*muss = 0 sein*/ if((inp(port+8)&1)!=1) return(0); /*muss = 1 sein*/ }
if(pci_version) { port=PciGetIO(pci_product_id); if(port==0) return(0); /*Dann wurde die Karte nicht gefunden*/ }
return(1); /*OK*/ }
|
|