This commit is contained in:
xyj 2024-01-05 16:39:44 +08:00
parent fbcea1b018
commit 6541e34ab5
9 changed files with 56 additions and 8 deletions

18
close_blue_led.py Normal file
View File

@ -0,0 +1,18 @@
'''
实验名称熄灭第1个LED
实验平台核桃派
'''
# 导入相关模块
import board
from digitalio import DigitalInOut, Direction
if __name__ == '__main__':
try:
# 构建LED对象和初始化
led = DigitalInOut(board.LED) # 定义引脚编号
led.direction = Direction.OUTPUT # IO为输出
led.value = 0 # 输出低电平熄灭板载LED蓝灯
except Exception as e:
pass

View File

@ -0,0 +1,7 @@
#!/bin/bash
set -e
sudo crontab -l > cron.cron
echo "*/1 * * * * /usr/bin/bash /home/pi/lot_manager/conf/example/bash/start_dataupload_internal_one_hour.sh" >> cron.cron
sudo crontab cron.cron
sudo systemctl restart cron.service
sudo rm -rf cron.cron

View File

@ -0,0 +1,2 @@
#!/bin/bash
supervisorctl restart data_upload

View File

@ -0,0 +1,2 @@
#!/bin/bash
supervisorctl stop data_upload

View File

@ -0,0 +1,2 @@
# 每隔一分钟执行一次任务
*/1 * * * * /usr/bin/bash /home/pi/lot_manager/conf/example/bash/start_dataupload_internal_one_hour.sh

View File

@ -1,8 +0,0 @@
#!/bin/bash
set -e
sudo crontab -l > cron.cron
echo "0 9 * * * sudo /usr/bin/python /home/pi/lot_manager/open_led.py" >> cron.cron
echo "0 17 * * * sudo /usr/bin/python /home/pi/lot_manager/close_led.py" >> cron.cron
sudo crontab cron.cron
sudo systemctl restart cron.service
sudo rm -rf cron.cron

18
open_blue_led.py Normal file
View File

@ -0,0 +1,18 @@
'''
实验名称熄灭第1个LED
实验平台核桃派
'''
# 导入相关模块
import board
from digitalio import DigitalInOut, Direction
if __name__ == '__main__':
try:
# 构建LED对象和初始化
led = DigitalInOut(board.LED) # 定义引脚编号
led.direction = Direction.OUTPUT # IO为输出
led.value = 1 # 输出高电平点亮板载LED蓝灯
except Exception as e:
pass

View File

@ -1,4 +1,5 @@
import os import os
import subprocess
import time import time
import serial import serial
@ -190,6 +191,9 @@ def local():
} }
t = LOT_DATA(**data) t = LOT_DATA(**data)
add(t) add(t)
subprocess.Popen(
["/usr/bin/bash /home/pi/lot_manager/conf/example/bash/stop_dataupload_internal_one_hour.sh"],
shell=True)
except Exception as e: except Exception as e:
# print(e) # print(e)
pass pass

View File

@ -195,6 +195,9 @@ def get_data():
t2 = LOT_DATA(**data) t2 = LOT_DATA(**data)
client.publish(publish_topic, payload=json.dumps(data, ensure_ascii=False), qos=0) client.publish(publish_topic, payload=json.dumps(data, ensure_ascii=False), qos=0)
add(t2) add(t2)
subprocess.Popen(
["/usr/bin/bash /home/pi/lot_manager/conf/example/bash/stop_dataupload_internal_one_hour.sh"],
shell=True)
except Exception as e: except Exception as e:
# print(e) # print(e)
pass pass