ffi-gphoto2 0.6.1 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 47eba00fa220e5731024fb274417962e94dd3f9d
4
- data.tar.gz: 7dc8ef9e1df14a714b959b0155d229aa4bced308
3
+ metadata.gz: cf11eabf2214ce078d1aeb77ead538196bd288a7
4
+ data.tar.gz: ea9df058f1c06e0d490bdc9ef8be4c6b5de4aaf8
5
5
  SHA512:
6
- metadata.gz: f4c3d6e6eeaf9ccb3579405b3410214a299c0b5ef9a94b0f3c1462963d5012a82585354411d4803609526191477f495374e5668c1f190812471ac6ec31d9bd9b
7
- data.tar.gz: c8323dd877ff8d23fb5e9c3aca348be5cd6683f5643cc46e7b498da246f5e08b4b7b30aec248e85220cb55dbe90d48cc97a52fc9a3b65ad29e56d9d2d1206b57
6
+ metadata.gz: c56d4570c4888b01440abd7dd8e4cf0782b99cec74958f15ae2751ec8c16a0df3ccb110f7b23ab84898be468da1b1cd7af61031eccb73e6a24cf273aa65cc811
7
+ data.tar.gz: 98b399dbb55eb4d813befb69494caf9c841c3eb663440c0fc1dfd0add182ec294a99655039fbc5e83c45db20cd4eeea30a754045571dff13127e6d83b6d291e3
@@ -2,6 +2,15 @@
2
2
 
3
3
  ## HEAD
4
4
 
5
+ ## 0.7.0 (2016-09-19)
6
+
7
+ * [CHANGE] Raise minimum `libgphoto2` version to 2.5.2. This version introduced
8
+ `gp_port_reset`.
9
+ * [ADD] Add `FFI::GPhoto2Port::GPPort` struct and related functions to do a
10
+ port reset.
11
+
12
+ ## 0.6.1 (2016-08-21)
13
+
5
14
  * [FIX] `ManagedStruct.release` actually calls `*_free` functions. Autorelease
6
15
  invocations were silently failing with a `TypeError` because the functions
7
16
  expected structs, not pointers.
data/README.md CHANGED
@@ -13,7 +13,8 @@ idiomatic Ruby way.
13
13
  ### Prerequisites
14
14
 
15
15
  * Ruby >= 1.9
16
- * libgphoto2 >= 2.5.0
16
+ * libgphoto2 >= 2.5.2
17
+ * libgphoto2_port >= 0.10.1
17
18
 
18
19
  ### Gem
19
20
 
@@ -19,7 +19,8 @@ Gem::Specification.new do |spec|
19
19
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
20
20
  spec.require_paths = ['lib']
21
21
 
22
- spec.requirements << 'libgphoto2 >= 2.5.0'
22
+ spec.requirements << 'libgphoto2 >= 2.5.2'
23
+ spec.requirements << 'libgphoto2_port >= 0.10.1'
23
24
  spec.required_ruby_version = '>= 1.9'
24
25
 
25
26
  spec.add_development_dependency 'bundler', '~> 1.3'
@@ -8,9 +8,16 @@ module FFI
8
8
  require 'ffi/gphoto2_port/gp_port_result'
9
9
 
10
10
  # enums
11
+ require 'ffi/gphoto2_port/gp_port_serial_parity'
11
12
  require 'ffi/gphoto2_port/gp_port_type'
12
13
 
13
14
  # structs
15
+ require 'ffi/gphoto2_port/gp_port_settings_serial'
16
+ require 'ffi/gphoto2_port/gp_port_settings_usb'
17
+ require 'ffi/gphoto2_port/gp_port_settings_usb_disk_direct'
18
+ require 'ffi/gphoto2_port/gp_port_settings_usb_scsi'
19
+ require 'ffi/gphoto2_port/gp_port_settings'
20
+ require 'ffi/gphoto2_port/gp_port'
14
21
  require 'ffi/gphoto2_port/gp_port_info'
15
22
  require 'ffi/gphoto2_port/gp_port_info_list'
16
23
 
@@ -27,5 +34,16 @@ module FFI
27
34
 
28
35
  # libgphoto2_port/gphoto2/gphoto2-port-result.h
29
36
  attach_function :gp_port_result_as_string, [:int], :string
37
+
38
+ # libgphoto2_port/gphoto2/gphoto2-port.h
39
+ attach_function :gp_port_new, [:pointer], :int
40
+ attach_function :gp_port_free, [:pointer], :int
41
+
42
+ attach_function :gp_port_set_info, [GPPort.by_ref, GPPortInfo], :int
43
+
44
+ attach_function :gp_port_open, [GPPort.by_ref], :int
45
+ attach_function :gp_port_close, [GPPort.by_ref], :int
46
+
47
+ attach_function :gp_port_reset, [GPPort.by_ref], :int
30
48
  end
