Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
D
deployTool
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
aohui.li
deployTool
Commits
310754db
Commit
310754db
authored
Feb 27, 2025
by
aohui.li
😋
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加pyTool.py 脚本
parent
3e52f1cc
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
155 additions
and
132 deletions
+155
-132
README.md
README.md
+24
-129
read_high_data.png
attachment/read_high_data.png
+0
-0
read_version.png
attachment/read_version.png
+0
-0
pyTool.py
pyTool.py
+131
-3
No files found.
README.md
View file @
310754db
# deployTool
## Readme 说明
### 读取传感器ID
# 测试
```
bash
sudo
python3 sensor_update.py
read
1
# 读取通道1上的传感器ID
```
### 中断信号读取
> 可用于排查过零信号
```
bash
sudo
make isr_app
#编译
sudo
./isr_app 467
#读取GPIO 467上的中断
## 调试说明
### pyTool.py 调试工具说明
> pyTool.py 需要在source_code目录下运行。
#### 1. 使用该脚本获取高速数据
```
shell
# 示例
# 读取通道1上的传感器高速数据
sudo
python3 pyTool.py high 1
```

## 物理连接

1.
使用全速TypeC连接到电脑;
2.
以太网连接路由器;
## 底板基础镜像烧录
### 0. RKDevTool 工具


检查如上所示的镜像列表;

如果下面一行没有显示“发现一个ADB设备”,请更换一个全速Type-C或者重新插拔数据线,重新上电重启网关。
> 结果判断:如果有高速数据,就会打印出来,如图所示。

右侧有切换成功的Log信息后,点击“执行”,开始烧录。

等待右侧Log信息提示,下载完成即可,随后拔掉数据线。
## 软件镜像部署
### 1. 预备
```
bash
sudo
bash ./prepare.sh
```
### 2. 开始部署
```
bash
sudo
make
#### 2. 使用该脚本获取传感器版本
```
shell
# 示例
# 读取通道1上的传感器版本
sudo
python3 pyTool.py version 1
```
整体执行流程 :-> 安装 debian 应用 ->安装 Pip whl 包 -> 安装 iic 驱动,点亮所有LED -> 编译中断测试程序 -> 克隆 source code -> 命令行终端选择程序并下载 -> 配置程序 -> 结束
选择程序,会出现以下界面:

通过方向键,跳转到607-> wtdiagnose:


选中wtdiagnose.zip进行下载
> 结果判断:如果有传感器版本打印出来,说明该通道的RS485是通的。

通过方向键右键,选择Cancel 退出,等待自动配置即可。
完成后,检查LED的灯是否全部亮起。

### 3. 运行测试
#### 3.1 电流测试

```
bash
# 测试电流,MQTT 订阅主题,如WT/+/24010545W/#
sudo
make wtcurrent_test
# 检查有电流值a为19.576,说明通道正常,通过测试
# Ctrl + C 退出
```


#### 3.2 远程测试
-
开远程
发送:
`WT/WTG6XXF/24010543/RemoteConnect`
内容:
`{"cmd":3}`
返回:

-
远程
-
输入
`cat /proc/serialnum `
, 确定远程的是正在测试的SN

-
关闭远程
发送:
`WT/WTG6XXF/24010543/RemoteConnect`
内容:
`{"cmd":4}`
返回:

#### 3.3 RS485 检查
-
在485端口上接一个485传感器

```
bash
sudo
make rs485_app
# 显示成功,表示RS485功能正常
# Ctrl + C 退出
```
### 中断信号读取
> 用于排查过零信号
#### 3.4 中断测试
```
bash
sudo
./isr 467
# ---- 通道 DIAB --5
sudo
./isr 468
# ---- 通道 DIAB --6
sudo
./isr 463
# ---- 通道 AIN4 --1
sudo
./isr 464
# ---- 通道 AIN4 --2
sudo
./isr 465
# ---- 通道 AIN4 --3
# Ctrl + C 退出
sudo
python3 6_isr.py
# 结果判断:如果有打印信息,表示中断信号被触发。
```

