Skip to content

Commit 8de96e9

Browse files
Merge pull request #55 from brainelectronics/bugfix/update-outdated-documentation
Update outdated documentation
2 parents f810a5c + 9e14c5a commit 8de96e9

19 files changed

+928
-492
lines changed

Dockerfile.tests_manually

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Build image
2+
# $ docker build -t micropython-test-manually -f Dockerfile.tests_manually .
3+
# if a unittest fails, it will exit with non-zero code
4+
#
5+
# Run image, only possible if all tests passed
6+
# $ docker run -it --rm --name micropython-test-manually micropython-test-manually
7+
8+
FROM micropython/unix:v1.18
9+
10+
COPY ./ /home
11+
# keep examples and tests registers JSON file easily in sync
12+
COPY registers/example.json /home/tests/test-registers.json
13+
COPY umodbus /root/.micropython/lib/umodbus
14+
COPY mpy_unittest.py /root/.micropython/lib/mpy_unittest.py
15+
16+
RUN micropython-dev -m upip install micropython-ulogging
17+
18+
ENTRYPOINT ["/bin/bash"]

README.md

Lines changed: 40 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ Forked from [Exo Sense Py][ref-sferalabs-exo-sense], based on
1818
[PyCom Modbus][ref-pycom-modbus] and extended with other functionalities to
1919
become a powerfull MicroPython library
2020

21-
The latest documentation is available at
22-
[MicroPython Modbus ReadTheDocs][ref-rtd-micropython-modbus]
21+
📚 The latest documentation is available at
22+
[MicroPython Modbus ReadTheDocs][ref-rtd-micropython-modbus] 📚
2323

2424
<!-- MarkdownTOC -->
2525

