# Pymodbus REPL
## Dependencies
Depends on [prompt_toolkit](https://python-prompt-toolkit.readthedocs.io/en/stable/index.html) and [click](http://click.pocoo.org/6/quickstart/)
Install dependencies
```
$ pip install click prompt_toolkit --upgrade
```
Or
Install pymodbus with repl support
```
$ pip install pymodbus[repl] --upgrade
```
## Usage Instructions
RTU and TCP are supported as of now
```
bash-3.2$ pymodbus.console
Usage: pymodbus.console [OPTIONS] COMMAND [ARGS]...
Options:
--version Show the version and exit.
--verbose Verbose logs
--support-diag Support Diagnostic messages
--help Show this message and exit.
Commands:
serial
tcp
```
TCP Options
```
bash-3.2$ pymodbus.console tcp --help
Usage: pymodbus.console tcp [OPTIONS]
Options:
--host TEXT Modbus TCP IP
--port INTEGER Modbus TCP port
--help Show this message and exit.
```
SERIAL Options
```
bash-3.2$ pymodbus.console serial --help
Usage: pymodbus.console serial [OPTIONS]
Options:
--method TEXT Modbus Serial Mode (rtu/ascii)
--port TEXT Modbus RTU port
--baudrate INTEGER Modbus RTU serial baudrate to use. Defaults to 9600
--bytesize [5|6|7|8] Modbus RTU serial Number of data bits. Possible
values: FIVEBITS, SIXBITS, SEVENBITS, EIGHTBITS.
Defaults to 8
--parity [N|E|O|M|S] Modbus RTU serial parity. Enable parity checking.
Possible values: PARITY_NONE, PARITY_EVEN, PARITY_ODD
PARITY_MARK, PARITY_SPACE. Default to 'N'
--stopbits [1|1.5|2] Modbus RTU serial stop bits. Number of stop bits.
Possible values: STOPBITS_ONE,
STOPBITS_ONE_POINT_FIVE, STOPBITS_TWO. Default to '1'
--xonxoff INTEGER Modbus RTU serial xonxoff. Enable software flow
control.Defaults to 0
--rtscts INTEGER Modbus RTU serial rtscts. Enable hardware (RTS/CTS)
flow control. Defaults to 0
--dsrdtr INTEGER Modbus RTU serial dsrdtr. Enable hardware (DSR/DTR)
flow control. Defaults to 0
--timeout FLOAT Modbus RTU serial read timeout. Defaults to 0.025 sec
--write-timeout FLOAT Modbus RTU serial write timeout. Defaults to 2 sec
--help Show this message and exit.
```
To view all available commands type `help`
TCP
```
$ pymodbus.console tcp --host 192.168.128.126 --port 5020
> help
Available commands:
client.change_ascii_input_delimiter Diagnostic sub command, Change message delimiter for future requests.
client.clear_counters Diagnostic sub command, Clear all counters and diag registers.
client.clear_overrun_count Diagnostic sub command, Clear over run counter.
client.close Closes the underlying socket connection
client.connect Connect to the modbus tcp server
client.debug_enabled Returns a boolean indicating if debug is enabled.
client.force_listen_only_mode Diagnostic sub command, Forces the addressed remote device to its Listen Only Mode.
client.get_clear_modbus_plus Diagnostic sub command, Get or clear stats of remote modbus plus device.
client.get_com_event_counter Read status word and an event count from the remote device's communication event counter.
client.get_com_event_log Read status word, event count, message count, and a field of event bytes from the remote device.
client.host Read Only!
client.idle_time Bus Idle Time to initiate next transaction
client.is_socket_open Check whether the underlying socket/serial is open or not.
client.last_frame_end Read Only!
client.mask_write_register Mask content of holding register at `address` with `and_mask` and `or_mask`.
client.port Read Only!
client.read_coils Reads `count` coils from a given slave starting at `address`.
client.read_device_information Read the identification and additional information of remote slave.
client.read_discrete_inputs Reads `count` number of discrete inputs starting at offset `address`.
client.read_exception_status Read the contents of eight Exception Status outputs in a remote device.
client.read_holding_registers Read `count` number of holding registers starting at `address`.
client.read_input_registers Read `count` number of input registers starting at `address`.
client.readwrite_registers Read `read_count` number of holding registers starting at `read_address` and write `write_registers` starting at `write_address`.
client.report_slave_id Report information about remote slave ID.
client.restart_comm_option Diagnostic sub command, initialize and restart remote devices serial interface and clear all of its communications event counters .
client.return_bus_com_error_count Diagnostic sub command, Return count of CRC errors received by remote slave.
client.return_bus_exception_error_count Diagnostic sub command, Return count of Modbus exceptions returned by remote slave.
client.return_bus_message_count Diagnostic sub command, Return count of message detected on bus by remote slave.
client.return_diagnostic_register Diagnostic sub command, Read 16-bit diagnostic register.
client.return_iop_overrun_count Diagnostic sub command, Return count of iop overrun errors by remote slave.
client.return_query_data Diagnostic sub command , Loop back data sent in response.
client.return_slave_bus_char_overrun_count Diagnostic sub command, Return count of messages not handled by remote slave due to character overrun condition.
client.return_slave_busy_count Diagnostic sub command, Return count of server busy exceptions sent by remote slave.
client.return_slave_message_count Diagnostic sub command, Return count of messages addressed to remote slave.
client.return_slave_no_ack_count Diagnostic sub command, Return count of NO ACK exceptions sent by remote slave.
client.return_slave_no_response_count Diagnostic sub command, Return count of No responses by remote slave.
client.silent_interval Read Only!
client.state Read Only!
client.timeout Read Only!
client.write_coil Write `value` to coil at `address`.
client.write_coils Write `value` to coil at `address`.
client.write_register Write `value` to register at `address`.
client.write_registers Write list of `values` to registers starting at `address`.
```
SERIAL
```
$ pymodbus.console serial --port /dev/ttyUSB0 --baudrate 19200 --timeout 2
> help
Available commands:
client.baudrate Read Only!
client.bytesize Read Only!
client.change_ascii_input_delimiter Diagnostic sub command, Change message delimiter for future requests.
client.clear_counters Diagnostic sub command, Clear all counters and diag registers.
client.clear_overrun_count Diagnostic sub command, Clear over run counter.
client.close Closes the underlying socket connection
client.connect Connect to the modbus serial server
client.debug_enabled
没有合适的资源?快使用搜索试试~ 我知道了~
pymodbus, 在 python 中,编写了一个完整的modbus协议.zip
共308个文件
py:169个
rst:61个
txt:7个
1星 需积分: 34 97 下载量 38 浏览量
2019-10-11
03:12:47
上传
评论 4
收藏 1.18MB ZIP 举报
温馨提示
pymodbus, 在 python 中,编写了一个完整的modbus协议 摘要Pymodbus是使用 Twisted 实现异步通信内核的完整Modbus协议实现。 如果需要更轻量级的项目,也可以不使用任何第三方依赖项( 除了 pyserial ) 。 这里外,它应该在任何 python 版本>
资源推荐
资源详情
资源评论
收起资源包目录
pymodbus, 在 python 中,编写了一个完整的modbus协议.zip (308个子文件)
AUTHORS 47B
tty0tty.c 16KB
crc.c 3KB
tty0tty.c 3KB
virtual_serial.c 1KB
lrc.c 733B
setup.cfg 376B
COPYING 18KB
.coveragerc 56B
bootstrap.min.css 96KB
bootstrap_responsive.css 21KB
bootstrap_responsive.min.css 16KB
application.css 132B
device_mapping 35B
diagslave 448KB
.doxygen 62KB
setup.exe 192KB
fileopen.gif 1KB
.gitignore 542B
simulator.glade 9KB
index.html 4KB
MANIFEST.in 65B
tox.ini 459B
INSTALL 2KB
INSTALL 369B
jamod 1KB
jamod_1.2.jar 145KB
ClientExample.java 4KB
ModbusSerialSlave.java 3KB
ModbusTcpSlave.java 2KB
ModbusUdpSlave.java 2KB
jquery.min.js 91KB
bootstrap.js 55KB
backbone.js 52KB
bootstrap.min.js 25KB
backbone.min.js 16KB
underscore.min.js 13KB
application.js 4KB
LICENSE 1KB
LICENSE_FREE 5KB
Makefile 2KB
Makefile 756B
Makefile 605B
Makefile 116B
Makefile 95B
README.md 14KB
REPL.md 14KB
ISSUE_TEMPLATE.md 794B
PULL_REQUEST_TEMPLATE.md 78B
modpoll 450KB
glyphicons_halflings.png 12KB
glyphicons_halflings_white.png 9KB
.project 362B
diag_message.py 29KB
sync.py 24KB
__init__.py 24KB
client.py 24KB
device.py 23KB
test_transaction.py 22KB
sync.py 20KB
transaction.py 19KB
libmodbus_client.py 18KB
test_server_sync.py 16KB
payload.py 16KB
build.py 15KB
other_message.py 14KB
asynchronous.py 14KB
test_device.py 14KB
file_message.py 14KB
test_client_sync.py 14KB
test_client_async_tornado.py 13KB
test_datastore.py 13KB
register_read_message.py 13KB
simulator.py 12KB
simulator.py 12KB
factory.py 12KB
rtu_framer.py 12KB
register_write_message.py 12KB
test_client_async_asyncio.py 11KB
simulator.py 11KB
main.py 11KB
test_server_async.py 11KB
modbus_mapper.py 11KB
frontend.py 11KB
sunspec_client.py 11KB
test_client_async.py 11KB
test_file_message.py 11KB
helper.py 10KB
modbus_scraper.py 10KB
ez_setup.py 10KB
concurrent_client.py 10KB
synchronous_client_ext.py 10KB
test_factory.py 10KB
test_payload.py 9KB
__init__.py 9KB
modicon_payload.py 9KB
bit_write_message.py 9KB
redis_datastore.py 9KB
test_client_async_twisted.py 9KB
store.py 9KB
共 308 条
- 1
- 2
- 3
- 4
资源评论
- wangclub2020-12-31python搬运工?
weixin_38744207
- 粉丝: 343
- 资源: 2万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功