diff --git a/.gitignore b/.gitignore
index 380ab00..2248133 100644
--- a/.gitignore
+++ b/.gitignore
@@ -14,4 +14,5 @@ __pycache__/
python/build/
python/dist/
*.xlsx
-*.json
\ No newline at end of file
+*.json
+quest_info.txt
\ No newline at end of file
diff --git a/coder_2channel.uvoptx b/coder_2channel.uvoptx
index 360e0d9..07718fa 100644
--- a/coder_2channel.uvoptx
+++ b/coder_2channel.uvoptx
@@ -148,24 +148,7 @@
-
-
- 0
- 0
- 93
- 1
- 134261600
- 0
- 0
- 0
- 0
- 0
- 1
- .\source\rt_thread\board.c
-
- \\coder_2channel_app\source/rt_thread/board.c\93
-
-
+
0
@@ -385,7 +368,24 @@
-
+
+
+ 0
+ 0
+ 93
+ 1
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ .\source\rt_thread\board.c
+
+
+
+
0
diff --git a/source/main/compiler_info.h b/source/main/compiler_info.h
index 8fc3218..a08c133 100644
--- a/source/main/compiler_info.h
+++ b/source/main/compiler_info.h
@@ -6,7 +6,7 @@
-#define BUILD_DATE "2023-09-14 17:45:04"
+#define BUILD_DATE "2023-09-15 10:12:28"
#define SOFT_VERSION "0.01"
diff --git a/source/mycopy.py b/source/mycopy.py
index 9720da7..aafbdae 100644
--- a/source/mycopy.py
+++ b/source/mycopy.py
@@ -2,7 +2,6 @@ import shutil
import sys
import os
import prebuild as time
-import mysql
@@ -147,9 +146,12 @@ def main():
with open(dst,"wb") as f:
f.write(data)
print(dst+' create app file success.')
- sql=mysql.sql()
- if(sql.init(SQL_APP_PATH)==True):
- sql.insert(dst)
+ readback=os.popen("upload "+SQL_APP_PATH+" "+dst).readlines()
+ for i in readback:
+ print(i)
+ # sql=mysql.sql()
+ # if(sql.init(SQL_APP_PATH)==True):
+ # sql.insert(dst)
boot=BOOT_FILE_SRC+".bin"
boot_dst=BOOT_FILE_DST+"_"+date+".bin"
if os.path.exists(boot):
diff --git a/source/mysql.py b/source/mysql.py
deleted file mode 100644
index 825588e..0000000
--- a/source/mysql.py
+++ /dev/null
@@ -1,166 +0,0 @@
-import pymysql as mysql
-import datetime
-from datetime import datetime, timedelta
-import hashlib
-import os
-
-def connect():
- try:
- db=mysql.connect(host='124.70.178.159',user='admin',passwd='Rc5345750.',port=3306)
- print("connect mysql success.")
- return db
- except Exception as e:
- print("can not connect service.")
- return None
-
-
-# 获取北京时间
-def get_date():
- now_time = datetime.utcnow()
- utc_time = now_time + timedelta(hours=8) # UTC只是比北京时间提前了8个小时
- utc_time = utc_time.strftime("%Y%m%d")
- return utc_time
-
-# 获取北京时间
-def get_time():
- now_time = datetime.utcnow()
- utc_time = now_time + timedelta(hours=8) # UTC只是比北京时间提前了8个小时
- utc_time = utc_time.strftime("%Y-%m-%d %H:%M:%S")
- return utc_time
-
-
-# 获取数据md5
-def md5(data:bytearray):
- m=hashlib.md5(data).hexdigest()
- # print(m)
- return m
-
-
-# 获得主板sn号
-def get_computer_sn():
- sn = os.popen("wmic bios get serialnumber").readlines()
- return sn[2].strip()
-
-
-class sql:
- def __init__(self) -> None:
- self.download_path="download/"
- if not os.path.exists(self.download_path):
- os.makedirs(self.download_path)
-
-
- # 初始化返回True成功
- def init(self,table_name:str):
- self.db=connect()
- self.table_name=table_name
- if(self.db!=None):
- self.cur=self.db.cursor()
- self.cur.execute("use andy_data")
- self.cur.execute("select version()")
- a=self.cur.fetchone()
- print(a)
- self.create_table(self.table_name)
- return True
- return False
-
- # 创建表
- def create_table(self,table_name:str):
- cmd="""CREATE TABLE IF NOT EXISTS `{d1}`(
- `id` INT UNSIGNED AUTO_INCREMENT,
- `time` VARCHAR(30) NOT NULL,
- `name` VARCHAR(256) NOT NULL,
- `md5` VARCHAR(33) NOT NULL,
- `data` MEDIUMBLOB NOT NULL,
- PRIMARY KEY ( `id` )
- )ENGINE=InnoDB DEFAULT CHARSET=utf8;""".format(d1=table_name)
-
- self.cur.execute(cmd)
-
- # 插入数据
- def insert(self,file_name:str):
- s=file_name.split('.')
- if(len(s)<2):
- print("file name without type suffix,will not insert.")
- return
- with open(file_name,"rb") as f:
- d=f.read()
- md=md5(d)
- lis=self.show()
- if(len(lis)>0):
- if(lis[-1][3]==md):
- print("the same file was saved,will not insert.")
- return
- try:
- cmd="INSERT INTO {d1} (time,name,md5,data) VALUES (%s,%s,%s,%s);".format(d1=self.table_name)
- self.db.begin()
- self.cur.execute(cmd,([get_time(),file_name,md,d]))
- self.db.commit()
- print("insert file success.")
- except Exception as e:
- self.db.rollback()
- print(str(e))
-
- # 查看数据
- def show(self):
- cmd= "select id,time,name,md5 from {d1};".format(d1=self.table_name)
- self.cur.execute(cmd)
- a=self.cur.fetchall()
- # for i in a:
- # print(i[0],i[1],i[2],i[3])
- return a
- # 下载指定文件,返回文件路径
- def download(self,id:int):
- ack,name=self.exists(id)
- if(ack==True):
- print("the same file is exists,will not download.")
- return name
- cmd="select name,data from {d1} WHERE id={d2};".format(d1=self.table_name,d2=id)
- self.cur.execute(cmd)
- a=self.cur.fetchall()
- for i in a:
- ss=i[0].replace('\\','/')
- ss=ss.split('/')[-1].split('.')
- name=self.download_path+ss[0]+' -'+str(id)+'.'+ss[1]
- with open(name,'+bw') as f:
- f.write(i[1])
- return name
- print("can not find the file with id:",id)
- return ""
-
- # 获取md5
- def get_md5(self,id:int):
- cmd="select md5 from {d1} WHERE id={d2};".format(d1=self.table_name,d2=id)
- self.cur.execute(cmd)
- a=self.cur.fetchall()[0]
- return a[0]
-
- # 扫描文件
- def scan_files(self):
- path = self.download_path
- if not os.path.exists(path):
- os.makedirs(path)
- list=os.listdir(path)
- return list
- # 判断文件是否存在
- def exists(self,id:int):
- for i in self.scan_files():
- s=i.split('.')[-2].split('-')[-1]
- if(int(s)==id):
- with open(self.download_path+i,"rb") as f:
- md=md5(f.read())
- if(md==self.get_md5(id)):
- return True,i
- return False,""
-
-
-if __name__ == "__main__":
- s=sql()
- if(s.init("test_data")==True):
- s.insert("file\\check_result.csv")
- s.show()
- file=s.download(1)
- print("save file:",file)
-
-
-
-