2626
- [Quickstart](#quickstart)
27-
- [Install package on board with pip](#install-package-on-board-with-pip)
27+
- [Install package on board with mip or upip](#install-package-on-board-with-mip-or-upip)
2828
- [Request coil status](#request-coil-status)
2929
- [TCP](#tcp)
3030
- [RTU](#rtu)
@@ -41,17 +41,19 @@ This is a quickstart to install the `micropython-modbus` library on a
4141
MicroPython board.
4242

4343
A more detailed guide of the development environment can be found in
44-
[SETUP](SETUP.md). Further details about the usage can be found in
45-
[USAGE](USAGE.md)
44+
[SETUP](SETUP.md), further details about the usage can be found in
45+
[USAGE](USAGE.md), descriptions for testing can be found in
46+
[TESTING](TESTING.md) and several examples in [EXAMPLES](EXAMPLES.md)
4647

4748
```bash
4849
python3 -m venv .venv
4950
source .venv/bin/activate
5051

5152
pip install 'rshell>=0.0.30,<1.0.0'
53+
pip install 'mpremote>=0.4.0,<1'
5254
```
5355

54-
### Install package on board with pip
56+
### Install package on board with mip or upip
5557

5658
```bash
5759
rshell -p /dev/tty.SLAB_USBtoUART --editor nano
@@ -60,6 +62,23 @@ rshell -p /dev/tty.SLAB_USBtoUART --editor nano
6062
Inside the [rshell][ref-remote-upy-shell] open a REPL and execute these
6163
commands inside the REPL
6264

65+
```python
66+
import machine
67+
import network
68+
import time
69+
import mip
70+
station = network.WLAN(network.STA_IF)
71+
station.active(True)
72+
station.connect('SSID', 'PASSWORD')
73+
time.sleep(1)
74+
print('Device connected to network: {}'.format(station.isconnected()))
75+
mip.install('micropython-modbus', index='https://pypi.org/pypi')
76+
print('Installation completed')
77+
machine.soft_reset()
78+
```
79+
80+
For MicroPython versions below 1.19.1 use the `upip` package instead of `mip`
81+
6382
```python
6483
import machine
6584
import network
@@ -81,8 +100,7 @@ After a successful installation of the package and reboot of the system as
81100
described in the [installation section](#install-package-on-board-with-pip)
82101
the following commands can be used to request a coil state of a target/client
83102
device. Further usage examples can be found in the
84-
[examples folder][ref-examples-folder] and in the
85-
[Micropython section of USAGE](USAGE.md)
103+
[examples folder][ref-examples-folder] and in the [USAGE chapter](USAGE.md)
86104

87105
#### TCP
88106

@@ -110,15 +128,16 @@ print('Status of coil {}: {}'.format(coil_status, coil_address))
110128
#### RTU
111129

112130
```python
113-
from umodbus.serial import ModbusRTU
131+
from umodbus.serial import Serial as ModbusRTUMaster
114132

115-
host = ModbusRTU(
116-
addr=1, # address of this Master/Host on bus
133+
host = ModbusRTUMaster(
134+
pins=(25, 26), # given as tuple (TX, RX), check MicroPython port specific syntax
117135
# baudrate=9600, # optional, default 9600
118136
# data_bits=8, # optional, default 8
119137
# stop_bits=1, # optional, default 1
120138
# parity=None, # optional, default None
121-
pins=(25, 26) # (TX, RX)
139+
# ctrl_pin=12, # optional, control DE/RE
140+
# uart_id=1 # optional, see port specific documentation
122141
)
123142

124143
# address of the target/client/slave device on the bus
@@ -130,7 +149,7 @@ coil_status = host.read_coils(
130149
slave_addr=slave_addr,
131150
starting_addr=coil_address,
132151
coil_qty=coil_qty)
133-
print('Status of coil {}: {}'.format(coil_status, coil_address))
152+
print('Status of coil {}: {}'.format(coil_address, coil_status))
134153
```
135154

136155
### Install additional MicroPython packages
@@ -141,17 +160,22 @@ which are not part of this repo/package. To install these modules on the
141160
device, connect to a network and install them via `upip` as follows
142161

143162
```python
163+
# with MicroPython version 1.19.1 or newer
164+
import mip
165+
mip.install('micropython-brainelectronics-helpers', index='https://pypi.org/pypi')
166+
167+
# before MicroPython version 1.19.1
144168
import upip
145169
upip.install('micropython-brainelectronics-helpers')
146170
```
147171

148172
Check also the README of the
149-
[brainelectronics MicroPython modules][ref-github-be-mircopython-modules]
150-
and the [SETUP guide](SETUP.md)
173+
[brainelectronics MicroPython modules][ref-github-be-mircopython-modules], the
174+
[INSTALLATION](INSTALLATION.md) and the [SETUP](SETUP.md) guides.
151175

152176
## Usage
153177

154-
See [USAGE](USAGE.md)
178+
See [USAGE](USAGE.md) and [DOCUMENTATION](DOCUMENTATION.md)
155179

156180
## Supported Modbus functions
157181

changelog.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,23 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1515
<!-- ## [Unreleased] -->
1616

1717
## Released
18+
## [2.3.2] - 2023-01-09
19+
### Added
20+
- Installation instructions for `mip` usage on MicroPython 1.19.1 or newer, see #44
21+
- [Manual testing Dockerfile](Dockerfile.tests_manually)
22+
- [INSTALLATION](docs/INSTALLATION.md), [TESTING](docs/TESTING.md) and [EXAMPLES](docs/EXAMPLES.md) files for simpler docs structure
23+
24+
### Changed
25+
- Split [SETUP](docs/SETUP.md) into [INSTALLATION](docs/INSTALLATION.md)
26+
- Split [USAGE](docs/USAGE.md) into [TESTING](docs/TESTING.md) and [EXAMPLES](docs/EXAMPLES.md)
27+
- Use callback to reset register data in [RTU client example](examples/rtu_client_example.py)
28+
- Update docs copyright year to 2023
29+
- Use fakes machine module instead of classic Mock in docs config file
30+
31+
### Fixed
32+
- Basic RTU host example in root [README](README.md) uses correct init values, optional parameters are listed after mandatory ones
33+
- Remove outdated warning sections about #35 bug from [USAGE](docs/USAGE.md)
34+
1835
## [2.3.1] - 2023-01-06
1936
### Added
2037
- Unittest to read multiple coils at any location if defined as list, verifies #35
@@ -243,8 +260,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
243260
- PEP8 style issues on all files of [`lib/uModbus`](lib/uModbus)
244261

245262
<!-- Links -->
246-
[Unreleased]: https://github.com/brainelectronics/micropython-modbus/compare/2.3.1...develop
263+
[Unreleased]: https://github.com/brainelectronics/micropython-modbus/compare/2.3.2...develop
247264

265+
[2.3.2]: https://github.com/brainelectronics/micropython-modbus/tree/2.3.2
248266
[2.3.1]: https://github.com/brainelectronics/micropython-modbus/tree/2.3.1
249267
[2.3.0]: https://github.com/brainelectronics/micropython-modbus/tree/2.3.0
250268
[2.2.0]: https://github.com/brainelectronics/micropython-modbus/tree/2.2.0

docs/CONTRIBUTING.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1-
# CONTRIBUTING
1+
# Contributing
22

33
Guideline to contribute to this package
4+
5+
---------------
6+
7+
## TBD

docs/DOCUMENTATION.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Documentation
2+
3+
Documentation is generated by using Sphinx and published on RTD
4+
5+
---------------
6+
7+
## Documentation
8+
9+
Documentation is automatically created on each merge to the development
10+
branch, as well as with each pull request and available
11+
[📚 here at Read the Docs][ref-rtd-micropython-modbus]
12+
13+
### Install required packages
14+
15+
```bash
16+
# create and activate virtual environment
17+
python3 -m venv .venv
18+
source .venv/bin/activate
19+
20+
# install and upgrade required packages
21+
pip install -U -r docs/requirements.txt
22+
```
23+
24+
### Create documentation
25+
26+
Some usefull checks have been disabled in the `docs/conf.py` file. Please
27+
check the documentation build output locally before opening a PR.
28+
29+
```bash
30+
# perform link checks
31+
sphinx-build docs/ docs/build/linkcheck -d docs/build/docs_doctree/ --color -blinkcheck -j auto -W
32+
33+
# create documentation
34+
sphinx-build docs/ docs/build/html/ -d docs/build/docs_doctree/ --color -bhtml -j auto -W
35+
```
36+
37+
The created documentation can be found at [`docs/build/html`](docs/build/html).
38+
39+
<!-- Links -->
40+
[ref-rtd-micropython-modbus]: https://micropython-modbus.readthedocs.io/en/latest/

0 commit comments

Comments
 (0)