Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
130 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,25 @@ | ||
.. include:: ../../README.rst | ||
|
||
Contents: | ||
--------- | ||
.... | ||
|
||
How uModus works | ||
---------------- | ||
|
||
.. toctree:: | ||
:maxdepth: 2 | ||
|
||
installation | ||
usage | ||
modbus_server | ||
modbus_client | ||
configuration | ||
changelog | ||
|
||
|
||
The Modbus protocol explained | ||
----------------------------- | ||
|
||
.. toctree:: | ||
:maxdepth: 2 | ||
|
||
decompose_requests | ||
functions | ||
changelog |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
Modbus client | ||
--------------- | ||
|
||
Sample use | ||
========== | ||
|
||
Currently a client has been implemented to do Modbus TCP requests. All | ||
functions codes for Modbus TCP/IP are supported. U can use the client like | ||
this: | ||
|
||
|
||
.. include:: ../../scripts/examples/simple_client.py | ||
:code: python | ||
|
||
|
||
API | ||
=== | ||
|
||
.. autofunction:: umodbus.client.tcp.send_message | ||
|
||
.. autofunction:: umodbus.client.tcp.parse_response_adu | ||
|
||
.. autofunction:: umodbus.client.tcp.read_coils | ||
|
||
.. autofunction:: umodbus.client.tcp.read_discrete_inputs | ||
|
||
.. autofunction:: umodbus.client.tcp.read_holding_registers | ||
|
||
.. autofunction:: umodbus.client.tcp.read_input_registers | ||
|
||
.. autofunction:: umodbus.client.tcp.write_single_coil | ||
|
||
.. autofunction:: umodbus.client.tcp.write_single_register | ||
|
||
.. autofunction:: umodbus.client.tcp.write_multiple_coils | ||
|
||
.. autofunction:: umodbus.client.tcp.write_multiple_registers |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/usr/bin/env python | ||
# scripts/examples/simple_client.py | ||
import socket | ||
|
||
from umodbus.client import tcp | ||
|
||
|
||
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | ||
sock.connect(('localhost', 502)) | ||
|
||
# Returns a message or Application Data Unit (ADU) specific for doing | ||
# Modbus TCP/IP. | ||
message = tcp.write_multiple_coils(slave_id=1, address=1, values=[1, 0, 1, 1]) | ||
|
||
# Response depends on Modbus function code. This particular returns the | ||
# amount of coils written, in this case it isr3. | ||
response = tcp.send_message(message, sock) | ||
|
||
sock.close() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters