Skip to content

Instantly share code, notes, and snippets.

@granolocks
Created March 27, 2012 17:38
Show Gist options
  • Save granolocks/2218260 to your computer and use it in GitHub Desktop.
Save granolocks/2218260 to your computer and use it in GitHub Desktop.
Simple Serial
# Simple Serial Listener I have used to listen to Arduino from Ubuntu.
# That is all.
require "serialport"
#params for serial port
port_str = "/dev/ttyACM0" #may be different for on different machines
baud_rate = 9600
data_bits = 8
stop_bits = 1
parity = SerialPort::NONE
sp = SerialPort.new(port_str, baud_rate, data_bits, stop_bits, parity)
#just read forever
while true do
getc = sp.getc
getc != nil ? printf("%c", getc) : getc = 0
end
sp.close
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment