Compare commits

...

119 Commits

Author SHA1 Message Date
leimingsheng
88f871c880 feat(master) update to 1.10 base dev 2
1.[新增功能]解耦脚本参数配置功能, 脚本配置全部放到project.config中
2.[新增功能]增加对pmbus set命令的支持
3.[新增功能]增加setup.sh, 用于一键部署脚本
4.[功能优化]代码结构目录重新归档
2026-04-17 17:09:43 +08:00
leimingsheng
efb7017a53 feat(master : nicsensor) Release Version 1.10 2026-03-12 15:54:06 +08:00
leimingsheng
938adf43be update code 2026-03-12 09:19:37 +08:00
leimingsheng
5095763b6b update code 2026-03-11 14:28:21 +08:00
leimingsheng
3a15c90acf feat(master : nicsensor) 参数配置支持配置fru offset 2026-03-11 14:09:45 +08:00
leimingsheng
8777d0a279 update reademe 2026-03-11 14:00:26 +08:00
leimingsheng
67b07fcf8b feat(master : nicsensor) update to 1.9.8
1.支持get/set配置默认i2cbus
2026-03-11 11:17:37 +08:00
leimingsheng
3a66d3557b Merge branch 'master' of 121.36.59.21:Marcin/nicsensor 2026-03-10 18:35:44 +08:00
leimingsheng
e5a4a4e28d 移除 nicsensor_s.sh 2026-03-10 18:34:39 +08:00
leimingsheng
27ae0a4dc4 feat(master : nicsensor) update to 1.9.7 【重要】
1.原生支持 stress 压力测试
2.新增stress_test插件
2026-03-10 18:22:38 +08:00
leimingsheng
c7730923a1 fix(master : nicsensor) 修复 1.9.4 引入的执行时语法错误 2026-03-10 15:57:18 +08:00
leimingsheng
04c0342367 feat(master : nicsensor.sh) update to 1.9.6
1.增加安全性检查内容
2.pmbus_cmd_list 引入版本号
2026-03-10 15:27:18 +08:00
leimingsheng
f526fa8190 fix(master : nicsensor) update to 1.9.5
修正拼写错误
2026-03-09 09:39:19 +08:00
8119bf1b69 更新 readme.md 2026-02-10 14:42:30 +08:00
leimingsheng
37d328c7f3 refactor(master : nicsensor) update to 1.9.4
优化代码:重构将十六进制转化为十进制的代码,便于阅读代码
2026-02-10 14:35:11 +08:00
leimingsheng
7bb15f6de8 feat(master : nicsensor) update to 1.9.3
新增支持温度传感器 lm95241
2026-02-10 13:58:43 +08:00
leimingsheng
952f281365 optimize(master : nicsensor.sh) update to 1.9.2
优化 help 显示功能
2026-01-15 14:10:19 +08:00
leimingsheng
559263cc2d feat(master : nicsensor) update to 1.9.1 【重要】
1.新增适配传感器ina226
2.优化help功能
3.优化代码可读性
2026-01-09 16:47:11 +08:00
leimingsheng
d91a9f87ae feat(master : nicsensor) Release Version 1.9 2026-01-05 14:36:18 +08:00
leimingsheng
cdb7b9ef5c fix(master : nicsensor) update to 1.8.9
修正pmbus的显示功能
2026-01-04 16:59:30 +08:00
leimingsheng
71a40e88f6 feat(master : nicsensor) update to 1.8.8
get/set操作支持配置fru size
2025-12-26 16:28:52 +08:00
leimingsheng
fe33854677 fix(master : nicsensor) update to 1.8.7
将get/set功能中的detect选项变更为 n_detect , 便于理解
2025-12-26 16:21:16 +08:00
leimingsheng
988d217008 refactor(master : nicsensor) update to 1.8.6
重构pmbus功能
2025-12-26 13:56:08 +08:00
leimingsheng
d584304e10 perf(master : nicsensor) update to 1.8.5
优化部分pmbus功能相关的提示性信息
2025-12-26 09:42:17 +08:00
leimingsheng
6423cc73a3 doc(master : nicsensor) 更新扩展脚本说明.md 2025-12-25 17:35:24 +08:00
leimingsheng
832daa21ab feat(master : nicsensor) update to 1.8.4 [重要]
新增pmbus功能,由于pmbus代码量极大且后期可能需要人为维护,将pmbus作为插件功能加入到nicsensor中.
后期维护 pmbus_cmd_list.sh 即可

遗留事项:pmbus set功能未实现,当前仅支持读取
2025-12-25 17:34:51 +08:00
leimingsheng
523f597353 feat(plugin : nicsensor)同步自动获取服务器类型得功能 2025-12-10 16:05:58 +08:00
leimingsheng
72c0ce073e fix(plugin : platform_5280m7) 修复detect时不显示插槽信息得问题 2025-12-10 16:05:27 +08:00
leimingsheng
625118199f fix(master : nicsensor) fix spell error , update to 1.8.3 2025-12-05 14:01:49 +08:00
2bc1bf05c6 更新 readme.md 2025-12-04 09:41:52 +08:00
leimingsheng
0bb410c72f feat(master : nicsensor) update to version 1.8.2
1.增加配置项fru_size,默认读取大小256字节
2025-12-04 09:21:49 +08:00
leimingsheng
a316ea37ca feat(master : nicsensor) update to version 1.8.1
1.fru写操作支持写入大于256字节的数据
2025-11-24 14:15:25 +08:00
leimingsheng
580de7fa6f feat(master : nicsensor) Release Version 1.8 2025-08-18 14:21:01 +08:00
leimingsheng
b5a0cac6e2 feat(master : nicsensor) 新增脚本nicsensor_s.sh 2025-08-18 14:20:10 +08:00
leimingsheng
2f6078586d feat(master : nicsensor) version change to intest 1.7.7 2025-07-25 15:37:26 +08:00
leimingsheng
ee381afcd6 perf(master : nicsensor) 修正部分变量名称,增强脚本可读性 2025-07-25 15:36:53 +08:00
leimingsheng
9642f77447 doc(master : readme) 更新readme以支持配置关键变量功能 2025-07-25 15:33:58 +08:00
leimingsheng
7b6ae2a932 feat(master : nicsensor) 支持通过命令配置关键变量 2025-07-25 15:23:55 +08:00
leimingsheng
e2ccb19dd3 feat(master : nicsensor) version change to intest 1.7.6 2025-07-07 16:48:16 +08:00
leimingsheng
fbe3fcbe07 style(master : nicsensor) 2025-07-07 16:47:35 +08:00
leimingsheng
85fccf4704 refactor(master : nicsensor) 整合fmt_print功能为一个函数 2025-07-07 16:32:08 +08:00
leimingsheng
86e92f0302 style(master : nicsensor) 精简脚本注释及格式 2025-07-07 16:25:26 +08:00
leimingsheng
3710481735 fix(master : nicsensor)优化try_get_server_type函数 2025-07-04 15:03:31 +08:00
leimingsheng
a49c474ee5 feat(master : nicsensor)version change to intest 1.7.5 2025-07-04 09:27:08 +08:00
leimingsheng
abb16fd798 refactor(master : nicsensor)更新代码结构 2025-07-04 09:25:38 +08:00
leimingsheng
a841ae4363 refactor(master : nicsensor) 更新补充usage 2025-07-04 09:08:37 +08:00
leimingsheng
6b40c9c790 feat(plugin : plugin_%)同步可配置为disable跳过数据转化的功能到V2 2025-07-03 10:08:37 +08:00
leimingsheng
d480139f1d feat(master : test_tool)添加阈值判断脚本 2025-06-27 14:29:53 +08:00
leimingsheng
b17104dc2f refactor(master : nicsensor) 调整部分传感器执行时的显示样式 2025-06-26 14:35:31 +08:00
leimingsheng
5f4c3ea8ac feat(master : nicsensor) version change to intest 1.7.4 2025-06-26 13:58:50 +08:00
leimingsheng
0592c4b786 doc(master : nicsensor)update readme 2025-06-26 13:58:00 +08:00
leimingsheng
9e07465212 refactor(master : nicsensor)重新整理变量结构 2025-06-26 13:53:43 +08:00
leimingsheng
0f24ea84f5 feat(master : nicsensor)当channel name配置为disable时,跳过该channel的解析 2025-06-26 13:44:19 +08:00
leimingsheng
fda6c0ab2b refactor(master : nicsensor) debug模式下跳过服务器识别功能 2025-06-26 11:43:51 +08:00
leimingsheng
58f45494af feat(master : nicsensor) version change to intest 1.7.3 2025-06-26 10:31:06 +08:00
leimingsheng
1eecd40539 refactor(master : nicsensor)提高auto识别服务器的健壮性 2025-06-26 10:27:25 +08:00
leimingsheng
6fce071426 fix(master : nicsensor)修正 parse_nic_slot无法识别两位数槽位号的问题 2025-06-26 10:19:22 +08:00
leimingsheng
d8f8aa9cb0 doc(master : readme) update readme 2025-06-24 10:51:52 +08:00
993bb01922 feat(master : nicsensor)version change to intest 1.7.2 2025-06-21 18:20:49 +08:00
bf9a77ddd2 refactor(master : nicsensor.sh)将触发自动识别服务器的type类型由default变更为auto 2025-06-21 18:19:42 +08:00
leimingsheng
ccce95117a feat(master : nicsensor) version change to intest 1.7.1 2025-06-20 15:42:48 +08:00
leimingsheng
55600bd77e doc(master : readme) 更新server_type的描述 2025-06-20 15:41:30 +08:00
leimingsheng
6eacac1f1a feat(master : nicsensor)添加功能: 根据boardid自动匹配服务器型号 2025-06-20 15:39:03 +08:00
leimingsheng
1e2f32dce3 feat(plugin : platform_%.sh)在platform函数下新增透传i2c命令的功能 2025-06-20 14:01:43 +08:00
leimingsheng
0bc98aa5cd feat(master : nicsensor) Release Version 1.7 2025-06-10 14:20:26 +08:00
leimingsheng
0220e932ce doc(master : readme) 补充描述 2025-06-10 10:52:54 +08:00
leimingsheng
6f1e3f89b2 doc(master : readme) 补充描述 2025-06-10 10:49:51 +08:00
leimingsheng
9c20fcd070 doc(master : 新增扩展脚本方法) 2025-06-05 16:36:47 +08:00
marcinlei@outlook.com
97b42937fb doc(master : code_structure)添加对detect功能的描述 2025-05-13 20:22:37 +08:00
leimingsheng
d5f4a6f0d8 doc(master : readme)添加Project Varible的说明 2025-05-13 10:20:05 +08:00
leimingsheng
aecfcb4ada doc(master : readme)补充2.6描述 2025-05-13 09:55:58 +08:00
leimingsheng
87a625426f feat(master : nicsensor) version change to intest 1.6.5 2025-05-12 14:17:44 +08:00
leimingsheng
03d6900ceb doc(master : readme) 添加扩展功能的说明 2025-05-12 14:17:13 +08:00
leimingsheng
26adc0bda8 feat(master : nicsensor)预留用户自定义功能 2025-05-12 14:09:12 +08:00
8a08250df7 feat(master : nicsensor)version change to intest 1.6.4 2025-05-09 23:04:55 +08:00
d211f41f55 feat(master : nicsensor)预留扩展函数 2025-05-09 23:03:59 +08:00
leimingsheng
c73dba1433 fix(plugin : plugin_ina3221)修正read方法中调用i2c_script的错误参数使用 2025-05-09 14:09:48 +08:00
leimingsheng
333530ac5a feat(plugin : nicsensor)导入操作执行完毕后默认关闭PCA9548的策略 2025-05-09 11:43:23 +08:00
leimingsheng
bba1d037d5 feat(master : nicsensor)version change to intest 1.6.3 2025-05-08 16:57:56 +08:00
leimingsheng
2d663d4ec8 refactor(master : nicsensor)调整init debug log函数 2025-05-08 14:59:33 +08:00
leimingsheng
abd632d4f2 refactor(master : nicsensor) 将所有的‘==’替换为‘=’ 2025-05-08 14:49:01 +08:00
leimingsheng
0f7ee5e040 feat(master : nicsensor)version change to intest 1.6.2 2025-05-08 11:00:27 +08:00
leimingsheng
c4d8503a46 refactor(master : nicsensor) 修正一处help info描述 2025-05-08 10:59:42 +08:00
leimingsheng
b7671e12e1 feat(master : nicsensor) version change to intest 1.6.1 2025-04-27 10:33:12 +08:00
leimingsheng
c11cd9317a refactor(master : nicsensor)将参数校验等功能移入到pre_exec_hook中 2025-04-27 10:31:53 +08:00
leimingsheng
d3ad01482a refactor(master : nicsensor) 整理 配置检查 和 调试日志初始化为同一个接口使用
新接口:pre_exec_hook
2025-04-27 10:21:37 +08:00
leimingsheng
3301d9fdf7 feat(master : nicsensor) Release Version 1.6 2025-04-22 14:31:10 +08:00
leimingsheng
2a2ee7fc99 refactor(master : nicsensor) update to 1.5.6
1.update print_usage fuction
2.add feature : nicsensor.sh version
2025-04-22 14:24:38 +08:00
leimingsheng
a3f5e1a151 fix(master : nicsensor) 每次执行sensor读取后都执行reset pca9548 2025-04-14 13:40:17 +08:00
leimingsheng
0ff7ca20e4 docs(master : docs) create docs folder 2025-04-14 11:01:11 +08:00
741c0e8d95 perf(master : nicsensor)默认在传感器读取时不执行detect操作 2025-04-13 23:49:07 +08:00
marcinlei@outlook.com
03c2190edb format(master : nicsensor) delete unicode character 2025-04-12 00:38:48 +08:00
marcinlei@outlook.com
148e16f874 feat(master : nicsensor) 添加Disable Detect功能
功能说明:
启用时不在切换9641和9548时执行i2cdetect
2025-04-12 00:36:49 +08:00
leimingsheng
3db9c092e0 docs(master : readme) update readme 2025-04-11 14:49:23 +08:00
leimingsheng
2c3d736f05 docs(master : readme) update readme 2025-04-11 09:46:31 +08:00
leimingsheng
92cef5023b feat(master : readme) update readme 2025-04-10 20:24:27 +08:00
leimingsheng
132b128881 feat(master : readme) 更新readme 2025-04-09 18:05:28 +08:00
leimingsheng
48300473d9 refactor(plugin : arch) 重构platform脚本的异常退出功能 2025-03-27 09:43:19 +08:00
leimingsheng
032b36ea7b fix(master : nicsensor)修正detect操作后未恢复9548状态的问题
问题描述:
做detect操作后,没有将PCA9548状态恢复,导致下一次检测时仍有之前的数据。当下一次检测时换了另一个9548会产生冲突
2025-03-26 15:21:18 +08:00
0d3111a190 更新 nicsensor_v2/readme.md 2025-03-13 23:34:48 +08:00
leimingsheng
ec9473b347 feat(plugin : readme) add readme 2025-03-13 17:43:07 +08:00
leimingsheng
778c25787d feat(plugin : release) release nicsensor v2 2025-03-13 16:40:53 +08:00
leimingsheng
099dc264a3 Merge branch 'plugin' 2025-03-13 16:38:00 +08:00
leimingsheng
2b91b4ac61 code sync 2025-03-13 16:34:05 +08:00
leimingsheng
13ae2836ba feat(master : nicsensor.sh) Update to version 1.5 Rev1
1.优化 help info
2.优化readme
2025-03-13 16:30:44 +08:00
leimingsheng
cdfcd05232 feat(master : nicsensor.sh)Update to version 1.5 Standard 2025-03-04 19:03:02 +08:00
leimingsheng
a9f2123ad5 fix(master : nicsensor.sh)Update to version 1.4Rev3
1.修正5688m7的I2C bus及9641 slave地址
2.增加脚本交互逻辑,不支持测试OCP的服务器添加提示打印
2025-03-04 19:02:02 +08:00
leimingsheng
d71261692d code sync 2025-02-26 16:28:01 +08:00
leimingsheng
99cd4926d6 code sync 2025-02-24 20:15:41 +08:00
leimingsheng
576d831af1 code sync 2025-02-21 11:10:37 +08:00
leimingsheng
7393c6bfb4 code sync 2025-02-21 09:33:20 +08:00
leimingsheng
f0662a752d code sync 2025-02-20 18:10:19 +08:00
leimingsheng
e19d0e87ee refactor(master : nicsensor.sh)增强脚本可读性 2025-02-19 17:14:58 +08:00
leimingsheng
96cf6e7fd6 fix(master : nicsensor.sh) fix syntax error 2025-02-19 14:06:04 +08:00
leimingsheng
af5c649a40 feat(master : nicsensor.sh)添加对服务器5688m7的I2C拓扑支持 2025-02-19 13:55:55 +08:00
leimingsheng
0b3f79b1af code sync 2025-02-19 13:43:50 +08:00
leimingsheng
914889f21f feat(master : nicsensor.sh)Update to 1.4 Standard
1.修正fru write操作逻辑,并通过验证
2025-01-10 14:14:13 +08:00
leimingsheng
49bc774a60 feat(master : tool)添加windows下可以使用的hexdump工具 2025-01-10 09:32:43 +08:00
leimingsheng
73d92cbb61 feat(plugin : scripts)添加基本I2C功能脚本 2025-01-08 13:46:18 +08:00
32 changed files with 3896 additions and 920 deletions