#### 3.5 振动传感器数据测试
可以看到CheckIn信息,检查上发的version是否是自己要部署的。


检查上发的Data
## 4. 结束测试正式发布
```
bash
sudo
make release_app
#硬件重启后,请关注数据和远程是否正常。
```
重启之后,通过MQTT 在
**正式平台**
,订阅数据和调试远程。
# 部署
[
6系网关部署和测试教程
](
https://witexpert.yuque.com/ckn81t/ctfgds/ardadevhsht7?singleDoc#
)
\ No newline at end of file
attachment/read_high_data.png
0 → 100644
View file @
310754db
77.1 KB
attachment/read_version.png
0 → 100644
View file @
310754db
12.8 KB
sensor_update
.py
→
pyTool
.py
View file @
310754db
...
...
@@ -6,6 +6,8 @@ from module.wtserial import wtserial
from
i2c_io.i2c_gpio
import
i2c_gpio
from
modbus.wtmodbus
import
wtmodbus
from
module.wtserial
import
wtserial
from
wtusb.wtusb
import
wtusb
from
module.wtserial
import
wtserial
_operate
=
sys
.
argv
[
1
]
...
...
@@ -35,6 +37,124 @@ wakeup_gpio_num = sensorDict[updataAddr]["wakeup"] # 495~506
updating_img
=
'WTS4V3C_v2.62.bin'
update_data
=
None
print
(
updating_com
)
def
decode_segments_to_floats
(
self
,
segments
):
x_data
=
[]
y_data
=
[]
z_data
=
[]
for
segment_id
in
sorted
(
segments
.
keys
()):
segment
=
segments
[
segment_id
]
for
i
in
range
(
0
,
360
,
4
):
value
=
struct
.
unpack
(
'f'
,
segment
[
i
:
i
+
4
])[
0
]
if
i
<
120
:
x_data
.
append
(
round
(
value
,
2
))
elif
i
<
240
:
y_data
.
append
(
round
(
value
,
2
))
else
:
z_data
.
append
(
round
(
value
,
2
))
return
x_data
,
y_data
,
z_data
def
extract_valid_segments
(
self
,
serdata
):
segments
=
{}
segment_id
=
1
index
=
0
#(30 * 12 + 4 + 2 + 1) // Head(1)+ Length(2) + Data(360) + Temperture(2) + CheckSum(1) +Tail(1)
#(=367)
COMMUNICATION_HEAD
=
0x55
SEGMENT_LENGTH
=
365
CONNUNICATION_END
=
0xAA
while
index
<
len
(
serdata
):
start_index
=
serdata
.
find
(
COMMUNICATION_HEAD
,
index
)
# Break if no more start bytes are found
if
start_index
==
-
1
:
break
# else:
print
(
f
"find 0x55 at index[{start_index}]"
)
# Check for valid segment
if
start_index
+
SEGMENT_LENGTH
+
1
<
len
(
serdata
)
and
serdata
[
start_index
+
SEGMENT_LENGTH
+
1
]
==
CONNUNICATION_END
:
segment
=
serdata
[
start_index
+
3
:
start_index
+
SEGMENT_LENGTH
]
# Skip Head and Length
checkSum
=
self
.
calculate_checksum
(
segment
)
if
checkSum
==
serdata
[
start_index
+
SEGMENT_LENGTH
]:
segments
[
segment_id
]
=
segment
segment_id
+=
1
index
=
start_index
+
SEGMENT_LENGTH
+
3
# Move to byte after the current end byte
TempertureReal
=
serdata
[
start_index
+
SEGMENT_LENGTH
-
2
]
TempertureDecimal
=
serdata
[
start_index
+
SEGMENT_LENGTH
-
1
]
# print(f"Temperture Real:{TempertureReal}, Decimal:{TempertureDecimal}")
if
TempertureReal
==
0XFF
and
TempertureDecimal
==
0XFF
:
pass
else
:
self
.
_sensor
.
setSensorTemperture
(
float
(
TempertureReal
+
TempertureDecimal
/
100.0
))
t
=
self
.
_sensor
.
getSensorTemperture
()
# print(f"Temperture:{t}")
else
:
print
(
"Break."
)
break
#index = start_index + 1
else
:
index
=
start_index
+
1
return
segments
###
def
readHighSpeed
(
updating_com
):
try
:
iic_gpio
=
i2c_gpio
()
iic_gpio
.
write_gpio
(
str
(
wakeup_gpio_num
),
"1"
)
time
.
sleep
(
2
)
ser
=
wtserial
(
str
(
updating_com
),
115200
)
smodbus
=
wtmodbus
(
None
,
None
,
str
(
wakeup_gpio_num
),
1
,
ser
,
iic_gpio
.
write_gpio
)
smodbus
.
setMBHighSpeed
()
time
.
sleep
(
1
)
iic_gpio
.
write_gpio
(
str
(
wakeup_gpio_num
),
"0"
)
time
.
sleep
(
10
)
print
(
updating_com
)
ser
.
serial_stop
()
time
.
sleep
(
5
)
del
ser
ser
=
wtusb
(
updating_com
,
4000000
,
123456
,
None
,
None
,
None
,
iic_gpio
.
write_gpio
)
print
(
1
)
time
.
sleep
(
1
)
iic_gpio
.
write_gpio
(
str
(
wakeup_gpio_num
),
"0"
)
except
:
print
(
"ser wtusb init fail!"
)
exit
(
1
)
read_num
=
(
int
(
360
/
30
+
6
))
*
368
print
(
"读取数据中..."
)
data
=
ser
.
get_wave
(
read_num
,
10
)
print
(
"读取操作结束!"
)
ser
.
serial_stop
()
del
ser
if
data
is
None
:
print
(
"没有读到数据"
)
else
:
print
(
"读取到数据"
)
print
(
data
)
valid_segments
=
extract_valid_segments
(
data
)
realData
[
'x'
],
realData
[
'y'
],
realData
[
'z'
]
=
decode_segments_to_floats
(
valid_segments
)
print
(
f
"real Data:{realData['x']}"
)
def
update
(
self
,
bin_data
,
per_package_size
=
120
,
version
=
"2.99"
):
if
self
.
_wakeup_callback
is
not
None
:
self
.
_wakeup_callback
(
str
(
self
.
_wakeup
),
'1'
)
...
...
@@ -140,19 +260,27 @@ def main():
iic_gpio
.
write_gpio
(
str
(
wakeup_gpio_num
),
"0"
)
print
(
"Update Finished."
)
elif
_operate
==
'
read
'
:
elif
_operate
==
'
version
'
:
print
(
f
"Read addr {updataAddr} <START>"
)
iic_gpio
=
i2c_gpio
()
iic_gpio
.
write_gpio
(
str
(
wakeup_gpio_num
),
"1"
)
ser
=
wtserial
(
str
(
updating_com
),
115200
)
smodbus
=
wtmodbus
(
None
,
None
,
None
,
1
,
ser
,
iic_gpio
.
write_gpio
)
smodbus
=
wtmodbus
(
None
,
None
,
str
(
wakeup_gpio_num
)
,
1
,
ser
,
iic_gpio
.
write_gpio
)
time
.
sleep
(
1
)
sensor_info
=
smodbus
.
get_sensor_base_parameter
()
print
(
sensor_info
)
print
(
"Start Update."
)
iic_gpio
.
write_gpio
(
str
(
wakeup_gpio_num
),
"0"
)
print
(
f
"Read addr {updataAddr} <END>"
)
elif
_operate
==
'high'
:
print
(
f
"Read addr High Speed Data {updataAddr} <START>"
)
readHighSpeed
(
updating_com
)
print
(
f
"Read addr High Speed Data {updataAddr} <END>"
)
else
:
print
(
"USAGE: sudo python3 sensor.py update 1 # 升级通1上的传感器"
)
print
(
"USAGE: sudo python3 sensor.py high 1 # 读取通1上的传感器高速数据"
)
print
(
"USAGE: sudo python3 sensor.py version 1 # 读取通1上的传感器版本"
)
if
__name__
==
"__main__"
:
main
()
exit
(
0
)
\ No newline at end of file
exit
(
0
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment