This software serves data read from a Modbus slave through a websocket server. Data from various Modbus object types (coils, discrete inputs, input registers, holding registers) are converted to a JSON structure. Through this service then, Modbus data can be read easily from web applications.
Configuration of all the Modbus parameters resides in config.yml, along with its documentation, so this service can be easily adapted to any Modbus slave device.
For now this service can handle just one slave device, since it was created for the purpose of reading data from my solar inverter, but it can be easily extended to read data from multiple slaves.
At the moment this service lacks of handling of errors and no security precautions were implemented since it's used in a private dedicated lan.
There's a Raspberry PI deploy configuration for mina
Before starting the server, you need to configure your own config.yml, you can use config.example.yml as reference
$ ruby server_handler.rb start
Install on Raspberry-Pi
This script install gems in the user directory, so we can easily manage gems without using sudo. This is particularly useful if you use deployment tools such as capistrano or mina.
$ sudo apt-get install ruby git $ echo "gem: --user-install --no-rdoc --no-ri" > ~/.gemrc $ gem install bundler $ echo "export PATH=$PATH:~/.gem/ruby/2.1.0/bin" >> ~/.profile $ source ~/.profile $ bundle config --global path ~/.gem/ruby/2.1.0 $ git clone https://github.com/gabrypulzio/modbus-webspy.git $ cd modbus-webspy $ bundle
Load at startup
# cp scripts/modbus-webspy.sh /etc/init.d/ # chmod a+x /etc/init.d/modbus-webspy.sh # update-rc.d modbus-webspy.sh defaults