bucaneer 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/bucaneer/bus_pirate.rb +17 -15
- data/lib/bucaneer/protocol/i2c.rb +1 -0
- data/lib/bucaneer/protocol/spi.rb +1 -0
- data/lib/bucaneer/version.rb +1 -1
- metadata +4 -4
data/lib/bucaneer/bus_pirate.rb
CHANGED
@@ -30,22 +30,21 @@ module Bucaneer
|
|
30
30
|
raise "no mode specified" unless mode
|
31
31
|
|
32
32
|
serial_port = SerialPort.new(dev, baud)
|
33
|
+
bus_pirate = Bucaneer::BusPirate.new(serial_port, mode, options)
|
33
34
|
|
34
|
-
|
35
|
-
bus_pirate = Bucaneer::BusPirate.new(serial_port, mode, options)
|
36
|
-
yield bus_pirate.protocol if block_given?
|
37
|
-
ensure
|
35
|
+
if block_given?
|
38
36
|
begin
|
39
|
-
|
40
|
-
|
41
|
-
|
37
|
+
yield bus_pirate.protocol
|
38
|
+
ensure
|
39
|
+
begin
|
40
|
+
bus_pirate.close
|
41
|
+
rescue
|
42
|
+
# Do nothing.
|
42
43
|
end
|
43
|
-
|
44
|
-
serial_port.close
|
45
|
-
rescue
|
46
|
-
# Do nothing.
|
47
44
|
end
|
48
45
|
end
|
46
|
+
|
47
|
+
bus_pirate
|
49
48
|
end
|
50
49
|
|
51
50
|
def initialize(serial_port, mode, options)
|
@@ -53,6 +52,12 @@ module Bucaneer
|
|
53
52
|
set_mode(mode.to_sym, options)
|
54
53
|
end
|
55
54
|
|
55
|
+
def close
|
56
|
+
enter_bitbang_mode
|
57
|
+
reset
|
58
|
+
@serial_port.close
|
59
|
+
end
|
60
|
+
|
56
61
|
def tx(byte, expected = SUCCESS)
|
57
62
|
@serial_port.putc byte
|
58
63
|
sleep TIMEOUT
|
@@ -72,10 +77,6 @@ module Bucaneer
|
|
72
77
|
end until response == "BBIO1"
|
73
78
|
end
|
74
79
|
|
75
|
-
def exit_bitbang_mode
|
76
|
-
tx(BITBANG_MODE)
|
77
|
-
end
|
78
|
-
|
79
80
|
def reset
|
80
81
|
tx(RESET)
|
81
82
|
end
|
@@ -92,6 +93,7 @@ module Bucaneer
|
|
92
93
|
end
|
93
94
|
|
94
95
|
private
|
96
|
+
|
95
97
|
# Set the BusPirate to the given mode.
|
96
98
|
def set_mode(mode, options)
|
97
99
|
enter_bitbang_mode
|
data/lib/bucaneer/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bucaneer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 1
|
10
|
+
version: 0.1.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Josh Bassett
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-09-
|
18
|
+
date: 2010-09-27 00:00:00 +10:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|