wquart 1.0.0.5__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ Metadata-Version: 2.1
2
+ Name: wquart
3
+ Version: 1.0.0.5
4
+ Summary: wuqi chip7033 uart message resolve
5
+ Home-page: http://www.wuqi-tech.com/
6
+ Author: wuqi-wanjian
7
+ Author-email: wan.jian@wuqi-tech.com
8
+ Classifier: Intended Audience :: Developers
9
+ Classifier: Operating System :: OS Independent
10
+ Classifier: Natural Language :: Chinese (Simplified)
11
+ Classifier: Programming Language :: Python :: 3.6
12
+ Classifier: Programming Language :: Python :: 3.7
13
+ Classifier: Programming Language :: Python :: 3.8
14
+ Classifier: Programming Language :: Python :: 3.9
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: Topic :: Utilities
20
+
21
+ wuqi-chip7033 uart message resolve
@@ -0,0 +1,17 @@
1
+ # 1.wquart 使用卸载说明
2
+ 安装和更新(会先卸载再安装)
3
+ ``` python
4
+ pip install wquart-9.9.9.tar.gz
5
+ ```
6
+ 会安装在python安装目录的Lib\site-packages下,和从pypi下载的一样使用。
7
+
8
+ 卸载 -y 不询问
9
+ ``` python
10
+ pip uninstall wquart -y
11
+ ```
12
+ # 2.demo 运行
13
+ ``` shell
14
+ python demo.py COM92 2000000 tws-basic-7035AX-B-1.3.3.1.wpk
15
+
16
+ ```
17
+
@@ -0,0 +1,10 @@
1
+ [sdist]
2
+ dist-dir = dist
3
+
4
+ [metadata]
5
+ version = 1.0.0.5
6
+
7
+ [egg_info]
8
+ tag_build =
9
+ tag_date = 0
10
+
@@ -0,0 +1,28 @@
1
+ #!/usr/bin/python
2
+ # -*- coding: utf-8 -*-
3
+ from setuptools import setup#,find_packages
4
+ setup(name = 'wquart', # 包名
5
+ description = 'wuqi chip7033 uart message resolve',
6
+ long_description = 'wuqi-chip7033 uart message resolve',
7
+ author = 'wuqi-wanjian',
8
+ author_email = 'wan.jian@wuqi-tech.com',
9
+ url = 'http://www.wuqi-tech.com/',
10
+ license = '',
11
+ install_requires = ["pyserial"],
12
+ classifiers = [
13
+ 'Intended Audience :: Developers',
14
+ 'Operating System :: OS Independent',
15
+ 'Natural Language :: Chinese (Simplified)',
16
+ 'Programming Language :: Python :: 3.6',
17
+ 'Programming Language :: Python :: 3.7',
18
+ 'Programming Language :: Python :: 3.8',
19
+ 'Programming Language :: Python :: 3.9',
20
+ 'Programming Language :: Python :: 3.10',
21
+ 'Programming Language :: Python :: 3.11',
22
+ 'Programming Language :: Python :: 3.12',
23
+ 'Programming Language :: Python :: 3.13',
24
+ 'Topic :: Utilities'
25
+ ],
26
+ package_dir = {'wquart':'wquart'},
27
+ packages= ['wquart'],
28
+ )
@@ -0,0 +1,8 @@
1
+ from __future__ import absolute_import
2
+ from .message import *
3
+ from .decode import *
4
+ from .log import *
5
+ from .utility import *
6
+ from .btsnoop import *
7
+ __version__ = '1.0.0'
8
+ __license__ = ''
@@ -0,0 +1,57 @@
1
+ from io import TextIOWrapper
2
+ import struct
3
+ import time
4
+ import datetime
5
+ class SnoopHeader():
6
+ def __init__(self) -> None:
7
+ self.version:int = 1
8
+ self.datalink:int = 0x03ea
9
+ def getbytes(self)->bytes:
10
+ return struct.pack('>2I',self.version,self.datalink)
11
+ class SnoopRecord():
12
+ def __init__(self,data:bytes) -> None:
13
+ self.cumdrops:int=0
14
+ self.data=data
15
+ self.timestamp:datetime = datetime.datetime.now()
16
+ def getincllen(self)->int:
17
+ if self.data:
18
+ return len(self.data)-1
19
+ return 0
20
+ def getoriglen(self)->int:
21
+ if self.data:
22
+ return len(self.data)-1
23
+ return 0
24
+ def getflags(self)->int:
25
+ f0= 1 if self.data[0]==0 else 0
26
+ f1= 1 if self.data[1]==1 or self.data[1]==4 else 0
27
+ return f1<<1 | f0
28
+ def gettimestamp(self)->int:
29
+ stamp= time.time() + 8*3600 # 东八区 得加回8小时
30
+ return round(stamp *1000*1000) + 0x00dcddb30f2f8000
31
+ def getdata(self):
32
+ return self.data[1:]
33
+ def getbytes(self)->bytes:
34
+ return struct.pack('>4Iq',self.getoriglen(),self.getincllen(),self.getflags(),self.cumdrops,self.gettimestamp()) +self.getdata()
35
+ class BTSnoop():
36
+ def __init__(self) -> None:
37
+ self.header= SnoopHeader()
38
+ self.writer:TextIOWrapper=None
39
+ def createHeader(self,file:str = 'snoop.cfa'):
40
+ if not self.writer:
41
+ self.writer= open(file,'wb+')
42
+ btsnoop_magic = b'btsnoop\0'
43
+ self.writer.write(btsnoop_magic)
44
+ hb= self.header.getbytes()
45
+ self.writer.write(hb)
46
+ self.writer.flush()
47
+ def addRecord(self,data:bytes):
48
+ if not data or len(data)<2:
49
+ return
50
+ if self.writer:
51
+ pkg= SnoopRecord(data)
52
+ cfa= pkg.getbytes()
53
+ self.writer.write(cfa)
54
+ def close(self):
55
+ if self.writer and not self.writer.closed:
56
+ self.writer.close()
57
+
@@ -0,0 +1,55 @@
1
+ #!/usr/bin/python
2
+ # -*- coding: utf-8 -*-
3
+
4
+ import binascii
5
+ binascii.crc8 = lambda data: Crc.crc8_calc(data)
6
+
7
+
8
+ class Crc:
9
+
10
+ _crc8_table = [
11
+ 0x00, 0x5e, 0xbc, 0xe2, 0x61, 0x3f, 0xdd, 0x83,
12
+ 0xc2, 0x9c, 0x7e, 0x20, 0xa3, 0xfd, 0x1f, 0x41,
13
+ 0x9d, 0xc3, 0x21, 0x7f, 0xfc, 0xa2, 0x40, 0x1e,
14
+ 0x5f, 0x01, 0xe3, 0xbd, 0x3e, 0x60, 0x82, 0xdc,
15
+ 0x23, 0x7d, 0x9f, 0xc1, 0x42, 0x1c, 0xfe, 0xa0,
16
+ 0xe1, 0xbf, 0x5d, 0x03, 0x80, 0xde, 0x3c, 0x62,
17
+ 0xbe, 0xe0, 0x02, 0x5c, 0xdf, 0x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4, 0xaa, 0x48, 0x16,
39
+ 0xe9, 0xb7, 0x55, 0x0b, 0x88, 0xd6, 0x34, 0x6a,
40
+ 0x2b, 0x75, 0x97, 0xc9, 0x4a, 0x14, 0xf6, 0xa8,
41
+ 0x74, 0x2a, 0xc8, 0x96, 0x15, 0x4b, 0xa9, 0xf7,
42
+ 0xb6, 0xe8, 0x0a, 0x54, 0xd7, 0x89, 0x6b, 0x35,
43
+ ]
44
+
45
+ @staticmethod
46
+ def _crc8_update(init_vect, buf):
47
+ crc = init_vect
48
+ for i in range(len(buf)):
49
+ crc = Crc._crc8_table[(crc ^ buf[i]) & 0xff]
50
+ return crc
51
+
52
+ @staticmethod
53
+ def crc8_calc(buf):
54
+ crc = Crc._crc8_update(0xff, buf)
55
+ return crc ^ 0xff