Permalink
Browse files

Slower, but more reliable handshake for windows serial. Also closes #12

  • Loading branch information...
1 parent e7ff676 commit 4c1bc25024cc6324966828e0097fadedbf1bd289 @vickash vickash committed Apr 1, 2013
Showing with 14 additions and 2 deletions.
  1. +1 −1 lib/dino/tx_rx/base.rb
  2. +13 −1 lib/dino/tx_rx/serial.rb
View
@@ -27,7 +27,7 @@ def close_read
def write(message)
loop do
if IO.select(nil, [io], nil)
- io.puts(message)
+ io.syswrite(message)
break
end
end
View
@@ -15,6 +15,14 @@ def io
@io ||= connect
end
+ def handshake
+ if on_windows?
+ io; sleep 3
+ end
+
+ super
+ end
+
private
def connect
@@ -24,9 +32,13 @@ def connect
def tty_devices
return [@device] if @device
- return (1..9).map { |n| "COM#{n}" } if RUBY_PLATFORM.match /mswin|mingw/i
+ return (1..9).map { |n| "COM#{n}" } if on_windows?
`ls /dev`.split("\n").grep(/usb|ACM/).map{ |d| "/dev/#{d}" }
end
+
+ def on_windows?
+ RUBY_PLATFORM.match /mswin|mingw/i
+ end
end
end
end

0 comments on commit 4c1bc25

Please sign in to comment.