Skip to content

Commit

Permalink
Trying to match nil to a regex was killing the read thread X_X
Browse files Browse the repository at this point in the history
  • Loading branch information
vickash committed Mar 2, 2013
1 parent 74924b8 commit d350df0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions lib/dino/tx_rx/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def read
@thread ||= Thread.new do
loop do
line = gets
if line.match /\A\d+:/
if line && line.match(/\A\d+:/)
pin, message = line.chop.split(/:/)
pin && message && changed && notify_observers(pin, message)
end
Expand All @@ -34,12 +34,13 @@ def write(message)
end

def handshake
flush_read
100.times do
begin
write("!9000000.")
Timeout::timeout(0.1) do
line = gets.to_s
if line.match /ACK/
if line.match /ACK:/
flush_read
return line.chop.split(/:/)[1].to_i
end
Expand Down
2 changes: 1 addition & 1 deletion lib/dino/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Dino
VERSION = "0.11.0"
VERSION = "0.11.1"
end

0 comments on commit d350df0

Please sign in to comment.