bonjour
je viens (pour mon PFE) de programmer (en c utilisant le pic c) une carte de controle d'acces et au meme temps réalise le pointage par digicode utilisant le pic 16F877...j'ai essayer mais j'ai trouver des problemes.
SVP ma probleme est:
-erreur dans la programmation du code d'acces
-je veux declencher une sirene si les code est mal entrer 3 fois(port E1)
-et afficher l'historique des agents qui ont été entré
SVP j'ai fait beaucoup d'effort et à vous de m'aider un peu
et merci d'avance
le code est:
Code:#include E:\pfe\prog_digicode\progdigicode\programmedigicode.h #include "progpricipal.h" #include "LCDpointeuse.C" #include "PCF8583.C" #include "2432pointeuse.C" #include <ctype.h> #include <string.h> char code [4]; char code1[4]; byte key, ee_adr,i ; long int chartoint(char code[3]) {long int param; param=(code[1]-48 +(code[0]-48)*10); return param; } char bytetochar(byte x) {char param [3]; param[0]=x/100+48; param[1]=x/10-((param[0]-48)*10); param[2]=x-((param[0]-48)*100)-((param[1]-48)*10); return x; } void main() {int page,an,a,x; long int timeout; char c; char code[2]; date_time_t dt; timeout=0; setup_adc_ports(NO_ANALOGS); setup_adc(ADC_OFF); setup_psp(PSP_DISABLED); setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1); setup_timer_1(T1_DISABLED); setup_timer_2(T2_DISABLED,0,1); lcd_init(); init_ext_eeprom(); PCF8583_init(); an=read_eeprom(0); printf("Voulez vous regler le temps/date de\n\r"); SET_TRIS_C(0x86); output_low(PIN_C0); while(1) { while (!kbhit()&&(++timeout<3000)) {delay_ms(1);++timeout;lcd_gotoxy(1,1);lcd_putc("Init...");} if (timeout >3000){break;} c = getc(); c = toupper(c); if(c == 'O') { L1:printf("\n\r"); printf("donnez le mois Format:XX\n\r"); while(!kbhit());gets(code); dt.month = chartoint(code); if (dt.month >12){printf("format Incorrect ?\n\r");goto L1;} printf("\n\r"); L2:printf("donnez le jour Format:XX\n\r"); while(!kbhit());gets(code); dt.day = chartoint(code); printf("\n\r"); if (dt.day >31){printf("format Incorrect ?\n\r");goto L2;} L3:printf("donnez année Format:XX\n\r"); while(!kbhit());gets(code); an = chartoint(code);printf("\n\r"); if (an <7){printf("Date invalide ?\n\r");goto L3;} if (an >99){printf("Date invalide ?\n\r");goto L3;} write_EEPROM(0,an); L4:printf("donnez heure Format:XX\n\r"); while(!kbhit());gets(code); dt.hours = chartoint(code);printf("\n\r"); if (dt.hours >23){printf("format Incorrect ?\n\r");goto L4;} L5:printf("donnez minute Format:XX\n\r"); while(!kbhit());gets(code); dt.minutes = chartoint(code);printf("\n\r"); if (dt.minutes >59){printf("format Incorrect ?\n\r");goto L5;} dt.seconds = 0; dt.weekday = 0; PCF8583_set_datetime(&dt); printf("\n\r"); printf("Nouvelle date/temps est ecrite dans le PCF8583.\n\r"); break; } if(c == 'N') break; } printf("\n\r"); printf("Voulez vous lire les données de\n\r"); printf("pointage ? (O/N)\n\r"); timeout=0; while(1) { while (!kbhit()&&(++timeout<3000)) {delay_ms(1);++timeout;lcd_gotoxy(1,1);lcd_putc("Init...");} if (timeout >3000){break;} c = getc(); c = toupper(c); if(c == 'O') { for (c=1;c<256;c=c+1) { printf("employer N"); putc(bytetochar(x)); for (page=1;page<31;page=page+1) { dt.day=read_ext_eeprom(page+c-48);putc(dt.day); printf(" "); dt.month=read_ext_eeprom(page+c-48+256);putc(dt.month);printf(" "); dt.hours=read_ext_eeprom(page+c-48+512);putc(dt.hours);printf(" "); dt.minutes=read_ext_eeprom(page+c-48+1024);putc(dt.minutes);printf(" ");printf("\n\r"); } } break; } if(c == 'N') break; } printf("\n\r"); printf("Démarrage avec succé \n\r"); while(1) { delay_ms(1000); PCF8583_read_datetime(&dt); lcd_gotoxy(1,1); printf(LCD_putc," %u/%u/%02u, %u:%02u:%02u\n\r", dt.day, dt.month, an, dt.hours, dt.minutes, dt.seconds); lcd_gotoxy(1,2);lcd_putc("Inserez votre code"); } code1[0]=read_eeprom(0); code1[1]=read_eeprom(1); code1[2]=read_eeprom(2); code1[3]=read_eeprom(3); init:; i= 0; //----------------------------------- do { if (input(pin_a0)==0) {goto init;} } while(!(code[i]=kbd_getc())); lcd_putc('\f'); do { lcd_putc(code[i]); i++; while(!(code[i]=kbd_getc())); } while (i!=3); //------------------------------------------------------------test code pour change if (code[0]!=code1[0]) {lcd_putc('\f');lcd_putc("Error");goto haja;} if (code[1]!=code1[1]) {lcd_putc('\f');lcd_putc("Error");goto haja;} if (code[2]!=code1[2]) {lcd_putc('\f');lcd_putc("Error");goto haja;} if (code[3]!=code1[3]) {lcd_putc('\f');lcd_putc("Error");goto haja;} lcd_putc('\f'); lcd_putc("ok"); i=0;ee_adr=0; do { while(!(code[i]=kbd_getc())); write_eeprom(ee_adr,code[i]); ee_adr++; lcd_putc(code[i]); }while (ee_adr!=4); haja:; while(!(code[i]=kbd_getc())); } //------------------------------------------entrer code pour overture if (input(pin_a0)==0) ///////////////////////////entre code { lcd_putc('\f'); lcd_putc("Votre Code S.V.P"); do { lcd_putc(code[i]); i++; while(!(code[i]=kbd_getc())); } while (i!=3); code1[0]=read_eeprom(0); code1[1]=read_eeprom(1); code1[2]=read_eeprom(2); code1[3]=read_eeprom(3); //--------------------------------test 1erst bit if (code[0]!=code1[0]) { lcd_putc('\f'); lcd_putc("Error"); output_high(PIN_A2); delay_ms(700); output_low(PIN_A2); delay_ms(500); goto out; } //-----------------------------------test 2cd bit if (code[1]!=code1[1]) { lcd_putc('\f'); lcd_putc("Error"); output_high(PIN_A2); delay_ms(700); output_low(PIN_A2); delay_ms(500); goto out; } //------------------------------------test 3rd bit if (code[2]!=code1[2]) { lcd_putc('\f'); lcd_putc("Error"); output_high(PIN_A2); delay_ms(700); output_low(PIN_A2); delay_ms(500);goto out; } //---------------------------------test 4th bit if (code[3]!=code1[3]) { lcd_putc('\f'); lcd_putc("Error"); output_high(PIN_A2); delay_ms(700); output_low(PIN_A2); delay_ms(500); goto out; } //------------------------------test ok lcd_putc('\f'); lcd_putc("Ok"); output_high(PIN_A1);////////////////////open delay_ms(1000); output_low(PIN_A1); out:; } goto init; }
-----