Skip to content

Commit 979e99c

Browse files
committed
Merge branch 'release'
2 parents 496065e + 0da142f commit 979e99c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+1041
-872
lines changed

.travis.yml

Lines changed: 10 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,16 @@
1-
sudo: false
21
language: rust
3-
# Dependencies of kcov, used by coverage
4-
addons:
5-
apt:
6-
packages:
7-
- libcurl4-openssl-dev
8-
- libelf-dev
9-
- libdw-dev
10-
- binutils-dev
11-
- cmake
12-
sources:
13-
- kalakris-cmake
142
rust:
153
- stable
164
- beta
175
- nightly
18-
before_script:
19-
- |
20-
cargo install cargo-travis &&
21-
export PATH=$HOME/.cargo/bin:$PATH
22-
23-
# the main build
246
script:
25-
- |
26-
cargo test
27-
28-
after_success:
29-
# measure code coverage and upload to coveralls.io
30-
- cargo coveralls
7+
- cargo build --verbose
8+
- cargo test --verbose
9+
jobs:
10+
allow_failures:
11+
- rust: nightly
12+
fast_finish: true
13+
cache: cargo
14+
before_cache:
15+
- rm -rf "$TRAVIS_HOME/.cargo/registry/src"
16+
# rest of your existing "before_cache"

Cargo.toml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
2-
name = "libmodbus-rs"
3-
version = "0.9.0"
2+
name = "libmodbus"
3+
version = "1.0.0"
44
authors = ["Stefan Müller <co@zzeroo.com>"]
55
readme = "README.md"
66
keywords = ["modbus", "libmodbus"]
@@ -10,18 +10,18 @@ homepage = "http://zzeroo.github.io/libmodbus-rs"
1010
description = "libmodbus bindings for Rust"
1111
license = "LGPL-2.1" # same as libmodbus
1212
categories = ["api-bindings"]
13+
edition = "2018"
1314

1415
[badges]
1516
travis-ci = { repository = "zzeroo/libmodbus-rs" }
1617

1718
[dependencies]
18-
failure = "0.1.5"
19-
libc = "0.2.55"
20-
libmodbus-sys = { path = "libmodbus-sys", version = "0.9" }
21-
rand = "0.6.5"
22-
time = "0.1.42"
19+
libc = "0.2.80"
20+
libmodbus-sys = { path = "libmodbus-sys", version = "1" }
21+
rand = "0.7.3"
22+
time = "0.2.22"
2323

24-
[dependencies.clap]
24+
[dev-dependencies.clap]
2525
version = "2.33"
2626
default-features = false
2727
features = [ "color" ]

README.md

Lines changed: 35 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
1-
# libmodbus-rs
2-
## [libmodbus](http://libmodbus.org/) bindings for Rust &nbsp;
1+
# libmodbus
32

4-
**This crate is an reduced version without active bindgen! I need this because our build system can not deliver rust and libclang. Please don't use in production and expect odd behavior.**
3+
> This crate was renamed to just *libmodbus*. Before version 1.0.0 the name of the crate was libmodbus-rs.
4+
5+
## [libmodbus](http://libmodbus.org/) bindings for Rust
56

67
Libmodbus is a free software library to send and receive data with a device that respects the Modbus protocol. That crate contains the Rust bindings for the libmodbus library (written in C).
78
Like libmodbus self, this crate supports serial port and Ethernet connections for Modbus server and clients.
89

910

