Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fail fast on USB disconnect

  • Loading branch information...
commit 36e1433eb36856fafb4994af34ecd3899f5272bd 1 parent d47fb86
@tpope authored
Showing with 4 additions and 5 deletions.
  1. +4 −5 lib/zerbo.rb
View
9 lib/zerbo.rb
@@ -17,9 +17,6 @@ def initialize(device=nil)
else
require 'serialport'
@device = SerialPort.new(device, 38400)
- unless RUBY_PLATFORM =~ /darwin/
- @device.read_timeout = 0
- end
end
@callbacks = []
end
@@ -41,8 +38,10 @@ def next_packet
end
alias next next_packet
- def read(*args)
- device.read(*args)
+ def read(length)
+ data = device.read(length)
+ raise Error, "Read timeout" unless data.to_s.length == length
+ data
end
protected :read
Please sign in to comment.
Something went wrong with that request. Please try again.