From aaab358c9f4f6086a3f9039345928de8622c717c Mon Sep 17 00:00:00 2001
From: cshenfu <men883234@gmail.com>
Date: 星期二, 07 三月 2023 12:20:52 +0800
Subject: [PATCH] new server

---
 read-serial-python/example.py                                         |   11 
 read-serial-python/test.py                                            |   65 +
 read-serial-python/serialToExcel.py                                   |   54 +
 read-serial-python/socketio_client.py                                 |   66 +
 read-serial-python/bak_serial_ports_reader/sio_client.py              |   33 
 read-serial-python/serial_reader.py                                   |  182 +++++
 read-serial-python/collect_web_call.py                                |   33 
 read-serial-python/port1_read.bat                                     |    3 
 .DS_Store                                                             |    0 
 read-serial-python/bak_serial_ports_reader/client.py                  |   24 
 read-serial-python/bak_serial_ports_reader/server.py                  |   28 
 read-serial-python/serial_reader_2.py                                 |  239 ++++++
 read-serial-python/__pycache__/socketio_client.cpython-37.pyc         |    0 
 read-serial-python/chat.py                                            |   91 ++
 read-serial-python/serialToExcel.jpg                                  |    0 
 read-serial-python/serial_ports_reader.py                             |  194 +++++
 read-serial-python/bak_serial_ports_reader/socketio_a.py              |  124 +++
 read-serial-python/port2_read.bat                                     |    3 
 read-serial-python/README.md                                          |   44 +
 read-serial-python/bak_serial_ports_reader/bak_serial_ports_reader.py |   90 ++
 /dev/null                                                             |    1 
 read-serial-python/serial_ports_reader2.py                            |  194 +++++
 read-serial-python/serial_reader_1.py                                 |  239 ++++++
 read-serial-python/collandtrans.py                                    |  200 +++++
 read-serial-python/__pycache__/serialToExcel.cpython-37.pyc           |    0 
 read-serial-python/websockets.py                                      |   55 +
 read-serial-python/__pycache__/socketio_client.cpython-311.pyc        |    0 
 read-serial-python/websocket.html                                     |   96 ++
 read-serial-python/arduinoToExcel.ino                                 |   20 
 29 files changed, 2,088 insertions(+), 1 deletions(-)

