diff --git a/nicsensor_v2/readme.md b/nicsensor_v2/readme.md new file mode 100644 index 0000000..419fda0 --- /dev/null +++ b/nicsensor_v2/readme.md @@ -0,0 +1,118 @@ +# nicsensor tool V2 使用说明 + +## 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 I2C Scan + +类似于标准执行, 使用前需要现先在 `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 方法读取传感器的读值并解析 +``` \ No newline at end of file