Skip to content

Instantly share code, notes, and snippets.

Created April 5, 2015 16:15
Show Gist options
  • Save anonymous/ca7e90593a398a66d90b to your computer and use it in GitHub Desktop.
Save anonymous/ca7e90593a398a66d90b to your computer and use it in GitHub Desktop.
require 'serialport'
port_str = '/dev/ttyUSB0'
baud_rate = 9600
data_bits = 8
stop_bits = 1
parity = SerialPort::NONE
time = Time.new
sr = SerialPort.new(port_str, baud_rate, data_bits, stop_bits, parity)
while(true) do
message = sr.readline("\r")
puts time.strftime("%Y-%m-%d %H:%M:%S")
puts message
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment