Created
June 12, 2012 13:58
-
-
Save dennysfredericci/2917690 to your computer and use it in GitHub Desktop.
ruby script to serial port
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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