Linux Modbus Command line utility to set a coil on/off

  • Thread starter Avinoam Aharoni
  • Start date
A

Thread Starter

Avinoam Aharoni

Hi,

Is anyone aware of a command line utility for Linux to set the value of a coil on a modbus device (like modpoll but to set a value not read)?

Thanks!
 
T

Tallak Tveide

ruby -rrmodbus -e 'ModBus::TCPClient.new '1.2.3.4' do |cl|;cl.write_coil(1000, 0);end'

;-)
 
T

Tallak Tveide

<pre>ruby -rrmodbus -e 'ModBus::TCPClient.new "1.2.3.4" do |cl|;cl.write_coil(1000, 0);end'

or better, in file write_coil.rb:
----
#!/usr/bin/env ruby

require 'rmodbus'
ModBus::TCPClient.new "1.2.3.4" do |cl|
cl.write_coil(1000, 0)
end</pre>
----

then run chmod +x write_coil.rb, and run with ./write_coil.rb
 
Top