@ -1,24 +0,0 @@
# Script Version 1.3 20241229
Release Note
1.[新增功能]支持5280m7的OCP卡的使用
2.[新增功能]支持传感器tmp468和tmp112
# Script Version 1.2 20241102
Release Note:
1.[新增功能]支持写入板卡FRU
2.[新增功能]添加适配服务器 donghu yichun qiandaohu
3.[功能优化]修复一些交互类bug,增强脚本健壮性
4.[功能优化]更便捷的支持脚本传感器名称本地化
5.[功能优化]debug模式下执行i2c detect时可自定义执行detect内容
# Script Version 1.1 20240912
Release Note:
1.[新增功能]添加根据服务器类型适配 pcie slot 和 i2c对应关系的接口逻辑。当前可应用的服务器, 5280M7,5468M7.
2.[新增功能]添加debug模式,通过修改变量启用debug模式:
2.1 debug模式下, 不会执行选通9641和9548的操作,仅执行读取传感器的操作
2.2 debug模式下, 执行detect操作仅会针对当前配置的I2C bus进行一次detect
3.[功能优化]考虑到读取寄存器时可能也会操作fpga芯片, 为防止混淆, 修改命令cpld, 名称更改为 chip
# Script Version 1.0 20240614
Release Mote:
1.发布初版

80
docs/change_list.txt Normal file

@ -0,0 +1,80 @@
# Script Version 1.11
#Release Note
1.[新增功能]解耦脚本参数配置功能, 脚本配置全部放到project.config中
2.[新增功能]增加对pmbus set命令的支持
3.[新增功能]增加setup.sh, 用于一键部署脚本
4.[功能优化]代码结构目录重新归档
# Script Verison 1.10
Release Note
1.[新增功能]新增适配传感器 ina226, lm95241
2.[新增功能]增加stress压测插件, 可支持自定义压测读取功能
3.[功能优化]优化help显示功能
4.[功能优化]优化脚本交互, 增加安全性检查
5.[功能优化]插件脚本加入版本号
6.[功能优化]nicsensor配置项全部放置到 /tmp/nicsensor_config 目录下, 便于维护
7.[功能优化]version命令移除debug, n_detect的显示,仅显示脚本版本号
8.[功能优化]默认i2cbus支持在参数配置功能中通过命令配置, 可用于debug模式默认搜索
9.[功能优化]默认fru offset支持在参数配置功能中通过命令配置
# Script Verison 1.9
Release Note
1.[新增功能]添加pmbus插件功能, 可支持对VR芯片的pmbus测试
2.[功能优化]fru size支持在属性配置功能中通过命令配置大小
3.[功能优化]对于 DISABLE_DETECT 的简写由 detect 变更为 n_detect, 便于理解
4.[问题修复]修复nicsensor_v2中5280m7平台的detect功能不显示插槽信息的问题
# Script Version 1.8
Release Note
1.[新增功能]默认server type调整为auto, 通用服务器可自动检索boardid,确认服务器类型
2.[新增功能]新增set get功能, 可使用命令对配置进行修改(详见readme)
3.[问题修复]修正无法识别两位数槽位号的问题
4.[功能优化]添加脚本 nicsensor_s.sh, 是nicsensor主体功能的简化版,删去了相对次要功能来确保功能快速执行
# Script Version 1.7 20250610
Release Note
1.[新增功能]预留扩展函数, 用于自定义选通网卡后的I2C操作
2.[功能优化]优化代码结构
3.[文档完善]新增脚本扩展方法, 用于指导新增适配服务器
# Script Version 1.6 20250422
Release Note
1.[新增功能]添加配置项 DISABLE_DETECT ,默认在执行时不进行i2cdetect
2.[问题修复]每次完成命令执行后进行pca9548 reset
3.[功能优化]优化help info
# Script Version 1.5 20250304
Release Note
1.[新增功能]添加适配服务器5688m7
2.[功能优化]优化程序执行
# Script Version 1.4 20250110
Release Note
1.[问题修复]修正tmp112传感器读取的逻辑问题
2.[新增功能]添加fru解析工具,位置 /tool/fru_parse/fru_parse.py
3.[功能优化]完善fru write操作逻辑(验证PASS)
# Script Version 1.3 20241229
Release Note
1.[新增功能]支持5280m7的OCP卡的使用
2.[新增功能]支持传感器tmp468和tmp112
# Script Version 1.2 20241102
Release Note:
1.[新增功能]支持写入板卡FRU
2.[新增功能]添加适配服务器 donghu yichun qiandaohu
3.[功能优化]修复一些交互类bug,增强脚本健壮性
4.[功能优化]更便捷的支持脚本传感器名称本地化
5.[功能优化]debug模式下执行i2c detect时可自定义执行detect内容
# Script Version 1.1 20240912
Release Note:
1.[新增功能]添加根据服务器类型适配 pcie slot 和 i2c对应关系的接口逻辑。当前可应用的服务器, 5280M7,5468M7.
2.[新增功能]添加debug模式,通过修改变量启用debug模式:
2.1 debug模式下, 不会执行选通9641和9548的操作,仅执行读取传感器的操作
2.2 debug模式下, 执行detect操作仅会针对当前配置的I2C bus进行一次detect
3.[功能优化]考虑到读取寄存器时可能也会操作fpga芯片, 为防止混淆, 修改命令cpld, 名称更改为 chip
# Script Version 1.0 20240614
Release Mote:
1.发布初版

@ -1,4 +1,5 @@
On Version V1.2
On Version V1.x
PART I. Sensor读取
start_get_sensor //启动读取Sensor的流程
|--->set_configuration
| |--->set_configuration_5280m7/5468m7/donghu/yichun //根据服务器类型设置具体I2C相关参数
@ -7,4 +8,8 @@ On Version V1.2
|--->process_sensor
|--->sensor_init //传感器可能需要初始化
|--->read_sensor_value //读取传感器的数值
|--->convert_sensor_value //处理传感器的读值并做可视化处理
|--->convert_sensor_value //处理传感器的读值并做可视化处理
PART II. Detect操作
start_detect_device //启动detect i2c的流程
|--->detect_on_5280m7/5468m7/donghu/yichun //根据服务器类型进行对应的detect操作

@ -17,13 +17,14 @@
### 正文
一、脚本使用方法 Version1.3
一、脚本使用方法 Version1.5
1.1、修改项目专属配置
针对不同项目,请先修改脚本中的部分变量(ADC128电压传感器的分压系数,INA3221的分流精密电阻阻值)
针对不同服务器产品,请对应修改server_type变量, 当前支持设置的服务器型号:
5280m7
5468m7
5688m7
donghu
yichun
qiandaohu
@ -38,7 +39,7 @@
参数说明:
pcie_slot : 网卡所在的PCIE槽位, 填数字0,1,2,3,4,5
chip_type : 传感器芯片的类型, emc1413,adc128,ina3221,tmp268,tmp112
chip_type : 传感器芯片的类型, emc1413,adc128,ina3221,tmp468,tmp112
chip_slave: 传感器芯片的I2C地址(7bit)
举例说明:读取PCIE 1 上网卡的adc128芯片, 芯片slave地址为0x1f
@ -61,8 +62,12 @@
1.4.2 fru命令
命令: ./nicsensor.sh <pcie_slot> fru <chip_slave> read
举例说明:读取Ravel板卡的EEPROM中的FRU(0x57)
举例说明:读取板卡的EEPROM中的FRU(0x57)
- ./nicsensor.sh 5 fru 0x57 read
命令: ./nicsensor.sh <pcie_slot> fru <chip_slave> write <fru.bin>
举例说明:写入板卡的EEPROM中的FRU(0x57)
- ./nicsensor.sh 5 fru 0x57 write fru.bin
1.4.3 读取芯片寄存器

119
docs/扩展脚本说明.md Normal file

@ -0,0 +1,119 @@
# 如何扩展脚本?
## 一、前言
> [!tip]
>
> 脚本扩展一般涉及到两部分内容的扩充,包含对于支持服务器类型的扩充,或者对支持读取的传感器类型的扩充。
不论如何修改脚本,请在完成后主要修改后,修改 `SCRIPT_VERSION` 用于和主线脚本进行版本区分。
例如:
- `SCRIPT_VERSION="1.6.5 for project"` 代表基于脚本1.6.5版本为某个项目做特殊定制
## 二、新增支持服务器
### 修改点1-Support_Server_List
``````sh
# 可以在这里添加对应的服务器型号
Support_Server_List="5280m7, 5468m7, 5688m7, donghu, yichun, qiandaohu"
``````
### 修改点2-添加服务器配置入口
``````sh
# 修改函数 set_configuration
set_configuration(){
# ... 省略部分代码
case ${server_type} in
"5280m7")
set_configuration_5280m7
;;
# [开始修改]在这里针对要添加的服务器添加如下语句,将 {server_name} 替换为对应的服务器型号
# 这里修改的意义在于添加一个设置服务器I2C拓扑的入口后面会专门编写 set_configuration_{server_name} 函数
"{server_name}")
set_configuration_{server_name}
;;
# [结束修改]
esac
# ... 省略部分代码
}
``````
### 修改点3-添加I2C拓扑适配函数
``````sh
# 在脚本中找到函数 set_configuration_5280m7在这个函数上面新建一个函数名为
set_configuration_{server_name}(){
# 可以模仿 5280m7 函数的写法,来编写本函数
# 主体编写的内容就是针对卡的类型和槽位来配置通道上正确的I2C属性
# 需要考虑的内容如下:
# 1.是否支持OCP网卡
# 2.I2C链路上是否存在PCA9641
# 3.每个物理slot和I2C Bus的对应关系
# 4.每个物理slot和I2C PCA9546/9548 channel的对应关系
# 5.PCA9641和PCA9546/9548的slave地址
# 提供一种模板
# 首先判断网卡类型是否为 pcie (ocp形态同理)
if [ ${nic_type} = "pcie" ];then
# 根据 SLOT number 做针对性配置
if [ ${slot_number} -eq 0 ];then
i2c_bus=12
is_have_pca9641=1
pca9641_slave=0x41
pca9548_slave=0x70
pca9548_channel="0x01"
elif [ ${slot_number} -eq 1 ]; then
i2c_bus=12
is_have_pca9641=1
pca9641_slave=0x41
pca9548_slave=0x70
pca9548_channel="0x02"
elif [ ${slot_number} -eq 2 ]; then
i2c_bus=12
is_have_pca9641=1
pca9641_slave=0x41
pca9548_slave=0x70
pca9548_channel="0x04"
else
format_print $WARNING "Unspecified card slot!"
fi
fi
}
``````
### 修改点4-添加I2C扫描函数可选
``````sh
# 类似 修改点2, 在 start_detect_device 函数中添加入口函数
# 形如 detect_on_{server_name}
# 随后新建一个对应的函数
detect_on_{server_name}(){
# 首先给定对应 slot 的 i2c bus号码
i2c_bus=12
# 根据链路上是否存在9641来编写如果没有9641跳过这里
pca9641_slave="0x31"
get_pca9641_control
# 调用 do_i2c_detect 函数来执行一次9548的通道切换并做一次i2cdetect
# 参数表如下 i2cbus 9548_slave 9548_channel(hex) 9548_index slot_number
do_i2c_detect $i2c_bus "0x70" "0x01" 0 1
do_i2c_detect $i2c_bus "0x70" "0x02" 1 2
do_i2c_detect $i2c_bus "0x70" "0x04" 2 3
}
``````
### 修改点5-服务器auto选择配置可选
> [!note]
>
> script v1.8 新增特性:
>
> - server_type 配置为 auto 后可以自行搜索boardid进行匹配服务器类型仅限通用服务器
可以针对已知的boardid对 `try_get_server_type`函数中做针对性修改。

195
extension/pmbus_cmd_list.sh Normal file