diff --git a/.DS_Store b/.DS_Store
index 93967e6..897c05e 100644
--- a/.DS_Store
+++ b/.DS_Store
Binary files differ
diff --git a/Reading-Serial-Port-With-Python b/Reading-Serial-Port-With-Python
deleted file mode 160000
index d422460..0000000
--- a/Reading-Serial-Port-With-Python
+++ /dev/null
@@ -1 +0,0 @@
-Subproject commit d422460f38cce5485dae0f9b93fee81895bf2caf
diff --git a/read-serial-python/README.md b/read-serial-python/README.md
new file mode 100644
index 0000000..8aa1d50
--- /dev/null
+++ b/read-serial-python/README.md
@@ -0,0 +1,44 @@
+# Reading Data From Serial Port With Python
+
+Bu projede STM32-F103C6TX2 mikrodenetleyicisinin USART portundan gelen mesaj verisinin Python arac谋l谋臒谋 ile okunmas谋n谋 sa臒layan kod yaz谋lm谋艧t谋r. Bu mant谋臒谋 kullanarak STM32 'nin USART portundan gelen veriyi okuyabilir ve bu gelen veriyi i艧leyebilirsiniz. Kodu 莽al谋艧t谋rd谋臒谋n谋zda a莽谋k olan Port 'lar谋 g枚r眉nt眉leyebilir, Portu se莽ebilir ve Haberle艧me H谋z谋n谋(Boud Rate) girebilirsiniz. 陌lgili de臒erler girildikten sonra kod gelen veriyi okumaya ba艧layacakt谋r.
+
+![prg hk gif](https://user-images.githubusercontent.com/74931027/158285012-bb844194-e7ff-400f-a767-5ee9ab53ae1f.gif)
+
+Gerekli K眉t眉phaneler:
+pip install -i https://mirrors.aliyun.com/pypi/simple/ numpy==1.18.2
+
+
+-> import serial -- Komut sat谋r谋na **pip install pyserial** yazarak bu k眉t眉phaneyi kolayca kurabilirsiniz.
+
+-> import serial.tools.list_ports
+
+-> import time
+
+# STM32-F103C6TX Mikrodenetleyicisi 陌le G枚nderilen Verinin Seri Monit枚rden Okunan Mesaj谋:
+![putyyyy](https://user-images.githubusercontent.com/74931027/158284236-49620d0a-6119-4714-96a4-863be1c54627.gif)
+
+# STM32-F103C6TX Mikrodenetleyicisi 陌le G枚nderilen Verinin Python Kodundan Okunan Mesaj谋:
+![gitgit](https://user-images.githubusercontent.com/74931027/158281892-6ac1d0a4-a422-4700-af93-81bcd8094232.png)
+
+Not: Gecikmeden kaynakl谋 TEST mesaj谋 ard谋 ard谋na yaz谋l谋yor. STM32 geli艧tirme kart谋n谋n yollad谋臒谋 veri kodunda gecikme var ve ayn谋 艧ekilde Python kodunda da bir gecikme var. Ufak bi d眉zenleme ile bu sorunun 眉stesinden gelinebilir.
+
+# STM32 Mikrodenetleyici 陌le G枚nderilen Mesaj谋n Kodu: (STM32CubeIDE yaz谋l谋m谋 kullan谋larak yaz谋lm谋艧t谋r.)
+![stm32kod](https://user-images.githubusercontent.com/74931027/158085426-854d6287-a107-4f29-814c-b4ed50bb65af.png)
+
+# STM32-F103C6TX Mikrodenetleyicisinin USART Ayar谋: (STM32CubeIDE yaz谋l谋m谋 kullan谋larak yaz谋lm谋艧t谋r.)
+![stm32ioc](https://user-images.githubusercontent.com/74931027/158085433-ad24a111-05ea-493a-8418-2bd5a8f6983d.png)
+
+# Faydal谋 olmas谋 dile臒imle... 陌yi 莽al谋艧malar.
+**陌SMA陌L SEL脟UK 脟INAR / Electrical and Electronics & Aeronautical Engineering Student - 3rd Year**
+
+馃摟 &nbsp;If you have any problems you can send me an email at cinarismailselcuk@gmail.com I will try to answer as soon as possible.
+### 馃馃徎 &nbsp;Contact Me & Social Media
+
+<p align="center">
+<a href="mailto:cinarismailselcuk@gmail.com"><img src="https://img.shields.io/badge/-Mail-D14836?style=flat&logo=Gmail&logoColor=white"/></a>
+<a href="https://www.linkedin.com/in/ismailselcukcinar/"><img src="https://img.shields.io/badge/-LinkedIn-0077B5?style=flat&logo=Linkedin&logoColor=white%22"/</a>
+<a href="https://instagram.com/ismail_selcuks"><img src="https://img.shields.io/badge/-Instagram_-E4405F?style=flat&logo=Instagram&logoColor=white"/></a>
+<a href="https://twitter.com/ismail_selcuks"><img src="https://img.shields.io/badge/-Twitter_-1976c2?style=flat&logo=Twitter&logoColor=white"/></a>
+<a href="https://www.youtube.com/channel/UCSt6rE5y6iklyFBpm-0xOYA"><img src="https://img.shields.io/badge/-YouTube_-c4302b?style=flat&logo=YouTube&logoColor=white"/></a>
+<a href="https://discordapp.com/users/652243845790302239/"><img src="https://img.shields.io/badge/-Discord_-6A5ACD?style=flat&logo=Discord&logoColor=white"/></a>
+</p>
diff --git a/read-serial-python/__pycache__/serialToExcel.cpython-37.pyc b/read-serial-python/__pycache__/serialToExcel.cpython-37.pyc
new file mode 100644
index 0000000..7d3a154
--- /dev/null
+++ b/read-serial-python/__pycache__/serialToExcel.cpython-37.pyc
Binary files differ
diff --git a/read-serial-python/__pycache__/socketio_client.cpython-311.pyc b/read-serial-python/__pycache__/socketio_client.cpython-311.pyc
new file mode 100644
index 0000000..4d188cf
--- /dev/null
+++ b/read-serial-python/__pycache__/socketio_client.cpython-311.pyc
Binary files differ
diff --git a/read-serial-python/__pycache__/socketio_client.cpython-37.pyc b/read-serial-python/__pycache__/socketio_client.cpython-37.pyc
new file mode 100644
index 0000000..29013da
--- /dev/null
+++ b/read-serial-python/__pycache__/socketio_client.cpython-37.pyc
Binary files differ
diff --git a/read-serial-python/arduinoToExcel.ino b/read-serial-python/arduinoToExcel.ino
new file mode 100644
index 0000000..1cbc25a
--- /dev/null
+++ b/read-serial-python/arduinoToExcel.ino
@@ -0,0 +1,20 @@
+int sensorPin = A0;
+int ledPin = 13;  
+int sensorValue = 0; 
+
+void setup() {
+  Serial.begin(115200);
+}
+
+int i = 0;
+void loop() {
+  
+  sensorValue = analogRead(sensorPin);
+  Serial.print(i);
+  Serial.print(",");
+  Serial.print(sensorValue);
+  Serial.println(";");
+  i = i + 1;
+
+  delay(10);
+}
diff --git a/read-serial-python/bak_serial_ports_reader/bak_serial_ports_reader.py b/read-serial-python/bak_serial_ports_reader/bak_serial_ports_reader.py
new file mode 100644
index 0000000..cb731da
--- /dev/null
+++ b/read-serial-python/bak_serial_ports_reader/bak_serial_ports_reader.py
@@ -0,0 +1,90 @@
+#!/usr/bin/python
+# -*-coding: utf-8 -*-
+
+import serial
+import threading
+import binascii
+from datetime import datetime
+import struct
+import csv
+
+class SerialPort:
+    def __init__(self, port, buand):
+        self.port = serial.Serial(port, buand)
+        self.port.close()
+        if not self.port.isOpen():
+            self.port.open()
+
+    def port_open(self):
+        if not self.port.isOpen():
+            self.port.open()
+
+    def port_close(self):
+        self.port.close()
+
+    def send_data(self):
+        self.port.write('')
+
+    def read_data(self):
+        global is_exit
+        global data_bytes
+        while not is_exit:
+            count = self.port.inWaiting()
+            if count > 0:
+                rec_str = self.port.read(count)
+                data_bytes=data_bytes+rec_str
+                #print('褰撳墠鏁版嵁鎺ユ敹鎬诲瓧鑺傛暟锛�'+str(len(data_bytes))+' 鏈鎺ユ敹瀛楄妭鏁帮細'+str(len(rec_str)))
+                #print(str(datetime.now()),':',binascii.b2a_hex(rec_str))
+
+
+serialPort = 'COM4'  # 涓插彛
+baudRate = 115200  # 娉㈢壒鐜�
+is_exit=False
+data_bytes=bytearray()
+
+if __name__ == '__main__':
+    #鎵撳紑涓插彛
+    mSerial = SerialPort(serialPort, baudRate)
+
+    #鏂囦欢鍐欏叆鎿嶄綔
+    filename=input('璇疯緭鍏ユ枃浠跺悕锛氭瘮濡倀est.csv:')
+    dt=datetime.now()
+    nowtime_str=dt.strftime('%y-%m-%d %I-%M-%S')  #鏃堕棿
+    filename=nowtime_str+'_'+filename
+    out=open(filename,'a+')
+    csv_writer=csv.writer(out)
+
+    #寮�濮嬫暟鎹鍙栫嚎绋�
+    t1 = threading.Thread(target=mSerial.read_data)
+    t1.setDaemon(True)
+    t1.start()
+    
+    while not is_exit:
+        #涓荤嚎绋�:瀵硅鍙栫殑涓插彛鏁版嵁杩涜澶勭悊
+        data_len=len(data_bytes)
+        i=0
+        while(i<data_len-1):
+            if(data_bytes[i]==0xFF and data_bytes[i+1]==0x5A):
+                frame_code=data_bytes[i+2]
+                frame_len=struct.unpack('<H',data_bytes[i+4:i+6])[0]
+                frame_time=struct.unpack('<I',data_bytes[i+6:i+10])[0]
+                print('甯х被鍨嬶細',frame_code,'甯ч暱搴︼細',frame_len,'鏃堕棿鎴筹細',frame_time)
+                #print(frame_code,frame_len,frame_time)
+                if frame_code==0x03:   #鍒ゆ柇甯х被鍨�
+                    #struct 瑙f瀽鏁版嵁甯�
+                    accelerated_x,accelerated_y,accelerated_z,angular_x,angular_y,angular_z,tem,speed_x,speed_y,speed_z,\
+                    angular_v_x,angular_v_y,angular_v_z=struct.unpack('<fffffffffffff',data_bytes[i+12:i+12+frame_len-6])
+                    dt=datetime.now()
+                    nowtime_str=dt.strftime('%y-%m-%d %I:%M:%S')  #鏃堕棿
+                    loc_str=[nowtime_str,frame_time,accelerated_x,accelerated_y,accelerated_z,angular_x,angular_y,angular_z,tem,speed_x,speed_y,speed_z,\
+                    angular_v_x,angular_v_y,angular_v_z]
+
+                    #鍐欏叆csv鏂囦欢
+                    try:
+                       csv_writer.writerow(loc_str)
+                    except Exception as e:
+                       raise e       
+                i=i+6+frame_len+3
+            else:
+                i=i+1
+        data_bytes[0:i]=b''
\ No newline at end of file
diff --git a/read-serial-python/bak_serial_ports_reader/client.py b/read-serial-python/bak_serial_ports_reader/client.py
new file mode 100644
index 0000000..0308dbb
--- /dev/null
+++ b/read-serial-python/bak_serial_ports_reader/client.py
@@ -0,0 +1,24 @@
+import os
+import socket
+
+remote_IP='127.0.0.1'
+remote_port=5555
+
+remote_addr=(remote_IP,remote_port)
+socket=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
+socket.connect(remote_addr)
+
+while True:
+    print('缁撴潫瀵硅瘽: (Q)')
+    str=input('璇疯緭鍏ュ璇濆唴瀹�: ')
+    if str=='Q' or str=='q':
+        str = str.encode('utf-8')
+        socket.send(str)
+        print('瀹㈡埛绔粨鏉熷璇�')
+        break
+    else:
+        str=str.encode('utf-8')
+        socket.send(str)
+
+socket.close()
+
diff --git a/read-serial-python/bak_serial_ports_reader/server.py b/read-serial-python/bak_serial_ports_reader/server.py
new file mode 100644
index 0000000..03505f5
--- /dev/null
+++ b/read-serial-python/bak_serial_ports_reader/server.py
@@ -0,0 +1,28 @@
+import os
+import socket
+
+remote_IP='127.0.0.1'
+remote_port=5555
+
+remote_addr=(remote_IP,remote_port)
+socket=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
+
+#缁戝畾IP鍦板潃鍜岀鍙e彿
+socket.bind(remote_addr)
+#鐩戝惉鏉ヨ嚜瀹㈡埛绔殑淇℃伅
+socket.listen()
+print('姝e湪鐩戝惉鏉ヨ嚜瀹㈡埛绔殑淇℃伅......')
+
+#new_socket鐢ㄤ簬涓庡鎴锋満鐨勫璇�
+new_socket,addr=socket.accept()
+while True:
+    print('缁撴潫瀵硅瘽: (Q or q)')
+    str=new_socket.recv(1024).decode('utf-8')
+    if str=='Q' or str=='q':
+        print('鏈嶅姟鍣ㄧ粨鏉熷璇�')
+        new_socket.close()
+        break
+    else:
+        print(str)
+
+
diff --git a/read-serial-python/bak_serial_ports_reader/sio_client.py b/read-serial-python/bak_serial_ports_reader/sio_client.py
new file mode 100644
index 0000000..7b46eb5
--- /dev/null
+++ b/read-serial-python/bak_serial_ports_reader/sio_client.py
@@ -0,0 +1,33 @@
+import socketio
+
+def create_client():
+    print('-----------start socketio.clent------------')
+    sio = socketio.Client()
+   
+    @sio.event
+    def connect():
+        print('connection established')
+        sio.emit('client', {'msg': 'connect success'})
+
+    @sio.on('serve')
+    def on_message(data):
+        print('client received a message!',data)
+    # @sio.event
+    # def message(data):
+    #     print('message received with ', data)
+    #     sio.emit('client', {'response': 'my response'})
+
+    @sio.event
+    def connect_error():
+        print("The connection failed!")
+        sio.disconnect()
+
+    @sio.event
+    def disconnect():
+        print('disconnected from server')
+        sio.disconnect()
+    
+    sio.connect('http://localhost:5000')
+    # sio.wait()
+
+#create_client()
\ No newline at end of file
diff --git a/read-serial-python/bak_serial_ports_reader/socketio_a.py b/read-serial-python/bak_serial_ports_reader/socketio_a.py
new file mode 100644
index 0000000..761ab6a
--- /dev/null
+++ b/read-serial-python/bak_serial_ports_reader/socketio_a.py
@@ -0,0 +1,124 @@
+import this
+import socketio
+
+
+def sio(url,tparams):
+    if not tparams:
+        sio = socketio.Client()
+        sio.connect(url)
+        sio.on('connect', on_connect)
+        sio.on('chat_message', revc_message)
+        sio.on('disconnect', on_disconnect)
+        sio.on('reconnect', on_reconnect)
+        print(tparams)
+        return sio
+
+
+def get_sessionid(userid, roomid):
+    pass
+
+def on_connect(*args):
+    # print(*args)
+    print('connect')
+
+def on_disconnect():
+    print('## disconnect ##')
+
+def on_reconnect():
+    print('reconnect')
+
+def revc_message(*args):  # 杩欎釜鍑芥暟寰堥噸瑕� 鏄痵ocketio鐩戝惉淇℃伅鑾峰彇鐨勫嚱鏁�, 杩欓噷闈ocketio浼氳嚜琛岃皟鐢ㄨ繖涓嚱鏁�
+    response_data_format = {}
+    response_data = eval(args[0])
+    print(response_data)
+
+def revc_message_mutil(*args):  # 杩欎釜鍑芥暟寰堥噸瑕� 鏄痵ocketio鐩戝惉淇℃伅鑾峰彇鐨勫嚱鏁�, 杩欓噷闈ocketio浼氳嚜琛岃皟鐢ㄨ繖涓嚱鏁�
+    response_data_format = {}
+    response_data = eval(args[0])
+    print(response_data)
+
+def create_params(userid, roomid):  # 杩欎釜鏂规硶绫讳技requests搴撶殑灏佽鏂规硶 鐪嬪簳灞傝矊浼间笌requests鐨剈rllib3鏂规硶涓�鏍�
+    vsessionid, tsessionid = get_sessionid(userid, roomid)
+    vparams = {
+        'sessionid': vsessionid,
+    }
+    tparams = {
+        'sessionid': tsessionid,
+    }
+    return vparams, tparams
+
+def sio(url=' xxx.net', vparams='', tparams=''):
+    if not tparams:
+        sio = socketio.Client()
+        this.sio.connect('http://localhost:5000')
+        print('socketio connect success!!!')
+        sio.on('connect', on_connect)
+        sio.on('chat_message', revc_message)
+        sio.on('disconnect', on_disconnect)
+        sio.on('reconnect', on_reconnect)
+        return teacher, vsocketIO, tsocketIO
+
+def send_msg(domain_host, featurestype, sendmessage, userid, roomid, timer=1):
+    teacher, vsocketIO, tsocketIO = sio(userid, roomid, host=domain_host)
+    for i in range(timer):
+        teacher.emit('chat_message', f'{sendmessage}', revc_message)
+        vsocketIO.wait(seconds=1)
+        tsocketIO.wait(seconds=1)
+    return VIEWER_DATA, TEACHER_DATA
+
+def send_msg_mutil(domain_host, featurestype, sendmessage, userid, roomid, timer=1, vparams='', tparams=''):
+    teacher, vsocketIO, tsocketIO = sio(userid, roomid, host=domain_host, vparams=vparams, tparams=tparams)
+    for i in range(timer):
+        teacher.emit('chat_message', f'{sendmessage}', revc_message_mutil)
+        vsocketIO.wait(seconds=1)
+        tsocketIO.wait(seconds=1)
+    return VIEWER_DATA, TEACHER_DATA
+
+def clear_data():
+    VIEWER_DATA.clear()
+    TEACHER_DATA.clear()
+
+class Socketio_client():
+
+    sio = socketio.Client()
+
+    def create_client():
+        print('-----------start socketio.clent------------')
+        # sio = socketio.Client()
+        this.sio.connect('http://localhost:5000')
+        print('socketio connect success!!!')
+
+        @this.sio.event
+        def connect():
+            print('connection established')
+            this.sio.emit('client', {'msg': 'connect success'})
+
+        @this.sio.on('serve')
+        def on_message(data):
+            print('client received a message!',data)
+        # @sio.event
+        # def message(data):
+        #     print('message received with ', data)
+        #     sio.emit('client', {'response': 'my response'})
+
+        @this.sio.event
+        def connect_error():
+            print("The connection failed!")
+            this.sio.disconnect()
+
+        @this.sio.event
+        def disconnect():
+            print('disconnected from server')
+            this.sio.disconnect()
+        
+        # sio.wait()
+
+    def sendmsg(msg): 
+        this.sio.emit('client', {'msg': msg})
+
+    def connect(): 
+        this.sio.connect('http://localhost:5000')
+        print('socketio connect success!!!')
+
+
+    create_client()
\ No newline at end of file
diff --git a/read-serial-python/chat.py b/read-serial-python/chat.py
new file mode 100644
index 0000000..b7d2e1f
--- /dev/null
+++ b/read-serial-python/chat.py
@@ -0,0 +1,91 @@
+from socketIO_client import SocketIO, BaseNamespace
+import time
+import requests
+import logging
+# 杩欓噷寮曞叆鍥涗釜鍙橀噺 鏀惧湪flask閲岄潰璧蜂竴涓崟鐙枃浠堕槻姝㈡湁鍧�!
+from app.test_report.constant import VIEWER_DATA, TEACHER_DATA, VIEWER_DATA_MUTIL, TEACHER_DATA_MUTIL
+logging.getLogger('socketIO-client').setLevel(logging.DEBUG)
+logging.basicConfig()  # 璋冭瘯鏃跺�欏彲浠ヨ嚜瀹氫箟鏃ュ織
+
+class TeacherNamespace(BaseNamespace):
+    def on_teacher_response(self, *args):
+        print('qqq', args, type(args))
+
+class ViewerNamespace(BaseNamespace):
+    def on_viewer_response(self, *args):
+        print(args, type(args))
+
+def get_sessionid(userid, roomid):
+    pass
+
+def on_connect(*args):
+    # print(*args)
+    print('connect')
+
+def on_disconnect():
+    print('## disconnect ##')
+
+def on_reconnect():
+    print('reconnect')
+
+def revc_message(*args):  # 杩欎釜鍑芥暟寰堥噸瑕� 鏄痵ocketio鐩戝惉淇℃伅鑾峰彇鐨勫嚱鏁�, 杩欓噷闈ocketio浼氳嚜琛岃皟鐢ㄨ繖涓嚱鏁�
+    response_data_format = {}
+    response_data = eval(args[0])
+    print(response_data)
+
+def revc_message_mutil(*args):  # 杩欎釜鍑芥暟寰堥噸瑕� 鏄痵ocketio鐩戝惉淇℃伅鑾峰彇鐨勫嚱鏁�, 杩欓噷闈ocketio浼氳嚜琛岃皟鐢ㄨ繖涓嚱鏁�
+    response_data_format = {}
+    response_data = eval(args[0])
+    print(response_data)
+
+def create_params(userid, roomid):  # 杩欎釜鏂规硶绫讳技requests搴撶殑灏佽鏂规硶 鐪嬪簳灞傝矊浼间笌requests鐨剈rllib3鏂规硶涓�鏍�
+    vsessionid, tsessionid = get_sessionid(userid, roomid)
+    vparams = {
+        'sessionid': vsessionid,
+    }
+    tparams = {
+        'sessionid': tsessionid,
+    }
+    return vparams, tparams
+
+def sio(userid, roomid, host=' xxx.net', vparams='', tparams=''):
+    if not vparams and not tparams:
+        vparams, tparams = create_params(userid, roomid)
+    vsocketIO = SocketIO(host, params=vparams)
+    tsocketIO = SocketIO(host, params=tparams)
+    viewer = vsocketIO.define(ViewerNamespace, path=f'/asjbfasbfk')  # 杩欎釜path绫讳技浜庝俊閬撶殑璺緞 寰堥噸瑕�
+    teacher = tsocketIO.define(TeacherNamespace, path=f'/asjbfasbfk')  # 杩欎釜path绫讳技浜庝俊閬撶殑璺緞 寰堥噸瑕�
+    viewer.on('connect', on_connect)
+    viewer.on('chat_message', revc_message)
+    viewer.on('disconnect', on_disconnect)
+    viewer.on('reconnect', on_reconnect)
+    teacher.on('connect', on_connect)
+    teacher.on('chat_message', revc_message)
+    teacher.on('disconnect', on_disconnect)
+    teacher.on('reconnect', on_reconnect)
+    return teacher, vsocketIO, tsocketIO
+
+def send_msg(domain_host, featurestype, sendmessage, userid, roomid, timer=1):
+    teacher, vsocketIO, tsocketIO = sio(userid, roomid, host=domain_host)
+    for i in range(timer):
+        teacher.emit('chat_message', f'{sendmessage}', revc_message)
+        vsocketIO.wait(seconds=1)
+        tsocketIO.wait(seconds=1)
+    return VIEWER_DATA, TEACHER_DATA
+
+def send_msg_mutil(domain_host, featurestype, sendmessage, userid, roomid, timer=1, vparams='', tparams=''):
+    teacher, vsocketIO, tsocketIO = sio(userid, roomid, host=domain_host, vparams=vparams, tparams=tparams)
+    for i in range(timer):
+        teacher.emit('chat_message', f'{sendmessage}', revc_message_mutil)
+        vsocketIO.wait(seconds=1)
+        tsocketIO.wait(seconds=1)
+    return VIEWER_DATA, TEACHER_DATA
+
+def clear_data():
+    VIEWER_DATA.clear()
+    TEACHER_DATA.clear()
+if __name__ == '__main__':
+    s = time.time()
+    print(send_msg('xxxx.net', 1, '鍙戦�佷俊鎭�1', '7848DB3F76g7ts7057F', 'E301DFFFCDDAG7S79GY9A01307461'))
+    print(time.time()-s)
+    clear_data()
diff --git a/read-serial-python/collandtrans.py b/read-serial-python/collandtrans.py
new file mode 100644
index 0000000..c696f54
--- /dev/null
+++ b/read-serial-python/collandtrans.py
@@ -0,0 +1,200 @@
+#coded by 浼婄帥鐩殑闂ㄥ緬
+#coding=utf-8
+from wordpress_xmlrpc import Client, WordPressPost
+from wordpress_xmlrpc.methods.posts import GetPosts, NewPost
+from wordpress_xmlrpc.methods.users import GetUserInfo
+import time
+import requests
+from bs4 import BeautifulSoup
+import re
+ 
+ 
+from concurrent.futures import ThreadPoolExecutor
+ 
+ 
+start = time.clock()  # 璁℃椂-寮�濮�
+urllist=[]
+titlelist=[]
+ 
+header={'user-agent':'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.XXXX.XXX Safari/537.36'}
+ 
+ 
+ 
+def do(i):
+    try:
+ 
+        cd=[]
+        html=requests.get('http://futures.hexun.com/domestic/index-'+str(i)+'.html',headers=header)
+ 
+        html.encoding='gbk'
+ 
+        Soup = BeautifulSoup(html.text, "lxml")
+        #ab=Soup.select('li a[target="_blank"]')
+        ab=Soup.select('div.temp01 ul li a[target="_blank"]')
+ 
+        for x in range(len(ab)):
+            if (x % 2) == 1:
+                cd.append (ab[x])
+ 
+        #print ('--------------')
+ 
+        pattern = re.compile(r'<a href="(.*?)" target="_blank">',re.S)   # 鏌ユ壘鏁板瓧
+        result1 = pattern.findall(str(cd))
+        pattern2 = re.compile(r'target="_blank">(.*?)</a>',re.S)
+        result2 = pattern2.findall(str(cd))
+        #print (result1)
+        urllist.extend(result1)
+        #print (result2)
+        titlelist.extend(result2)
+ 
+ 
+        list1.remove(i)
+ 
+ 
+ 
+    except:
+        pass
+ 
+ 
+ 
+# 澶氱嚎绋�
+def multithreading():
+    sum=0
+ 
+    while len(list1)>0:
+        with ThreadPoolExecutor(max_workers=10) as executor:
+            for result in executor.map(do, list1):
+                sum+=1
+ 
+    return sum
+ 
+ 
+ 
+ 
+#list1=list(range(1,393,1))
+list1=list(range(392,393,1))
+ 
+sum=multithreading()
+print ('杩樺墿涓媨}椤�'.format(list1))
+ 
+ 
+ 
+end = time.clock()  # 璁℃椂-缁撴潫
+print (("鐖彇瀹屾垚 鐢ㄦ椂锛�"))
+print ((end - start))
+ 
+ 
+print ('鎬荤埇鍙� %d 椤� '%(sum))
+ 
+while None in titlelist:
+    titlelist.remove(None)
+ 
+while None in urllist:
+    urllist.remove(None)
+ 
+#print (titlelist)
+ 
+#print (urllist)
+ 
+ 
+'''
+#鍙綔涓篢XT杈撳嚭
+with open("test.txt","w") as f:
+        for thing in urllist:
+            f.write(thing)
+            f.write('\r\n')
+'''
+ 
+ 
+ 
+ 
+ 
+def getcontent(url,j):
+    try:
+        print (listj)
+ 
+        html=requests.get(url,headers=header)
+ 
+        html.encoding='gbk'
+ 
+        Soup = BeautifulSoup(html.text, "lxml")
+ 
+        con=Soup.select('div.art_contextBox ')
+ 
+        cont=''
+        for y in con:
+            #print (type(str(y)))
+            cont=cont+str(y)
+ 
+        #print (cont)
+        #print (j)
+        listj.remove(j)
+        #print ('****')
+        #print (listj)
+        return (cont)
+ 
+ 
+ 
+ 
+ 
+    except:
+        pass
+ 
+ 
+def wpsend(title,content):
+ 
+    wp = Client('http://www.6324.xyz/xmlrpc.php', '浣犵殑鐢ㄦ埛鍚�', '浣犵殑瀵嗙爜')
+ 
+    #print (content)
+    post = WordPressPost()
+    post.title = title
+    #post.content = " ''' "+ content +" ''' "
+    post.content = "  "+ str(content) +"  "
+    post.post_status = 'publish'
+    post.terms_names = {
+       'post_tag': ['鎿嶇洏绛栫暐'],
+      'category': [ '鏈熻揣']
+    }
+    wp.call(NewPost(post))
+    localtime = time.localtime(time.time())
+    print ('鏂囨。宸蹭笂浼�,鎵ц鏃堕棿 {}'.format(time.strftime("%Y-%m-%d %H:%M:%S",localtime)))
+ 
+ 
+def work(j):
+ 
+    url=urllist[j]
+    title=titlelist[j]
+ 
+    cont=getcontent(url,j)
+    wpsend(title,cont)
+ 
+    print ('鎴愬姛瀹屾垚浠诲姟閲囬泦浠诲姟绗� {}鍙蜂换鍔�'.format(j))
+ 
+ 
+ 
+ 
+ 
+ 
+# 澶氱嚎绋�
+def multithreading_con():
+    sum=0
+    global listj
+    listj=list(range(len(urllist)))
+    #print (type(listj))
+    #print (listj)
+ 
+    while len(listj)>0:
+        with ThreadPoolExecutor(max_workers=5) as executor:
+            for result in executor.map(work,listj ):
+                sum+=1
+ 
+    return sum
+ 
+ 
+ 
+multithreading_con()
+ 
+end = time.clock()  # 璁℃椂-缁撴潫
+print ("鍏ㄩ儴涓婁紶瀹屾垚 鐢ㄦ椂锛�")
+ 
+print ((end - start))
\ No newline at end of file
diff --git a/read-serial-python/collect_web_call.py b/read-serial-python/collect_web_call.py
new file mode 100644
index 0000000..f6ba77a
--- /dev/null
+++ b/read-serial-python/collect_web_call.py
@@ -0,0 +1,33 @@
+from http.client import SWITCHING_PROTOCOLS
+from flask import Flask, request, redirect, url_for, render_template
+
+
+class switch_case(object):
+    def case_to_function(self, case):
+        fun_name = "case_fun_" + str(case)
+        method = getattr(self, fun_name, self.case_fun_other)
+        return method
+    def case_fun_start(self, msg):
+        print(msg)
+    def case_fun_stop(self, msg):
+        print(msg)
+    def case_fun_other(self, msg):
+        print(msg)
+
+# 鍒涘缓Flask鏈嶅姟
+app = Flask(__name__)
+
+# 璁块棶URL锛歨ttp://127.0.0.1:8080/home/hello
+# 杩斿洖缁撴灉锛歿"data":"welcome to use flask.","msg":"hello"}
+@app.route('/home/<name>')
+def home(name):
+    cls.case_to_function(name)("case_fun_"+name+" is called")
+    return {
+        "msg": name,
+        "data": "welcome to use flask."
+    }
+
+if __name__ == "__main__":
+    cls = switch_case()
+    # 鍚姩Flask鏈嶅姟锛屾寚瀹氫富鏈篒P鍜岀鍙�
+    app.run(host='127.0.0.1', port=8080)
\ No newline at end of file
diff --git a/read-serial-python/example.py b/read-serial-python/example.py
new file mode 100644
index 0000000..5f182d7
--- /dev/null
+++ b/read-serial-python/example.py
@@ -0,0 +1,11 @@
+from serialToExcel import SerialToExcel
+
+serialToExcel = SerialToExcel("COM4",115200)
+
+columnas = ["Nro Lectura","Valor"]
+
+serialToExcel.setColumns(["Nro Lectura","Valor"])
+serialToExcel.setRecordsNumber(10)
+serialToExcel.readPort()
+
+serialToExcel.writeFile("archivo1.xls")
\ No newline at end of file
diff --git a/read-serial-python/port1_read.bat b/read-serial-python/port1_read.bat
new file mode 100644
index 0000000..8b25e90
--- /dev/null
+++ b/read-serial-python/port1_read.bat
@@ -0,0 +1,3 @@
+@echo off
+set local enabledelayedexpansion
+python serial_reader_1.py
\ No newline at end of file
diff --git a/read-serial-python/port2_read.bat b/read-serial-python/port2_read.bat
new file mode 100644
index 0000000..e9b6090
--- /dev/null
+++ b/read-serial-python/port2_read.bat
@@ -0,0 +1,3 @@
+@echo off
+set local enabledelayedexpansion
+python serial_reader_2.py
\ No newline at end of file
diff --git a/read-serial-python/serialToExcel.jpg b/read-serial-python/serialToExcel.jpg
new file mode 100644
index 0000000..12699fb
--- /dev/null
+++ b/read-serial-python/serialToExcel.jpg
Binary files differ
diff --git a/read-serial-python/serialToExcel.py b/read-serial-python/serialToExcel.py
new file mode 100644
index 0000000..6557452
--- /dev/null
+++ b/read-serial-python/serialToExcel.py
@@ -0,0 +1,54 @@
+import serial
+import xlwt
+from datetime import datetime
+
+class SerialToExcel:
+
+    def __init__(self,port,speed):
+        
+        self.port = port
+        self.speed = speed
+
+        self.wb = xlwt.Workbook()
+        self.ws = self.wb.add_sheet("Data from Serial",cell_overwrite_ok=True)
+        self.ws.write(0, 0, "Data from Serial")
+        self.columns = ["Date Time"]
+        self.number = 100
+        
+
+    def setColumns(self,col):
+        self.columns.extend(col)
+        
+    def setRecordsNumber(self,number):
+        self.number = number
+        
+    def readPort(self):
+        ser = serial.Serial(self.port, self.speed, timeout=1)
+        c = 0
+        for col in self.columns:
+            self.ws.write(1, c, col)
+            c = c + 1
+        self.fila = 2
+
+        i = 0
+        while(i<self.number):
+            line = str(ser.readline())
+            if(len(line) > 0):
+                now = datetime.now()
+                date_time = now.strftime("%m/%d/%Y, %H:%M:%S")
+                print(date_time,line)
+                if(line.find(",")):
+                    c = 1
+                    self.ws.write(self.fila, 0, date_time)
+                    columnas = line.split(",")
+                    for col in columnas:
+                        self.ws.write(self.fila, c, col)
+                        c = c + 1
+
+                i = i + 1
+                self.fila = self.fila + 1
+    
+    def writeFile(self,archivo):
+    	self.wb.save(archivo)
+
+    
\ No newline at end of file
diff --git a/read-serial-python/serial_ports_reader.py b/read-serial-python/serial_ports_reader.py
new file mode 100644
index 0000000..61a017e
--- /dev/null
+++ b/read-serial-python/serial_ports_reader.py
@@ -0,0 +1,194 @@
+#!/usr/bin/python
+# -*-coding: utf-8 -*-
+
+from asyncio import sleep
+from collections import deque
+from pickle import FALSE
+import serial
+import threading
+from datetime import datetime
+import socketio
+import time
+import csv
+
+
+class SerialPort:
+    def __init__(self, port, buand):
+        self.port = serial.Serial(port, buand)
+        self.port.close()
+        if not self.port.isOpen():
+            self.port.open()
+
+    def port_open(self):
+        if not self.port.isOpen():
+            self.port.open()
+
+    def port_close(self):
+        self.port.close()
+
+    def send_data(self):
+        self.port.write('')
+
+    def read_data(self):
+        global is_exit
+        global data_bytes,data_list
+        while True: 
+            while not is_exit:
+                count = self.port.inWaiting()
+                if count > 0:
+                    rec_str = self.port.read(count)
+                    data_list.append(rec_str)
+                    # data_bytes = data_bytes+rec_str
+                    # print(str(datetime.now()),':','褰撳墠鏁版嵁鎺ユ敹鎬诲瓧鑺傛暟锛�'+str(len(data_bytes))+' 鏈鎺ユ敹瀛楄妭鏁帮細'+str(len(rec_str)))
+
+    def write_data(self): 
+        global data_L,L,index_,is_exit,data_list,send_list
+        newData = False
+        while True:
+            while not is_exit:
+                # i,is_60_index,is_65_index,is_68_index = 0
+                # is_first = False
+                if len(data_list)<1: 
+                    continue
+                # 鍐欏叆csv鏂囦欢
+                text_ = data_list.popleft()
+                for each in text_:
+                    send_list.append(int(each))
+                dt = datetime.now()
+                nowtime_str = dt.strftime('%Y-%m-%d %H:%M:%S.%f')  # 鏃堕棿
+                while len(send_list)>0:
+                    x = send_list.popleft()
+                    if(x == 60):
+                        if len(send_list)<3:
+                            send_list.appendleft(x)
+                            break
+                        else:
+                            y = send_list.popleft()
+                            z = send_list.popleft()
+                            m = send_list.popleft()
+                            if (x == 60  and y == 170 and z == 85):
+                                if(m == 65):
+                                    index_ = 0
+                                    data_L=[[],[],[],[]]
+                                if(m == 66):
+                                    index_ = 1
+                                    data_L[index_] = []
+                                if(m == 67):
+                                    index_ = 2
+                                    data_L[index_] = []
+                                if(m == 68):
+                                    index_ = 3
+                                    data_L[index_] = []
+                                data_L[index_].append(x)    
+                                data_L[index_].append(y)
+                                data_L[index_].append(z)
+                                data_L[index_].append(m)
+                            else:
+                                data_L[index_].append(x)
+                                send_list.appendleft(m)
+                                send_list.appendleft(z)
+                                send_list.appendleft(y)
+                    else:
+                        data_L[index_].append(x)
+                # 鍙戦�乻ocket娑堟伅
+                if(len(data_L[3])>0 and len(data_L[3])==len(data_L[2])):
+                    if sio.connected:
+                        sio.emit("msg",{"time": nowtime_str,"serialport":serialPort,"data":data_L})
+                    data_L=[[],[],[],[]] 
+                    
+                # socket_.send("msg",{"data":text_})
+                # try:
+                #     # writedata ='{}'.format(data_list.popleft())
+                #     # Note.write(writedata.encode('hex'))
+                #     csv_writer.writerow(text_)
+                # except Exception as e:
+                #     raise e
+
+    def test(self):
+        global is_exit
+        while True: 
+            sleep(10)
+            is_exit = False
+            sleep(10)
+            is_exit = True
+
+serialPort = '/dev/tty.usbserial-14130'  # 涓插彛
+baudRate = 115200  # 娉㈢壒鐜�
+socketurl_ = "http://192.168.0.30:3001"
+is_exit = False
+data_bytes = bytearray()
+data_list = deque()
+send_list = deque()
+L = []
+data_L = [[],[],[],[]]
+index_ = 0 #绗� A/B/C/D 缁勬暟鎹�
+# sio = socketio.Client(logger=True, engineio_logger=True)
+sio = socketio.Client()
+start_timer = None
+csv_writer = None
+is_data_header = False
+
+@sio.event
+def connect():
+    print('connected to server')
+
+
+@sio.event
+def pong_from_server():
+    global start_timer
+    latency = time.time() - start_timer
+    print('latency is {0:.2f} ms'.format(latency * 1000))
+    sio.sleep(1)
+    if sio.connected:
+        print(' reconnected')
+
+
+@sio.on('command_msg')
+def command_msg(data):
+    global is_exit
+    if data['command'] == 'stop':
+        is_exit = True
+    if data['command'] == 'start':
+        is_exit = False
+
+if __name__ == '__main__':
+    # serialPort = input("璇疯緭鍏ヤ覆鍙e瓧绗︿覆")
+    # 鎵撳紑涓插彛
+    mSerial = SerialPort(serialPort, baudRate)
+
+    # 鏂囦欢鍐欏叆鎿嶄綔
+    # filename = input('璇疯緭鍏ユ枃浠跺悕锛氭瘮濡倀est.csv:')
+    filename = 'test.csv'
+    dt = datetime.now()
+    nowtime_str = dt.strftime('%y-%m-%d %I-%M-%S')  # 鏃堕棿
+    # filename = nowtime_str+'_'+filename
+    # out = open(filename, 'w')
+    # csv_writer = csv.writer(out)
+    # txt鍐欏叆
+    # Note=open(nowtime_str+'_test.txt',mode='w')
+
+    # 寮�濮嬫暟鎹鍙栫嚎绋�
+    t1 = threading.Thread(target=mSerial.read_data)
+    t1.setDaemon(True)
+    t1.start()
+
+    # 杩炴帴socketio
+    sio.connect(socketurl_)
+    print('-----------------------------000000000000000---------------------------------')
+    # 寮�濮嬪啓鏁版嵁
+    t3 =  threading.Thread(target=mSerial.write_data())
+    t3.setDaemon(True)
+    t3.start()
+    print('-----------------------------11111111111111---------------------------------')
+    
+    # sio.wait() #sio浜嬩欢澶勭悊
+    t4 =  threading.Thread(target=sio.wait())
+    t4.setDaemon(True)
+    t4.start()
+
+    # 杩炴帴socket
+    # remote_IP='192.168.0.225'
+    # remote_port=5000
+    # remote_addr=(remote_IP,remote_port)
+    # socket_=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
+    # socket_.connect(remote_addr)
\ No newline at end of file
diff --git a/read-serial-python/serial_ports_reader2.py b/read-serial-python/serial_ports_reader2.py
new file mode 100644
index 0000000..98b1db6
--- /dev/null
+++ b/read-serial-python/serial_ports_reader2.py
@@ -0,0 +1,194 @@
+#!/usr/bin/python
+# -*-coding: utf-8 -*-
+
+from asyncio import sleep
+from collections import deque
+from pickle import FALSE
+import serial
+import threading
+from datetime import datetime
+import socketio
+import time
+import csv
+
+
+class SerialPort:
+    def __init__(self, port, buand):
+        self.port = serial.Serial(port, buand)
+        self.port.close()
+        if not self.port.isOpen():
+            self.port.open()
+
+    def port_open(self):
+        if not self.port.isOpen():
+            self.port.open()
+
+    def port_close(self):
+        self.port.close()
+
+    def send_data(self):
+        self.port.write('')
+
+    def read_data(self):
+        global is_exit
+        global data_bytes,data_list
+        while True: 
+            while not is_exit:
+                count = self.port.inWaiting()
+                if count > 0:
+                    rec_str = self.port.read(count)
+                    data_list.append(rec_str)
+                    # data_bytes = data_bytes+rec_str
+                    # print(str(datetime.now()),':','褰撳墠鏁版嵁鎺ユ敹鎬诲瓧鑺傛暟锛�'+str(len(data_bytes))+' 鏈鎺ユ敹瀛楄妭鏁帮細'+str(len(rec_str)))
+
+    def write_data(self): 
+        global data_L,L,index_,is_exit,data_list,send_list
+        newData = False
+        while True:
+            while not is_exit:
+                # i,is_60_index,is_65_index,is_68_index = 0
+                # is_first = False
+                if len(data_list)<1: 
+                    continue
+                # 鍐欏叆csv鏂囦欢
+                text_ = data_list.popleft()
+                for each in text_:
+                    send_list.append(int(each))
+                dt = datetime.now()
+                nowtime_str = dt.strftime('%Y-%m-%d %H:%M:%S.%f')  # 鏃堕棿
+                while len(send_list)>0:
+                    x = send_list.popleft()
+                    if(x == 60):
+                        if len(send_list)<3:
+                            send_list.appendleft(x)
+                            break
+                        else:
+                            y = send_list.popleft()
+                            z = send_list.popleft()
+                            m = send_list.popleft()
+                            if (x == 60  and y == 170 and z == 85):
+                                if(m == 65):
+                                    index_ = 0
+                                    data_L=[[],[],[],[]]
+                                if(m == 66):
+                                    index_ = 1
+                                    data_L[index_] = []
+                                if(m == 67):
+                                    index_ = 2
+                                    data_L[index_] = []
+                                if(m == 68):
+                                    index_ = 3
+                                    data_L[index_] = []
+                                data_L[index_].append(x)    
+                                data_L[index_].append(y)
+                                data_L[index_].append(z)
+                                data_L[index_].append(m)
+                            else:
+                                data_L[index_].append(x)
+                                send_list.appendleft(m)
+                                send_list.appendleft(z)
+                                send_list.appendleft(y)
+                    else:
+                        data_L[index_].append(x)
+                # 鍙戦�乻ocket娑堟伅
+                if(len(data_L[3])>0 and len(data_L[3])==len(data_L[2])):
+                    if sio.connected:
+                        sio.emit("msg",{"time": nowtime_str,"serialport":serialPort,"data":data_L})
+                    data_L=[[],[],[],[]] 
+                    
+                # socket_.send("msg",{"data":text_})
+                # try:
+                #     # writedata ='{}'.format(data_list.popleft())
+                #     # Note.write(writedata.encode('hex'))
+                #     csv_writer.writerow(text_)
+                # except Exception as e:
+                #     raise e
+
+    def test(self):
+        global is_exit
+        while True: 
+            sleep(10)
+            is_exit = False
+            sleep(10)
+            is_exit = True
+
+serialPort = '/dev/tty.usbserial-14110'  # 涓插彛
+baudRate = 115200  # 娉㈢壒鐜�
+socketurl_ = "http://192.168.0.30:3001"
+is_exit = False
+data_bytes = bytearray()
+data_list = deque()
+send_list = deque()
+L = []
+data_L = [[],[],[],[]]
+index_ = 0 #绗� A/B/C/D 缁勬暟鎹�
+# sio = socketio.Client(logger=True, engineio_logger=True)
+sio = socketio.Client()
+start_timer = None
+csv_writer = None
+is_data_header = False
+
+@sio.event
+def connect():
+    print('connected to server')
+
+
+@sio.event
+def pong_from_server():
+    global start_timer
+    latency = time.time() - start_timer
+    print('latency is {0:.2f} ms'.format(latency * 1000))
+    sio.sleep(1)
+    if sio.connected:
+        print(' reconnected')
+
+
+@sio.on('command_msg')
+def command_msg(data):
+    global is_exit
+    if data['command'] == 'stop':
+        is_exit = True
+    if data['command'] == 'start':
+        is_exit = False
+
+if __name__ == '__main__':
+    # serialPort = input("璇疯緭鍏ヤ覆鍙e瓧绗︿覆")
+    # 鎵撳紑涓插彛
+    mSerial = SerialPort(serialPort, baudRate)
+
+    # 鏂囦欢鍐欏叆鎿嶄綔
+    # filename = input('璇疯緭鍏ユ枃浠跺悕锛氭瘮濡倀est.csv:')
+    filename = 'test.csv'
+    dt = datetime.now()
+    nowtime_str = dt.strftime('%y-%m-%d %I-%M-%S')  # 鏃堕棿
+    # filename = nowtime_str+'_'+filename
+    # out = open(filename, 'w')
+    # csv_writer = csv.writer(out)
+    # txt鍐欏叆
+    # Note=open(nowtime_str+'_test.txt',mode='w')
+
+    # 寮�濮嬫暟鎹鍙栫嚎绋�
+    t1 = threading.Thread(target=mSerial.read_data)
+    t1.setDaemon(True)
+    t1.start()
+
+    # 杩炴帴socketio
+    sio.connect(socketurl_)
+    print('-----------------------------000000000000000---------------------------------')
+    # 寮�濮嬪啓鏁版嵁
+    t3 =  threading.Thread(target=mSerial.write_data())
+    t3.setDaemon(True)
+    t3.start()
+    print('-----------------------------11111111111111---------------------------------')
+    
+    # sio.wait() #sio浜嬩欢澶勭悊
+    t4 =  threading.Thread(target=sio.wait())
+    t4.setDaemon(True)
+    t4.start()
+
+    # 杩炴帴socket
+    # remote_IP='192.168.0.225'
+    # remote_port=5000
+    # remote_addr=(remote_IP,remote_port)
+    # socket_=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
+    # socket_.connect(remote_addr)
\ No newline at end of file
diff --git a/read-serial-python/serial_reader.py b/read-serial-python/serial_reader.py
new file mode 100644
index 0000000..1ae8075
--- /dev/null
+++ b/read-serial-python/serial_reader.py
@@ -0,0 +1,182 @@
+#!/usr/bin/python
+# -*-coding: utf-8 -*-
+
+from asyncio import sleep
+from collections import deque
+from pickle import FALSE
+from socketio_client import connect_, sio, send_msg
+import sys
+import serial
+import threading
+import binascii
+from datetime import datetime
+import socketio
+import time
+import csv
+import socket
+# import numpy
+
+
+class SerialPort:
+    def __init__(self, port, buand):
+        self.port = serial.Serial(port, buand)
+        self.port.close()
+        if not self.port.isOpen():
+            self.port.open()
+
+    def port_open(self):
+        if not self.port.isOpen():
+            self.port.open()
+
+    def port_close(self):
+        self.port.close()
+
+    def send_data(self):
+        self.port.write('')
+
+    def read_data(self):
+        global is_exit
+        global data_bytes,data_list
+        while True: 
+            while not is_exit:
+                count = self.port.inWaiting()
+                if count > 0:
+                    rec_str = self.port.read(count)
+                    data_list.append(rec_str)
+                    # data_bytes = data_bytes+rec_str
+                    # print(str(datetime.now()),':','褰撳墠鏁版嵁鎺ユ敹鎬诲瓧鑺傛暟锛�'+str(len(data_bytes))+' 鏈鎺ユ敹瀛楄妭鏁帮細'+str(len(rec_str)))
+
+    def write_data(self): 
+        global is_exit,data_bytes,data_list,csv_writer,L,sio,start_timer,is_data_header,send_list
+        newData = False
+        while True:
+            while not is_exit:
+                i,is_60_index,is_65_index,is_68_index = 0
+                is_first = False
+                # 涓荤嚎绋�:瀵硅鍙栫殑涓插彛鏁版嵁杩涜澶勭悊
+                if len(data_list)<1: 
+                    continue
+                dt = datetime.now()
+                nowtime_str = dt.strftime('%y-%m-%d %I:%M:%S')  # 鏃堕棿
+                # 鍐欏叆csv鏂囦欢
+                text_ = data_list.popleft()
+                print(type(text_))
+                # if len(send_list) < 1:
+                #     continue
+                for each in text_:
+                    L.append(int(each))
+                for i in range(len(L)):
+                    if(L[i] == 60 and L[i+1]==170 and L[i+2] ==85  and not is_first):
+                        is_first = True
+                        is_60_first = i 
+                        match (L[i+3]):
+                            case 65:
+                                is_65_index = i
+                            case 66:
+                                is_68_index = 0
+                            case 67:
+                                is_68_index = 0
+                            case 68:
+                                is_68_index = i
+                    
+                # print('---------------------------start---------------------------------')
+                # print(L)
+                try:
+                    # writedata ='{}'.format(data_list.popleft())
+                    # Note.write(writedata.encode('hex'))
+                    csv_writer.writerow(text_)
+                except Exception as e:
+                    raise e
+                # 鍙戦�乻ocket娑堟伅
+                # sio.emit('msg', {'response': 'my response'})
+                if sio.connected:
+                    sio.emit("msg",{"time": nowtime_str,"data":L})
+                # socket_.send("msg",{"data":text_})
+                L.clear()
+                # print('-----------------------------end---------------------------------')
+
+    def test(self):
+        global is_exit
+        while True: 
+            sleep(10)
+            is_exit = False
+            sleep(10)
+            is_exit = True
+
+serialPort = 'COM4'  # 涓插彛
+baudRate = 115200  # 娉㈢壒鐜�
+socketurl_ = "http://192.168.0.225:5000"
+is_exit = False
+data_bytes = bytearray()
+data_list = deque()
+send_list = deque()
+L = []
+data_L = [[],[],[],[]]
+sio = socketio.Client(logger=True, engineio_logger=True)
+# sio = socketio.Client()
+start_timer = None
+csv_writer = None
+is_data_header = False
+
+@sio.event
+def connect():
+    print('connected to server')
+
+
+@sio.event
+def pong_from_server():
+    global start_timer
+    latency = time.time() - start_timer
+    print('latency is {0:.2f} ms'.format(latency * 1000))
+    sio.sleep(1)
+    if sio.connected:
+        print(' reconnected')
+
+
+@sio.on('command_msg')
+def command_msg(data):
+    global is_exit
+    if data['command'] == 'stop':
+        is_exit = True
+    if data['command'] == 'start':
+        is_exit = False
+
+if __name__ == '__main__':
+    # 鎵撳紑涓插彛
+    mSerial = SerialPort(serialPort, baudRate)
+
+    # 鏂囦欢鍐欏叆鎿嶄綔
+    # filename = input('璇疯緭鍏ユ枃浠跺悕锛氭瘮濡倀est.csv:')
+    filename = 'test.csv'
+    dt = datetime.now()
+    nowtime_str = dt.strftime('%y-%m-%d %I-%M-%S')  # 鏃堕棿
+    filename = nowtime_str+'_'+filename
+    out = open(filename, 'w')
+    csv_writer = csv.writer(out)
+    # txt鍐欏叆
+    # Note=open(nowtime_str+'_test.txt',mode='w')
+
+    # 寮�濮嬫暟鎹鍙栫嚎绋�
+    t1 = threading.Thread(target=mSerial.read_data)
+    t1.setDaemon(True)
+    t1.start()
+
+    # 杩炴帴socketio
+    sio.connect(socketurl_)
+
+    # 寮�濮嬪啓鏁版嵁
+    t3 =  threading.Thread(target=mSerial.write_data())
+    t3.setDaemon(True)
+    t3.start()
+
+    # sio.wait() #sio浜嬩欢澶勭悊
+    t2 =  threading.Thread(target=sio.wait())
+    t2.setDaemon(True)
+    t2.start()
+
+    # 杩炴帴socket
+    # remote_IP='192.168.0.225'
+    # remote_port=5000
+    # remote_addr=(remote_IP,remote_port)
+    # socket_=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
+    # socket_.connect(remote_addr)
\ No newline at end of file
diff --git a/read-serial-python/serial_reader_1.py b/read-serial-python/serial_reader_1.py
new file mode 100644
index 0000000..c7d4069
--- /dev/null
+++ b/read-serial-python/serial_reader_1.py
@@ -0,0 +1,239 @@
+#!/usr/bin/python
+# -*-coding: utf-8 -*-
+
+from asyncio import sleep
+from collections import deque
+from distutils.log import debug
+from multiprocessing.connection import wait
+from pickle import FALSE
+from tracemalloc import start
+import serial
+import threading
+from datetime import datetime
+import socketio
+import time
+import csv
+# import pysnooper
+
+
+class SerialPort:
+    def __init__(self, port, buand):
+        self.port = serial.Serial(port, buand)
+        self.port.close()
+        if not self.port.isOpen():
+            self.port.open()
+
+    def port_open(self):
+        if not self.port.isOpen():
+            self.port.open()
+
+    def port_close(self):
+        self.port.close()
+
+    def send_data(self):
+        self.port.write('')
+
+    # @pysnooper.snoop()
+    def read_data(self):
+        global is_exit
+        global data_bytes,data_list,csv_writer,int_list
+        while True: 
+            while not is_exit:
+                count = self.port.inWaiting()
+                if count > 0:
+                    rec_str = self.port.read(count)
+                    # data_list.append(rec_str)
+                    for byte in rec_str:
+                        # print('----------------------------',type(byte),byte)
+                        int_list.append(byte)
+                    # data_bytes = data_bytes+rec_str
+                    # print(str(datetime.now()),':','褰撳墠鏁版嵁鎺ユ敹鎬诲瓧鑺傛暟锛�'+str(len(data_bytes))+' 鏈鎺ユ敹瀛楄妭鏁帮細'+str(len(rec_str)))
+                    # wait(10000)
+                    # try:
+                    #     # writedata ='{}'.format(data_list.popleft())
+                    #     # Note.write(writedata.encode('hex'))
+                    #     csv_writer.writerow(rec_str)
+                    # except Exception as e:
+                    #     raise e
+    # @pysnooper.snoop()
+    def write_data(self): 
+        global data_L,index_,is_exit,send_list,int_list,sio,serialPort
+        start_array = False
+        while True:
+            while not is_exit:
+                if len(int_list)<1: 
+                    continue    
+                x = int_list.popleft()
+                if(not start_array and x==60):
+                    if len(int_list)<3:
+                        int_list.appendleft(x)
+                        break
+                    else:
+                        y = int_list.popleft()
+                        z = int_list.popleft()
+                        m = int_list.popleft()
+                        if (y == 170 and z == 85 and m==65):
+                            data_L=[[],[],[],[]]
+                            index_ =(abs(69-m)%4)  
+                            data_L[index_].append(x)
+                            data_L[index_].append(y)
+                            data_L[index_].append(z)
+                            data_L[index_].append(m)
+                            start_array = True
+                        else:
+                            data_L[index_].append(x)
+                            int_list.appendleft(m)
+                            int_list.appendleft(z)
+                            int_list.appendleft(y)
+                else:
+                    if(len(data_L[index_]) == 61):
+                        index_ = (index_+1)%4
+                        data_L[index_].append(x)
+                    else:
+                        data_L[index_].append(x)
+                if(len(data_L[3]) == 61):
+                    # send_list.append(data_L)
+                    if(data_L[0][3] != 65):
+                        start_array = False
+                        break
+                    try:
+                        for r in data_L:
+                            csv_writer.writerow(r)
+                    except Exception as e:
+                        raise e
+                    ret = [[],[],[],[]]
+                    i = 0
+                    while(i<4):
+                        if(len(data_L[i]) != 61):
+                            continue
+                        j = 5
+                        while(j<61):
+                            ret[i].append(data_L[i][j+1]*256 + data_L[i][j])
+                            j = j+2
+                        i = i+1  
+                    # print(parse_data(send_list.popleft()))
+                    if sio.connected:
+                        dt = datetime.now()
+                        nowtime_str = dt.strftime('%Y-%m-%d %H:%M:%S.%f')  # 鏃堕棿
+                        sio.emit("msg",{"time": nowtime_str,"serialport":serialPort,"data":ret})
+                    data_L = [[],[],[],[]]
+                    index_ = 0
+
+    def send_data(self): 
+        global send_list,sio
+        while True:
+            while not is_exit:
+                if sio.connected:
+                    dt = datetime.now()
+                    nowtime_str = dt.strftime('%Y-%m-%d %H:%M:%S.%f')  # 鏃堕棿
+                    sio.emit("msg",{"time": nowtime_str,"data":send_list.popleft()})
+                # try:
+                #     for r in data_L:
+                #         csv_writer.writerow(r)
+                # except Exception as e:
+                #     raise e
+
+    def test(self):
+        global is_exit
+        while True: 
+            sleep(10)
+            is_exit = False
+            sleep(10)
+            is_exit = True
+
+serialPort = '/dev/tty.usbserial-14130'  # 涓插彛
+baudRate = 115200  # 娉㈢壒鐜�
+socketurl_ = "http://127.0.0.1:3001"
+is_exit = False
+data_bytes = bytearray()
+data_list = deque()
+send_list = deque()
+int_list= deque()
+L = []
+base_length = 61
+data_L = [[],[],[],[]]
+index_ = 0 #绗� A/B/C/D 缁勬暟鎹�
+sio = socketio.Client(logger=True, engineio_logger=True)
+# sio = socketio.Client()
+start_timer = None
+csv_writer = None
+is_data_header = False
+
+@sio.event
+def connect():
+    print('connected to server')
+
+
+@sio.event
+def pong_from_server():
+    global start_timer
+    latency = time.time() - start_timer
+    print('latency is {0:.2f} ms'.format(latency * 1000))
+    sio.sleep(1)
+    if sio.connected:
+        print(' reconnected')
+
+
+@sio.on('command_msg')
+def command_msg(data):
+    global is_exit
+    if data['command'] == 'stop':
+        is_exit = True
+    if data['command'] == 'start':
+        is_exit = False
+
+def parse_data(data):
+    ret = [[],[],[],[]]
+    i = 0
+    while(i<4):
+        j = 5
+        arr = data[i]
+        print(arr)
+        while(j<61):
+            print('------------------',i,j,arr[j],'----------------------')
+            # ret[i].append(data[i][j+1]*256 + data[i][j])
+            j = j+2
+        i = i+1
+    return ret
+
+
+if __name__ == '__main__':
+    # serialPort = input("璇疯緭鍏ヤ覆鍙e瓧绗︿覆")
+    # 鎵撳紑涓插彛
+    mSerial = SerialPort(serialPort, baudRate)
+
+    # 鏂囦欢鍐欏叆鎿嶄綔
+    # filename = input('璇疯緭鍏ユ枃浠跺悕锛氭瘮濡倀est.csv:')
+    filename = 'test.csv'
+    dt = datetime.now()
+    nowtime_str = dt.strftime('%y-%m-%d %I-%M-%S')  # 鏃堕棿
+    filename = nowtime_str+'_'+filename
+    out = open(filename, 'w')
+    csv_writer = csv.writer(out)
+    # txt鍐欏叆
+    # Note=open(nowtime_str+'_test.txt',mode='w')
+
+    # 寮�濮嬫暟鎹鍙栫嚎绋�
+    t1 = threading.Thread(target=mSerial.read_data)
+    t1.setDaemon(True)
+    t1.start()
+
+    # 杩炴帴socketio
+    sio.connect(socketurl_)
+    # 寮�濮嬪啓鏁版嵁
+    t2 =  threading.Thread(target=mSerial.write_data())
+    t2.setDaemon(True)
+    t2.start()
+    
+    # sio.wait() #sio浜嬩欢澶勭悊
+    t4 =  threading.Thread(target=sio.wait())
+    print('------------------------------------------------------------------------')
+    t4.setDaemon(True)
+    t4.start()
+
+    # 杩炴帴socket
+    # remote_IP='192.168.0.225'
+    # remote_port=5000
+    # remote_addr=(remote_IP,remote_port)
+    # socket_=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
+    # socket_.connect(remote_addr)
\ No newline at end of file
diff --git a/read-serial-python/serial_reader_2.py b/read-serial-python/serial_reader_2.py
new file mode 100644
index 0000000..f4d9463
--- /dev/null
+++ b/read-serial-python/serial_reader_2.py
@@ -0,0 +1,239 @@
+#!/usr/bin/python
+# -*-coding: utf-8 -*-
+
+from asyncio import sleep
+from collections import deque
+from distutils.log import debug
+from multiprocessing.connection import wait
+from pickle import FALSE
+from tracemalloc import start
+import serial
+import threading
+from datetime import datetime
+import socketio
+import time
+import csv
+# import pysnooper
+
+
+class SerialPort:
+    def __init__(self, port, buand):
+        self.port = serial.Serial(port, buand)
+        self.port.close()
+        if not self.port.isOpen():
+            self.port.open()
+
+    def port_open(self):
+        if not self.port.isOpen():
+            self.port.open()
+
+    def port_close(self):
+        self.port.close()
+
+    def send_data(self):
+        self.port.write('')
+
+    # @pysnooper.snoop()
+    def read_data(self):
+        global is_exit
+        global data_bytes,data_list,csv_writer,int_list
+        while True: 
+            while not is_exit:
+                count = self.port.inWaiting()
+                if count > 0:
+                    rec_str = self.port.read(count)
+                    # data_list.append(rec_str)
+                    for byte in rec_str:
+                        # print('----------------------------',type(byte),byte)
+                        int_list.append(byte)
+                    # data_bytes = data_bytes+rec_str
+                    # print(str(datetime.now()),':','褰撳墠鏁版嵁鎺ユ敹鎬诲瓧鑺傛暟锛�'+str(len(data_bytes))+' 鏈鎺ユ敹瀛楄妭鏁帮細'+str(len(rec_str)))
+                    # wait(10000)
+                    # try:
+                    #     # writedata ='{}'.format(data_list.popleft())
+                    #     # Note.write(writedata.encode('hex'))
+                    #     csv_writer.writerow(rec_str)
+                    # except Exception as e:
+                    #     raise e
+    # @pysnooper.snoop()
+    def write_data(self): 
+        global data_L,index_,is_exit,send_list,int_list,sio,serialPort
+        start_array = False
+        while True:
+            while not is_exit:
+                if len(int_list)<1: 
+                    continue    
+                x = int_list.popleft()
+                if(not start_array and x==60):
+                    if len(int_list)<3:
+                        int_list.appendleft(x)
+                        break
+                    else:
+                        y = int_list.popleft()
+                        z = int_list.popleft()
+                        m = int_list.popleft()
+                        if (y == 170 and z == 85 and m==65):
+                            data_L=[[],[],[],[]]
+                            index_ =(abs(69-m)%4)  
+                            data_L[index_].append(x)
+                            data_L[index_].append(y)
+                            data_L[index_].append(z)
+                            data_L[index_].append(m)
+                            start_array = True
+                        else:
+                            data_L[index_].append(x)
+                            int_list.appendleft(m)
+                            int_list.appendleft(z)
+                            int_list.appendleft(y)
+                else:
+                    if(len(data_L[index_]) == 61):
+                        index_ = (index_+1)%4
+                        data_L[index_].append(x)
+                    else:
+                        data_L[index_].append(x)
+                if(len(data_L[3]) == 61):
+                    # send_list.append(data_L)
+                    if(data_L[0][3] != 65):
+                        start_array = False
+                        break
+                    try:
+                        for r in data_L:
+                            csv_writer.writerow(r)
+                    except Exception as e:
+                        raise e
+                    ret = [[],[],[],[]]
+                    i = 0
+                    while(i<4):
+                        if(len(data_L[i]) != 61):
+                            continue
+                        j = 5
+                        while(j<61):
+                            ret[i].append(data_L[i][j+1]*256 + data_L[i][j])
+                            j = j+2
+                        i = i+1  
+                    # print(parse_data(send_list.popleft()))
+                    if sio.connected:
+                        dt = datetime.now()
+                        nowtime_str = dt.strftime('%Y-%m-%d %H:%M:%S.%f')  # 鏃堕棿
+                        sio.emit("msg",{"time": nowtime_str,"serialport":serialPort,"data":ret})
+                    data_L = [[],[],[],[]]
+                    index_ = 0
+
+    def send_data(self): 
+        global send_list,sio
+        while True:
+            while not is_exit:
+                if sio.connected:
+                    dt = datetime.now()
+                    nowtime_str = dt.strftime('%Y-%m-%d %H:%M:%S.%f')  # 鏃堕棿
+                    sio.emit("msg",{"time": nowtime_str,"data":send_list.popleft()})
+                # try:
+                #     for r in data_L:
+                #         csv_writer.writerow(r)
+                # except Exception as e:
+                #     raise e
+
+    def test(self):
+        global is_exit
+        while True: 
+            sleep(10)
+            is_exit = False
+            sleep(10)
+            is_exit = True
+
+serialPort = '/dev/tty.usbserial-14110'  # 涓插彛
+baudRate = 115200  # 娉㈢壒鐜�
+socketurl_ = "http://127.0.0.1:3001"
+is_exit = False
+data_bytes = bytearray()
+data_list = deque()
+send_list = deque()
+int_list= deque()
+L = []
+base_length = 61
+data_L = [[],[],[],[]]
+index_ = 0 #绗� A/B/C/D 缁勬暟鎹�
+sio = socketio.Client(logger=True, engineio_logger=True)
+# sio = socketio.Client()
+start_timer = None
+csv_writer = None
+is_data_header = False
+
+@sio.event
+def connect():
+    print('connected to server')
+
+
+@sio.event
+def pong_from_server():
+    global start_timer
+    latency = time.time() - start_timer
+    print('latency is {0:.2f} ms'.format(latency * 1000))
+    sio.sleep(1)
+    if sio.connected:
+        print(' reconnected')
+
+
+@sio.on('command_msg')
+def command_msg(data):
+    global is_exit
+    if data['command'] == 'stop':
+        is_exit = True
+    if data['command'] == 'start':
+        is_exit = False
+
+def parse_data(data):
+    ret = [[],[],[],[]]
+    i = 0
+    while(i<4):
+        j = 5
+        arr = data[i]
+        print(arr)
+        while(j<61):
+            print('------------------',i,j,arr[j],'----------------------')
+            # ret[i].append(data[i][j+1]*256 + data[i][j])
+            j = j+2
+        i = i+1
+    return ret
+
+
+if __name__ == '__main__':
+    # serialPort = input("璇疯緭鍏ヤ覆鍙e瓧绗︿覆")
+    # 鎵撳紑涓插彛
+    mSerial = SerialPort(serialPort, baudRate)
+
+    # 鏂囦欢鍐欏叆鎿嶄綔
+    # filename = input('璇疯緭鍏ユ枃浠跺悕锛氭瘮濡倀est.csv:')
+    filename = 'test.csv'
+    dt = datetime.now()
+    nowtime_str = dt.strftime('%y-%m-%d %I-%M-%S')  # 鏃堕棿
+    filename = nowtime_str+'_'+filename
+    out = open(filename, 'w')
+    csv_writer = csv.writer(out)
+    # txt鍐欏叆
+    # Note=open(nowtime_str+'_test.txt',mode='w')
+
+    # 寮�濮嬫暟鎹鍙栫嚎绋�
+    t1 = threading.Thread(target=mSerial.read_data)
+    t1.setDaemon(True)
+    t1.start()
+
+    # 杩炴帴socketio
+    sio.connect(socketurl_)
+    # 寮�濮嬪啓鏁版嵁
+    t2 =  threading.Thread(target=mSerial.write_data())
+    t2.setDaemon(True)
+    t2.start()
+    
+    # sio.wait() #sio浜嬩欢澶勭悊
+    t4 =  threading.Thread(target=sio.wait())
+    print('------------------------------------------------------------------------')
+    t4.setDaemon(True)
+    t4.start()
+
+    # 杩炴帴socket
+    # remote_IP='192.168.0.225'
+    # remote_port=5000
+    # remote_addr=(remote_IP,remote_port)
+    # socket_=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
+    # socket_.connect(remote_addr)
\ No newline at end of file
diff --git a/read-serial-python/socketio_client.py b/read-serial-python/socketio_client.py
new file mode 100644
index 0000000..fdeffe1
--- /dev/null
+++ b/read-serial-python/socketio_client.py
@@ -0,0 +1,66 @@
+import socketio
+
+def create_sio():
+    sio = socketio.Client()
+    return sio
+
+def connect_(url,sio):
+    if not url:
+        sio.connect(url)
+        sio.on('connect', on_connect)
+        sio.on('chat_message', revc_message)
+        sio.on('disconnect', on_disconnect)
+        sio.on('reconnect', on_reconnect)
+        print('create sio')
+        return sio
+
+def sio(url,tparams):
+    if not tparams:
+        sio = socketio.Client()
+        sio.connect(url)
+        sio.on('connect', on_connect)
+        sio.on('chat_message', revc_message)
+        sio.on('disconnect', on_disconnect)
+        sio.on('reconnect', on_reconnect)
+        return sio
+
+
+def get_sessionid(userid, roomid):
+    pass
+
+def on_connect(*args):
+    # print(*args)
+    print('connect')
+
+def on_disconnect():
+    print('## disconnect ##')
+
+def on_reconnect():
+    print('reconnect')
+
+def send_msg(sendmessage, sio):
+    sio.emit('msg', b'{sendmessage}')
+    return 
+
+def revc_message(*args):  # 杩欎釜鍑芥暟寰堥噸瑕� 鏄痵ocketio鐩戝惉淇℃伅鑾峰彇鐨勫嚱鏁�, 杩欓噷闈ocketio浼氳嚜琛岃皟鐢ㄨ繖涓嚱鏁�
+    response_data_format = {}
+    response_data = eval(args[0])
+    print(response_data)
+
+def revc_message_mutil(*args):  # 杩欎釜鍑芥暟寰堥噸瑕� 鏄痵ocketio鐩戝惉淇℃伅鑾峰彇鐨勫嚱鏁�, 杩欓噷闈ocketio浼氳嚜琛岃皟鐢ㄨ繖涓嚱鏁�
+    response_data_format = {}
+    response_data = eval(args[0])
+    print(response_data)
+
+def create_params(userid, roomid):  # 杩欎釜鏂规硶绫讳技requests搴撶殑灏佽鏂规硶 鐪嬪簳灞傝矊浼间笌requests鐨剈rllib3鏂规硶涓�鏍�
+    vsessionid, tsessionid = get_sessionid(userid, roomid)
+    vparams = {
+        'sessionid': vsessionid,
+    }
+    tparams = {
+        'sessionid': tsessionid,
+    }
+    return vparams, tparams
+
+def clear_data():
+    print('sessionid')
\ No newline at end of file
diff --git a/read-serial-python/test.py b/read-serial-python/test.py
new file mode 100644
index 0000000..0088bbf
--- /dev/null
+++ b/read-serial-python/test.py
@@ -0,0 +1,65 @@
+L = []
+a = b'\x00\xef\xa2\xa0\xb3\x8b\x9d\x1e\xf8\x98\x19\x39\xd9\x9d\xfdthe first line\n\r\a\b\t\\\f\'\"\v\b\n\000'
+print(a)
+for each in a:
+    L.append(int(each))
+with open('data.txt','w') as p:
+    p.write(str(L))
+print(L)
+
+ 
+with open('data.txt','r') as p:
+    line = p.readline()
+print(b''.join([bytes([int(i)]) for i in line[1:-1].split(',')]))
+
+
+def readbytetxt2(filename):
+    dic = {
+    '0': 0,    '1': 1,    '2': 2,
+    '3': 3,    '4': 4,    '5': 5,
+    '6': 6,    '7': 7,    '8': 8,
+    '9': 9,    'a': 10,   'b': 11,
+    'c': 12,   'd': 13,   'e': 14,
+    'f': 15,
+    }
+    dic2 = {
+    'a': '\a',     'b': '\b', 
+    'f': '\f',     'n': '\n', 
+    'r': '\r',     'v': '\v', 
+    '\'': '\'',    '\"': '', 
+    '\\': '\\', 
+    }
+    with open(filename,'r') as p:
+        line = p.readline()
+        while line:
+            if line[-1] == '\n':
+                line = line[:-1]
+            i = 2
+            L = b''
+            while i+1 < len(line):
+                if line[i:i+2] == '\\x' and (line[i+2] in dic.keys()) and (line[i+3] in dic.keys()):
+                    L += bytes([dic[line[i+2]]*16+dic[line[i+3]]])
+                    i += 4
+                elif line[i] == '\\' and line[i+1] in dic2.keys():
+                    L += bytes(dic2[line[i+1]],'utf8')
+                    i += 2
+                elif line[i:i+4] == '\\000':
+                    L += bytes('\000','utf8')
+                    i += 2
+                else:
+                    L += bytes(line[i],'utf8')
+                    i += 1
+            yield L
+            line = p.readline()
+ 
+a = b'\x00\xef\xa2\xa0\xb3\x8b\x9d\x1e\xf8\x98\x19\x39\xd9\x9d\xfdthe first line\n\r\a\b\t\\\f\'\"\v\b\n\000'
+b = b'\xa0\xdf\xa2\xa0\xb3\x8b\x9d\x1e\xf8\x98\x19\x39\xd9\x9d\xfdthe second line\nn'
+c = b'\xe0\xaf\xa2\xa0\xb3\x8b\x9d\x1e\xf8\x98\x19\x39\xd9\x9d\xfdthe third line\\'
+with open('data.txt','w') as p:
+    p.write(str(a)+'\n')
+    p.write(str(b)+'\n')
+    p.write(str(c))
+ 
+line = readbytetxt2('data.txt')
+ 
+print([a for a in line])    
\ No newline at end of file
diff --git a/read-serial-python/websocket.html b/read-serial-python/websocket.html
new file mode 100644
index 0000000..c159756
--- /dev/null
+++ b/read-serial-python/websocket.html
@@ -0,0 +1,96 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <title>WebSocket</title>
+
+    <style>
+        html, body {
+            font: normal 1em arial, helvetica;
+        }
+
+        #log {
+            width: 400px;
+            height: 200px;
+            border: 1px solid #000000;
+            overflow: auto;
+        }
+
+        #msg {
+            width: 330px;
+        }
+    </style>
+
+    <script>
+        var socket;
+
+        function init() {
+            var host = "ws://127.0.0.1:5000/";
+            try {
+                socket = new WebSocket(host);
+                socket.onopen = function (msg) {
+                    log("Begin Connection!");
+                };
+                socket.onmessage = function (msg) {
+                    log(msg.data);
+                };
+                socket.onclose = function (msg) {
+                    log("Lose Connection!");
+                };
+            }
+            catch (ex) {
+                log(ex);
+            }
+            $("msg").focus();
+        }
+
+        function send() {
+            var txt, msg;
+            txt = $("msg");
+            msg = txt.value;
+            if (!msg) {
+                alert("Message can not be empty");
+                return;
+            }
+            txt.value = "";
+            txt.focus();
+            try {
+                socket.send(msg);
+            } catch (ex) {
+                log(ex);
+            }
+        }
+
+        window.onbeforeunload = function () {
+            try {
+                socket.send('quit');
+                socket.close();
+                socket = null;
+            }
+            catch (ex) {
+                log(ex);
+            }
+        };
+
+
+        function $(id) {
+            return document.getElementById(id);
+        }
+        function log(msg) {
+            $("log").innerHTML += "<br>" + msg;
+        }
+        function onkey(event) {
+            if (event.keyCode == 13) {
+                send();
+            }
+        }
+    </script>
+
+</head>
+<body onload="init()">
+<h3>WebSocket</h3>
+<br>
+<div id="log"></div>
+<input id="msg" type="textbox" onkeypress="onkey(event)"/>
+<button onclick="send()">鍙戦��</button>
+</body>
+</html>
diff --git a/read-serial-python/websockets.py b/read-serial-python/websockets.py
new file mode 100644
index 0000000..81c542e
--- /dev/null
+++ b/read-serial-python/websockets.py
@@ -0,0 +1,55 @@
+import threading
+from time import sleep
+import eventlet
+import socketio
+
+
+def create_serve():
+    sio = socketio.Server()
+    app = socketio.WSGIApp(sio, static_files={
+        '/': {'content_type': 'text/html', 'filename': 'index.html'}
+    })
+
+    @sio.event
+    def connect(sid, environ):
+        print('connect ', sid)
+        sio.emit('serve', {'response': 'connert success'})
+        # delay_cmd = Delay_cmd(sio)
+        # t3 = threading.Thread(target=delay_cmd.send(delay_cmd))
+        # t3.setDaemon(True)
+        # t3.start()
+
+    @sio.on('msg')
+    def on_message(sid, data):
+        print('serve received a message! on_message',data)
+        # sio.emit('command_msg', {'command': 'stop', "params":"nothing"})
+
+    @sio.on('client')
+    def another_event(sid, data):
+        print('serve received a message!', data)
+
+    # @sio.event
+    # def my_event(sid, data):
+    #     print('message ', data)
+    #     sio.emit('serve', {'response': 'connert success'})
+
+    @sio.event
+    def disconnect(sid):
+        print('disconnect ', sid)
+
+    if __name__ == '__main__':
+        eventlet.wsgi.server(eventlet.listen(('', 5000)), app)
+
+
+class Delay_cmd():
+    def __init__(self, sio,):
+        self.sio = sio
+    
+    def send(self):
+        while True:
+            sleep(10)
+            self.sio.emit('command_msg', {'command': 'stop', "params":"nothing"})
+            sleep(10)
+            self.sio.emit('command_msg', {'command': 'start', "params":"nothing"})
+
+create_serve()
\ No newline at end of file

--
Gitblit v1.9.1