31
49
  end
@@ -0,0 +1,17 @@
1
+ module FFI
2
+ module GPhoto2Port
3
+ class GPPort < FFI::ManagedStruct
4
+ # libgphoto2_port/libgphoto2_port/gphoto2-port.h
5
+ layout :type, GPPortType,
6
+ :settings, GPPortSettings,
7
+ :settings_pending, GPPortSettings,
8
+ :timeout, :int,
9
+ :pl, :pointer, # GPPortPrivateLibrary *
10
+ :pc, :pointer # GPPortPrivateCore *
11
+
12
+ def self.release(ptr)
13
+ FFI::GPhoto2.gp_port_free(ptr)
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,6 @@
1
+ module FFI
2
+ module GPhoto2Port
3
+ # libgphoto2_port/libgphoto2_port/gphoto2-port.h
4
+ GPPortSerialParity = enum :off, :even, :odd
5
+ end
6
+ end
@@ -0,0 +1,11 @@
1
+ module FFI
2
+ module GPhoto2Port
3
+ class GPPortSettings < FFI::Struct
4
+ # libgphoto2_port/libgphoto2_port/gphoto2-port.h
5
+ layout :serial, GPPortSettingsSerial,
6
+ :usb, GPPortSettingsUSB,
7
+ :usbdiskdirect, GPPortSettingsUsbDiskDirect,
8
+ :usbscsi, GPPortSettingsUsbScsi
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,12 @@
1
+ module FFI
2
+ module GPhoto2Port
3
+ class GPPortSettingsSerial < FFI::Struct
4
+ # libgphoto2_port/libgphoto2_port/gphoto2-port.h
5
+ layout :port, [:char, 128],
6
+ :speed, :int,
7
+ :bits, :int,
8
+ :parity, GPPortSerialParity,
9
+ :stopbits, :int
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,15 @@
1
+ module FFI
2
+ module GPhoto2Port
3
+ class GPPortSettingsUSB < FFI::Struct
4
+ # libgphoto2_port/libgphoto2_port/gphoto2-port.h
5
+ layout :inep, :int,
6
+ :outep, :int,
7
+ :intep, :int,
8
+ :config, :int,
9
+ :interface, :int,
10
+ :altsetting, :int,
11
+ :maxpacketsize, :int,
12
+ :port, [:char, 64]
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,8 @@
1
+ module FFI
2
+ module GPhoto2Port
3
+ class GPPortSettingsUsbDiskDirect < FFI::Struct
4
+ # libgphoto2_port/libgphoto2_port/gphoto2-port.h
5
+ layout :path, [:char, 128]
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ module FFI
2
+ module GPhoto2Port
3
+ class GPPortSettingsUsbScsi < FFI::Struct
4
+ # libgphoto2_port/libgphoto2_port/gphoto2-port.h
5
+ layout :path, [:char, 128]
6
+ end
7
+ end
8
+ end
@@ -35,6 +35,7 @@ require 'gphoto2/camera_folder'
35
35
  require 'gphoto2/camera_list'
36
36
  require 'gphoto2/context'
37
37
  require 'gphoto2/entry'
38
+ require 'gphoto2/port'
38
39
  require 'gphoto2/port_info'
39
40
  require 'gphoto2/port_info_list'
40
41
  require 'gphoto2/port_result'
@@ -0,0 +1,61 @@
1
+ module GPhoto2
2
+ class Port
3
+ include FFI::GPhoto2Port
4
+ include GPhoto2::Struct
5
+
6
+ def initialize
7
+ @ptr = new
8
+ end
9
+
10
+ # @param [PortInfo]
11
+ # @return [PortInfo]
12
+ def info=(info)
13
+ set_info(info)
14
+ info
15
+ end
16
+
17
+ # @return [void]
18
+ def open
19
+ _open
20
+ end
21
+
22
+ # @return [void]
23
+ def close
24
+ _close
25
+ end
26
+
27
+ # @return [void]
28
+ def reset
29
+ _reset
30
+ end
31
+
32
+ private
33
+
34
+ def new
35
+ ptr = FFI::MemoryPointer.new(:pointer)
36
+ rc = gp_port_new(ptr)
37
+ GPhoto2.check!(rc)
38
+ FFI::GPhoto2Port::GPPort.new(ptr.read_pointer)
39
+ end
40
+
41
+ def _open
42
+ rc = gp_port_open(ptr)
43
+ GPhoto2.check!(rc)
44
+ end
45
+
46
+ def _close
47
+ rc = gp_port_close(ptr)
48
+ GPhoto2.check!(rc)
49
+ end
50
+
51
+ def _reset
52
+ rc = gp_port_reset(ptr)
53
+ GPhoto2.check!(rc)
54
+ end
55
+
56
+ def set_info(port_info)
57
+ rc = gp_port_set_info(ptr, port_info.ptr)
58
+ GPhoto2.check!(rc)
59
+ end
60
+ end
61
+ end
@@ -1,3 +1,3 @@
1
1
  module GPhoto2
