Skip to content

Commit

Permalink
error message
Browse files Browse the repository at this point in the history
  • Loading branch information
shokai committed Nov 20, 2010
1 parent 0636012 commit 69164b6
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions serial-socket-gateway
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
begin
require 'serialport' # system gem
rescue LoadError => e
STDERR.puts e
STDERR.puts 'cannot load serialport from system, loading rubygems...'
end
require 'rubygems'
require 'serialport' # ruby gem
Expand All @@ -11,9 +11,9 @@ require 'socket'

if ARGV.size < 1
if RUBY_PLATFORM =~ /mswin|mingw|cygwin|bccwin/
puts 'serial-socket-gateway COM1'
puts 'e.g. serial-socket-gateway COM1'
else
puts 'serial-socket-gateway /dev/tty.your-usbdevice'
puts 'e.g. serial-socket-gateway /dev/tty.your-usbdevice'
end
exit 1
end
Expand All @@ -27,7 +27,13 @@ clients = Array.new
serial_to_clients = Array.new

serial_device = ARGV.shift
sp = SerialPort.new(serial_device, 9600, 8, 1, SerialPort::NONE) # 9600bps, 8bit, stopbit 1, parity none
begin
sp = SerialPort.new(serial_device, 9600, 8, 1, SerialPort::NONE) # 9600bps, 8bit, stopbit 1, parity none
rescue => e
STDERR.puts 'cannot open serialport!!'
STDERR.puts e
exit 1
end


EventMachine::run do
Expand Down

0 comments on commit 69164b6

Please sign in to comment.