@ -0,0 +1,195 @@
#!/bin/sh
# Desc : This script used to find pmbus code and read size
# Changelist : 2025-12-25|v0.1 Create this file
# 2026-04-17|v1.1 Add PAGE command support
# How to use this pmbus plugin?
# Follow readme.md file to use this plugin or use setup.sh to install this plugin
EXTENSION_VERSION="v1.1"
# ---------------------------------------------------------
# Varible Define
# ---------------------------------------------------------
operation_type=$1
str_cmd=$2
hex_cmd=0xff
read_size=0
PMBUS_BYTE=1
PMBUS_WORD=2
PMBUS_BLOCK=3
PMBUS_RAW=4
# ---------------------------------------------------------
# Function Define
# ---------------------------------------------------------
pmbus_command_help(){
echo " Extend Function - PMBUS command test"
echo " Version : $EXTENSION_VERSION"
echo " 1) Command Format : ./nicsensor.sh [slot] pmbus [slave] [command] <data>"
echo " 2) Option Detail"
echo " - [slot] : 0 1 2 3 4 5 ..."
echo " - [slave] : power manage chip slave address , please provide 7 bit address"
echo " - [command] : The pmbus command which will set to the power manage chip"
echo " - <data> : The data which will set to the power manage chip, only set operation type is set"
echo " 3) E.G. : ./nicsensor.sh pcie1 pmbus 0x60 READ_TEMPERATURE_1"
echo " : ./nicsensor.sh pcie1 pmbus 0x60 PAGE 0x00"
echo ""
echo " *****************Pmbus Support Command List********************"
echo " Command Name Code op_type Read Size "
echo " PAGE 0x00 set Byte "
echo " READ_VIN 0x88 get Word "
echo " READ_IIN 0x89 get Word "
echo " READ_VOUT 0x8b get Word "
echo " READ_IOUT 0x8c get Word "
echo " READ_TEMPERATURE_1 0x8d get Word "
echo " READ_TEMPERATURE_2 0x8e get Word "
echo " READ_TEMPERATURE_3 0x8f get Word "
echo " READ_POUT 0x96 get Word "
echo " READ_PIN 0x97 get Word "
echo " ***************************************************************"
echo ""
}
find_pmbus_hex_code(){
case ${str_cmd} in
"PAGE")
hex_cmd=0x00
;;
"READ_VIN")
hex_cmd=0x88
;;
"READ_IIN")
hex_cmd=0x89
;;
"READ_VOUT")
hex_cmd=0x8b
;;
"READ_IOUT")
hex_cmd=0x8c
;;
"READ_TEMPERATURE_1")
hex_cmd=0x8d
;;
"READ_TEMPERATURE_2")
hex_cmd=0x8e
;;
"READ_TEMPERATURE_3")
hex_cmd=0x8f
;;
"READ_POUT")
hex_cmd=0x96
;;
"READ_PIN")
hex_cmd=0x97
;;
*)
hex_cmd=0xff
;;
esac
echo $hex_cmd
}
find_pmbus_operation_type(){
case ${str_cmd} in
"PAGE")
op_type="set"
;;
"READ_VIN")
op_type="get"
;;
"READ_IIN")
op_type="get"
;;
"READ_VOUT")
op_type="get"
;;
"READ_IOUT")
op_type="get"
;;
"READ_TEMPERATURE_1")
op_type="get"
;;
"READ_TEMPERATURE_2")
op_type="get"
;;
"READ_TEMPERATURE_3")
op_type="get"
;;
"READ_POUT")
op_type="get"
;;
"READ_PIN")
op_type="get"
;;
*)
op_type=""
;;
esac
echo $op_type
}
find_pmbus_read_size(){
case ${str_cmd} in
"PAGE")
read_size=$PMBUS_BYTE
;;
"READ_VIN")
read_size=$PMBUS_WORD
;;
"READ_IIN")
read_size=$PMBUS_WORD
;;
"READ_VOUT")
read_size=$PMBUS_WORD
;;
"READ_IOUT")
read_size=$PMBUS_WORD
;;
"READ_TEMPERATURE_1")
read_size=$PMBUS_WORD
;;
"READ_TEMPERATURE_2")
read_size=$PMBUS_WORD
;;
"READ_TEMPERATURE_3")
read_size=$PMBUS_WORD
;;
"READ_POUT")
read_size=$PMBUS_WORD
;;
"READ_PIN")
read_size=$PMBUS_WORD
;;
*)
read_size=0
;;
esac
echo $read_size
}
main(){
case ${operation_type} in
"code")
find_pmbus_hex_code
;;
"operation")
find_pmbus_operation_type
;;
"size")
find_pmbus_read_size
;;
"help")
pmbus_command_help
;;
*)
echo "Error command type"
;;
esac
}
# ---------------------------------------------------------
# Start Execute Script(main)
# ---------------------------------------------------------
main

209
extension/stress_test.sh Normal file

@ -0,0 +1,209 @@
#!/bin/sh
# Desc: Stress test script for nicsensor
# Detail: This script will stress test the nicsensor by reading the sensor data
# and print the result to the console.
EXTENSION_VERSION="v1.0 Base Dev 1"
# ---------------------------------------------------------
# Varible Define
# ---------------------------------------------------------
Param1=$1
Param2=$2
CONFIG_DIR="/tmp/nicsensor_config"
CONFIG_NICSENSOR="${CONFIG_DIR}/stress_tool"
CONFIG_SLOT="${CONFIG_DIR}/stress_slot"
CONFIG_SENSOR="${CONFIG_DIR}/stress_sensor"
CONFIG_ROUND="${CONFIG_DIR}/stress_round"
CONFIG_INTERVAL="${CONFIG_DIR}/stress_interval"
CONFIG_SLAVE="${CONFIG_DIR}/stress_slave"
config_tool=""
# ---------------------------------------------------------
# Function Define
# ---------------------------------------------------------
print_usage(){
echo " Extend Function - Stress Test"
echo " Version: $EXTENSION_VERSION"
echo " 1) Description"
echo " This plugin will stress test the nicsensor by reading the sensor data"
echo " and print the result to the console."
echo " 2) Command Format : ./nicsensor.sh [slot] stress [option] [data]"
echo " 3) Option Detail"
echo " - [slot] : The nicsensor slot number"
echo " - [option] : start|show|round|tool|interval|slot|sensor|slave"
echo " - [data] : The option data"
echo " 4) Example"
echo " Case: Test PCIe1 Nic's INA3221, slave=0x42, round=1000, interval=3s"
echo " Step 1 : Set the stress test parameter"
echo " ./nicsensor.sh pcie1 stress slot pcie1"
echo " ./nicsensor.sh pcie1 stress round 1000"
echo " ./nicsensor.sh pcie1 stress interval 3"
echo " ./nicsensor.sh pcie1 stress sensor ina3221"
echo " ./nicsensor.sh pcie1 stress slave 0x42"
echo " Step 2 : Check the stress test configuration"
echo " ./nicsensor.sh pcie1 stress show"
echo " Step 3 : Start the stress test"
echo " ./nicsensor.sh pcie1 stress start"
}
set_stress_config(){
case ${Param1} in
"round")
echo "Set the stress test round to ${Param2}"
echo ${Param2} > ${CONFIG_ROUND}
;;
"interval")
echo "Set the stress test interval to ${Param2}s"
echo ${Param2} > ${CONFIG_INTERVAL}
;;
"sensor")
echo "Set the stress test sensor to ${Param2}"
echo ${Param2} > ${CONFIG_SENSOR}
;;
"slave")
echo "Set the stress test slave to ${Param2}"
echo ${Param2} > ${CONFIG_SLAVE}
;;
"slot")
echo "Set the stress test slot to ${Param2}"
echo ${Param2} > ${CONFIG_SLOT}
;;
"tool")
echo "Set the stress test tool to ${Param2}"
echo ${Param2} > ${CONFIG_NICSENSOR}
;;
*)
echo "Invalid option: ${Param1}"
;;
esac
}
get_stress_all_config(){
echo "Stress Test Config:"
if [ -f ${CONFIG_NICSENSOR} ]; then
echo " Tool : $(cat ${CONFIG_NICSENSOR})"
else
echo " Tool : nicsensor.sh"
fi
if [ -f ${CONFIG_ROUND} ]; then
echo " Round : $(cat ${CONFIG_ROUND})"
else
echo " Round : Not Set"
fi
if [ -f ${CONFIG_INTERVAL} ]; then
echo " Interval: $(cat ${CONFIG_INTERVAL})s"
else
echo " Interval: Not Set"
fi
if [ -f ${CONFIG_SLOT} ]; then
echo " Slot : $(cat ${CONFIG_SLOT})"
else
echo " Slot : Not Set"
fi
if [ -f ${CONFIG_SENSOR} ]; then
echo " Sensor : $(cat ${CONFIG_SENSOR})"
else
echo " Sensor : Not Set"
fi
if [ -f ${CONFIG_SLAVE} ]; then
echo " Slave : $(cat ${CONFIG_SLAVE})"
else
echo " Slave : Not Set"
fi
}
start_stress_test(){
# nicsensor tool check
if [ -f ${CONFIG_NICSENSOR} ]; then
config_tool=$(cat ${CONFIG_NICSENSOR})
else
config_tool="/extlog/nicsensor/nicsensor.sh"
fi
if [ ! -f "${config_tool}" ]; then
echo "Error: ${config_tool} tool not found"
echo "Info : Please check the nicsensor tool path and name"
return 1
fi
# option check
if [ ! -f ${CONFIG_ROUND} ]; then
echo "Error: Round is not set"
echo "Info : Please set the stress test round first, use command: ${config_tool} [slot] stress round [data]"
return 1
fi
if [ ! -f ${CONFIG_INTERVAL} ]; then
echo "Error: Interval is not set"
echo "Info : Please set the stress test interval first, use command: ${config_tool} [slot] stress interval [data]"
return 1
fi
if [ ! -f ${CONFIG_SLOT} ]; then
echo "Error: Slot is not set"
echo "Info : Please set the stress test slot first, use command: ${config_tool} [slot] stress slot [data]"
return 1
fi
if [ ! -f ${CONFIG_SENSOR} ]; then
echo "Error: Sensor is not set"
echo "Info : Please set the stress test sensor first, use command: ${config_tool} [slot] stress sensor [data]"
return 1
fi
if [ ! -f ${CONFIG_SLAVE} ]; then
echo "Error: Slave is not set"
echo "Info : Please set the stress test slave first, use command: ${config_tool} [slot] stress slave [data]"
return 1
fi
# start stress test
echo "Stress Test Config Info:"
config_round=$(cat ${CONFIG_ROUND})
config_interval=$(cat ${CONFIG_INTERVAL})
config_slot=$(cat ${CONFIG_SLOT})
config_sensor=$(cat ${CONFIG_SENSOR})
config_slave=$(cat ${CONFIG_SLAVE})
echo " Round : ${config_round}"
echo " Interval: ${config_interval}s"
echo " Slot : ${config_slot}"
echo " Sensor : ${config_sensor}"
echo " Slave : ${config_slave}"
run_count=1
while [ ${run_count} -le ${config_round} ]; do
echo ""
timestamp=$(date +"%Y-%m-%dT%H:%M:%S")
echo "====== ${timestamp}, Run Count: ${run_count}"
exec_cmd="${config_tool} ${config_slot} ${config_sensor} ${config_slave}"
${exec_cmd}
sleep ${config_interval}
run_count=$((run_count+1))
done
echo "==========================================="
echo " Stress Test Completed"
}
main(){
cmd=${Param1}
case ${cmd} in
"start")
echo "Start the stress test"
start_stress_test
;;
"show")
echo "Show the stress test configuration"
get_stress_all_config
;;
"help")
print_usage
;;
*)
echo "Set Stress Config"
set_stress_config
;;
esac
}
# ---------------------------------------------------------
# Start Execute Script(main)
# ---------------------------------------------------------
main

File diff suppressed because it is too large Load Diff

56
project.config Normal file

@ -0,0 +1,56 @@
# ADC128 Division factor
votage_division_factor_0="1"
votage_division_factor_1="1"
votage_division_factor_2="1"
votage_division_factor_3="0.8"
votage_division_factor_4="0.6"
votage_division_factor_5="0.6"
votage_division_factor_6="0.2326"
votage_division_factor_7="1"
# ADC128 channel name
ADC128_Channel0_name="Channel0"
ADC128_Channel1_name="Channel1"
ADC128_Channel2_name="Channel2"
ADC128_Channel3_name="Channel3"
ADC128_Channel4_name="Channel4"
ADC128_Channel5_name="Channel5"
ADC128_Channel6_name="Channel6"
ADC128_Channel7_name="Channel7"
# INA3221 shunt resistor(unit: mohm)
shunt_resistor_0="2"
shunt_resistor_1="2"
shunt_resistor_2="5"
# INA3221 channel name
INA3221_Channel0_name="Channel0"
INA3221_Channel1_name="Channel1"
INA3221_Channel2_name="Channel2"
# EMC1413 channel name
EMC1413_Channel0_name="Channel0"
EMC1413_Channel1_name="Channel1"
EMC1413_Channel2_name="Channel2"
# TMP468 channel name
TMP468_Channel0_name="Local"
TMP468_Channel1_name="Remote1"
TMP468_Channel2_name="Remote2"
TMP468_Channel3_name="Remote3"
TMP468_Channel4_name="Remote4"
TMP468_Channel5_name="Remote5"
TMP468_Channel6_name="Remote6"
TMP468_Channel7_name="Remote7"
TMP468_Channel8_name="Remote8"
# TMP112 sensor name
TMP112_Sensor_name="Temperature"
# INA226 channel name
INA226_Channel0_name="Channel0"
# LM95241 channel name
LM95241_Local_name="Local"
LM95241_Remote1_name="Remote1"
LM95241_Remote2_name="Remote2"

429
readme.md Normal file