2
- VERSION = '0.6.1'
2
+ VERSION = '0.7.0'
3
3
  end
@@ -0,0 +1,22 @@
1
+ require 'spec_helper'
2
+
3
+ module GPhoto2
4
+ describe Port do
5
+ before do
6
+ allow_any_instance_of(Port).to receive(:new)
7
+ end
8
+
9
+ describe '#info=' do
10
+ let(:port) { Port.new }
11
+
12
+ before do
13
+ allow(port).to receive(:set_info)
14
+ end
15
+
16
+ it 'returns the input value' do
17
+ info = double(:port_info)
18
+ expect(port.info = info).to eq(info)
19
+ end
20
+ end
21
+ end
22
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ffi-gphoto2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Macias
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-08-22 00:00:00.000000000 Z
11
+ date: 2016-09-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -132,9 +132,16 @@ files:
132
132
  - lib/ffi/gphoto2/gp_context.rb
133
133
  - lib/ffi/gphoto2/gphoto_device_type.rb
134
134
  - lib/ffi/gphoto2_port.rb
135
+ - lib/ffi/gphoto2_port/gp_port.rb
135
136
  - lib/ffi/gphoto2_port/gp_port_info.rb
136
137
  - lib/ffi/gphoto2_port/gp_port_info_list.rb
137
138
  - lib/ffi/gphoto2_port/gp_port_result.rb
139
+ - lib/ffi/gphoto2_port/gp_port_serial_parity.rb
140
+ - lib/ffi/gphoto2_port/gp_port_settings.rb
141
+ - lib/ffi/gphoto2_port/gp_port_settings_serial.rb
142
+ - lib/ffi/gphoto2_port/gp_port_settings_usb.rb
143
+ - lib/ffi/gphoto2_port/gp_port_settings_usb_disk_direct.rb
144
+ - lib/ffi/gphoto2_port/gp_port_settings_usb_scsi.rb
138
145
  - lib/ffi/gphoto2_port/gp_port_type.rb
139
146
  - lib/gphoto2.rb
140
147
  - lib/gphoto2/camera.rb
@@ -162,6 +169,7 @@ files:
162
169
  - lib/gphoto2/camera_widgets/window_camera_widget.rb
163
170
  - lib/gphoto2/context.rb
164
171
  - lib/gphoto2/entry.rb
172
+ - lib/gphoto2/port.rb
165
173
  - lib/gphoto2/port_info.rb
166
174
  - lib/gphoto2/port_info_list.rb
167
175
  - lib/gphoto2/port_result.rb
@@ -184,6 +192,7 @@ files:
184
192
  - spec/gphoto2/entry_spec.rb
185
193
  - spec/gphoto2/port_info_list_spec.rb
186
194
  - spec/gphoto2/port_info_spec.rb
195
+ - spec/gphoto2/port_spec.rb
187
196
  - spec/gphoto2_spec.rb
188
197
  - spec/spec_helper.rb
189
198
  - spec/support/shared_examples/camera/capture_examples.rb
@@ -211,7 +220,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
211
220
  - !ruby/object:Gem::Version
212
221
  version: '0'
213
222
  requirements:
214
- - libgphoto2 >= 2.5.0
223
+ - libgphoto2 >= 2.5.2
224
+ - libgphoto2_port >= 0.10.1
215
225
  rubyforge_project:
216
226
  rubygems_version: 2.6.4
217
227
  signing_key:
@@ -235,6 +245,7 @@ test_files:
235
245
  - spec/gphoto2/entry_spec.rb
236
246
  - spec/gphoto2/port_info_list_spec.rb
237
247
  - spec/gphoto2/port_info_spec.rb
248
+ - spec/gphoto2/port_spec.rb
238
249
  - spec/gphoto2_spec.rb
239
250
  - spec/spec_helper.rb
240
251
  - spec/support/shared_examples/camera/capture_examples.rb