Hi, I'm trying to modify the following codes(from DT and using Mr_e's Keypad routine), which reads data from eeprom (Data @0, 5,"12345")
The above codes works perfectly fine. i added a modification but having trouble make it work.Code:Init: enable ReStart = 0 pause 500 Failed = 0 Read 0, ComboLength serout PortD.5,T9600,[$1B,$63,$30] Serout PortD.5, T9600, [$1B,$45,"Enter PIN Code"] on interrupt goto KeypadINT Start: pause 1 Timeout = Timeout - 1 if (ComboPtr > 0) and (Timeout = 0) then Gosub Reset if ReStart then Init goto Start ;_____________________________________________________________________________ disable @ ifndef HIGH_SECURITY @ #define HIGH_SECURITY 0 ; default to Low security @ endif KeypadINT: 'Serout PortD.5, 6, [$FE,1,"Enter PIN Code"] 'Serout PortD.5, T9600, [$1b, $2a,$80] 'Turn backlight half broghtness @ READKEYPAD _ByteA ; Get the keypress TRISB=110000 ; Reset I/O's PORTB=0 ; Set all columns LOW INTCON.0 = 0 ; Clear RBIF Timeout = MaxTime ; Reset the Timeout lookup ByteA,[0,"123A456B789C*0#D"],Key ; convert keypress if Key = "C" then 'Select C Serout PortD.5, T9600, [$1B,$45,"Password"] Serout PortD.5,T9600, [$D,"Cancel entry"] pause 1000 scroll = 1 goto main Endif 'Serout PortD.5,T9600, [$D,"Key=",key] serout PortD.5,T9600,[$1B,$63,$31] Serout PortD.5,T9600, [$D] if key = "#" OR key = "*" then DTMFOUT PortA.0,[key] else DTMFOUT PortA.3,[key] ; convert keypress to sound Endif ComboPtr = ComboPtr + 1 ; point to next digit @ if HIGH_SECURITY == 1 'Serout PortD.5,T9600, [$1B,$45,"Key=",key] Serout PortD.5, T9600, ["*"] ; print a Mask character if Key = "*" then cn = cn+1 goto Reset Endif if Key = "#" then Finish @ endif if ComboPtr <= ComboLength then Read ComboPtr, ByteA ; Get the digit from EEPROM if Key = ByteA then ; is it the same ? Read 0, ByteA ; Get the length of the combo @ if HIGH_SECURITY == 0 'Serout PortD.5,T9600, [$1B,$45,"Key=",key] Serout PortD.5, T9600, ["*"] ; print a Mask character if ComboPtr = ByteA then AccessGranted ; Done?, Grant Access @ endif else @ if HIGH_SECURITY == 0 ComboPtr = 0 Serout PortD.5,T9600 ,[$1B,$45] ; Wrong digit goto AccessDenied ; terminate entry @ else ; -HIGH_SECURITY- Failed = 1 ; let them keep entering @ endif ; makes it harder to figure Endif ; the combination endif resume ; must end with # sign
I added two more passwords for access in the eeprom.
And upon entry...in order to select the location/identification client users must enter 11 or 12.Code:DATA @0, 5,"12345" ' Admin DATA @14,5,"43521" ' Client 1 DATA @21,5,"25632" ' Client 2
useradd variable is used to hold the location where to start reading the data from eeprom.Code:if myvarkey = "#" then ' Test it here If cnt1 = 0 then useradd = 0 Serout PortD.5,T9600, [$D,"ADMIN"] useradd = 0 ' at address 0 pause 1000 cnt1 = 0 else IF ByteD[0]="1" and ByteD[1]="1" then ' Client 1 Serout PortD.5,T9600, [$D,"Client 1"] pause 1000 useradd = 14 ' at address 14 Endif IF ByteD[0]="1" and ByteD[1]="2" then ' Client 2 Serout PortD.5,T9600, [$D,"Client 2"] pause 1000 useradd = 21 ' at address 21 Endif Endif goto init else ByteD[cnt1]=myvarkey Serout2 PortD.5,84, [$D, ">" , ByteD[cnt1]] cnt1=cnt1+1 Endif
When pressing '#' and entering the pin code will be reading DATA @ 0,5,"12345", '11' and entering the pin code will be reading DATA @14,5, "45321" and so on.
The following modifications on the code can not get me to read the correct pin code/location.
Can you help me point out what I'm doing wrong in the code.Code:if ComboPtr <= ComboLength then Read useradd, ByteA ; Get the digit from EEPROM if Key = ByteA then ; is it the same ? Read useradd, ByteA ; Get the length of the combo @ if HIGH_SECURITY == 0 'Serout PortD.5,T9600, [$1B,$45,"Key=",key] Serout PortD.5, T9600, ["*"] ; print a Mask character if ComboPtr = ByteA then AccessGranted ; Done?, Grant Access @ endif else @ if HIGH_SECURITY == 0 ComboPtr = 0 Serout PortD.5,T9600 ,[$1B,$45] ; Wrong digit goto AccessDenied ; terminate entry @ else ; -HIGH_SECURITY- Failed = 1 ; let them keep entering @ endif ; makes it harder to figure Endif ; the combination endif resume
Thanks in advance,
tacbanon




Bookmarks