1011
[![Crates.io version](https://img.shields.io/crates/v/libmodbus-rs.svg)](https://crates.io/crates/libmodbus-rs) &nbsp;
1112
[![Build Status](https://travis-ci.org/zzeroo/libmodbus-rs.svg?branch=master)](https://travis-ci.org/zzeroo/libmodbus-rs) &nbsp;
13+
[![Build status](https://ci.appveyor.com/api/projects/status/v24293bvng52ihn5/branch/master?svg=true)](https://ci.appveyor.com/project/zzeroo/libmodbus-rs/branch/master) &nbsp;
1214
[![Coverage Status](https://coveralls.io/repos/github/zzeroo/libmodbus-rs/badge.svg?branch=master)](https://coveralls.io/github/zzeroo/libmodbus-rs?branch=master)
1315

1416
[Homepage |][homepage] &nbsp;
@@ -27,7 +29,7 @@ Include the dependencies into your `Cargo.toml` file.
2729

2830
```toml
2931
[dependencies]
30-
libmodbus-rs = "0.6"
32+
libmodbus-rs = "1"
3133
```
3234

3335
### or development (github master)
@@ -43,7 +45,7 @@ For example if you what to build an modbus server, in the modbus tcp context, in
4345
```rust
4446
extern crate libmodbus_rs;
4547

46-
use libmodbus_rs::{Modbus, ModbusServer, ModbusTCP};
48+
use libmodbus::{Modbus, ModbusServer, ModbusTCP};
4749
```
4850

4951
The examples in the examples directory show this.
@@ -56,7 +58,7 @@ The examples in the examples directory show this.
5658

5759
## Building libmodbus-rs
5860

59-
The libmodbus ffi bindings (libmodbus-sys) are build using [bindgen][bindgen]. [Bindgen need Clang 3.9 or greater on your system.][bindgen-reg]
61+
The libmodbus ffi bindings (libmodbus-sys) are build using [bindgen][bindgen]. [Bindgen need Clang 3.9 or greater on your system.][bindgen-requirements]
6062

6163
### Dependencies Archlinux
6264

@@ -72,7 +74,29 @@ apt install autoconf build-essential curl clang git-core libtool
7274

7375
Look also at the local ci/ docker files under `./ci/docker-archlinux` and `.ci/docker-debian9` for a known working, minimal setup.
7476

75-
For more information about the bindgen requirements please visit [https://servo.github.io/rust-bindgen/requirements.html][bindgen-reg]
77+
For more information about the bindgen requirements please visit [https://servo.github.io/rust-bindgen/requirements.html][bindgen-requirements]
78+
79+
## Dependencies Windows
80+
81+
Follow the msys2 instructions <https://www.msys2.org>
82+
83+
```sh
84+
pacman -Syu
85+
```
86+
87+
Followed by the second update step
88+
89+
```sh
90+
pacman -Su
91+
```
92+
93+
Finally install clang
94+
95+
```sh
96+
pacman -S mingw64/mingw-w64-x86_64-clang
97+
```
98+
99+
----
76100

77101
If all dependencies are solved, compile with `cargo build` and/ or run the tests with `cargo test`.
78102

@@ -82,11 +106,10 @@ cd libmodbus-rs
82106
cargo build
83107
```
84108

85-
86109
## Examples
87110

88-
All original libmodbus examples are reproduced in Rust. You can find them in the
89-
`examples` directory of this crate.
111+
Most of the original libmodbus examples are reproduced in Rust.
112+
You can found them in the `examples` directory of this crate.
90113

91114
**Please have look at the README.md in the examples directory for more information about the examples.**
92115

@@ -97,16 +120,15 @@ cargo run --example random-test-server
97120
```
98121

99122
In another shell start the client after the server
123+
100124
```sh
101125
cargo run --example random-test-client
102126
```
103127

104-
105128
# License
106129

107130
`libmodbus-rs` is distributed under the terms of the LGPL-2.1 license, which is the same license, [libmodbus](http://libmodbus.org/) is using.
108131

109-
110132
# Links
111133

112134
* [http://libmodbus.org][libmodbus]
@@ -124,4 +146,4 @@ This project hosts the original libmodbus documentation, used here, as well. Ple
124146
[libmodbus-repo]: https://github.com/stephane/libmodbus.git
125147
[libmodbus-doc]: http://zzeroo.github.io/libmodbus-rs/libmodbus/libmodbus.html
126148
[bindgen]: https://github.com/servo/rust-bindgen
127-
[bindgen-reg]: https://servo.github.io/rust-bindgen/requirements.html
149+
[bindgen-requirements]: https://servo.github.io/rust-bindgen/requirements.html

TODO.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# TODOs
2+
3+
## Urgend
4+
5+
- Error Handling
6+
[] remove failure crate
7+
[] create custom error or use another crate 'fehler'
8+
[] fix strange error in RTU
9+
```bash
10+
sudo socat PTY,link=/dev/ttyS10 PTY,link=/dev/ttyS11 &
11+
# this works only one time. The server then process strange data
12+
cargo run --example simple-server -- -b rtu -s /dev/ttyS10 &
13+
cargo run --example simple-client -- -b rtu -s /dev/ttyS11 &
14+
15+
# If you change the client/ server ports all is fine
16+
cargo run --example simple-server -- -b rtu -s /dev/ttyS11 &
17+
cargo run --example simple-client -- -b rtu -s /dev/ttyS10 &
18+
```

appveyor.bat

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
echo on
2+
SetLocal EnableDelayedExpansion
3+
4+
rem Matrix-driven Appveyor CI script for libmodbus-rs
5+
rem Currently only does MSYS2 builds.
6+
rem https://www.appveyor.com/docs/installed-software#mingw-msys-cygwin
7+
rem Needs the following vars:
8+
rem MSYS2_ARCH: x86_64 or i686
9+
rem MSYSTEM: MINGW64 or MINGW32
10+
rem target: x86_64-pc-windows-gnu, i686-pc-windows-gnu
11+
rem channel: stable, beta, nightly
12+
rem This script based on the work of the libmypaint team.
13+
14+
rem Download rust
15+
set RUSTUP_URL=https://win.rustup.rs/rustup-init.exe
16+
echo Downloading %RUSTUP_URL%...
17+
powershell -Command "appveyor DownloadFile https://win.rustup.rs/ -FileName rustup-init.exe"
18+
rustup-init -yv --default-toolchain %channel% --default-host %target%
19+
set PATH=%PATH%;%USERPROFILE%\.cargo\bin
20+
rustc -vV
21+
cargo -vV
22+
23+
rem Set the paths appropriately
24+
PATH C:\msys64\%MSYSTEM%\bin;C:\msys64\usr\bin;%PATH%
25+
PATH %PATH%;%USERPROFILE%\.cargo\bin
26+
27+
rem Upgrade the MSYS2 platform
28+
bash -lc "pacman --noconfirm --sync --refresh --refresh pacman"
29+
bash -lc "pacman --noconfirm --sync --refresh --refresh --sysupgrade --sysupgrade"
30+
31+
rem Install required tools
32+
bash -xlc "pacman --noconfirm -S --needed base-devel"
33+
34+
rem Install the relevant native dependencies
35+
bash -xlc "pacman --noconfirm -S --needed mingw-w64-%MSYS2_ARCH%-clang"
36+
37+
rem Invoke subsequent bash in the build tree
38+
cd %APPVEYOR_BUILD_FOLDER%
39+
set CHERE_INVOKING=yes
40+
41+
rem Build/test scripting
42+
bash -xlc "set pwd"
43+
bash -xlc "env"
44+
45+
cargo build --verbose
46+
cargo test --verbose

appveyor.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Appveyor configuration for Rust using rustup for Rust installation
2+
# Based on the template https://github.com/starkat99/appveyor-rust
3+
# Please validate before push https://ci.appveyor.com/tools/validate-yaml
4+
5+
## Operating System (VM environment) ##
6+
7+
# Rust needs at least Visual Studio 2013 Appveyor OS for MSVC targets.
8+
os: Visual Studio 2015
9+
10+
## Build Matrix ##
11+
12+
environment:
13+
matrix:
14+
- compiler: msys2
15+
ARCH: x64
16+
MSYS2_ARCH: x86_64
17+
MSYS2_DIR: msys64
18+
MSYSTEM: MINGW64
19+
channel: stable
20+
target: x86_64-pc-windows-gnu
21+
- compiler: msys2
22+
ARCH: x64
23+
MSYS2_ARCH: x86_64
24+
MSYS2_DIR: msys64
25+
MSYSTEM: MINGW64
26+
channel: nightly
27+
target: x86_64-pc-windows-gnu
28+
# - compiler: msys2
29+
# ARCH: x86
30+
# MSYS2_ARCH: i686
31+
# MSYS2_DIR: msys64
32+
# MSYSTEM: MINGW32
33+
# channel: stable
34+
# target: i686-pc-windows-gnu
35+
36+
### Allowed failures ###
37+
38+
matrix:
39+
allow_failures:
40+
- channel: nightly
41+
42+
build_script:
43+
- '%APPVEYOR_BUILD_FOLDER%\appveyor.bat'
44+
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
extern crate libmodbus_rs;
21
extern crate time;
32

43
mod unit_test_config;
54

6-
use libmodbus_rs::{Modbus, ModbusClient, ModbusTCP, ModbusRTU};
5+
use libmodbus::{Modbus, ModbusClient, ModbusTCP, ModbusRTU};
76
use std::env;
87
use std::io::Error;
98
use std::mem::size_of;
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
extern crate libmodbus_rs;
2-
31
mod unit_test_config;
42

5-
use libmodbus_rs::{Modbus, ModbusMapping, ModbusTCP};
3+
use libmodbus::{Modbus, ModbusMapping, ModbusTCP};
64

75

86
const NB_CONNECTION: i32 = 5;
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
extern crate libmodbus_rs;
2-
31
mod unit_test_config;
42

5-
use libmodbus_rs::{Modbus, ModbusMapping, ModbusServer, ModbusTCP, ModbusRTU};
3+
use libmodbus::{Modbus, ModbusMapping, ModbusServer, ModbusTCP, ModbusRTU};
64
use std::env;
75
use unit_test_config::*;
86

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
extern crate rand;
2-
extern crate libmodbus_rs;
3-
4-
use libmodbus_rs::{Modbus, ModbusClient};
1+
use libmodbus::{Modbus, ModbusClient};
52
use rand::Rng;
63

74

@@ -33,12 +30,12 @@ fn run() -> Result<(), String> {
3330
let mut rng = rand::thread_rng();
3431

3532
// // RTU
36-
// use libmodbus_rs::ModbusRTU;
33+
// use libmodbus::ModbusRTU;
3734
// let mut modbus = Modbus::new_rtu("/dev/ttyUSB0", 19200, 'N', 8, 1).expect("could not create RTU context");
3835
// modbus.set_slave(SERVER_ID).expect("could not set slave ID");
3936

4037
// TCP
41-
use libmodbus_rs::ModbusTCP;
38+
use libmodbus::ModbusTCP;
4239
let mut modbus = Modbus::new_tcp("127.0.0.1", 1502).expect("could not create TCP context");
4340

4441
modbus.set_debug(true).expect("could not set DEBUG mode");

0 commit comments

Comments
 (0)