-
Notifications
You must be signed in to change notification settings - Fork 0
/
prova.py
executable file
·63 lines (51 loc) · 1.26 KB
/
prova.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
#!/usr/bin/python
# monitor.py
# In Circuit Programming utility for FOX Board and Netus G20
# Versione per banco basato su CM3-Panel
import serial
import time
import sys
import getopt
import string
import time
import sys
import getopt
import string
import datetime
import RPi.GPIO as GPIO
import os
# GPIO usati per inviare comandi
power_on=25
chip_enable=26
switch_up=27
switch_down=28
home_state=29
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
GPIO.setup(power_on, GPIO.OUT)
GPIO.setup(chip_enable, GPIO.OUT)
GPIO.setup(switch_up, GPIO.IN,pull_up_down=GPIO.PUD_UP)
GPIO.setup(switch_down, GPIO.IN,pull_up_down=GPIO.PUD_UP)
GPIO.output(chip_enable,0)
GPIO.output(power_on,0)
print "Monitor"
counter=0
while True:
if GPIO.input(switch_up)==0:
print "Lancia la programmazione"
os.system("/home/pi/banco/flash.py <> /dev/console >&0 2>&1")
#os.system("ls -al <> /dev/console >&0 2>&1")
print "Lanciato"
while GPIO.input(switch_up)==0:
time.sleep(0.2)
if GPIO.input(switch_down)==0:
print "Stop programmazione"
os.system("pkill flash.py")
GPIO.output(chip_enable,0)
GPIO.output(power_on,0)
os.system("clear <> /dev/console >&0 2>&1")
while GPIO.input(switch_down)==0:
time.sleep(0.2)
time.sleep(0.2)
counter=counter+1
print counter