Skip to content

Instantly share code, notes, and snippets.

@dennysfredericci
Created June 12, 2012 13:58
Show Gist options
  • Save dennysfredericci/2917690 to your computer and use it in GitHub Desktop.
Save dennysfredericci/2917690 to your computer and use it in GitHub Desktop.
ruby script to serial port
require 'rubygems'
require 'serialport'
begin
parameters = {"baud" => 19200, "data_bits" => 8, "stop_bits"=>1,"parity"=>SerialPort::NONE}
comm_port = '/dev/tty.usbmodem411'
sp = SerialPort.new(comm_port, parameters)
#sp.read_timeout = 1000
#sp.write_timeout = 1000
sp.write "AT+CPIN?\r\n"
puts sp.read
rescue
puts "Error: #{$!}"
sp.close
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment