Skip to content

Instantly share code, notes, and snippets.

@kumekay
Created December 20, 2016 01:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kumekay/7bd87f072cbb5411faa847031d9ae81e to your computer and use it in GitHub Desktop.
Save kumekay/7bd87f072cbb5411faa847031d9ae81e to your computer and use it in GitHub Desktop.
Apas test client
require 'socket'
server = TCPSocket.open(ENV.fetch('APAS_TCP_SERVER', 'localhost'),
ENV.fetch('APAS_TCP_PORT', '4040'))
ready = server.gets(5)
puts ready
loop do
msg = rand > 0.1 ? "AT_pour_amb=#{100 + rand(200).to_i};" : 'AT_bottle_changed=1;'
server.print(msg)
puts msg
sleep rand(10)
end
server.close
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment