modbus
Version, currently master branch1 version
- master branchlatestSep 14, 2020
github.com/scttnlsn/modbus.cr
Modbus client library for Crystal
2 stars
0 dependents
License: MIT
Installation
# Add this to your shard.yml
dependencies:
modbus:
github: scttnlsn/modbus.cr
branch: mastermaster is a branch, not a release, so this tracks it rather than pinning a version.
Then run:
shards installshard.yml
- Crystal
0.33.0- License
- MIT
- Author
- Scott Nelson
Dependencies
This version declares no dependencies.
README
modbus.cr
Modbus client library for Crystal
Installation
-
Add the dependency to your
shard.yml:dependencies: modbus: github: scttnlsn/modbus.cr -
Run
shards install
Usage
require "modbus"
Documentation
Example
stty -F /dev/ttyUSB0 cs8 19200 ignbrk -brkint -icrnl -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke noflsh -ixon -crtscts -hupcl
require "modbus"
serial_port = File.open("/dev/ttyUSB0", "r+")
rtu_client = Modbus::RTUClient.open(serial_port)
# read 4 coils starting at address 1
coils : BitArray = rtu_client.read_coils(1, 4)
puts coils
require "socket"
socket = TCPSocket.new("example.modbus.host", 502)
tcp_client = Modbus::TCPClient.new(socket)
# read 1 register starting at address 123
registers = tcp_client.read_holding_registers(123, 1)
puts registers[0]
Testing
To run the tests:
crystal spec
Resources
Modbus protocol info:
- https://www.fernhillsoftware.com/help/drivers/modbus/modbus-protocol.html
- https://minimalmodbus.readthedocs.io/en/stable/modbusdetails.html
Documentation
Built from the current release. The first visit to a release nobody has asked for starts its build.
Links
This branch
- Branch
master- Seen
- Sep 14, 2020
- Crystal
0.33.0- Indexed
- yes
Dependents
No indexed shard depends on this one yet.
Repository
github.com/scttnlsn/modbus.cr
Metadata
- Created
- Aug 12, 2026
- Updated
- Aug 15, 2026
- Synced
- Aug 15, 2026
- Versions
- 1