Skip to content

Instantly share code, notes, and snippets.

@cpfarher
Created December 22, 2017 19:15
Show Gist options
  • Select an option

  • Save cpfarher/da750b8a9e87a6334a708485a0e55e68 to your computer and use it in GitHub Desktop.

Select an option

Save cpfarher/da750b8a9e87a6334a708485a0e55e68 to your computer and use it in GitHub Desktop.
#require "plc_engine/daemons/plc_reading_engine"
#require "plc_engine/daemons/plc_writing_engine"
require 'colorize'
require 'rmodbus'
ip="10.0.0.2"
sl1 = ModBus::TCPClient.new(ip).with_slave(1)
sl2 = ModBus::TCPClient.new(ip).with_slave(1)
Thread.new do
loop { puts sl2.holding_registers[0..10]; puts "outside thread".green }
end
Thread.new do
loop { sl1.holding_registers[0..10]; puts "inside thread".red }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment