forked from ericescobar/Chicken_Door
-
Notifications
You must be signed in to change notification settings - Fork 1
/
sensordebug.py
executable file
·43 lines (35 loc) · 1.4 KB
/
sensordebug.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
#!/usr/bin/python2
# -*- coding: utf-8 -*-
# vim: tabstop=4 shiftwidth=4 softtabstop=4
#
# Infinate loop that prints the sensor states, helps for sensor positioning
import argparse
import ConfigParser
import time
import robocoop
if __name__ == '__main__':
description = ('debug door sensors')
parser = argparse.ArgumentParser(description=description)
parser.add_argument('--door', dest='door', nargs='*', default='NULL',
help='A space seperated list of door names to operate on')
args, __ = parser.parse_known_args()
config = ConfigParser.ConfigParser()
config.read('robocoop.cfg')
door = args.door[0]
try:
obj = robocoop.robocoop(door, config.getint(door, 'top_sensor_pin'),
config.getint(door, 'bottom_sensor_pin'),
config.getint(door, 'motor_a_pin'),
config.getint(door, 'motor_b_pin'),
config.getint(door, 'safety_limit'))
toppin = config.getint(door, 'top_sensor_pin')
botpin = config.getint(door, 'bottom_sensor_pin')
while True:
print("TOP: %s" % robocoop.GPIO.input(toppin))
print("BOTTOM: %s" % robocoop.GPIO.input(botpin))
time.sleep(1)
except KeyboardInterrupt:
print (' peace out')
finally:
print('cleaning up')
obj.cleanup()