Commit a3bcaa22 刘韬

开机自启动

1 个父辈 d577295e
正在显示 40 个修改的文件 包含 87 行增加17 行删除
# Byte-compiled / optimized / DLL files
__pycache__/*
*__pycache__/*
__pycache__/
*.py[cod]
*$py.class
......@@ -105,3 +107,4 @@ venv.bak/
# add
.idea/
smartshelf/app/__pycache__/induction_post.cpython-39.pyc
......@@ -4,13 +4,14 @@
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python: Flask",
"type": "python",
"request": "launch",
"module": "flask",
"env": {
"FLASK_APP": "app",
"FLASK_APP": "smartshelf/app",
"FLASK_ENV": "development"
},
"args": [
......
cd smartshelf
cd smartshelf/app
flask run -p 5000 -h 0.0.0.0
pause
\ No newline at end of file
{
// 使用 IntelliSense 了解相关属性。
// 悬停以查看现有属性的描述。
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python: Flask",
"type": "python",
"request": "launch",
"module": "flask",
"env": {
"FLASK_APP": "app",
"FLASK_ENV": "development"
},
"args": [
"run",
"--host=0.0.0.0",
"--no-debugger",
"--no-reload"
],
"jinja": true
}
]
}
\ No newline at end of file
import requests
import threading
from flask import Flask
from flask_babel import Babel
from config import Config
import logging
from logging.handlers import RotatingFileHandler,TimedRotatingFileHandler
# from flask_socketio import SocketIO
def setup_log():
......@@ -18,6 +21,8 @@ def setup_log():
# 为全局的日志工具对象(flask app使用的)添加日志记录器
logging.getLogger().addHandler(file_log_handler)
Serl=None
setup_log()
app = Flask(__name__)
babel = Babel(app)
......@@ -29,6 +34,15 @@ LANGUAGES = {
"ja": "Japanese"
}
from app import induction_post,induction_test,induction_admin,induction_config,autoback,qr_code,scan_collection
import time
def s():
data = {'key1':'value1','key2':'value2'}
time.sleep(2)
requests.post("http://127.0.0.1:5000/stoppost",data)
time.sleep(2)
requests.post("http://127.0.0.1:5000/startpost",data)
t =threading.Thread(target=s)
t.start()
# return app
\ No newline at end of file
......@@ -32,8 +32,8 @@ ss16mm[] = {1,---100}
{"ADDR":"99","setcalibrate":[1,100,600,150],"threshold":45}
{"ADDR":"99","calibrate":"min","threshold":45}
{"ADDR":"99","setcalibrate":"max","threshold":45}
{"ADDR":"1","ledtype":[1,1,1,1,1]}
{"ADDR":"99","action":"siteid","hwid":"FFFFFFF","addr":1}
version 0.3 0708
scan command:"A1\nA2\nA3\n" //for example this command means scan addr 1,2,3 and return 1,2 and 3 location status
......
......@@ -104,9 +104,8 @@ def hancalibrate():
command = str(json.dumps({"ADDR":addr,"setcalibrate":setcalibrate})) + '\n'
ser = SerialCommunication()
ser.send_data(command)
line_response = ser.read_Line()
print (command)
msg = "handle calibrate:{}已发送".format(line_response)
msg = "handle calibrate:{}已发送".format(command)
return json.dumps({'msg':msg})
......
......@@ -105,7 +105,7 @@ def confirm_autostart():
result = re.findall(r"\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b", ip_config['ip'])
if result:
ip = result[0]
server_add = "http://{}/smf".format(ip)
server_add = "http://{}/neotel".format(ip)
else:
server_add = "127.0.0.1:5000"
line1 = "Comment = star chrome and enter the website for \"{}\"".format(server_add)
......
......@@ -21,12 +21,12 @@ from flask_babel import Babel, gettext as _
import serial
import timeit
# from serial_config import ReadConfig
#serl=None
curren_l = 'zh'
scan_state = False
config_dict,convert_dict = Location().read_location_file()
option_list = Location().init_location_option()
ser = SerialCommunication()
#ser = SerialCommunication()
# state_addr = []
basepath = os.path.dirname(__file__)
uploads_path = basepath + Config.UPLOAD_FOLDER
......@@ -144,6 +144,7 @@ def process_linetest(data):
@app.route('/indlineledon', methods=['POST'])
# @checkscan
def indlineledon():
ser=SerialCommunication();
data = request.get_json()
texts = process_linetest(data)
logging.warning("指令:{}".format(texts))
......@@ -160,6 +161,7 @@ def indlineledon():
@app.route('/indlineledoff', methods=['POST'])
def indlineledoff():
ser=SerialCommunication();
data = request.get_json()
texts = process_linetest(data)
logging.warning("指令:{}".format(texts))
......@@ -195,6 +197,7 @@ def process_lightindex(data):
# 库位灯打开
@app.route('/indledopen',methods=['POST'])
def indledopen():
ser=SerialCommunication();
data = request.get_json()
texts = process_lightindex(data)
# logging.warning("当前通道1ON_LED:{},当前通道2ON_LED:{}".format(led_lights1,led_lights2))
......@@ -208,6 +211,7 @@ def indledopen():
# 库位灯关闭
@app.route('/indledoff',methods=['POST'])
def indledoff():
ser=SerialCommunication();
data = request.get_json()
texts = process_lightindex(data)
print (texts)
......@@ -219,6 +223,7 @@ def indledoff():
@app.route('/indresetled',methods=['POST'])
def indresetled():
ser=SerialCommunication();
try:
data = {'channel_num':'all','channel_color':'off'}
texts = process_linetest(data)
......@@ -239,6 +244,7 @@ def indresetled():
@app.route('/indworkinglight',methods=['POST'])
def indworkinglight():
ser=SerialCommunication();
data = request.get_json()
# channel = data['workchannel']
text=maincollection(data)
......@@ -251,6 +257,7 @@ def indworkinglight():
@app.route('/indworkingoff',methods=['POST'])
def indworkingoff():
ser=SerialCommunication();
data = request.get_json()
text=maincollection(data)
ser.send_data(text)
......@@ -284,7 +291,7 @@ def scancom():
@app.route('/resetmain',methods=['POST'])
def resetmain():
# ser = SerialCommunication()
ser = SerialCommunication()
data = request.get_json()
text=maincollection(data)
print (text)
......@@ -295,6 +302,7 @@ def resetmain():
@app.route('/powermain',methods=['POST'])
def powermain():
ser=SerialCommunication();
data = request.get_json()
text=maincollection(data)
print (text)
......
A1@A2@A3@A4@A5@A6@A7@A8@A9
\ No newline at end of file
A1
\ No newline at end of file
http://192.168.101.108/smdbox,ls01
http://192.168.1.243/smf-core,4
\ No newline at end of file
/dev/ttyUSB0
\ No newline at end of file
/dev/ttyUSB0
\ No newline at end of file
/dev/ttyUSBCOM9
\ No newline at end of file
1.3-0818
\ No newline at end of file
1.2
\ No newline at end of file
class g():
def __init__(self):
self.seal=None
@property
def name(self):
return self.seal
@name.setter
def name(self, value):
self.seal = value
......@@ -4,15 +4,17 @@
@ content: 串口通讯实现类
@ date: 2021.5.10
'''
import imp
import serial
import serial.tools.list_ports
import logging
from config import Config
serl = None
# from serial_config import ReadConfig
# from app.induction_config import read_com
class SerialCommunication():
def __init__(self):
global serl
# serial_cf = ReadConfig()
# self.port = serial_cf.get_serial("DEFAULT_COM")
# self.bps = int(serial_cf.get_serial("DEFAULT_BAUDRATE"))
......@@ -24,14 +26,16 @@ class SerialCommunication():
self.port = serialcom.strip("\n")
self.bps = 115200
self.timeout = 1
if serl is None:
try:
# 打开串口,并得到串口对象
self.main_engine= serial.Serial(port=self.port,baudrate=self.bps,timeout=self.timeout)
serl = serial.Serial(port=self.port,baudrate=self.bps,timeout=self.timeout)
# 判断是否打开成功
# if (self.main_engine.is_open):
# print ("串口已打开")
except Exception as e:
print("---异常---:", e)
self.main_engine=serl
# 打印设备基本信息
def print_name(self):
......
此文件类型无法预览
此文件的差异太大,无法显示。
flask run -p 5000 -h 0.0.0.0
pause
\ No newline at end of file
import configparser
import os
import time
import config as Config
class ReadConfig():
"""定义一个读取配置文件的类"""
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!