访问modbus设备的命令行工具

modbus_cli的Python项目详细描述


Author:favalex@gmail.com
Date:2017-06-04
Copyright:MPL 2.0
Version:0.1
Manual section:1

概要

modbus [-h] [-r REGISTERS] [-s SLAVE_ID] [-b BAUD] [-p STOP_BITS] [-v] device access [access …]

说明

modbus允许从命令行读取和写入modbus设备的寄存器。

它可以与TCP和RTU(即串行)设备通信,并可以编码和解码 在modbus 16位寄存器中输入大于16位的类型(例如浮点)。

寄存器定义(由寄存器地址及其类型组成)可以是 直接在命令行上提供或从文件加载并由 象征性的名字,为了方便。

modbus是在提供的协议实现之上用python实现的 通过umodbus python库。

选项

设备
/dev/ttyXXX表示串行设备,或hostname[:port]表示TCP设备
访问
一个或多个读或写操作。请参阅下面的访问语法。
-r FILE, --registers=FILE
Read registers definitions from FILE.
-v, --verbosePrint on screen the bytes transferred on the wire.
-b BAUD, --baud=BAUD
Set the baud rate for serial connections.
-p BITS, --stop-bits=BITS
Set the number of stop bits for serial connections.
-h, --helpShow this help message and exit.

访问语法

[modbus类型@]地址[/二进制类型][=值]

modbus类型=H I C D

modbus类型,其中之一

codenamesizewritable
^{tt3}$holding register16 bitsyes
^{tt4}$input register16 bitsno
^{tt5}$coil1 bityes
^{tt6}$discrete input1 bitno
地址=<;数字>;
基于0的寄存器地址
二进制类型=<;压缩格式>;

python标准pack模块接受的任何格式描述。一些常见的格式是:

codetype
^{tt3}$16 bits signed integer
^{tt9}$16 bits unsigned integer
^{tt4}$32 bits signed integer
^{tt11}$32 bits unsigned integer
^{tt12}$32 bits IEEE 754 float

默认字节顺序是big endian,使用格式中的<前缀指定little endian。

值=<;数字>;
要写入寄存器的值。如果不存在,将读取寄存器。

示例

^{tt14}$read the 32-bits unsigned integer stored in holding registers at addresses 39 and 40
^{tt15}$same as above (h is the default modbus type)
^{tt16}$write the integer 42 to that register
^{tt17}$same as above, provided the registers file contains the definition ^{tt18}$
^{tt19}$the value can be specified in hexadecimal
^{tt20}$read coil at address 5
^{tt21}$write a floating point value to holding registers at addresses 24 and 25
^{tt22}$read six unsigned bytes stored in input registers at addresses 1, 2 and 3

寄存器文件语法

一个#开始一个注释。

每行包含一个符号名,后跟寄存器定义,用空格分隔。

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java如何在jetty请求日志中添加milliscond字段?   java在使用Scanner类从文件读取信息时遇到问题   为什么。类不适用于泛型类型?   SQLite插入上的java空指针异常   java能告诉我们Guava缓存是在禁用统计数据的情况下构建的吗?   java在应用程序中使用常量   java无法使用AutoIT和Selenium Webdriver在所需位置/文件夹保存图像   java如何在jtable中更新jprogress栏   java是比较给定日期和当前日期(在给定时区中没有时间段)的最佳方法   安卓代码中的java错误   java无法访问实体类中的字段   java如何在tomcat中处理三个JDBC连接池?   java无法使用Spring Security保护AngularJS页面   如何在没有TCP/IP协议栈的情况下用Java发送以太帧