-
Notifications
You must be signed in to change notification settings - Fork 0
/
DoorStrike.py
executable file
·67 lines (61 loc) · 1.19 KB
/
DoorStrike.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/usr/bin/python
#
# DoorStrike.py 1.0
#
# Send command to momentarily strike the door to the Viking ES-1
#
# 2009.12.26 - K.C. Budd
#
#
import serial
import datetime
import time
import syslog
import re
import sys
import os
import string
import signal
######## logit(logline)
#
#
def logit(logline):
try:
syslog.openlog("Viking ES-1",0,syslog.LOG_LOCAL1)
syslog.syslog(logline)
syslog.closelog()
except:
print "Unexpected error (syslog):", sys.exc_info()[0]
raise
#
########
######## main()...
#
def main():
try:
ser = serial.Serial(1,19200,timeout = 10)
except:
logit("Unexpected error (serial)")
logit(str(sys.exc_info()[1]))
raise
ser.write("ATX0DT*6;H0\r");
y = 0
while(1):
line=ser.readline()
if line[:2] == 'OK':
print "Success."
break;
else:
y = y + 1
if y > 3:
print "Failed. Check modem."
ser.close()
exit(255)
ser.close()
exit(0)
# logline="["+str(serialno)+"] Door: " + a_door + " Card ID: " + a_card + " Result: " + a_result
# logit(logline)
#
######## end main()...
if __name__ == '__main__':
main()