canonball 0.1.3 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.DS_Store +0 -0
- data/lib/canonball/canonball.so +0 -0
- data/lib/canonball/error_codes.rb +152 -0
- data/lib/canonball/version.rb +1 -1
- data/lib/canonball.rb +6 -0
- data/spec/lib/canonball_spec.rb +6 -1
- data/spec/spec_helper.rb +9 -0
- data/src/.DS_Store +0 -0
- data/src/canonball.cpp +69 -66
- data/src/download/.DS_Store +0 -0
- data/src/headers/canonball.h +16 -0
- data/src/test.rb +8 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6c664aea45ea7c8829fe5f11b537c5383e9bbf70
|
4
|
+
data.tar.gz: 75680357f179a695de8dc01bb611934368122842
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 632e5110a13ee248621c689f4da1820e0f201a831da502948057c7fe386242a61221f255f4941115be812d45f5c15b6c1a58c02231006cf0f6a388a040b65819
|
7
|
+
data.tar.gz: 52996b9c68d51b0b3f0919732c155b59c81bdececaefc4b944df81b6278ff10255ff14a553803a27a8abfd38b4e2ae7e840cacbf79785895343422389985e4b1
|
data/.DS_Store
CHANGED
Binary file
|
data/lib/canonball/canonball.so
CHANGED
Binary file
|
@@ -0,0 +1,152 @@
|
|
1
|
+
module Canonball
|
2
|
+
# ED-SDK Error Code Masks
|
3
|
+
EDS_ISSPECIFIC_MASK = 0
|
4
|
+
EDS_COMPONENTID_MASK = 0
|
5
|
+
EDS_RESERVED_MASK = 16711680
|
6
|
+
EDS_ERRORID_MASK = 65535
|
7
|
+
# ED-SDK Base Component IDs
|
8
|
+
EDS_CMP_ID_CLIENT_COMPONENTID = 16777216
|
9
|
+
EDS_CMP_ID_LLSDK_COMPONENTID = 33554432
|
10
|
+
EDS_CMP_ID_HLSDK_COMPONENTID = 50331648
|
11
|
+
# ED-SDK Functin Success Code
|
12
|
+
EDS_ERR_OK = 0
|
13
|
+
# Miscellaneous errors
|
14
|
+
EDS_ERR_UNIMPLEMENTED = 1
|
15
|
+
EDS_ERR_INTERNAL_ERROR = 2
|
16
|
+
EDS_ERR_MEM_ALLOC_FAILED = 3
|
17
|
+
EDS_ERR_MEM_FREE_FAILED = 4
|
18
|
+
EDS_ERR_OPERATION_CANCELLED = 5
|
19
|
+
EDS_ERR_INCOMPATIBLE_VERSION = 6
|
20
|
+
EDS_ERR_NOT_SUPPORTED = 7
|
21
|
+
EDS_ERR_UNEXPECTED_EXCEPTION = 8
|
22
|
+
EDS_ERR_PROTECTION_VIOLATION = 9
|
23
|
+
EDS_ERR_MISSING_SUBCOMPONENT = 10
|
24
|
+
EDS_ERR_SELECTION_UNAVAILABLE = 11
|
25
|
+
# File errors
|
26
|
+
EDS_ERR_FILE_IO_ERROR = 32
|
27
|
+
EDS_ERR_FILE_TOO_MANY_OPEN = 33
|
28
|
+
EDS_ERR_FILE_NOT_FOUND = 34
|
29
|
+
EDS_ERR_FILE_OPEN_ERROR = 35
|
30
|
+
EDS_ERR_FILE_CLOSE_ERROR = 36
|
31
|
+
EDS_ERR_FILE_SEEK_ERROR = 37
|
32
|
+
EDS_ERR_FILE_TELL_ERROR = 38
|
33
|
+
EDS_ERR_FILE_READ_ERROR = 39
|
34
|
+
EDS_ERR_FILE_WRITE_ERROR = 40
|
35
|
+
EDS_ERR_FILE_PERMISSION_ERROR = 41
|
36
|
+
EDS_ERR_FILE_DISK_FULL_ERROR = 42
|
37
|
+
EDS_ERR_FILE_ALREADY_EXISTS = 43
|
38
|
+
EDS_ERR_FILE_FORMAT_UNRECOGNIZED = 44
|
39
|
+
EDS_ERR_FILE_DATA_CORRUPT = 45
|
40
|
+
EDS_ERR_FILE_NAMING_NA = 46
|
41
|
+
# Directory errors
|
42
|
+
EDS_ERR_DIR_NOT_FOUND = 64
|
43
|
+
EDS_ERR_DIR_IO_ERROR = 65
|
44
|
+
EDS_ERR_DIR_ENTRY_NOT_FOUND = 66
|
45
|
+
EDS_ERR_DIR_ENTRY_EXISTS = 67
|
46
|
+
EDS_ERR_DIR_NOT_EMPTY = 68
|
47
|
+
# Property errors
|
48
|
+
EDS_ERR_PROPERTIES_UNAVAILABLE = 80
|
49
|
+
EDS_ERR_PROPERTIES_MISMATCH = 81
|
50
|
+
EDS_ERR_PROPERTIES_NOT_LOADED = 83
|
51
|
+
# Function Parameter errors
|
52
|
+
EDS_ERR_INVALID_PARAMETER = 96
|
53
|
+
EDS_ERR_INVALID_HANDLE = 97
|
54
|
+
EDS_ERR_INVALID_POINTER = 98
|
55
|
+
EDS_ERR_INVALID_INDEX = 99
|
56
|
+
EDS_ERR_INVALID_LENGTH = 100
|
57
|
+
EDS_ERR_INVALID_FN_POINTER = 101
|
58
|
+
EDS_ERR_INVALID_SORT_FN = 102
|
59
|
+
# Device errors
|
60
|
+
EDS_ERR_DEVICE_NOT_FOUND = 128
|
61
|
+
EDS_ERR_DEVICE_BUSY = 129
|
62
|
+
EDS_ERR_DEVICE_INVALID = 130
|
63
|
+
EDS_ERR_DEVICE_EMERGENCY = 131
|
64
|
+
EDS_ERR_DEVICE_MEMORY_FULL = 132
|
65
|
+
EDS_ERR_DEVICE_INTERNAL_ERROR = 133
|
66
|
+
EDS_ERR_DEVICE_INVALID_PARAMETER = 134
|
67
|
+
EDS_ERR_DEVICE_NO_DISK = 135
|
68
|
+
EDS_ERR_DEVICE_DISK_ERROR = 136
|
69
|
+
EDS_ERR_DEVICE_CF_GATE_CHANGED = 137
|
70
|
+
EDS_ERR_DEVICE_DIAL_CHANGED = 138
|
71
|
+
EDS_ERR_DEVICE_NOT_INSTALLED = 139
|
72
|
+
EDS_ERR_DEVICE_STAY_AWAKE = 140
|
73
|
+
EDS_ERR_DEVICE_NOT_RELEASED = 141
|
74
|
+
# Stream errors
|
75
|
+
EDS_ERR_STREAM_IO_ERROR = 160
|
76
|
+
EDS_ERR_STREAM_NOT_OPEN = 161
|
77
|
+
EDS_ERR_STREAM_ALREADY_OPEN = 162
|
78
|
+
EDS_ERR_STREAM_OPEN_ERROR = 163
|
79
|
+
EDS_ERR_STREAM_CLOSE_ERROR = 164
|
80
|
+
EDS_ERR_STREAM_SEEK_ERROR = 165
|
81
|
+
EDS_ERR_STREAM_TELL_ERROR = 166
|
82
|
+
EDS_ERR_STREAM_READ_ERROR = 167
|
83
|
+
EDS_ERR_STREAM_WRITE_ERROR = 168
|
84
|
+
EDS_ERR_STREAM_PERMISSION_ERROR = 169
|
85
|
+
EDS_ERR_STREAM_COULDNT_BEGIN_THREAD = 170
|
86
|
+
EDS_ERR_STREAM_BAD_OPTIONS = 171
|
87
|
+
EDS_ERR_STREAM_END_OF_STREAM = 172
|
88
|
+
# Communications errors
|
89
|
+
EDS_ERR_COMM_PORT_IS_IN_USE = 192
|
90
|
+
EDS_ERR_COMM_DISCONNECTED = 193
|
91
|
+
EDS_ERR_COMM_DEVICE_INCOMPATIBLE = 194
|
92
|
+
EDS_ERR_COMM_BUFFER_FULL = 195
|
93
|
+
EDS_ERR_COMM_USB_BUS_ERR = 196
|
94
|
+
# Lock/Unlock
|
95
|
+
EDS_ERR_USB_DEVICE_LOCK_ERROR = 208
|
96
|
+
EDS_ERR_USB_DEVICE_UNLOCK_ERROR = 209
|
97
|
+
# STI/WIA
|
98
|
+
EDS_ERR_STI_UNKNOWN_ERROR = 224
|
99
|
+
EDS_ERR_STI_INTERNAL_ERROR = 225
|
100
|
+
EDS_ERR_STI_DEVICE_CREATE_ERROR = 226
|
101
|
+
EDS_ERR_STI_DEVICE_RELEASE_ERROR = 227
|
102
|
+
EDS_ERR_DEVICE_NOT_LAUNCHED = 228
|
103
|
+
EDS_ERR_ENUM_NA = 240
|
104
|
+
EDS_ERR_INVALID_FN_CALL = 241
|
105
|
+
EDS_ERR_HANDLE_NOT_FOUND = 242
|
106
|
+
EDS_ERR_INVALID_ID = 243
|
107
|
+
EDS_ERR_WAIT_TIMEOUT_ERROR = 244
|
108
|
+
# PTP
|
109
|
+
EDS_ERR_SESSION_NOT_OPEN = 8195
|
110
|
+
EDS_ERR_INVALID_TRANSACTIONID = 8196
|
111
|
+
EDS_ERR_INCOMPLETE_TRANSFER = 8199
|
112
|
+
EDS_ERR_INVALID_STRAGEID = 8200
|
113
|
+
EDS_ERR_DEVICEPROP_NOT_SUPPORTED = 8202
|
114
|
+
EDS_ERR_INVALID_OBJECTFORMATCODE = 8203
|
115
|
+
EDS_ERR_SELF_TEST_FAILED = 8209
|
116
|
+
EDS_ERR_PARTIAL_DELETION = 8210
|
117
|
+
EDS_ERR_SPECIFICATION_BY_FORMAT_UNSUPPORTED = 8212
|
118
|
+
EDS_ERR_NO_VALID_OBJECTINFO = 8213
|
119
|
+
EDS_ERR_INVALID_CODE_FORMAT = 8214
|
120
|
+
EDS_ERR_UNKNOWN_VENDOR_CODE = 8215
|
121
|
+
EDS_ERR_CAPTURE_ALREADY_TERMINATED = 8216
|
122
|
+
EDS_ERR_INVALID_PARENTOBJECT = 8218
|
123
|
+
EDS_ERR_INVALID_DEVICEPROP_FORMAT = 8219
|
124
|
+
EDS_ERR_INVALID_DEVICEPROP_VALUE = 8220
|
125
|
+
EDS_ERR_SESSION_ALREADY_OPEN = 8222
|
126
|
+
EDS_ERR_TRANSACTION_CANCELLED = 8223
|
127
|
+
EDS_ERR_SPECIFICATION_OF_DESTINATION_UNSUPPORTED = 8224
|
128
|
+
EDS_ERR_NOT_CAMERA_SUPPORT_SDK_VERSION = 8225
|
129
|
+
# PTP Vendor
|
130
|
+
EDS_ERR_UNKNOWN_COMMAND = 40961
|
131
|
+
EDS_ERR_OPERATION_REFUSED = 40965
|
132
|
+
EDS_ERR_LENS_COVER_CLOSE = 40966
|
133
|
+
EDS_ERR_LOW_BATTERY = 41217
|
134
|
+
EDS_ERR_OBJECT_NOTREADY = 41218
|
135
|
+
EDS_ERR_CANNOT_MAKE_OBJECT = 41220
|
136
|
+
EDS_ERR_MEMORYSTATUS_NOTREADY = 41222
|
137
|
+
# Take Picture errors
|
138
|
+
EDS_ERR_TAKE_PICTURE_AF_NG = 36097
|
139
|
+
EDS_ERR_TAKE_PICTURE_RESERVED = 36098
|
140
|
+
EDS_ERR_TAKE_PICTURE_MIRROR_UP_NG = 36099
|
141
|
+
EDS_ERR_TAKE_PICTURE_SENSOR_CLEANING_NG = 36100
|
142
|
+
EDS_ERR_TAKE_PICTURE_SILENCE_NG = 36101
|
143
|
+
EDS_ERR_TAKE_PICTURE_NO_CARD_NG = 36102
|
144
|
+
EDS_ERR_TAKE_PICTURE_CARD_NG = 36103
|
145
|
+
EDS_ERR_TAKE_PICTURE_CARD_PROTECT_NG = 36104
|
146
|
+
EDS_ERR_TAKE_PICTURE_MOVIE_CROP_NG = 36105
|
147
|
+
EDS_ERR_TAKE_PICTURE_STROBO_CHARGE_NG = 36106
|
148
|
+
EDS_ERR_TAKE_PICTURE_NO_LENS_NG = 36107
|
149
|
+
EDS_ERR_TAKE_PICTURE_SPECIAL_MOVIE_MODE_NG = 36108
|
150
|
+
EDS_ERR_TAKE_PICTURE_LV_REL_PROHIBIT_MODE_NG = 36109
|
151
|
+
EDS_ERR_LAST_GENERIC_ERROR_PLUS_ONE = 245
|
152
|
+
end
|
data/lib/canonball/version.rb
CHANGED
data/lib/canonball.rb
CHANGED
@@ -1,9 +1,15 @@
|
|
1
|
+
# coding: UTF-8
|
1
2
|
require 'ffi'
|
2
3
|
require "canonball/version"
|
4
|
+
require "canonball/error_codes"
|
3
5
|
|
4
6
|
module Canonball
|
5
7
|
extend FFI::Library
|
6
8
|
ffi_lib "#{File.expand_path(File.dirname(__FILE__))}/canonball/canonball.so"
|
9
|
+
attach_function :inialize_sdk, [], :int
|
10
|
+
attach_function :terminate_sdk, [], :int
|
11
|
+
attach_function :open_camera_session, [ :int ], :int
|
12
|
+
attach_function :close_camera_session, [ :int ], :int
|
7
13
|
attach_function :take_picture, [ :int ], :int
|
8
14
|
attach_function :download_files, [ :int, :string], :int
|
9
15
|
end
|
data/spec/lib/canonball_spec.rb
CHANGED
@@ -2,6 +2,11 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Canonball do
|
4
4
|
it "verfiy delegation" do
|
5
|
-
expect(Canonball).to respond_to :
|
5
|
+
expect(Canonball).to respond_to :inialize_sdk,
|
6
|
+
:terminate_sdk,
|
7
|
+
:open_camera_session,
|
8
|
+
:close_camera_session,
|
9
|
+
:take_picture,
|
10
|
+
:download_files
|
6
11
|
end
|
7
12
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,3 +1,12 @@
|
|
1
1
|
require "codeclimate-test-reporter"
|
2
2
|
CodeClimate::TestReporter.start
|
3
3
|
require "canonball"
|
4
|
+
|
5
|
+
RSpec.configure do |config|
|
6
|
+
config.order = "random"
|
7
|
+
Kernel.srand config.seed
|
8
|
+
config.mock_with :rspec do |mocks|
|
9
|
+
mocks.verify_doubled_constant_names = true
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
data/src/.DS_Store
CHANGED
Binary file
|
data/src/canonball.cpp
CHANGED
@@ -7,100 +7,103 @@
|
|
7
7
|
|
8
8
|
#include "headers/canonball.h"
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
EdsCameraListRef _camera_list = NULL;
|
13
|
-
|
14
|
-
void inialize_sdk() {
|
15
|
-
_error = EdsInitializeSDK();
|
16
|
-
if (_error != EDS_ERR_OK) printf("No framework detected\n");
|
10
|
+
int inialize_sdk() {
|
11
|
+
return EdsInitializeSDK();
|
17
12
|
}
|
18
13
|
|
19
|
-
|
20
|
-
|
21
|
-
if (_error != EDS_ERR_OK) printf("Failed terminating framework\n");
|
14
|
+
int terminate_sdk() {
|
15
|
+
return EdsTerminateSDK();
|
22
16
|
}
|
23
17
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
if (
|
18
|
+
int open_camera_session(int camera_index) {
|
19
|
+
EdsError error = EDS_ERR_OK;
|
20
|
+
EdsCameraRef camera = NULL;
|
21
|
+
EdsCameraListRef camera_list = NULL;
|
22
|
+
if (error == EDS_ERR_OK) error = EdsGetCameraList(&camera_list);
|
23
|
+
if (error == EDS_ERR_OK) error = EdsGetChildAtIndex(camera_list, camera_index, &camera);
|
24
|
+
if (error == EDS_ERR_OK) error = EdsOpenSession(camera);
|
25
|
+
return error;
|
29
26
|
}
|
30
27
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
if (
|
28
|
+
int close_camera_session(int camera_index) {
|
29
|
+
EdsError error = EDS_ERR_OK;
|
30
|
+
EdsCameraRef camera = NULL;
|
31
|
+
EdsCameraListRef camera_list = NULL;
|
32
|
+
if (error == EDS_ERR_OK) error = EdsGetCameraList(&camera_list);
|
33
|
+
if (error == EDS_ERR_OK) error = EdsGetChildAtIndex(camera_list, camera_index, &camera);
|
34
|
+
if (error == EDS_ERR_OK) error = EdsCloseSession(camera);
|
35
|
+
if (error == EDS_ERR_OK) error = EdsRelease(camera);
|
36
|
+
if (error == EDS_ERR_OK) error = EdsRelease(camera_list);
|
37
|
+
return error;
|
36
38
|
}
|
37
39
|
|
38
40
|
int take_picture(int camera_index) {
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
41
|
+
EdsError error = EDS_ERR_OK;
|
42
|
+
EdsCameraRef camera = NULL;
|
43
|
+
EdsCameraListRef camera_list = NULL;
|
44
|
+
if (error == EDS_ERR_OK) error = EdsGetCameraList(&camera_list);
|
45
|
+
if (error == EDS_ERR_OK) error = EdsGetChildAtIndex(camera_list, camera_index, &camera);
|
46
|
+
if (error == EDS_ERR_OK) error = EdsSendCommand(camera , kEdsCameraCommand_TakePicture, 0);
|
47
|
+
return error;
|
48
|
+
}
|
49
|
+
|
50
|
+
int download_file(EdsDirectoryItemRef file_pointer, std::string folder){
|
51
|
+
EdsError error = EDS_ERR_OK;
|
52
|
+
EdsStreamRef stream = NULL;
|
53
|
+
EdsDirectoryItemInfo file;
|
54
|
+
if (error == EDS_ERR_OK) error = EdsGetDirectoryItemInfo(file_pointer, &file);
|
55
|
+
if (error == EDS_ERR_OK) error = EdsCreateFileStream( ( folder + file.szFileName ).c_str(), kEdsFileCreateDisposition_CreateAlways, kEdsAccess_ReadWrite, &stream);
|
56
|
+
if (error == EDS_ERR_OK) error = EdsDownload( file_pointer, file.size, stream);
|
57
|
+
if (error == EDS_ERR_OK) error = EdsDownloadComplete(file_pointer);
|
58
|
+
if (error == EDS_ERR_OK) error = EdsDeleteDirectoryItem(file_pointer);
|
59
|
+
if (error == EDS_ERR_OK) error = EdsRelease(stream);
|
60
|
+
return error;
|
45
61
|
}
|
46
62
|
|
47
|
-
|
63
|
+
int download_files(int camera_index, const char* folder) {
|
64
|
+
EdsError error = EDS_ERR_OK;
|
65
|
+
EdsCameraRef camera = NULL;
|
66
|
+
EdsCameraListRef camera_list = NULL;
|
67
|
+
|
48
68
|
EdsUInt32 folder_count = 0;
|
49
69
|
EdsVolumeRef sd_card = NULL;
|
50
70
|
EdsDirectoryItemRef dcim_folder = NULL;
|
51
71
|
EdsDirectoryItemInfo folder_info;
|
52
|
-
|
53
|
-
|
72
|
+
|
73
|
+
// Get DCIM folder
|
74
|
+
if (error == EDS_ERR_OK) error = EdsGetCameraList(&camera_list);
|
75
|
+
if (error == EDS_ERR_OK) error = EdsGetChildAtIndex(camera_list, camera_index, &camera);
|
76
|
+
if (error == EDS_ERR_OK) error = EdsGetChildAtIndex(camera, 0, &sd_card);
|
77
|
+
|
78
|
+
if (error == EDS_ERR_OK) error = EdsGetChildCount( sd_card, &folder_count);
|
54
79
|
for(int i = 0; i < folder_count; i++){
|
55
|
-
if (
|
56
|
-
if (
|
80
|
+
if (error == EDS_ERR_OK) error = EdsGetChildAtIndex( sd_card, i, &dcim_folder ) ;
|
81
|
+
if (error == EDS_ERR_OK) error = EdsGetDirectoryItemInfo( dcim_folder, &folder_info );
|
57
82
|
std::string folderName = folder_info.szFileName;
|
58
83
|
if( folderName == "DCIM" ) break;
|
59
|
-
if (
|
84
|
+
if (error == EDS_ERR_OK) error = EdsRelease(dcim_folder);
|
60
85
|
}
|
61
|
-
if (
|
62
|
-
return dcim_folder;
|
63
|
-
}
|
64
|
-
|
65
|
-
void download_file(EdsDirectoryItemRef file_pointer, std::string folder){
|
66
|
-
EdsStreamRef stream = NULL;
|
67
|
-
EdsDirectoryItemInfo file;
|
68
|
-
if (_error == EDS_ERR_OK) _error = EdsGetDirectoryItemInfo(file_pointer, &file);
|
69
|
-
if (_error == EDS_ERR_OK) _error = EdsCreateFileStream( ( folder + file.szFileName ).c_str(), kEdsFileCreateDisposition_CreateAlways, kEdsAccess_ReadWrite, &stream);
|
70
|
-
if (_error == EDS_ERR_OK) _error = EdsDownload( file_pointer, file.size, stream);
|
71
|
-
if (_error == EDS_ERR_OK) _error = EdsDownloadComplete(file_pointer);
|
72
|
-
if (_error == EDS_ERR_OK) _error = EdsDeleteDirectoryItem(file_pointer);
|
73
|
-
if (_error == EDS_ERR_OK) _error = EdsRelease(stream);
|
74
|
-
if (_error != EDS_ERR_OK) printf("Error downloading file\n");
|
75
|
-
}
|
76
|
-
|
77
|
-
int download_files(int camera_index, const char* folder) {
|
78
|
-
inialize_sdk();
|
79
|
-
open_camera_session(camera_index);
|
86
|
+
if (error == EDS_ERR_OK) error = EdsRelease(sd_card);
|
80
87
|
|
88
|
+
// Iterate directories
|
81
89
|
EdsDirectoryItemRef images_folder = NULL;
|
82
90
|
EdsDirectoryItemRef file = NULL;
|
83
91
|
EdsUInt32 sub_folder_count = 0;
|
84
|
-
EdsDirectoryItemRef dcim_folder = DCIM_folder();
|
85
92
|
|
86
|
-
EdsGetChildCount(dcim_folder, &sub_folder_count);
|
93
|
+
if (error == EDS_ERR_OK) error = EdsGetChildCount(dcim_folder, &sub_folder_count);
|
87
94
|
int lastIndex = sub_folder_count-1;
|
88
95
|
EdsDirectoryItemInfo dirItemInfo_Sub;
|
89
|
-
|
90
|
-
|
96
|
+
if (error == EDS_ERR_OK) error = EdsGetChildAtIndex(dcim_folder, lastIndex, &images_folder ) ;
|
97
|
+
if (error == EDS_ERR_OK) error = EdsGetDirectoryItemInfo( images_folder, &dirItemInfo_Sub);
|
91
98
|
EdsUInt32 jpgCount = 0;
|
92
|
-
|
99
|
+
if (error == EDS_ERR_OK) error = EdsGetChildCount(images_folder, &jpgCount );
|
93
100
|
for(int i = 0; i < jpgCount; i++){
|
94
|
-
EdsGetChildAtIndex(images_folder, i, &file ) ;
|
95
|
-
download_file(file , folder);
|
101
|
+
if (error == EDS_ERR_OK) error = EdsGetChildAtIndex(images_folder, i, &file ) ;
|
102
|
+
if (error == EDS_ERR_OK) error = download_file(file , folder);
|
96
103
|
}
|
97
104
|
|
98
|
-
EdsRelease(dcim_folder);
|
99
|
-
EdsRelease(images_folder);
|
100
|
-
EdsRelease(file);
|
101
|
-
|
102
|
-
close_camera_session();
|
103
|
-
terminate_sdk();
|
104
|
-
|
105
|
-
return _error;
|
105
|
+
if (error == EDS_ERR_OK) error = EdsRelease(dcim_folder);
|
106
|
+
if (error == EDS_ERR_OK) error = EdsRelease(images_folder);
|
107
|
+
if (error == EDS_ERR_OK) error = EdsRelease(file);
|
108
|
+
return error;
|
106
109
|
}
|
Binary file
|
data/src/headers/canonball.h
CHANGED
@@ -10,6 +10,22 @@
|
|
10
10
|
#include <string>
|
11
11
|
#include "EDSDK.h"
|
12
12
|
|
13
|
+
extern "C" {
|
14
|
+
int inialize_sdk();
|
15
|
+
}
|
16
|
+
|
17
|
+
extern "C" {
|
18
|
+
int terminate_sdk();
|
19
|
+
}
|
20
|
+
|
21
|
+
extern "C" {
|
22
|
+
int open_camera_session(int camera_index);
|
23
|
+
}
|
24
|
+
|
25
|
+
extern "C" {
|
26
|
+
int close_camera_session(int camera_index);
|
27
|
+
}
|
28
|
+
|
13
29
|
extern "C" {
|
14
30
|
int take_picture(int camera_index);
|
15
31
|
}
|
data/src/test.rb
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
puts Canonball.inialize_sdk
|
2
|
+
puts Canonball.open_camera_session 0
|
3
|
+
t = Time.now
|
4
|
+
puts Canonball.take_picture 0
|
5
|
+
puts Time.now - t
|
6
|
+
puts Canonball.download_files 0, "#{File.expand_path(File.dirname(__FILE__))}/download/"
|
7
|
+
puts Canonball.close_camera_session 0
|
8
|
+
puts Canonball.terminate_sdk
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: canonball
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jon Christopher
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-11-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -97,6 +97,7 @@ files:
|
|
97
97
|
- lib/.DS_Store
|
98
98
|
- lib/canonball.rb
|
99
99
|
- lib/canonball/canonball.so
|
100
|
+
- lib/canonball/error_codes.rb
|
100
101
|
- lib/canonball/version.rb
|
101
102
|
- spec/.DS_Store
|
102
103
|
- spec/lib/.DS_Store
|
@@ -107,10 +108,12 @@ files:
|
|
107
108
|
- src/Makefile
|
108
109
|
- src/canonball.cpp
|
109
110
|
- src/canonball.so
|
111
|
+
- src/download/.DS_Store
|
110
112
|
- src/headers/EDSDK.h
|
111
113
|
- src/headers/EDSDKErrors.h
|
112
114
|
- src/headers/EDSDKTypes.h
|
113
115
|
- src/headers/canonball.h
|
116
|
+
- src/test.rb
|
114
117
|
homepage: https://github.com/hooty/canonball
|
115
118
|
licenses:
|
116
119
|
- MIT
|