You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
58 lines
1.4 KiB
58 lines
1.4 KiB
#!/usr/bin/python3
|
|
|
|
import sys
|
|
import time
|
|
import os
|
|
import signal
|
|
|
|
|
|
def stop_cams():
|
|
f = open("/tmp/pid_1", "r")
|
|
pid1 = int(f.read())
|
|
f.close()
|
|
f = open("/tmp/pid_2", "r")
|
|
pid2 = int(f.read())
|
|
f.close()
|
|
|
|
os.kill(pid1, signal.SIGINT)
|
|
os.kill(pid2, signal.SIGINT)
|
|
|
|
def read_old_time():
|
|
f = open("/tmp/sensor", "r")
|
|
sensor_time = int(f.read())
|
|
f.close()
|
|
return sensor_time
|
|
|
|
|
|
def main():
|
|
# minimum write time
|
|
record_time = 60
|
|
|
|
os.system("echo 0 > /tmp/sensor")
|
|
#os.system("./read_sensor.py &")
|
|
|
|
while (True):
|
|
time.sleep(1)
|
|
print (int(time.time()) - read_old_time())
|
|
|
|
if ((int(time.time()) - read_old_time()) <= record_time):
|
|
print("Wait to start camera script.")
|
|
os.system("./cam1.sh")
|
|
os.system("./cam2.sh")
|
|
time.sleep(10)
|
|
|
|
print("Start min write.")
|
|
time.sleep(record_time)
|
|
|
|
while ((int(time.time()) - read_old_time()) < record_time):
|
|
t = read_old_time() - (int(time.time()) - record_time)
|
|
print("Continue record video on camera -> " + str(t) + ".")
|
|
time.sleep(t)
|
|
|
|
print("Wait to stop camera script.")
|
|
stop_cams()
|
|
time.sleep(10)
|
|
print("Stop camera script.")
|
|
|
|
if __name__ == '__main__':
|
|
main()
|
|
|