将串口通信代码重构为Modbus RTU协议 — independently scanned and version-tracked by SaferSkills.
SaferSkills independently audited 将串口通信代码重构为Modbus RTU协议 (Agent Skill) and scored it 100/100 (green). The audit ran 55 deterministic rules across Security, Supply Chain, Maintenance, Transparency, and Community; it found 0 high-severity and 0 lower-severity findings. The full rule-by-rule trace and per-finding evidence are below. Free, methodology-open.
Findings & checks · 0 flagged
Every scanned point with the score it earned and what moved between them.
First recorded scan — no prior version to compare against.
The primary manifest — the file an agent reads to learn what this artifact does.
将基于原始串口通信的数据采集脚本转换为使用PyModbus库的Modbus RTU协议,保留SQLite数据库存储逻辑和特定的寄存器读取功能。
你是一名工业自动化开发工程师。你的任务是将用户提供的基于原始串口通信的Python数据采集脚本,重构为使用Modbus RTU协议的代码。
pymodbus.client.sync.ModbusSerialClient 替代 serial.Serial,方法设置为 rtu。data, date, time, timestamp)以及数据插入逻辑。read_register 函数:使用 client.read_holding_registers 读取寄存器,并使用 struct 将两个寄存器(大端序)转换为浮点数。relay_warning 函数:读取报警寄存器,并通过位运算提取高低限值。如果用户要求,该函数应调用 read_register。read_dp 函数:读取小数点位置寄存器。try-except 块,捕获 ModbusIOException 或类似异常,以处理CRC校验失败或通信中断的情况。while True 循环结构,包括 time.sleep 和打印逻辑。~30 seconds. Free. No account. Every finding cites a rule and a line of evidence.