@ -0,0 +1,429 @@
# nicsensor工具使用说明
> 本说明仅针对 nicsensorv1.x系列脚本
> 1.x系列工具本体: [nicsensor.sh](./nicsensor.sh)
## 快速使用
工具Usage `./nicsensor.sh help`
工具版本查询 `./nicsensor.sh version`
读取传感器:`./nicsensor.sh pcie0 ina3221 0x42` (读取PCIE_0 上网卡的 INA3221 传感器slave地址0x42)
## 目录
- [nicsensor工具使用说明](#nicsensor工具使用说明)
- [目录](#目录)
- [1.简介](#1_简介)
- [2.使用方法](#2_使用方法)
- [2.1 传感器读取](#2_1_传感器读取)
- [2.2 FRU读写](#2_2_fru读写)
- [2.3 命令透传](#2_3_命令透传)
- [2.4 服务器网卡通道I2C信息扫描](#2_4_服务器网卡通道I2C信息扫描)
- [2.5 调试模式](#2_5_调试模式)
- [2.6 扩展功能](#2_6_扩展功能)
- [2.7 参数配置](#2_7_参数配置)
- [2.8 PMBUS功能测试](#2_8_pmbus功能)
- [2.9 压力测试stress](#2_9_压力测试stress)
- [3.常见问题](#3_常见问题)
- [3.1 ADC128传感器读值为0](#3_1_adc128传感器读值为0)
- [3.2 脚本执行时出现大批量语法错误](#3_2_脚本执行时出现大批量语法错误)
- [3.3 传感器读值不正确](#3_3_传感器读值不正确)
- [4.附属工具](#4_附属工具)
- [4.1 FruParse](#4_1_fruparse)
- [4.2 nicsensor\_s(已停用)](#4_2_nicsensor_s)
- [5.关于nicsensor\_v2](#5_关于nicsensor_v2)
- [6.附录](#6_附录)
- [6.1 Project变量说明](#6_1_project变量说明)
## 1_简介
nicsensor工具是在带有i2ctool工具(i2ctransfer、i2cdetect)的BMC下用于测试网卡I2C功能的工具。
**当前支持的功能有:**
- 读取网卡上的I2C传感器
- 读取并修改网卡上的FRU
- 透传I2C命令到网卡的芯片上
- 遍历服务器上的PCIE插槽的I2C信息
- 部分服务器类型支持读取OCP卡
- 支持记录单次运行日志
- 支持测试PMBUS功能**(new)**
- 支持进行压力测试**(new)**
**当前支持测试的传感器类型**
- adc128
- ina3221
- ina226**(new)**
- emc1413
- tmp468
- tmp112
- lm95241**(new)**
## 2_使用方法
> [!warning]
> 在使用时针对网卡的硬件特性需要定制化修改脚本的 `Project Varible` ,变量的对应关系及说明见[Project变量说明](#6_1_project变量说明)
### 2_1_传感器读取
**命令格式**
``` shell
./nicsensor.sh <pcie_slot> <sensor_tpye> <sensor_slave>
```
**参数说明**
| Properties | type | 说明 |
| -------------- | ------- | ------------------------------------------------------------ |
| `pcie slot` | string | 网卡位于的PCIE SLOT槽位,需要指定pcie/ocp, 不指定时默认为pcie类型 |
| `sensor type` | string | 传感器类型 |
| `sensor slave` | hex num | 传感器的slave地址(7 bit) |
**命令示例**
``` shell
# 读取pcie2槽位上的adc128的信息, adc128芯片的地址为0x1f(7bit)
./nicsensor.sh pcie2 adc128 0x1f
# 读取pcie3槽位上的ina3221的信息, ina3221芯片的地址为0x40(7bit)
./nicsensor.sh 3 ina3221 0x40
# 读取ocp0槽位上的tmp112的信息, tmp112芯片的地址为0x48(7bit)
./nicsensor.sh ocp0 tmp112 0x48
```
### 2_2_FRU读写
> [!warning]
> 在写入网卡FRU操作时受限于服务器PCA9641的影响**建议**将服务器关机后执行
**命令格式**
``` shell
# 读取FRU
./nicsensor.sh <pcie_slot> fru <eeprom_slave>
# 写入FRU
./nicsensor.sh <pcie_slot> fru <eeprom_slave> write <filename>
```
**参数说明**
| Properties | type | 说明 |
| -------------- | ------- | ------------------------------------------------------------ |
| `pcie slot` | string | 网卡位于的PCIE SLOT槽位,需要指定pcie/ocp, 不指定时默认为pcie类型 |
| `eeprom slave` | hex num | FRU所在的eeprom芯片的slave地址(7 bit) |
| `filename` | string | 仅在写入FRU时提供, 要写入的FRU bin文件路径 |
**命令示例**
``` shell
# 读取pcie2槽位上的fru信息, eeprom的芯片地址为0x50(7bit)
./nicsensor.sh pcie2 fru 0x50
# 写入pcie2槽位上网卡的fru
./nicsensor.sh pcie2 fru 0x50 write fru.bin
```
### 2_3_命令透传
提供对芯片直接执行i2c命令的能力通常用于访问网卡核心芯片如FPGANic Controller等。
**命令格式**
``` shell
./nicsensor.sh <pcie_slot> chip <chip slave> <command>
```
**参数说明**
| Properties | type | 说明 |
| ------------ | ------- | ------------------------------------------------------------ |
| `pcie slot` | string | 网卡位于的PCIE SLOT槽位,需要指定pcie/ocp, 不指定时默认为pcie类型 |
| `chip slave` | hex num | 芯片的slave地址(7 bit) |
| `command` | string | 要透传执行的I2C命令 |
**命令示例**
``` shell
# 对pcie2槽位上的chip透传命令 i2ctransfer -y 12 w2@0x11 0x00 0x00 r2 , 芯片地址为0x11(7bit)
./nicsensor.sh pcie2 chip 0x11 "i2ctransfer -y 12 w2@0x11 0x00 0x00 r2"
```
### 2_4_服务器网卡通道I2C信息扫描
**命令格式**
``` shell
./nicsensor.sh detect <nic_type>
```
**参数说明**
- `nic type`:需要指定pcie/ocp, 不指定时默认为pcie类型
**命令示例**
``` shell
./nicsensor.sh detect pcie
```
### 2_5_调试模式
如果不需要借助脚本来选通服务器上对应的channel, 仅需要做传感器数值测试, 可以启用调试模式。
在调试模式下, 脚本不会执行选通PCA9641以及PCA9546/9548的操作。仅直接测试传感器。
**开启调试模式**
``````sh
./nicsensor.sh set debug 1
``````
**关闭调试模式**
``````sh
./nicsensor.sh set debug 0
``````
### 2_6_扩展功能
脚本中预留了函数 `handle_reserve` 用于扩展功能。针对有特殊需求的项目可能会使用。
`handle_reserve` 中可以自定义需要对网卡实现的功能。在调用该函数之前脚本会将 PCA9641及PCA9548选通。扩展功能时无需考虑PCA9641和PCA9548的状态。
### 2_7_参数配置
可以通过一组名为 `get/set` 的指令对脚本中的如下变量做即时修改而无需修改脚本(下电后恢复默认)。支持修改的变量如下:
| Properties | 对应脚本变量 | 说明 |
| ------------ | ---------------- | ---------------------------------------- |
| `server` | `server_type` | 脚本应用的服务器类型 |
| `debug` | `DEBUG_MODE` | 是否启用调试模式 |
| `n_detect` | `DISABLE_DETECT` | 是否禁止执行时的i2c detect操作 |
| `fru_size` | `fru_size` | 默认fru的读取字节数 |
| `fru_offset` | `fru_offset` | 默认fru在eeprom的起始偏移地址 |
| `i2cbus` | `i2c_bus` | 默认的i2c bus通常需要搭配debug一起使用 |
**命令格式**
``` shell
./nicsensor.sh <get/set> <property> <value>
```
**命令示例**
``` shell
./nicsensor.sh set server 5280m7
./nicsneosr.sh get debug
```
### 2_8_PMBUS功能
> [!warning]
> 支持的脚本版本v1.9及以上
> PMBUS功能属于额外的功能,需要将 [pmbus_cmd_list.sh](./pmbus_cmd_list.sh) 拷贝到和nicsensor脚本相同的目录。
> 如果不添加该脚本, 该功能无法正常使用
**命令格式**
``` shell
./nicsensor.sh <pcie slot> pmbus <chip slave> <pmbus cmd>
```
**参数说明**
- `pcie slot`: 网卡位于的PCIE SLOT槽位,需要指定pcie/ocp, 不指定时默认为pcie类型
- `chip slave`: 芯片的slave地址
- `pmbus cmd`: 要读取的pmbus命令码, 支持列表请使用命令 `./nicsensor.sh help` 查询
**命令示例**
``` shell
./nicsensor.sh pcie1 pmbus 0x60 READ_TEMPERATURE_1
```
### 2_9_压力测试stress
> [!Warning]
>
> 支持的脚本版本v1.10及以上
>
> 压力测试属于额外的功能,需要将 [stress_test.sh](./stress_test.sh) 拷贝到和nicsensor脚本相同的目录。
>
> 如果不添加该脚本,该功能无法正常使用
**功能介绍**
一个模块化的压力测试工具通过配置文件管理测试参数支持灵活设置测试轮次、间隔、传感器类型等方便用户进行nicsensor的稳定性测试。
**命令格式**
``````sh
./nicsensor.sh <pcie slot> stress <option> <option data>
``````
**参数说明**
| 参数名称 | 数据类型 | 说明 |
| ------------- | -------- | ------------------------------------------------------------ |
| `pcie slot` | string | nicsensor工具通用格式在这里无特殊含义 |
| `option` | string | 要执行的stress命令类型有如下取值<br>`start` : 开始执行压力测试无需option data<br>`show`: 显示压力测试的配置项, 无需option data<br>`round`: 要执行的压力测试圈数<br>`tool`: 要使用的nicsensor脚本默认为nicsensor.sh<br>`interval`: 每一圈执行的时间间隔,单位为秒(s)<br>`slot`: 目标测试的插槽号<br>`sensor`: 需要测试的传感器类型<br>`slave`: 目标传感器的slave地址 |
| `option data` | string | 依据option类型决定是否需要该字段 |
**命令示例**
``````sh
#场景说明对pcie1的网卡压测 ina3221(0x42) 100次, 读取间隔2s
# step 1 配置测试项
./nicsensor.sh pcie1 stress round 100
./nicsensor.sh pcie1 stress interval 2
./nicsensor.sh pcie1 stress slot pcie1
./nicsensor.sh pcie1 stress sensor ina3221
./nicsensor.sh pcie1 stress slave 0x42
# step 2 查看测试项是否符合预期
./nicsensor.sh pcie1 stress show
# step 3 开始测试
./nicsensor.sh pcie1 stress start
``````
## 3_常见问题
### 3_1_ADC128传感器读值为0
ADC128传感器在使用时需要初始化, 因此第一次读取时传感器可能并未完成初始化, 所以读值为0
### 3_2_脚本执行时出现大批量语法错误
通常是因为服务器上含有PCA9641切断了BMC的I2C控制权导致, 重试即可
### 3_3_传感器读值不正确
常见于ina3221传感器读值明显不正确, 因为ina3221的i2c slave地址比较敏感, 容易和pca9641产生冲突, 可首先按照i2c地址冲突的方向去排查问题。
## 4_附属工具
### 4_1_FruParse
提供了一个简单python脚本用于解析FRU的数据, 将nicsensor读取到的FRU数据拷贝到frudata.txt后, 执行
`python fru_parse.py`即可将读取到的数据转化为FRU内容
**工具路径**:[fru_parse.py](./tool/fru_parse/fru_parse.py)
### 4_2_nicsensor_s
该工具已于`nicsensor v1.10` 移除
~~基于脚本版本1.8, 剔除了所有记日志的操作, 用于加速i2c的执行, 确保在9641工作的生命周期内尽快完成i2c任务~~
~~**工具路径**:[nicsensor_s.sh](./nicsensor_s.sh)~~
## 5_关于nicsensor_v2
nicsensor_v2将服务器选通channel和读取传感器数值的功能解耦, 因此在单独使用某个功能时可以直接找到对应的脚本进行测试。
详见[nicsensor_v2](./nicsensor_v2/readme.md)
## 6_附录
### 6_1_Project变量说明
> [!important]
> 对于所有传感器的`xxx_Channel_name`, 将其配置为`disable`即可跳过对应的channel的数据解析。
> 推荐在硬件上空置的Channel将其配置为 `disable`,防止脚本解析数据时出现混淆
**ADC128**相关
| 变量 | 定义 |
| -------------------------- | ----------------------------------- |
| `votage_division_factor_0` | ADC128芯片Channel 0的分压系数 |
| `votage_division_factor_1` | ADC128芯片Channel 1的分压系数 |
| `votage_division_factor_2` | ADC128芯片Channel 2的分压系数 |
| `votage_division_factor_3` | ADC128芯片Channel 3的分压系数 |
| `votage_division_factor_4` | ADC128芯片Channel 4的分压系数 |
| `votage_division_factor_5` | ADC128芯片Channel 5的分压系数 |
| `votage_division_factor_6` | ADC128芯片Channel 6的分压系数 |
| `votage_division_factor_7` | ADC128芯片Channel 7的分压系数 |
| `ADC128_Channel0_name` | 定制化ADC128芯片Channel 0的电压名称 |
| `ADC128_Channel1_name` | 定制化ADC128芯片Channel 1的电压名称 |
| `ADC128_Channel2_name` | 定制化ADC128芯片Channel 2的电压名称 |
| `ADC128_Channel3_name` | 定制化ADC128芯片Channel 3的电压名称 |
| `ADC128_Channel4_name` | 定制化ADC128芯片Channel 4的电压名称 |
| `ADC128_Channel5_name` | 定制化ADC128芯片Channel 5的电压名称 |
| `ADC128_Channel6_name` | 定制化ADC128芯片Channel 6的电压名称 |
| `ADC128_Channel7_name` | 定制化ADC128芯片Channel 7的电压名称 |
**INA3221**相关
| 变量 | 定义 |
| ----------------------- | ----------------------------------------------------- |
| `shunt_resistor_0` | INA3221芯片的Channel 0外接的分流电阻的大小(单位:毫欧) |
| `shunt_resistor_1` | INA3221芯片的Channel 1外接的分流电阻的大小(单位:毫欧) |
| `shunt_resistor_2` | INA3221芯片的Channel 2外接的分流电阻的大小(单位:毫欧) |
| `INA3221_Channel0_name` | 定制化INA3221芯片Channel 0的名称 |
| `INA3221_Channel1_name` | 定制化INA3221芯片Channel 1的名称 |
| `INA3221_Channel2_name` | 定制化INA3221芯片Channel 2的名称 |
**EMC1413**相关
| 变量 | 定义 |
| ----------------------- | ------------------------------------ |
| `EMC1413_Channel0_name` | 定制化EMC1413芯片Channel 0的温度名称 |
| `EMC1413_Channel1_name` | 定制化EMC1413芯片Channel 1的温度名称 |
| `EMC1413_Channel2_name` | 定制化EMC1413芯片Channel 2的温度名称 |
**TMP468**相关
| 变量 | 定义 |
| ---------------------- | ----------------------------------------- |
| `TMP468_Channel0_name` | 定制化TMP468芯片Loacl Channel的温度名称 |
| `TMP468_Channel1_name` | 定制化TMP468芯片Remote1 Channel的温度名称 |
| `TMP468_Channel2_name` | 定制化TMP468芯片Remote2 Channel的温度名称 |
| `TMP468_Channel3_name` | 定制化TMP468芯片Remote3 Channel的温度名称 |
| `TMP468_Channel4_name` | 定制化TMP468芯片Remote4 Channel的温度名称 |
| `TMP468_Channel5_name` | 定制化TMP468芯片Remote5 Channel的温度名称 |
| `TMP468_Channel6_name` | 定制化TMP468芯片Remote6 Channel的温度名称 |
| `TMP468_Channel7_name` | 定制化TMP468芯片Remote7 Channel的温度名称 |
| `TMP468_Channel8_name` | 定制化TMP468芯片Remote8 Channel的温度名称 |
**TMP112**相关
| 变量 | 定义 |
| -------------------- | ---------------------- |
| `TMP112_Sensor_name` | 定制化TMP112对应的名称 |
**INA226**相关
| 变量 | 定义 |
| ---------------------- | ------------------------------- |
| `INA226_Channel0_name` | 定制化INA226芯片Channel 0的名称 |
**LM95241**相关
| 变量 | 定义 |
| ---------------------- | ------------------------------------------ |
| `LM95241_Local_name` | 定制化LM95241芯片Loacl Channel的温度名称 |
| `LM95241_Remote1_name` | 定制化LM95241芯片Remote1 Channel的温度名称 |
| `LM95241_Remote2_name` | 定制化LM95241芯片Remote2 Channel的温度名称 |

57
setup.sh Normal file

@ -0,0 +1,57 @@
#!/bin/sh
# Script Description:
# This script is used to auto setup the nicsensor tool and its extensions.
SCRIPT_VERSION="1.0.0"
SUPPORT_TOOL_VERSION="1.11"
# Default values
source_extension_dir="./extension"
destination_tool_dir="/extlog/nicsensor"
destination_extension_dir="/extlog/nicsensor/extension"
exec_path="/extlog/nicsensor/nicsensor.sh"
# PRINT SCRIPT INFO
echo "=== Nicsensor Quick Setup Script! ==="
echo "Setup Tool Version : $SCRIPT_VERSION"
echo "Support nicsensor tool Version : $SUPPORT_TOOL_VERSION"
# Check if the destination extension directory exists, if not, create it
if [ ! -d "$destination_extension_dir" ]; then
echo "Step 0 : Create directory $destination_extension_dir"
mkdir -p "$destination_extension_dir"
fi
# Get script Path
script_dir=$(pwd)
source_extension_dir="$script_dir/extension"
# check if the source extension directory exists, if not, exit
if [ ! -d "$source_extension_dir" ]; then
echo "Error : Source extension directory $source_extension_dir does not exist"
exit 1
fi
# copy the extension files to the destination directory
echo "Step 1 : Copy extension files to $destination_extension_dir"
cp -rf "$source_extension_dir"/* "$destination_extension_dir"
# Add execute permission for extension files
echo "Step 2 : Add execute permission for extension files"
chmod +x "$destination_extension_dir"/*
# copy the project config to the destination directory
echo "Step 3 : Copy project.config to $destination_tool_dir"
cp -f "./project.config" "$destination_tool_dir"
# copy the exec file to the destination directory
echo "Step 4 : Copy nicsensor to $exec_path"
cp -f "./nicsensor.sh" "$exec_path"
# Add execute permission for exec file
echo "Step 5 : Add execute permission for nicsensor"
chmod +x "$exec_path"
echo "Complete auto setup nicsensor tool and its extensions."

Binary file not shown.

@ -0,0 +1,23 @@
#!/bin/sh
# Get file conut first
file_num=`ls -l | wc -l`
i=2
while true
do
i=$(($i+1))
# Get filename by ls and awk
file=`ls -l | awk -v cnt=$i 'NR==cnt{print $9}'`
cmd="chmod +x $file"
echo "File ID: $i , $cmd"
# perform chmod
$cmd
if [ $i -eq $file_num ];then
echo "Done to add exec auth for every file"
break
fi
done

@ -0,0 +1,19 @@
#!/bin/sh
logfile="/tmp/nicsensor_debug.log"
direction=$1
level=$2
content=$3
case "${direction}" in
"console")
echo ">>> [$level] : $content"
;;
"log")
echo "[$level] : $content" >> $logfile
;;
*)
echo "Error In format_print.sh! Param : $direction"
;;
esac

@ -0,0 +1,20 @@
#!/bin/sh
i2c_bus=$1
wc=$2
slave=$3
data=$4
rc=$5
path=`pwd`
fmt_print="${path}/format_print.sh"
if [ $rc -eq 0 ];then
cmd=`i2c-test -b $i2c_bus -s $slave -w -d $data`
else
cmd=`i2c-test -b $i2c_bus -s $slave -m 1 -rc $rc -d $data | awk 'NR==2{for(i=1;i<=NF;i++){printf("0x%s ",$i)}}'`
fi
$fmt_print "log" "Info" "[M6 i2c Command]: $cmd"
$cmd

@ -0,0 +1,19 @@
#!/bin/sh
i2c_bus=$1
wc=$2
slave=$3
data=$4
rc=$5
path=`pwd`
fmt_print="${path}/format_print.sh"
if [ $rc -eq 0 ];then
cmd="i2ctransfer -y $i2c_bus w$wc@$slave $data"
else
cmd="i2ctransfer -y $i2c_bus w$wc@$slave $data r$5"
fi
$fmt_print "log" "Info" "[M7 i2c Command]: $cmd"
$cmd

@ -0,0 +1,171 @@
#!/bin/sh
script_version="v2.0"
default_server_type="5688m7"
server_platform="m7"
slot_name=$1
sensor_type=$2
chip_slave=$3
param_num=$#
nic_type=""
slot_id=""
server_type=""
path=`pwd`
server_script=""
sensor_script=""
i2c_script="${path}/i2c_${server_platform}.sh"
fmt_print="${path}/format_print.sh"
# According to boardid, parse server_type
# Only valid on Gen 7 series
try_get_server_type(){
if [ -e "/tmp/ns_servertype" ];then
server_type=`cat /tmp/ns_servertype`
else
boardid=`cat /proc/cmdline | awk -F 'boardid=' '{split($2, a," "); print a[1]}'`
if [ "$boardid" = "" ];then
server_type=$default_server_type
return
fi
if [ $boardid -eq 130 ];then
server_type="5280m7"
elif [ $boardid -eq 150 ];then
server_type="5468m7"
elif [ $boardid -eq 152 ];then
server_type="5688m7"
else
server_type=$default_server_type
exit 1
fi
echo $server_type > /tmp/ns_servertype
fi
}
script_info_load(){
path=`pwd`
server_script="${path}/platform_${server_type}.sh"
sensor_script="${path}/plugin_${sensor_type}.sh"
}
print_helper(){
echo "======>>> nicsensor Scirpt Usage <<<======"
echo "Genenral Usage : ./nicsensor.sh [slot] [sensor] [i2c slave]"
echo "For Detect : ./nicsensor.sh detect [ocp/pcie]"
echo "Current Server : $server_type"
echo "Script Version : $script_version"
}
perform_detect(){
if [ ! -e $server_script ];then
$fmt_print "console" "Error" "Server Script $server_script not exist! Maybe unsupport for now!"
exit 1
fi
$server_script "detect"
}
conf_pre_check(){
if [ $param_num -lt 1 ];then
print_helper
exit 0
fi
if [ ! -e $fmt_print ];then
echo "Missing file $fmt_print !!!"
exit 1
fi
if [ ! -e $server_script ];then
$fmt_print "console" "Error" "Server Script $server_script not exist! Maybe unsupport for now!"
exit 1
fi
# If action is detect , skip this check
if [ $param_num -gt 3 ];then
if [ ! -e $sensor_script ];then
$fmt_print "console" "Error" "Sensor Script $sensor_script not exist! Maybe unsupport for now!"
exit 1
fi
fi
if [ ! -e $i2c_script ];then
$fmt_print "console" "Error" "$i2c_script not exist!"
exit 1
fi
res_date=`date +%Y-%m-%dT%H:%M:%S`
$fmt_print "log" "Info" "Start Time : $res_date"
$fmt_print "log" "Info" "Script Version : $script_version"
$fmt_print "log" "Info" "Server Type : $server_type"
$fmt_print "log" "Info" "Slot Name : $slot_name"
}
parse_slot_name(){
# Get nic type and slot id from slot name
case "${slot_name}" in
ocp*)
nic_type="ocp"
slot_id=`echo $slot_name | cut -c 4`
;;
pcie*)
nic_type="pcie"
slot_id=`echo $slot_name | cut -c 5-`
;;
*)
$fmt_print "log" "Warning" "Undetermined nic type, default set to pcie"
nic_type="pcie"
slot_id=$slot_name
;;
esac
}
connect_i2c(){
$server_script "connect" "$nic_type" "$slot_id"
if [ $? -ne 0 ];then
$fmt_print "console" "Error" "Can't build i2c connection"
exit 1
fi
}
start_sensor_reading(){
$fmt_print "log" "Info" "start sensor reading"
$sensor_script "read" "${i2c_bus}" "${chip_slave}" "${server_platform}" "${server_type}"
}
pre_exec_hook(){
# init debug log
if [ -e "/tmp/nicsensor_debug.log" ];then
rm /tmp/nicsensor_debug.log
fi
try_get_server_type
script_info_load
conf_pre_check
}
# ---------------------------------------------------------
# Start Execute Script
# ---------------------------------------------------------
pre_exec_hook
# check if is detect option
if [ "$1" = "detect" ];then
perform_detect
exit 0
fi
parse_slot_name
i2c_bus=`connect_i2c`
if [ $i2c_bus -lt 0 ];then
$fmt_print "console" "Error" "An Error occured when build i2c connection with ${nic_type} ${slot_id}"
exit 1
fi
start_sensor_reading

@ -0,0 +1,208 @@
#!/bin/sh
action=$1
nic_type=$2
slot_id=$3
# Param: i2c_command only valid for function 'send'
i2c_command=$4
path=`pwd`
i2c_script="${path}/i2c_m7.sh"
fmt_print="${path}/format_print.sh"
pca9548_slave=""
pca9641_slave=""
i2c_bus=""
pca9548_channel=""
is_have_pca9641=0
# An func to echo a error code and then exit
# @Param1 error code
throw_error(){
echo $1
exit 1
}
record_i2c_status(){
$fmt_print "log" "Info" "[platform_5280m7] Start record i2c configuration"
$fmt_print "log" "Info" "Nic Type: $nic_type"
$fmt_print "log" "Info" "Nic slot: $slot_id"
$fmt_print "log" "Info" "i2c bus: $i2c_bus"
$fmt_print "log" "Info" "is have pca9641: $is_have_pca9641"
$fmt_print "log" "Info" "pca9641 slave: $is_have_pca9641"
$fmt_print "log" "Info" "pca9548 slave: $pca9548_slave"
$fmt_print "log" "Info" "pca9548 channel: $pca9548_channel"
}
set_i2c_config(){
# set pca9641 address && I2C BUS
if [ "${nic_type}" == "ocp" ];then
is_have_pca9641=0
pca9548_slave="0x70"
i2c_bus=3
else
is_have_pca9641=1
if [ $slot_id -le 2 ];then
pca9641_slave="0x41"
pca9548_slave="0x72"
i2c_bus=12
else
pca9641_slave="0x42"
pca9548_slave="0x72"
i2c_bus=13
fi
fi
# set pca9548 switch channel
if [ "${nic_type}" == "ocp" ];then
if [ $slot_id -eq 0 ];then
pca9548_channel="0x01"
elif [ $slot_id -eq 1 ];then
pca9548_channel="0x02"
elif [ $slot_id -eq 2 ];then
pca9548_channel="0x04"
else
$fmt_print "console" "Warning" "Unspecified card slot!"
fi
else
if [ $slot_id -eq 0 ];then
pca9548_channel="0x02"
elif [ $slot_id -eq 1 ];then
pca9548_channel="0x04"
elif [ $slot_id -eq 2 ];then
pca9548_channel="0x08"
elif [ $slot_id -eq 3 ];then
pca9548_channel="0x02"
elif [ $slot_id -eq 4 ];then
pca9548_channel="0x04"
elif [ $slot_id -eq 5 ];then
pca9548_channel="0x08"
else
$fmt_print "console" "Warning" "Unspecified card slot!"
fi
fi
record_i2c_status
}
get_pca9641_control(){
$fmt_print "log" "Info" "[platform_5280m7] Start Get pca9641 control"
# Request 9641 lock
res_lock=`i2ctransfer -y $i2c_bus w2@$pca9641_slave 0x01 0x81 r1`
$fmt_print "log" "Info" "[platform_5280m7] After request 9641 lock, The REG value is $res_lock"
# Build 9641 Connection
res_build=`i2ctransfer -y $i2c_bus w2@$pca9641_slave 0x01 0x85 r1`
$fmt_print "log" "Info" "[platform_5280m7] After Build 9641 connection, The REG value is $res_build"
if [ "$res_build" != "0x87" ];then
$fmt_print "console" "Error" "Cannot establish connection with pca9641 !!!"
throw_error "-1"
fi
}
select_pca9548_channel(){
$fmt_print "log" "Info" "[platform_5280m7] Start Switch PCA9548"
$i2c_script "$i2c_bus" 1 "$pca9548_slave" "$pca9548_channel" 0
}
build_i2c_connect(){
$fmt_print "log" "Info" "[platform_5280m7] Start build i2c connect"
set_i2c_config
if [ $is_have_pca9641 -eq 1 ];then
get_pca9641_control
fi
select_pca9548_channel
echo "$i2c_bus"
}
# switch pca9548 channels then do i2cdetect one times
# @Param1 i2c bus number
# @Param2 pca9548 slave address
# @Param3 pca9548 channel hex value
# @Param4 pca9548 channel
# @Param5 pcie slot number
do_i2c_detect(){
if [ "${nic_type}" == "ocp" ];then
$fmt_print "console" "Info" "OCP slot $5 : bus$1 9548channel$4"
else
$fmt_print "console" "Info" "PCIe slot $5 : bus$1 9548channel$4"
fi
i2ctransfer -y $1 w1@$2 $3
i2cdetect -y $1
}
detect_on_server(){
$fmt_print "console" "Info" "[platform_5280m7] Start i2c detect"
if [ "${nic_type}" == "ocp" ];then
i2c_bus=3
do_i2c_detect 3 0x70 0x01 0 0
do_i2c_detect 3 0x70 0x02 1 1
do_i2c_detect 3 0x70 0x04 2 2
i2ctransfer -y 3 w1@0x70 0x00
else
i2c_bus=12
pca9641_slave="0x41"
get_pca9641_control
do_i2c_detect 12 0x72 0x02 1 0
do_i2c_detect 12 0x72 0x04 2 1
do_i2c_detect 12 0x72 0x08 3 2
i2ctransfer -y 12 w1@0x72 0x00
i2c_bus=13
pca9641_slave="0x42"
get_pca9641_control
do_i2c_detect 13 0x72 0x02 1 3
do_i2c_detect 13 0x72 0x04 2 4
do_i2c_detect 13 0x72 0x08 3 5
i2ctransfer -y 13 w1@0x72 0x00
fi
}
reset_all_pca9548(){
$fmt_print "log" "Info" "[platform_5280m7] Bypass reset pca9548"
}
send_i2c_command(){
$fmt_print "log" "Info" "[platform_5280m7] Send an i2c command"
set_i2c_config
if [ $is_have_pca9641 -eq 1 ];then
get_pca9641_control
fi
select_pca9548_channel
$i2c_command
}
# ---------------------------------------------------
# Start Execute Script
# ---------------------------------------------------
case "${action}" in
"connect")
build_i2c_connect
;;
"detect")
detect_on_server
;;
"reset")
reset_all_pca9548
;;
"send")
send_i2c_command
;;
*)
$fmt_print "console" "Error" "[platform_5280m7] Unspecified Operation : $action"
exit 1
;;
esac
exit 0

@ -0,0 +1,197 @@
#!/bin/sh
action=$1
nic_type=$2
slot_id=$3
# Param: i2c_command only valid for function 'send'
i2c_command=$4
path=`pwd`
i2c_script="${path}/i2c_m7.sh"
fmt_print="${path}/format_print.sh"
pca9548_slave=""
pca9641_slave=""
i2c_bus=""
pca9548_channel=""
is_have_pca9641=0
# An func to echo a error code and then exit
# @Param1 error code
throw_error(){
echo $1
exit 1
}
record_i2c_status(){
$fmt_print "log" "Info" "[platform_5688m7] Start record i2c configuration"
$fmt_print "log" "Info" "Nic Type: $nic_type"
$fmt_print "log" "Info" "Nic slot: $slot_id"
$fmt_print "log" "Info" "i2c bus: $i2c_bus"
$fmt_print "log" "Info" "is have pca9641: $is_have_pca9641"
$fmt_print "log" "Info" "pca9641 slave: $is_have_pca9641"
$fmt_print "log" "Info" "pca9548 slave: $pca9548_slave"
$fmt_print "log" "Info" "pca9548 channel: $pca9548_channel"
}
set_i2c_config(){
# set pca9641 address && I2C BUS
if [ "${nic_type}" == "ocp" ];then
$fmt_print "console" "Error" "[platform_5688m7] Unsupport OCP Nic"
exit 1
else
is_have_pca9641=1
i2c_bus=12
pca9641_slave="0x31"
if [ $slot_id -le 3 ];then
pca9548_slave="0x71"
else
pca9548_slave="0x72"
fi
fi
# set pca9548 switch channel
if [ "${nic_type}" == "ocp" ];then
$fmt_print "console" "Error" "[platform_5688m7] Unsupport OCP Nic"
exit 1
else
if [ $slot_id -eq 0 ];then
pca9548_channel="0x01"
elif [ $slot_id -eq 1 ];then
pca9548_channel="0x02"
elif [ $slot_id -eq 2 ];then
pca9548_channel="0x04"
elif [ $slot_id -eq 3 ];then
pca9548_channel="0x08"
elif [ $slot_id -eq 4 ];then
pca9548_channel="0x01"
elif [ $slot_id -eq 5 ];then
pca9548_channel="0x02"
elif [ $slot_id -eq 6 ];then
pca9548_channel="0x04"
elif [ $slot_id -eq 7 ];then
pca9548_channel="0x08"
else
$fmt_print "console" "Warning" "Unspecified card slot!"
fi
fi
record_i2c_status
}
get_pca9641_control(){
$fmt_print "log" "Info" "[platform_5688m7] Start Get pca9641 control"
# Request 9641 lock
res_lock=`i2ctransfer -y $i2c_bus w2@$pca9641_slave 0x01 0x81 r1`
$fmt_print "log" "Info" "[platform_5688m7] After request 9641 lock, The REG value is $res_lock"
# Build 9641 Connection
res_build=`i2ctransfer -y $i2c_bus w2@$pca9641_slave 0x01 0x85 r1`
$fmt_print "log" "Info" "[platform_5688m7] After Build 9641 connection, The REG value is $res_build"
if [ "$res_build" != "0x87" ];then
$fmt_print "console" "Error" "Cannot establish connection with pca9641 !!!"
throw_error "-1"
fi
}
select_pca9548_channel(){
$fmt_print "log" "Info" "[platform_5688m7] Start Switch PCA9548"
$i2c_script "$i2c_bus" 1 "$pca9548_slave" "$pca9548_channel" 0
}
build_i2c_connect(){
$fmt_print "log" "Info" "[platform_5688m7] Start build i2c connect"
set_i2c_config
if [ $is_have_pca9641 -eq 1 ];then
get_pca9641_control
fi
select_pca9548_channel
echo "$i2c_bus"
}
# switch pca9548 channels then do i2cdetect one times
# @Param1 i2c bus number
# @Param2 pca9548 slave address
# @Param3 pca9548 channel hex value
# @Param4 pca9548 channel
# @Param5 pcie slot number
do_i2c_detect(){
if [ "${nic_type}" == "ocp" ];then
$fmt_print "console" "Info" "OCP slot $5 : bus$1 9548channel$4"
else
$fmt_print "console" "Info" "PCIe slot $5 : bus$1 9548channel$4"
fi
i2ctransfer -y $1 w1@$2 $3
i2cdetect -y $1
}
detect_on_server(){
$fmt_print "console" "Info" "[platform_5688m7] Start i2c detect"
if [ "${nic_type}" == "ocp" ];then
$fmt_print "console" "Error" "[platform_5688m7] Unsupport OCP Nic I2C Detect"
else
i2c_bus=12
pca9641_slave="0x31"
get_pca9641_control
do_i2c_detect $i2c_bus 0x71 0x01 0 0
do_i2c_detect $i2c_bus 0x71 0x02 1 1
do_i2c_detect $i2c_bus 0x71 0x04 2 2
do_i2c_detect $i2c_bus 0x71 0x08 3 3
i2ctransfer -y $i2c_bus w1@0x71 0x00
do_i2c_detect $i2c_bus 0x72 0x01 0 4
do_i2c_detect $i2c_bus 0x72 0x02 1 5
do_i2c_detect $i2c_bus 0x72 0x04 2 6
do_i2c_detect $i2c_bus 0x72 0x08 3 7
i2ctransfer -y $i2c_bus w1@0x72 0x00
fi
}
reset_all_pca9548(){
i2ctransfer -y 12 w1@0x71 0x00
i2ctransfer -y 12 w1@0x72 0x00
}
send_i2c_command(){
$fmt_print "log" "Info" "[platform_5280m7] Send an i2c command"
set_i2c_config
if [ $is_have_pca9641 -eq 1 ];then
get_pca9641_control
fi
select_pca9548_channel
$i2c_command
}
# ---------------------------------------------------
# Start Execute Script
# ---------------------------------------------------
case "${action}" in
"connect")
build_i2c_connect
;;
"detect")
detect_on_server
;;
"reset")
reset_all_pca9548
;;
"send")
send_i2c_command
;;
*)
$fmt_print "console" "Error" "[platform_5688m7] Unspecified Operation : $action"
exit 1
;;
esac
exit 0

@ -0,0 +1,176 @@
#!/bin/sh
# ADC128 Division factor
votage_division_factor_0="1"
votage_division_factor_1="1"
votage_division_factor_2="1"
votage_division_factor_3="0.8"
votage_division_factor_4="0.6"
votage_division_factor_5="0.6"
votage_division_factor_6="0.2326"
votage_division_factor_7="1"
# ADC128 channel name
ADC128_Channel0_name="Channel0"
ADC128_Channel1_name="Channel1"
ADC128_Channel2_name="Channel2"
ADC128_Channel3_name="Channel3"
ADC128_Channel4_name="Channel4"
ADC128_Channel5_name="Channel5"
ADC128_Channel6_name="Channel6"
ADC128_Channel7_name="Channel7"
mode=$1
i2c_bus=$2
chip_slave=$3
server_platform=$4
server_type=$5
# Only for test purpose
test_data1=$2
test_data2=$3
test_factor=$4
path=`pwd`
fmt_print="${path}/format_print.sh"
i2c_script="${path}/i2c_${server_platform}.sh"
server_script="${path}/platform_${server_type}.sh"
REG_adc128_config="0x00"
REG_adc128_advance="0x0b"
REG_adc128_status="0x0c"
REG_adc128_ch0="0x20"
REG_adc128_ch1="0x21"
REG_adc128_ch2="0x22"
REG_adc128_ch3="0x23"
REG_adc128_ch4="0x24"
REG_adc128_ch5="0x25"
REG_adc128_ch6="0x26"
REG_adc128_ch7="0x27"
print_help(){
echo "---------------------------------------------------------"
echo "<option> read"
echo " Format : ./plugin_adc128.sh read [i2c-bus] [slave] [platform]"
echo " Example: ./plugin_adc128.sh read 13 0x1f m7"
echo "---------------------------------------------------------"
echo "<option> test"
echo " Format : ./plugin_adc128.sh test [data1] [data2] [factor]"
echo " Example: ./plugin_adc128.sh test 0xc7 0x00 0.6"
echo "---------------------------------------------------------"
echo "<option> help"
echo " Format : ./plugin_adc128.sh help"
echo " Example: ./plugin_adc128.sh help"
echo "---------------------------------------------------------"
}
# adc128 chip init if need
check_adc128_init(){
# Get Reg 0x00 status
res_adc128_status=`$i2c_script $i2c_bus 1 $chip_slave $REG_adc128_config 1`
# format_log_print $INFO "REG adc128 STATUS : $res_adc128_status"
$fmt_print "log" "Info" "[plugin_adc128] REG adc128 STATUS : $res_adc128_status"
# if stauts is not 0x01 (Start Monitor) ,then do init
if [ "$res_adc128_status" != "0x01" ];then
$fmt_print "log" "Info" "[plugin_adc128] Start Init ADC128 Chip"
# Init ADC128 work as mode 1 (0x02)
res_adc128_advance=`$i2c_script $i2c_bus 2 $chip_slave "$REG_adc128_advance 0x02" 0`
# Set ADC128 on start (0x01)
res_adc128_setstart=`$i2c_script $i2c_bus 2 $chip_slave "$REG_adc128_config 0x01" 1`
$fmt_print "log" "Info" "[plugin_adc128] After Set status, the REG 0x00 value is $res_adc128_setstart "
fi
}
# process sensor data then print to console
# @Param 1 adc128 data high 8bit
# @Param 2 adc128 data low 8bit
# @Param 3 customization channel name
# @Param 4 division factor
convert_adc128_data(){
if [ "$3" = "disable" ];then
return
fi
# remove data prefix '0x'
hex_value1=$(echo "$1" | awk '{sub(/^0x/,""); print}')
hex_value2=$(echo "$2" | awk '{sub(/^0x/,""); print}')
merge_value="${hex_value1}${hex_value2}"
# bc calculator recognized upper case only, change data to upper case
upper_hex_value=$(echo "$merge_value" | awk '{
for(i=1; i<=length($0); i++){
if(tolower(substr($0,i,1)) ~ /^[a-f]$/)
printf toupper(substr($0,i,1));
else
printf substr($0,i,1);
}
print ""
}')
# calculate dec value then print it to console
dec_val=$(echo "ibase=16; $upper_hex_value" | bc)
volt=$(echo "scale=4; $dec_val / 16 / 4096 * 2.65 / $4" | bc)
format_volt=$(echo "$volt" | awk '{ if ($0 ~ /^\./) print "0" $0; else print $0 }')
echo "$3 : $format_volt v, hex value: $upper_hex_value"
}
read_adc128_data(){
# check if chip adc128 need init
check_adc128_init
res_ch0=`$i2c_script $i2c_bus 1 $chip_slave $REG_adc128_ch0 2`
res_ch1=`$i2c_script $i2c_bus 1 $chip_slave $REG_adc128_ch1 2`
res_ch2=`$i2c_script $i2c_bus 1 $chip_slave $REG_adc128_ch2 2`
res_ch3=`$i2c_script $i2c_bus 1 $chip_slave $REG_adc128_ch3 2`
res_ch4=`$i2c_script $i2c_bus 1 $chip_slave $REG_adc128_ch4 2`
res_ch5=`$i2c_script $i2c_bus 1 $chip_slave $REG_adc128_ch5 2`
res_ch6=`$i2c_script $i2c_bus 1 $chip_slave $REG_adc128_ch6 2`
res_ch7=`$i2c_script $i2c_bus 1 $chip_slave $REG_adc128_ch7 2`
# After read option , reset pca9548
$server_script reset
# record i2c raw data to log
$fmt_print "log" "Info" "[plugin_adc128] channel0 : $res_ch0"
$fmt_print "log" "Info" "[plugin_adc128] channel1 : $res_ch1"
$fmt_print "log" "Info" "[plugin_adc128] channel2 : $res_ch2"
$fmt_print "log" "Info" "[plugin_adc128] channel3 : $res_ch3"
$fmt_print "log" "Info" "[plugin_adc128] channel4 : $res_ch4"
$fmt_print "log" "Info" "[plugin_adc128] channel5 : $res_ch5"
$fmt_print "log" "Info" "[plugin_adc128] channel6 : $res_ch6"
$fmt_print "log" "Info" "[plugin_adc128] channel7 : $res_ch7"
# start parse raw data
$fmt_print "console" "Info" "The ADC128 value is :"
convert_adc128_data $res_ch0 "$ADC128_Channel0_name" $votage_division_factor_0
convert_adc128_data $res_ch1 "$ADC128_Channel1_name" $votage_division_factor_1
convert_adc128_data $res_ch2 "$ADC128_Channel2_name" $votage_division_factor_2
convert_adc128_data $res_ch3 "$ADC128_Channel3_name" $votage_division_factor_3
convert_adc128_data $res_ch4 "$ADC128_Channel4_name" $votage_division_factor_4
convert_adc128_data $res_ch5 "$ADC128_Channel5_name" $votage_division_factor_5
convert_adc128_data $res_ch6 "$ADC128_Channel6_name" $votage_division_factor_6
convert_adc128_data $res_ch7 "$ADC128_Channel7_name" $votage_division_factor_7
}
test_adc128_value(){
convert_adc128_data $test_data1 $test_data2 "Volt" $test_factor
}
case "${mode}" in
"read")
read_adc128_data
;;
"test")
test_adc128_value
;;
"help")
print_help
;;
*)
$fmt_print "console" "Error" "[plugin_adc128]Unexpected Input Param : $mode"
print_help
;;
esac

@ -0,0 +1,130 @@
#!/bin/sh
mode=$1
i2c_bus=$2
chip_slave=$3
server_platform=$4
server_type=$5
test_data1=$2
test_data2=$3
path=`pwd`
fmt_print="${path}/format_print.sh"
i2c_script="${path}/i2c_${server_platform}.sh"
server_script="${path}/platform_${server_type}.sh"
# EMC1413 channel name
EMC1413_Channel0_name="Channel0"
EMC1413_Channel1_name="Channel1"
EMC1413_Channel2_name="Channel2"
REG_emc1413_TD1_H="0x00"
REG_emc1413_TD1_L="0x29"
REG_emc1413_TD2_H="0x01"
REG_emc1413_TD2_L="0x10"
REG_emc1413_TD3_H="0x23"
REG_emc1413_TD3_L="0x24"
print_help(){
echo "---------------------------------------------------------"
echo "<option> read"
echo " Format : ./plugin_emc1413.sh read [i2c-bus] [slave] [platform]"
echo " Example: ./plugin_emc1413.sh read 13 0x42 m7"
echo "---------------------------------------------------------"
echo "<option> test"
echo " Format : ./plugin_emc1413.sh test [data1] [data2]"
echo " Example: ./plugin_emc1413.sh test 0x24 0x00"
echo "---------------------------------------------------------"
echo "<option> help"
echo " Format : ./plugin_emc1413.sh help"
echo " Example: ./plugin_emc1413.sh help"
echo "---------------------------------------------------------"
}
# @Param1 emc1413 data high 8bit
# @Param2 emc1413 data low 8bit
# @Param3 customization channel name
convert_emc1413_data(){
if [ "$3" = "disable" ];then
return
fi
# remove data prefix '0x'
hex_value1=$(echo "$1" | awk '{sub(/^0x/,""); print}')
hex_value2=$(echo "$2" | awk '{sub(/^0x/,""); print}')
# bc calculator recognized upper case only, change data to upper case
upper_hex_value1=$(echo "$hex_value1" | awk '{
for(i=1; i<=length($0); i++){
if(tolower(substr($0,i,1)) ~ /^[a-f]$/)
printf toupper(substr($0,i,1));
else
printf substr($0,i,1);
}
print ""
}')
upper_hex_value2=$(echo "$hex_value2" | awk '{
for(i=1; i<=length($0); i++){
if(tolower(substr($0,i,1)) ~ /^[a-f]$/)
printf toupper(substr($0,i,1));
else
printf substr($0,i,1);
}
print ""
}')
# change data from hex to dec
dec_value1=$(echo "ibase=16; $upper_hex_value1" | bc)
dec_value2=$(echo "ibase=16; $upper_hex_value2" | bc)
# calculate tempreture
temp=$(echo "scale=4; $dec_value1 + ($dec_value2 / 32 * 0.125 )" | bc)
# print result to consol
format_temp=$(echo "$temp" | awk '{ if ($0 ~ /^\./) print "0" $0; else print $0 }')
echo "$3 : $format_temp C, hex value : $hex_value1 $hex_value2"
}
read_emc1413_data(){
res_td1_h=`$i2c_script $i2c_bus 1 $chip_slave $REG_emc1413_TD1_H 1`
res_td1_l=`$i2c_script $i2c_bus 1 $chip_slave $REG_emc1413_TD1_L 1`
res_td2_h=`$i2c_script $i2c_bus 1 $chip_slave $REG_emc1413_TD2_H 1`
res_td2_l=`$i2c_script $i2c_bus 1 $chip_slave $REG_emc1413_TD2_L 1`
res_td3_h=`$i2c_script $i2c_bus 1 $chip_slave $REG_emc1413_TD3_H 1`
res_td3_l=`$i2c_script $i2c_bus 1 $chip_slave $REG_emc1413_TD3_L 1`
# After read option , reset pca9548
$server_script reset
$fmt_print "log" "Info" "[plugin_emc1413] TD1 : $res_td1_h $res_td1_l"
$fmt_print "log" "Info" "[plugin_emc1413] TD2 : $res_td2_h $res_td2_l"
$fmt_print "log" "Info" "[plugin_emc1413] TD3 : $res_td3_h $res_td3_l"
$fmt_print "console" "Info" "The EMC1413 value is :"
convert_emc1413_data $res_td1_h $res_td1_l "$EMC1413_Channel0_name"
convert_emc1413_data $res_td2_h $res_td2_l "$EMC1413_Channel1_name"
convert_emc1413_data $res_td3_h $res_td3_l "$EMC1413_Channel2_name"
}
test_emc1413_data(){
convert_emc1413_data $test_data1 $test_data2 "Temp"
}
case "${mode}" in
"read")
read_emc1413_data
;;
"test")
test_emc1413_data
;;
"help")
print_help
;;
*)
$fmt_print "console" "Error" "[plugin_emc1413]Unexpected Input Param : $mode"
print_help
;;
esac

@ -0,0 +1,192 @@
#!/bin/sh
mode=$1
i2c_bus=$2
chip_slave=$3
server_platform=$4
server_type=$5
test_data1=$2
test_data2=$3
test_resistor=$4
path=`pwd`
fmt_print="${path}/format_print.sh"
i2c_script="${path}/i2c_${server_platform}.sh"
server_script="${path}/platform_${server_type}.sh"
# INA3221 shunt resistor(unit: mohm)
shunt_resistor_0="2"
shunt_resistor_1="2"
shunt_resistor_2="5"
# INA3221 channel name
INA3221_Channel0_name="Channel0"
INA3221_Channel1_name="Channel1"
INA3221_Channel2_name="Channel2"
ina3221_ch0_volt="0"
ina3221_ch1_volt="0"
ina3221_ch2_volt="0"
ina3221_ch0_current="0"
ina3221_ch1_current="0"
ina3221_ch2_current="0"
REG_ina3221_ch1="0x01"
REG_ina3221_ch2="0x03"
REG_ina3221_ch3="0x05"
REG_ina3221_bus1="0x02"
REG_ina3221_bus2="0x04"
REG_ina3221_bus3="0x06"
INA3221_SHUNT_VOLT=0
INA3221_BUS_VOLT=1
INA3221_POWER=2
print_help(){
echo "---------------------------------------------------------"
echo "<option> read"
echo " Format : ./plugin_ina3221.sh read [i2c-bus] [slave] [platform]"
echo " Example: ./plugin_ina3221.sh read 13 0x1f m7"
echo "---------------------------------------------------------"
echo "<option> test"
echo " Format : ./plugin_ina3221.sh test [data1] [data2] [resistor]"
echo " Example: ./plugin_ina3221.sh test 0xc7 0x00 5"
echo "---------------------------------------------------------"
echo "<option> help"
echo " Format : ./plugin_ina3221.sh help"
echo " Example: ./plugin_ina3221.sh help"
echo "---------------------------------------------------------"
}
# @Param1 ina3221 data high 8bit
# @Param2 ina3221 data high 8bit
# @Param3 channel number
# @Param4 mode select 0 - shunt volt
# 1 - bus volt
# @Param5 shunt resistor(only used in mode shunt volt)
# @Param6 customization channel name
convert_ina3221_data(){
if [ "$6" = "disable" ];then
return
fi
hex_value1=$(echo "$1" | awk '{sub(/^0x/,""); print}')
hex_value2=$(echo "$2" | awk '{sub(/^0x/,""); print}')
merge_value="${hex_value1}${hex_value2}"
# bc calculator recognized upper case only, change data to upper case
upper_hex_value=$(echo "$merge_value" | awk '{
for(i=1; i<=length($0); i++){
if(tolower(substr($0,i,1)) ~ /^[a-f]$/)
printf toupper(substr($0,i,1));
else
printf substr($0,i,1);
}
print ""
}')
# change data from hex to dec
dec_val=$(echo "ibase=16; $upper_hex_value" | bc)
if [ $4 -eq $INA3221_BUS_VOLT ];then
volt=$(echo "scale=4; $dec_val / 8 * 40 / 10000 * 2" | bc)
format_volt=$(echo "$volt" | awk '{ if ($0 ~ /^\./) print "0" $0; else print $0 }')
echo "$6 : $format_volt V, hex value: $upper_hex_value"
if [ $3 -eq 0 ];then
ina3221_ch0_volt=$format_volt
elif [ $3 -eq 1 ];then
ina3221_ch1_volt=$format_volt
else
ina3221_ch2_volt=$format_volt
fi
elif [ $4 -eq $INA3221_SHUNT_VOLT ];then
current_mv=$(echo "scale=4; $dec_val / 8 * 40 / 1000" | bc)
current=$(echo "scale=4; $current_mv / $5" | bc)
format_current=$(echo "$current" | awk '{ if ($0 ~ /^\./) print "0" $0; else print $0 }')
format_current_mv=$(echo "$current_mv" | awk '{ if ($0 ~ /^\./) print "0" $0; else print $0 }')
echo "$6 : $format_current A, shunt volt: $format_current_mv mV, shunt resistor: $5 mOhm, hex value: $upper_hex_value"
if [ $3 -eq 0 ];then
ina3221_ch0_current=$format_current
elif [ $3 -eq 1 ];then
ina3221_ch1_current=$format_current
else
ina3221_ch2_current=$format_current
fi
elif [ $4 -eq $INA3221_POWER ];then
# calculate power
power_ch0=$(echo "scale=4; $ina3221_ch0_volt * $ina3221_ch0_current" | bc)
power_ch1=$(echo "scale=4; $ina3221_ch1_volt * $ina3221_ch1_current" | bc)
power_ch2=$(echo "scale=4; $ina3221_ch2_volt * $ina3221_ch2_current" | bc)
format_power_ch0=$(echo "$power_ch0" | awk '{ if ($0 ~ /^\./) print "0" $0; else print $0 }')
format_power_ch1=$(echo "$power_ch1" | awk '{ if ($0 ~ /^\./) print "0" $0; else print $0 }')
format_power_ch2=$(echo "$power_ch2" | awk '{ if ($0 ~ /^\./) print "0" $0; else print $0 }')
total_power=$(echo "scale=4; $power_ch0 + $power_ch1 + $power_ch2" | bc)
echo "$INA3221_Channel0_name : $format_power_ch0 W"
echo "$INA3221_Channel1_name : $format_power_ch1 W"
echo "$INA3221_Channel2_name : $format_power_ch2 W"
echo "total power: $total_power W"
fi
}
read_ina3221_data(){
res_ch0=`$i2c_script $i2c_bus 1 $chip_slave $REG_ina3221_ch1 2`
res_ch1=`$i2c_script $i2c_bus 1 $chip_slave $REG_ina3221_ch2 2`
res_ch2=`$i2c_script $i2c_bus 1 $chip_slave $REG_ina3221_ch3 2`
res_bus0=`$i2c_script $i2c_bus 1 $chip_slave $REG_ina3221_bus1 2`
res_bus1=`$i2c_script $i2c_bus 1 $chip_slave $REG_ina3221_bus2 2`
res_bus2=`$i2c_script $i2c_bus 1 $chip_slave $REG_ina3221_bus3 2`
# After read option , reset pca9548
$server_script reset
$fmt_print "log" "Info" "[plugin_ina3221] channel 0 shunt volt: $res_ch0"
$fmt_print "log" "Info" "[plugin_ina3221] channel 1 shunt volt: $res_ch1"
$fmt_print "log" "Info" "[plugin_ina3221] channel 2 shunt volt: $res_ch2"
$fmt_print "log" "Info" "[plugin_ina3221] channel 0 bus volt: $res_bus0"
$fmt_print "log" "Info" "[plugin_ina3221] channel 0 bus volt: $res_bus1"
$fmt_print "log" "Info" "[plugin_ina3221] channel 0 bus volt: $res_bus2"
$fmt_print "console" "Info" "The INA3221 shunt value is :"
convert_ina3221_data $res_ch0 0 $INA3221_SHUNT_VOLT $shunt_resistor_0 "$INA3221_Channel0_name"
convert_ina3221_data $res_ch1 1 $INA3221_SHUNT_VOLT $shunt_resistor_1 "$INA3221_Channel1_name"
convert_ina3221_data $res_ch2 2 $INA3221_SHUNT_VOLT $shunt_resistor_2 "$INA3221_Channel2_name"
$fmt_print "console" "Info" "The INA3221 bus value is :"
convert_ina3221_data $res_bus0 0 $INA3221_BUS_VOLT null "$INA3221_Channel0_name"
convert_ina3221_data $res_bus1 1 $INA3221_BUS_VOLT null "$INA3221_Channel1_name"
convert_ina3221_data $res_bus2 2 $INA3221_BUS_VOLT null "$INA3221_Channel2_name"
$fmt_print "console" "Info" "The INA3221 bus power is :"
convert_ina3221_data 0 0 0 $INA3221_POWER
}
test_ina3221_value(){
convert_ina3221_data $test_data1 $test_data2 0 $INA3221_SHUNT_VOLT $test_resistor "INA3221"
}
case "${mode}" in
"read")
read_ina3221_data
;;
"test")
test_ina3221_value
;;
"help")
print_help
;;
*)
$fmt_print "console" "Error" "[plugin_ina3221]Unexpected Input Param : $mode"
print_help
;;
esac

@ -0,0 +1,104 @@
#!/bin/sh
mode=$1
i2c_bus=$2
chip_slave=$3
server_platform=$4
server_type=$5
test_data1=$2
test_data2=$3
path=`pwd`
fmt_print="${path}/format_print.sh"
i2c_script="${path}/i2c_${server_platform}.sh"
server_script="${path}/platform_${server_type}.sh"
sensor_name="TMP112"
print_help(){
echo "---------------------------------------------------------"
echo "<option> read"
echo " Format : ./plugin_tmp112.sh read [i2c-bus] [slave] [platform]"
echo " Example: ./plugin_tmp112.sh read 13 0x48 m7"
echo "---------------------------------------------------------"
echo "<option> test"
echo " Format : ./plugin_tmp112.sh test [data1] [data2]"
echo " Example: ./plugin_tmp112.sh test 0x24 0x00"
echo "---------------------------------------------------------"
echo "<option> help"
echo " Format : ./plugin_tmp112.sh help"
echo " Example: ./plugin_tmp112.sh help"
echo "---------------------------------------------------------"
}
# @Param1 tmp112 data high 8bit
# @Param2 tmp112 data low 8bit
# @Param3 customization sensor name
convert_tmp112_data(){
if [ "$3" = "disable" ];then
return
fi
hex_value1=$(echo "$1" | awk '{sub(/^0x/,""); print}')
hex_value2=$(echo "$2" | awk '{sub(/^0x/,""); print}')
merge_value="${hex_value1}${hex_value2}"
# bc calculator recognized upper case only, change data to upper case
upper_hex_value=$(echo "$merge_value" | awk '{
for(i=1; i<=length($0); i++){
if(tolower(substr($0,i,1)) ~ /^[a-f]$/)
printf toupper(substr($0,i,1));
else
printf substr($0,i,1);
}
print ""
}')
# change data from hex to dec
dec_val=$(echo "ibase=16; $upper_hex_value" | bc)
binary_number=$(echo "ibase=16;obase=2;$upper_hex_value" | bc)
bin_length=$(echo $binary_number | awk '{print length($0)}')
last_digit=$(echo $binary_number | cut -c $bin_length)
if [ $last_digit -eq 0 ];then
temp=$(echo "scale=4; $dec_val / 16 * 0.0625" | bc)
elif [ $last_digit -eq 1 ];then
temp=$(echo "scale=4; ( $dec_val - 1 ) / 8 * 0.0625" | bc)
fi
echo "$3 : $temp"
$fmt_print "log" "Info" "[plugin_tmp112] hex value : ${merge_value}"
$fmt_print "log" "Info" "[plugin_tmp112] binary_number : ${binary_number}"
$fmt_print "log" "Info" "[plugin_tmp112] bin_length : ${bin_length}"
$fmt_print "log" "Info" "[plugin_tmp112] last_digit : ${last_digit}"
}
read_tmp112_data(){
res=`$i2c_script $i2c_bus "1" "$chip_slave" "0x00" "2"`
# After read option , reset pca9548
$server_script reset
convert_tmp112_data $res "$sensor_name"
}
test_tmp112_data(){
convert_tmp112_data $test_data1 $test_data2 "Temp"
}
case "${mode}" in
"read")
read_tmp112_data
;;
"test")
test_tmp112_data
;;
"help")
print_help
;;
*)
$fmt_print "console" "Error" "[plugin_tmp112] Unexpected Input Param : $mode"
print_help
;;
esac

@ -0,0 +1,133 @@
#!/bin/sh
mode=$1
i2c_bus=$2
chip_slave=$3
server_platform=$4
server_type=$5
test_data1=$2
test_data2=$3
path=`pwd`
fmt_print="${path}/format_print.sh"
i2c_script="${path}/i2c_${server_platform}.sh"
server_script="${path}/platform_${server_type}.sh"
REG_tmp468="0x80"
# TMP468 channel name
TMP468_Channel0_name="Local"
TMP468_Channel1_name="Remote1"
TMP468_Channel2_name="Remote2"
TMP468_Channel3_name="Remote3"
TMP468_Channel4_name="Remote4"
TMP468_Channel5_name="Remote5"
TMP468_Channel6_name="Remote6"
TMP468_Channel7_name="Remote7"
TMP468_Channel8_name="Remote8"
print_help(){
echo "---------------------------------------------------------"
echo "<option> read"
echo " Format : ./plugin_tmp468.sh read [i2c-bus] [slave] [platform]"
echo " Example: ./plugin_tmp468.sh read 13 0x48 m7"
echo "---------------------------------------------------------"
echo "<option> test"
echo " Format : ./plugin_tmp468.sh test [data1] [data2]"
echo " Example: ./plugin_tmp468.sh test 0x24 0x00"
echo "---------------------------------------------------------"
echo "<option> help"
echo " Format : ./plugin_tmp468.sh help"
echo " Example: ./plugin_tmp468.sh help"
echo "---------------------------------------------------------"
}
# @Param1 tmp468 data high 8bit
# @Param2 tmp468 data high 8bit
# @Param3 customization channel name
convert_tmp468_data(){
if [ "$3" = "disable" ];then
return
fi
hex_value1=$(echo "$1" | awk '{sub(/^0x/,""); print}')
hex_value2=$(echo "$2" | awk '{sub(/^0x/,""); print}')
merge_value="${hex_value1}${hex_value2}"
# bc calculator recognized upper case only, change data to upper case
upper_hex_value=$(echo "$merge_value" | awk '{
for(i=1; i<=length($0); i++){
if(tolower(substr($0,i,1)) ~ /^[a-f]$/)
printf toupper(substr($0,i,1));
else
printf substr($0,i,1);
}
print ""
}')
# change data from hex to dec
dec_val=$(echo "ibase=16; $upper_hex_value" | bc)
temp=$(echo "scale=4; $dec_val / 8 * 0.0625" | bc)
echo "$3 : $temp "
}
read_tmp468_data(){
res_tmp468=`$i2c_script $i2c_bus 1 $chip_slave $REG_tmp468 18`
# After read option , reset pca9548
$server_script reset
$fmt_print "log" "Info" "[plugin_tmp468] Read Raw Data : $res_tmp468"
tmp468_res1_h=`echo $res_tmp468 | awk '{print $1}'`
tmp468_res1_l=`echo $res_tmp468 | awk '{print $2}'`
tmp468_res2_h=`echo $res_tmp468 | awk '{print $3}'`
tmp468_res2_l=`echo $res_tmp468 | awk '{print $4}'`
tmp468_res3_h=`echo $res_tmp468 | awk '{print $5}'`
tmp468_res3_l=`echo $res_tmp468 | awk '{print $6}'`
tmp468_res4_h=`echo $res_tmp468 | awk '{print $7}'`
tmp468_res4_l=`echo $res_tmp468 | awk '{print $8}'`
tmp468_res5_h=`echo $res_tmp468 | awk '{print $9}'`
tmp468_res5_l=`echo $res_tmp468 | awk '{print $10}'`
tmp468_res6_h=`echo $res_tmp468 | awk '{print $11}'`
tmp468_res6_l=`echo $res_tmp468 | awk '{print $12}'`
tmp468_res7_h=`echo $res_tmp468 | awk '{print $13}'`
tmp468_res7_l=`echo $res_tmp468 | awk '{print $14}'`
tmp468_res8_h=`echo $res_tmp468 | awk '{print $15}'`
tmp468_res8_l=`echo $res_tmp468 | awk '{print $16}'`
tmp468_res9_h=`echo $res_tmp468 | awk '{print $17}'`
tmp468_res9_l=`echo $res_tmp468 | awk '{print $18}'`
$fmt_print "console" "Info" "Tmp468 read result:"
convert_tmp468_data $tmp468_res1_h $tmp468_res1_l "$TMP468_Channel0_name"
convert_tmp468_data $tmp468_res2_h $tmp468_res2_l "$TMP468_Channel1_name"
convert_tmp468_data $tmp468_res3_h $tmp468_res3_l "$TMP468_Channel2_name"
convert_tmp468_data $tmp468_res4_h $tmp468_res4_l "$TMP468_Channel3_name"
convert_tmp468_data $tmp468_res5_h $tmp468_res5_l "$TMP468_Channel4_name"
convert_tmp468_data $tmp468_res6_h $tmp468_res6_l "$TMP468_Channel5_name"
convert_tmp468_data $tmp468_res7_h $tmp468_res7_l "$TMP468_Channel6_name"
convert_tmp468_data $tmp468_res8_h $tmp468_res8_l "$TMP468_Channel7_name"
convert_tmp468_data $tmp468_res9_h $tmp468_res9_l "$TMP468_Channel8_name"
}
test_tmp468_data(){
convert_tmp468_data $test_data1 $test_data2 "Temp"
}
case "${mode}" in
"read")
read_tmp468_data
;;
"test")
test_tmp468_data
;;
"help")
print_help
;;
*)
$fmt_print "console" "Error" "[plugin_tmp468] Unexpected Input Param : $mode"
print_help
;;
esac

128
tool/nicsensor_v2/readme.md Normal file

@ -0,0 +1,128 @@
# nicsensor tool V2 使用说明
## 目录
- [1 简介](#1_简介)
- [2 使用方法](#2_使用方法)
- [2.1 标准执行](#2_1_标准执行)
- [2.2 i2c扫描](#2_2_I2cScan)
- [2.3 传感器单独调试](#2_3_传感器单独调试)
- [3 代码结构](#3_代码结构)
- [3.1 脚本结构](#3_1_脚本结构)
- [3.2 执行顺序](#3_2_执行顺序)
## 1_简介
相比于`v1.x`版本的主要差异点:
- 脚本模块化, 易于阅读和扩展
- 支持单独测试传感器数据
- 可扩展在多个平台的服务器使用
## 2_使用方法
### 2_1_标准执行
> **标准执行前**需要修改`nicsensor.sh` , 以及部分对应的 `plugin_xxx.sh`
>
>>对于 `nicsensor.sh`, 使用前需要先修改脚本中的如下变量:
>> - `server_type`: 要应用的服务器类型
>> - `server_platform`: 要应用服务器平台名称
>
>> 对于 `plugin_xxx.sh`, 使用前需要针对具体的sensor指定对应的特殊变量
标准执行命令格式
``` shell
./nicsensor.sh [nic_slot] [sensor_type] [sensor_slave]
```
参数说明
- `nic_slot`: 网卡所在的服务器槽位, 例如 `pcie2``ocp0`
- `sensor_type`: 需要测试的传感器类型, 例如 `adc128`, `ina3221`, `tmp468`
- `sensor_slave`: 传感器的I2C地址(7bit), 例如 `0x48`
命令示例
``` shell
# 读取服务器 PCIE2 号槽位上的 adc128 传感器, slave地址0x1f
./nicsensor.sh pcie2 adc128 0x1f
```
### 2_2_I2cScan
类似于标准执行, 使用前需要现先在 `nicsensor.sh` 脚本中指定使用的服务器类型
命令格式
``` shell
./nicsensor.sh detect [nic_type]
```
参数说明
- `nic_type`: 要扫描的网卡类型, 默认值是`pcie`, 可选值:
- `pcie`
- `ocp`
命令示例
```shell
./nicsensor.sh detect pcie
```
### 2_3_传感器单独调试
nicsensor v2 提供了针对每类传感器将十六进制读值直接可视化的功能用于单独调试
每一类可使用的sensor都有对应的 plugin_xxx.sh, 例如:
- `plugin_adc128.sh`
- `plugin_emc1413.sh`
- `plugin_ina3221.sh`
- `plugin_tmp112.sh`
- `plugin_tmp468.sh`
这些脚本都实现了一个 `test` 方法用于单独解析传感器的16进制的读值为可视化十进制数值
常见命令, 以 `plugin_tmp112.sh` 举例
``` shell
# 使用方法
./plugin_tmp112.sh help
# 单次调试数据
./plugin_tmp112.sh test 0x24 0x00
```
## 3_代码结构
### 3_1_脚本结构
- 主控脚本
- [nicsensor](./nicsensor.sh): 标准执行的入口脚本
- I2C接口脚本
- [i2c_m6](./i2c_m6.sh): M6平台I2C命令执行脚本
- [i2c_m7](./i2c_m7.sh): M7平台I2C命令执行脚本
- 服务器平台脚本
- [platform_5280m7](./platform_5280m7.sh): 5280M7的对应逻辑
- [platform_5688m7](./platform_5688m7.sh): 5688M7的对应逻辑
- 传感器脚本
- [plugin_adc128](./plugin_adc128.sh)
- [plugin_emc1413](./plugin_emc1413.sh)
- [plugin_ina3221](./plugin_ina3221.sh)
- [plugin_tmp112](./plugin_tmp112.sh)
- [plugin_tmp468](./plugin_tmp468.sh)
- 功能类脚本
- [format_print](./format_print.sh): 用于生成格式化console打印或者记录日志
- [auto_auth](./autoauth.sh): 用于一键执行为每个脚本文件赋予可执行权限
### 3_2_执行顺序
``` txt
nicsensor.sh
|
+--> init debug log 初始化日志文件
|
+--> is detect?
|
+-yes-> perform_detect : 调用 platform_xx.sh 的 detect 方法开始执行
|
+<--no--+
|
+--> conf_pre_check: 检查文件系统中脚本文件是否满足执行需求
|
+--> parse_slot_name: 根据 slot_name 解析槽位信息
|
+--> connect_i2c: 调用 platform_xx.sh 的 connect 方法选通对应槽位 I2C 通路
|
+--> start_sensor_reading: 调用 plugin_xx.sh 的 read 方法读取传感器的读值并解析
```

@ -1,34 +0,0 @@
#!/bin/sh
# process sensor data then print to console
# @Param 1 adc128 data high 8bit
# @Param 2 adc128 data low 8bit
# @Param 3 customization channel name
# @Param 4 division factor
convert_adc128_data(){
# remove data prefix '0x'
hex_value1=$(echo "$1" | awk '{sub(/^0x/,""); print}')
hex_value2=$(echo "$2" | awk '{sub(/^0x/,""); print}')
merge_value="${hex_value1}${hex_value2}"
# bc calculator recognized upper case only, change data to upper case
upper_hex_value=$(echo "$merge_value" | awk '{
for(i=1; i<=length($0); i++){
if(tolower(substr($0,i,1)) ~ /^[a-f]$/)
printf toupper(substr($0,i,1));
else
printf substr($0,i,1);
}
print ""
}')
# calculate dec value then print it to console
dec_val=$(echo "ibase=16; $upper_hex_value" | bc)
volt=$(echo "scale=4; $dec_val / 16 / 4096 * 2.65 / $4" | bc)
format_volt=$(echo "$volt" | awk '{ if ($0 ~ /^\./) print "0" $0; else print $0 }')
echo "$3 : $format_volt v, hex value: $upper_hex_value"
}
# E.G. convert_adc128_data 0x08 0x20 "3V3" "1"
convert_adc128_data $1 $2 $3 $4

@ -1,45 +0,0 @@
#!/bin/sh
# @Param1 emc1413 data high 8bit
# @Param2 emc1413 data low 8bit
# @Param3 customization channel name
convert_emc1413_data(){
# remove data prefix '0x'
hex_value1=$(echo "$1" | awk '{sub(/^0x/,""); print}')
hex_value2=$(echo "$2" | awk '{sub(/^0x/,""); print}')
# bc calculator recognized upper case only, change data to upper case
upper_hex_value1=$(echo "$hex_value1" | awk '{
for(i=1; i<=length($0); i++){
if(tolower(substr($0,i,1)) ~ /^[a-f]$/)
printf toupper(substr($0,i,1));
else
printf substr($0,i,1);
}
print ""
}')
upper_hex_value2=$(echo "$hex_value2" | awk '{
for(i=1; i<=length($0); i++){
if(tolower(substr($0,i,1)) ~ /^[a-f]$/)
printf toupper(substr($0,i,1));
else
printf substr($0,i,1);
}
print ""
}')
# change data from hex to dec
dec_value1=$(echo "ibase=16; $upper_hex_value1" | bc)
dec_value2=$(echo "ibase=16; $upper_hex_value2" | bc)
# calculate tempreture
temp=$(echo "scale=4; $dec_value1 + ($dec_value2 / 32 * 0.125 )" | bc)
# print result to consol
format_temp=$(echo "$temp" | awk '{ if ($0 ~ /^\./) print "0" $0; else print $0 }')
echo "$3 : $format_temp C, hex value : $hex_value1 $hex_value2"
}
convert_emc1413_data $1 $2 $3

@ -1,79 +0,0 @@
#!/bin/sh
# @Param1 ina3221 data high 8bit
# @Param2 ina3221 data high 8bit
# @Param3 channel number
# @Param4 mode select 0 - shunt volt
# 1 - bus volt
# @Param5 shunt resistor(only used in mode shunt volt)
# @Param6 customization channel name
convert_ina3221_data(){
hex_value1=$(echo "$1" | awk '{sub(/^0x/,""); print}')
hex_value2=$(echo "$2" | awk '{sub(/^0x/,""); print}')
merge_value="${hex_value1}${hex_value2}"
# bc calculator recognized upper case only, change data to upper case
upper_hex_value=$(echo "$merge_value" | awk '{
for(i=1; i<=length($0); i++){
if(tolower(substr($0,i,1)) ~ /^[a-f]$/)
printf toupper(substr($0,i,1));
else
printf substr($0,i,1);
}
print ""
}')
# change data from hex to dec
dec_val=$(echo "ibase=16; $upper_hex_value" | bc)
if [ $4 -eq $INA3221_BUS_VOLT ];then
volt=$(echo "scale=4; $dec_val / 8 * 40 / 10000 * 2" | bc)
format_volt=$(echo "$volt" | awk '{ if ($0 ~ /^\./) print "0" $0; else print $0 }')
echo "$6 : $format_volt V, hex value: $upper_hex_value"
if [ $3 -eq 0 ];then
ina3221_ch0_volt=$format_volt
elif [ $3 -eq 1 ];then
ina3221_ch1_volt=$format_volt
else
ina3221_ch2_volt=$format_volt
fi
elif [ $4 -eq $INA3221_SHUNT_VOLT ];then
current_mv=$(echo "scale=4; $dec_val / 8 * 40 / 1000" | bc)
current=$(echo "scale=4; $current_mv / $5" | bc)
format_current=$(echo "$current" | awk '{ if ($0 ~ /^\./) print "0" $0; else print $0 }')
format_current_mv=$(echo "$current_mv" | awk '{ if ($0 ~ /^\./) print "0" $0; else print $0 }')
echo "$6 : $format_current A, shunt volt: $format_current_mv mV, shunt resistor: $5 mOhm, hex value: $upper_hex_value"
if [ $3 -eq 0 ];then
ina3221_ch0_current=$format_current
elif [ $3 -eq 1 ];then
ina3221_ch1_current=$format_current
else
ina3221_ch2_current=$format_current
fi
elif [ $4 -eq $INA3221_POWER ];then
# calculate power
power_ch0=$(echo "scale=4; $ina3221_ch0_volt * $ina3221_ch0_current" | bc)
power_ch1=$(echo "scale=4; $ina3221_ch1_volt * $ina3221_ch1_current" | bc)
power_ch2=$(echo "scale=4; $ina3221_ch2_volt * $ina3221_ch2_current" | bc)
format_power_ch0=$(echo "$power_ch0" | awk '{ if ($0 ~ /^\./) print "0" $0; else print $0 }')
format_power_ch1=$(echo "$power_ch1" | awk '{ if ($0 ~ /^\./) print "0" $0; else print $0 }')
format_power_ch2=$(echo "$power_ch2" | awk '{ if ($0 ~ /^\./) print "0" $0; else print $0 }')
total_power=$(echo "scale=4; $power_ch0 + $power_ch1 + $power_ch2" | bc)
echo "$INA3221_Channel0_name : $format_power_ch0 W"
echo "$INA3221_Channel1_name : $format_power_ch1 W"
echo "$INA3221_Channel2_name : $format_power_ch2 W"
echo "total power: $total_power W"
fi
}
convert_ina3221_data $1 $2 $3 $4 $5 $6

@ -1,38 +0,0 @@
#!/bin/sh
# @Param1 tmp112 data high 8bit
# @Param2 tmp112 data low 8bit
# @Param3 customization sensor name
convert_tmp112_data(){
hex_value1=$(echo "$1" | awk '{sub(/^0x/,""); print}')
hex_value2=$(echo "$2" | awk '{sub(/^0x/,""); print}')
merge_value="${hex_value1}${hex_value2}"
# bc calculator recognized upper case only, change data to upper case
upper_hex_value=$(echo "$merge_value" | awk '{
for(i=1; i<=length($0); i++){
if(tolower(substr($0,i,1)) ~ /^[a-f]$/)
printf toupper(substr($0,i,1));
else
printf substr($0,i,1);
}
print ""
}')
# change data from hex to dec
dec_val=$(echo "ibase=16; $upper_hex_value" | bc)
binary_number=$(echo "ibase=16;obase=2;$upper_hex_value" | bc)
bin_length=$(echo $binary_number | awk '{print length($0)}')
last_digit=$(echo $binary_number | cut -c $bin_length)
if [ $last_digit -eq 0 ];then
temp=$(echo "scale=4; $dec_val / 16 * 0.0625" | bc)
elif [ $last_digit -eq 1 ];then
temp=$(echo "scale=4; ( $dec_val - 1 ) / 8 * 0.0625" | bc)
fi
echo "$3 : $temp"
}
# E.G. ./plugin_tmp112.sh 0x08 0x40 temp
convert_tmp112_data $1 $2 $3

@ -1,29 +0,0 @@
#!/bin/sh
# @Param1 tmp468 data high 8bit
# @Param2 tmp468 data high 8bit
# @Param3 customization channel name
convert_tmp468_data(){
hex_value1=$(echo "$1" | awk '{sub(/^0x/,""); print}')
hex_value2=$(echo "$2" | awk '{sub(/^0x/,""); print}')
merge_value="${hex_value1}${hex_value2}"
# bc calculator recognized upper case only, change data to upper case
upper_hex_value=$(echo "$merge_value" | awk '{
for(i=1; i<=length($0); i++){
if(tolower(substr($0,i,1)) ~ /^[a-f]$/)
printf toupper(substr($0,i,1));
else
printf substr($0,i,1);
}
print ""
}')
# change data from hex to dec
dec_val=$(echo "ibase=16; $upper_hex_value" | bc)
temp=$(echo "scale=4; $dec_val / 8 * 0.0625" | bc)
echo "$3 : $temp "
}
convert_tmp468_data $1 $2 $3

@ -0,0 +1,45 @@
#!/bin/sh
# 20250627
# A tool script to test a value greater or less than threhold
data=$1
direction=$2
threhold=$3
param_num=$#
print_usage(){
echo " Script Usage"
echo " ./check_threhold.sh <value> <direction> <threhold>"
echo " @Param direction : greater , >"
echo " less , <"
echo " equal , ="
echo ""
echo " E.G. ./check_threhold.sh 500 > 1000"
echo " +--> Result : 0"
echo ""
echo " About Result: 1 means true, 0 means fault"
echo ""
}
main(){
if [ ${param_num} -ne 3 ];then
print_usage
exit 0
fi
if [ "${direction}" = "great" ] || [ "${direction}" = ">" ];then
res= `echo " $data > $threhold" | bc -l`
elif [ "${direction}" = "less" ] || [ "${direction}" = "<" ];then
res= `echo " $data < $threhold" | bc -l`
elif [ "${direction}" = "equal" ] || [ "${direction}" = "=" ];then
res= `echo " $data = $threhold" | bc -l`
else
echo "Invalid direction"
print_usage
fi
echo $res
}
main

19
tool/test/readme.md Normal file

@ -0,0 +1,19 @@
# 测试治具说明
> [!info]
> nicsensor提供了一部分测试治具脚本用于辅助编写测试脚本
## 阈值校验脚本-check_threhold.sh
阈值校验脚本提供了判断数值是否大于目标阈值的方法, 可进行整数和小数的比较。使用方法如下:
```shell
# 测试数据大于阈值
# 例如测试数据是否大于100有如下使用方法
res=`./check_threhold.sh ${data} > 100`
if [ $res -eq 1 ];then
echo "data is greater than threholds"
else
echo "data isn't greater than threholds"
fi
```