-
Notifications
You must be signed in to change notification settings - Fork 80
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
11 changed files
with
78 additions
and
14 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
Client | ||
====== | ||
Modbus Client | ||
============= | ||
|
||
uModbus contains a client for Modbus TCP and Modbus RTU. | ||
|
||
|
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 |
---|---|---|
|
@@ -10,7 +10,6 @@ this: | |
.. include:: ../../../scripts/examples/simple_tcp_client.py | ||
:code: python | ||
|
||
|
||
API | ||
=== | ||
|
||
|
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,4 +1,4 @@ | ||
Modbus server | ||
Modbus Server | ||
------------- | ||
|
||
Viewpoint | ||
|
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,33 @@ | ||
#!/usr/bin/env python | ||
# scripts/example/simple_rtu_client.py | ||
import fcntl | ||
import struct | ||
from serial import Serial, PARITY_NONE | ||
|
||
from umodbus.client.serial impor rtu | ||
|
||
|
||
def get_serial_port(): | ||
""" Return serial.Serial instance, ready to use for RS485.""" | ||
port = Serial(port='/dev/ttyS1', baudrate=9600, parity=PARITY_NONE, | ||
stopbits=1, bytesize=8, timeout=1) | ||
|
||
fh = port.fileno() | ||
|
||
# A struct with configuration for serial port. | ||
serial_rs485 = struct.pack('hhhhhhhh', 1, 0, 0, 0, 0, 0, 0, 0) | ||
fcntl.ioctl(fh, 0x542F, serial_rs485) | ||
|
||
return port | ||
|
||
serial_port = get_serial_port() | ||
|
||
# Returns a message or Application Data Unit (ADU) specific for doing | ||
# Modbus RTU. | ||
message = rtu.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 is. | ||
response = rtu.send_message(message, serial_port) | ||
|
||
serial_port.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
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