tinkerforge 2.1.3 → 2.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/tinkerforge/brick_dc.rb +1 -1
- data/lib/tinkerforge/brick_imu.rb +1 -1
- data/lib/tinkerforge/brick_master.rb +1 -1
- data/lib/tinkerforge/brick_red.rb +821 -0
- data/lib/tinkerforge/brick_servo.rb +1 -1
- data/lib/tinkerforge/brick_stepper.rb +1 -1
- data/lib/tinkerforge/bricklet_ambient_light.rb +1 -1
- data/lib/tinkerforge/bricklet_analog_in.rb +1 -1
- data/lib/tinkerforge/bricklet_analog_out.rb +1 -1
- data/lib/tinkerforge/bricklet_barometer.rb +1 -1
- data/lib/tinkerforge/bricklet_color.rb +1 -1
- data/lib/tinkerforge/bricklet_current12.rb +1 -1
- data/lib/tinkerforge/bricklet_current25.rb +1 -1
- data/lib/tinkerforge/bricklet_distance_ir.rb +1 -1
- data/lib/tinkerforge/bricklet_distance_us.rb +1 -1
- data/lib/tinkerforge/bricklet_dual_button.rb +1 -1
- data/lib/tinkerforge/bricklet_dual_relay.rb +1 -1
- data/lib/tinkerforge/bricklet_gps.rb +1 -1
- data/lib/tinkerforge/bricklet_hall_effect.rb +1 -1
- data/lib/tinkerforge/bricklet_humidity.rb +1 -1
- data/lib/tinkerforge/bricklet_industrial_digital_in_4.rb +1 -1
- data/lib/tinkerforge/bricklet_industrial_digital_out_4.rb +1 -1
- data/lib/tinkerforge/bricklet_industrial_dual_0_20ma.rb +1 -1
- data/lib/tinkerforge/bricklet_industrial_quad_relay.rb +1 -1
- data/lib/tinkerforge/bricklet_io16.rb +1 -1
- data/lib/tinkerforge/bricklet_io4.rb +1 -1
- data/lib/tinkerforge/bricklet_joystick.rb +1 -1
- data/lib/tinkerforge/bricklet_lcd_16x2.rb +1 -1
- data/lib/tinkerforge/bricklet_lcd_20x4.rb +1 -1
- data/lib/tinkerforge/bricklet_led_strip.rb +1 -1
- data/lib/tinkerforge/bricklet_line.rb +1 -1
- data/lib/tinkerforge/bricklet_linear_poti.rb +1 -1
- data/lib/tinkerforge/bricklet_moisture.rb +1 -1
- data/lib/tinkerforge/bricklet_motion_detector.rb +1 -1
- data/lib/tinkerforge/bricklet_multi_touch.rb +1 -1
- data/lib/tinkerforge/bricklet_nfc_rfid.rb +1 -1
- data/lib/tinkerforge/bricklet_piezo_buzzer.rb +1 -1
- data/lib/tinkerforge/bricklet_piezo_speaker.rb +1 -1
- data/lib/tinkerforge/bricklet_ptc.rb +1 -1
- data/lib/tinkerforge/bricklet_remote_switch.rb +1 -1
- data/lib/tinkerforge/bricklet_rotary_encoder.rb +1 -1
- data/lib/tinkerforge/bricklet_rotary_poti.rb +1 -1
- data/lib/tinkerforge/bricklet_segment_display_4x7.rb +1 -1
- data/lib/tinkerforge/bricklet_solid_state_relay.rb +1 -1
- data/lib/tinkerforge/bricklet_sound_intensity.rb +1 -1
- data/lib/tinkerforge/bricklet_temperature.rb +1 -1
- data/lib/tinkerforge/bricklet_temperature_ir.rb +1 -1
- data/lib/tinkerforge/bricklet_tilt.rb +1 -1
- data/lib/tinkerforge/bricklet_voltage.rb +1 -1
- data/lib/tinkerforge/bricklet_voltage_current.rb +1 -1
- data/lib/tinkerforge/version.rb +1 -1
- metadata +2 -1
data/lib/tinkerforge/brick_dc.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
#############################################################
|
3
3
|
# This file was automatically generated on 2014-12-10. #
|
4
4
|
# #
|
5
|
-
# Bindings Version 2.1.
|
5
|
+
# Bindings Version 2.1.4 #
|
6
6
|
# #
|
7
7
|
# If you have a bugfix for this file and want to commit it, #
|
8
8
|
# please fix the bug in the generator. You can find a link #
|
@@ -2,7 +2,7 @@
|
|
2
2
|
#############################################################
|
3
3
|
# This file was automatically generated on 2014-12-10. #
|
4
4
|
# #
|
5
|
-
# Bindings Version 2.1.
|
5
|
+
# Bindings Version 2.1.4 #
|
6
6
|
# #
|
7
7
|
# If you have a bugfix for this file and want to commit it, #
|
8
8
|
# please fix the bug in the generator. You can find a link #
|
@@ -2,7 +2,7 @@
|
|
2
2
|
#############################################################
|
3
3
|
# This file was automatically generated on 2014-12-10. #
|
4
4
|
# #
|
5
|
-
# Bindings Version 2.1.
|
5
|
+
# Bindings Version 2.1.4 #
|
6
6
|
# #
|
7
7
|
# If you have a bugfix for this file and want to commit it, #
|
8
8
|
# please fix the bug in the generator. You can find a link #
|
@@ -0,0 +1,821 @@
|
|
1
|
+
# -*- ruby encoding: utf-8 -*-
|
2
|
+
#############################################################
|
3
|
+
# This file was automatically generated on 2014-12-10. #
|
4
|
+
# #
|
5
|
+
# Bindings Version 2.1.4 #
|
6
|
+
# #
|
7
|
+
# If you have a bugfix for this file and want to commit it, #
|
8
|
+
# please fix the bug in the generator. You can find a link #
|
9
|
+
# to the generator git on tinkerforge.com #
|
10
|
+
#############################################################
|
11
|
+
|
12
|
+
module Tinkerforge
|
13
|
+
# Device for running user programs standalone on the stack
|
14
|
+
class BrickRED < Device
|
15
|
+
DEVICE_IDENTIFIER = 17 # :nodoc:
|
16
|
+
|
17
|
+
# This callback reports the result of a call to the BrickRED#read_file_async
|
18
|
+
# function.
|
19
|
+
CALLBACK_ASYNC_FILE_READ = 30
|
20
|
+
|
21
|
+
# This callback reports the result of a call to the BrickRED#write_file_async
|
22
|
+
# function.
|
23
|
+
CALLBACK_ASYNC_FILE_WRITE = 31
|
24
|
+
|
25
|
+
#
|
26
|
+
CALLBACK_FILE_EVENTS_OCCURRED = 32
|
27
|
+
|
28
|
+
#
|
29
|
+
CALLBACK_PROCESS_STATE_CHANGED = 45
|
30
|
+
|
31
|
+
#
|
32
|
+
CALLBACK_PROGRAM_SCHEDULER_STATE_CHANGED = 65
|
33
|
+
|
34
|
+
#
|
35
|
+
CALLBACK_PROGRAM_PROCESS_SPAWNED = 66
|
36
|
+
|
37
|
+
FUNCTION_CREATE_SESSION = 1 # :nodoc:
|
38
|
+
FUNCTION_EXPIRE_SESSION = 2 # :nodoc:
|
39
|
+
FUNCTION_EXPIRE_SESSION_UNCHECKED = 3 # :nodoc:
|
40
|
+
FUNCTION_KEEP_SESSION_ALIVE = 4 # :nodoc:
|
41
|
+
FUNCTION_RELEASE_OBJECT = 5 # :nodoc:
|
42
|
+
FUNCTION_RELEASE_OBJECT_UNCHECKED = 6 # :nodoc:
|
43
|
+
FUNCTION_ALLOCATE_STRING = 7 # :nodoc:
|
44
|
+
FUNCTION_TRUNCATE_STRING = 8 # :nodoc:
|
45
|
+
FUNCTION_GET_STRING_LENGTH = 9 # :nodoc:
|
46
|
+
FUNCTION_SET_STRING_CHUNK = 10 # :nodoc:
|
47
|
+
FUNCTION_GET_STRING_CHUNK = 11 # :nodoc:
|
48
|
+
FUNCTION_ALLOCATE_LIST = 12 # :nodoc:
|
49
|
+
FUNCTION_GET_LIST_LENGTH = 13 # :nodoc:
|
50
|
+
FUNCTION_GET_LIST_ITEM = 14 # :nodoc:
|
51
|
+
FUNCTION_APPEND_TO_LIST = 15 # :nodoc:
|
52
|
+
FUNCTION_REMOVE_FROM_LIST = 16 # :nodoc:
|
53
|
+
FUNCTION_OPEN_FILE = 17 # :nodoc:
|
54
|
+
FUNCTION_CREATE_PIPE = 18 # :nodoc:
|
55
|
+
FUNCTION_GET_FILE_INFO = 19 # :nodoc:
|
56
|
+
FUNCTION_READ_FILE = 20 # :nodoc:
|
57
|
+
FUNCTION_READ_FILE_ASYNC = 21 # :nodoc:
|
58
|
+
FUNCTION_ABORT_ASYNC_FILE_READ = 22 # :nodoc:
|
59
|
+
FUNCTION_WRITE_FILE = 23 # :nodoc:
|
60
|
+
FUNCTION_WRITE_FILE_UNCHECKED = 24 # :nodoc:
|
61
|
+
FUNCTION_WRITE_FILE_ASYNC = 25 # :nodoc:
|
62
|
+
FUNCTION_SET_FILE_POSITION = 26 # :nodoc:
|
63
|
+
FUNCTION_GET_FILE_POSITION = 27 # :nodoc:
|
64
|
+
FUNCTION_SET_FILE_EVENTS = 28 # :nodoc:
|
65
|
+
FUNCTION_GET_FILE_EVENTS = 29 # :nodoc:
|
66
|
+
FUNCTION_OPEN_DIRECTORY = 33 # :nodoc:
|
67
|
+
FUNCTION_GET_DIRECTORY_NAME = 34 # :nodoc:
|
68
|
+
FUNCTION_GET_NEXT_DIRECTORY_ENTRY = 35 # :nodoc:
|
69
|
+
FUNCTION_REWIND_DIRECTORY = 36 # :nodoc:
|
70
|
+
FUNCTION_CREATE_DIRECTORY = 37 # :nodoc:
|
71
|
+
FUNCTION_GET_PROCESSES = 38 # :nodoc:
|
72
|
+
FUNCTION_SPAWN_PROCESS = 39 # :nodoc:
|
73
|
+
FUNCTION_KILL_PROCESS = 40 # :nodoc:
|
74
|
+
FUNCTION_GET_PROCESS_COMMAND = 41 # :nodoc:
|
75
|
+
FUNCTION_GET_PROCESS_IDENTITY = 42 # :nodoc:
|
76
|
+
FUNCTION_GET_PROCESS_STDIO = 43 # :nodoc:
|
77
|
+
FUNCTION_GET_PROCESS_STATE = 44 # :nodoc:
|
78
|
+
FUNCTION_GET_PROGRAMS = 46 # :nodoc:
|
79
|
+
FUNCTION_DEFINE_PROGRAM = 47 # :nodoc:
|
80
|
+
FUNCTION_PURGE_PROGRAM = 48 # :nodoc:
|
81
|
+
FUNCTION_GET_PROGRAM_IDENTIFIER = 49 # :nodoc:
|
82
|
+
FUNCTION_GET_PROGRAM_ROOT_DIRECTORY = 50 # :nodoc:
|
83
|
+
FUNCTION_SET_PROGRAM_COMMAND = 51 # :nodoc:
|
84
|
+
FUNCTION_GET_PROGRAM_COMMAND = 52 # :nodoc:
|
85
|
+
FUNCTION_SET_PROGRAM_STDIO_REDIRECTION = 53 # :nodoc:
|
86
|
+
FUNCTION_GET_PROGRAM_STDIO_REDIRECTION = 54 # :nodoc:
|
87
|
+
FUNCTION_SET_PROGRAM_SCHEDULE = 55 # :nodoc:
|
88
|
+
FUNCTION_GET_PROGRAM_SCHEDULE = 56 # :nodoc:
|
89
|
+
FUNCTION_GET_PROGRAM_SCHEDULER_STATE = 57 # :nodoc:
|
90
|
+
FUNCTION_CONTINUE_PROGRAM_SCHEDULE = 58 # :nodoc:
|
91
|
+
FUNCTION_START_PROGRAM = 59 # :nodoc:
|
92
|
+
FUNCTION_GET_LAST_SPAWNED_PROGRAM_PROCESS = 60 # :nodoc:
|
93
|
+
FUNCTION_GET_CUSTOM_PROGRAM_OPTION_NAMES = 61 # :nodoc:
|
94
|
+
FUNCTION_SET_CUSTOM_PROGRAM_OPTION_VALUE = 62 # :nodoc:
|
95
|
+
FUNCTION_GET_CUSTOM_PROGRAM_OPTION_VALUE = 63 # :nodoc:
|
96
|
+
FUNCTION_REMOVE_CUSTOM_PROGRAM_OPTION = 64 # :nodoc:
|
97
|
+
FUNCTION_GET_IDENTITY = 255 # :nodoc:
|
98
|
+
|
99
|
+
OBJECT_TYPE_STRING = 0 # :nodoc:
|
100
|
+
OBJECT_TYPE_LIST = 1 # :nodoc:
|
101
|
+
OBJECT_TYPE_FILE = 2 # :nodoc:
|
102
|
+
OBJECT_TYPE_DIRECTORY = 3 # :nodoc:
|
103
|
+
OBJECT_TYPE_PROCESS = 4 # :nodoc:
|
104
|
+
OBJECT_TYPE_PROGRAM = 5 # :nodoc:
|
105
|
+
FILE_FLAG_READ_ONLY = 1 # :nodoc:
|
106
|
+
FILE_FLAG_WRITE_ONLY = 2 # :nodoc:
|
107
|
+
FILE_FLAG_READ_WRITE = 4 # :nodoc:
|
108
|
+
FILE_FLAG_APPEND = 8 # :nodoc:
|
109
|
+
FILE_FLAG_CREATE = 16 # :nodoc:
|
110
|
+
FILE_FLAG_EXCLUSIVE = 32 # :nodoc:
|
111
|
+
FILE_FLAG_NON_BLOCKING = 64 # :nodoc:
|
112
|
+
FILE_FLAG_TRUNCATE = 128 # :nodoc:
|
113
|
+
FILE_FLAG_TEMPORARY = 256 # :nodoc:
|
114
|
+
FILE_FLAG_REPLACE = 512 # :nodoc:
|
115
|
+
FILE_PERMISSION_USER_ALL = 448 # :nodoc:
|
116
|
+
FILE_PERMISSION_USER_READ = 256 # :nodoc:
|
117
|
+
FILE_PERMISSION_USER_WRITE = 128 # :nodoc:
|
118
|
+
FILE_PERMISSION_USER_EXECUTE = 64 # :nodoc:
|
119
|
+
FILE_PERMISSION_GROUP_ALL = 56 # :nodoc:
|
120
|
+
FILE_PERMISSION_GROUP_READ = 32 # :nodoc:
|
121
|
+
FILE_PERMISSION_GROUP_WRITE = 16 # :nodoc:
|
122
|
+
FILE_PERMISSION_GROUP_EXECUTE = 8 # :nodoc:
|
123
|
+
FILE_PERMISSION_OTHERS_ALL = 7 # :nodoc:
|
124
|
+
FILE_PERMISSION_OTHERS_READ = 4 # :nodoc:
|
125
|
+
FILE_PERMISSION_OTHERS_WRITE = 2 # :nodoc:
|
126
|
+
FILE_PERMISSION_OTHERS_EXECUTE = 1 # :nodoc:
|
127
|
+
PIPE_FLAG_NON_BLOCKING_READ = 1 # :nodoc:
|
128
|
+
PIPE_FLAG_NON_BLOCKING_WRITE = 2 # :nodoc:
|
129
|
+
FILE_TYPE_UNKNOWN = 0 # :nodoc:
|
130
|
+
FILE_TYPE_REGULAR = 1 # :nodoc:
|
131
|
+
FILE_TYPE_DIRECTORY = 2 # :nodoc:
|
132
|
+
FILE_TYPE_CHARACTER = 3 # :nodoc:
|
133
|
+
FILE_TYPE_BLOCK = 4 # :nodoc:
|
134
|
+
FILE_TYPE_FIFO = 5 # :nodoc:
|
135
|
+
FILE_TYPE_SYMLINK = 6 # :nodoc:
|
136
|
+
FILE_TYPE_SOCKET = 7 # :nodoc:
|
137
|
+
FILE_TYPE_PIPE = 8 # :nodoc:
|
138
|
+
FILE_ORIGIN_BEGINNING = 0 # :nodoc:
|
139
|
+
FILE_ORIGIN_CURRENT = 1 # :nodoc:
|
140
|
+
FILE_ORIGIN_END = 2 # :nodoc:
|
141
|
+
FILE_EVENT_READABLE = 1 # :nodoc:
|
142
|
+
FILE_EVENT_WRITABLE = 2 # :nodoc:
|
143
|
+
DIRECTORY_ENTRY_TYPE_UNKNOWN = 0 # :nodoc:
|
144
|
+
DIRECTORY_ENTRY_TYPE_REGULAR = 1 # :nodoc:
|
145
|
+
DIRECTORY_ENTRY_TYPE_DIRECTORY = 2 # :nodoc:
|
146
|
+
DIRECTORY_ENTRY_TYPE_CHARACTER = 3 # :nodoc:
|
147
|
+
DIRECTORY_ENTRY_TYPE_BLOCK = 4 # :nodoc:
|
148
|
+
DIRECTORY_ENTRY_TYPE_FIFO = 5 # :nodoc:
|
149
|
+
DIRECTORY_ENTRY_TYPE_SYMLINK = 6 # :nodoc:
|
150
|
+
DIRECTORY_ENTRY_TYPE_SOCKET = 7 # :nodoc:
|
151
|
+
DIRECTORY_FLAG_RECURSIVE = 1 # :nodoc:
|
152
|
+
DIRECTORY_FLAG_EXCLUSIVE = 2 # :nodoc:
|
153
|
+
PROCESS_SIGNAL_INTERRUPT = 2 # :nodoc:
|
154
|
+
PROCESS_SIGNAL_QUIT = 3 # :nodoc:
|
155
|
+
PROCESS_SIGNAL_ABORT = 6 # :nodoc:
|
156
|
+
PROCESS_SIGNAL_KILL = 9 # :nodoc:
|
157
|
+
PROCESS_SIGNAL_USER1 = 10 # :nodoc:
|
158
|
+
PROCESS_SIGNAL_USER2 = 12 # :nodoc:
|
159
|
+
PROCESS_SIGNAL_TERMINATE = 15 # :nodoc:
|
160
|
+
PROCESS_SIGNAL_CONTINUE = 18 # :nodoc:
|
161
|
+
PROCESS_SIGNAL_STOP = 19 # :nodoc:
|
162
|
+
PROCESS_STATE_UNKNOWN = 0 # :nodoc:
|
163
|
+
PROCESS_STATE_RUNNING = 1 # :nodoc:
|
164
|
+
PROCESS_STATE_ERROR = 2 # :nodoc:
|
165
|
+
PROCESS_STATE_EXITED = 3 # :nodoc:
|
166
|
+
PROCESS_STATE_KILLED = 4 # :nodoc:
|
167
|
+
PROCESS_STATE_STOPPED = 5 # :nodoc:
|
168
|
+
PROGRAM_STDIO_REDIRECTION_DEV_NULL = 0 # :nodoc:
|
169
|
+
PROGRAM_STDIO_REDIRECTION_PIPE = 1 # :nodoc:
|
170
|
+
PROGRAM_STDIO_REDIRECTION_FILE = 2 # :nodoc:
|
171
|
+
PROGRAM_STDIO_REDIRECTION_INDIVIDUAL_LOG = 3 # :nodoc:
|
172
|
+
PROGRAM_STDIO_REDIRECTION_CONTINUOUS_LOG = 4 # :nodoc:
|
173
|
+
PROGRAM_STDIO_REDIRECTION_STDOUT = 5 # :nodoc:
|
174
|
+
PROGRAM_START_MODE_NEVER = 0 # :nodoc:
|
175
|
+
PROGRAM_START_MODE_ALWAYS = 1 # :nodoc:
|
176
|
+
PROGRAM_START_MODE_INTERVAL = 2 # :nodoc:
|
177
|
+
PROGRAM_START_MODE_CRON = 3 # :nodoc:
|
178
|
+
PROGRAM_SCHEDULER_STATE_STOPPED = 0 # :nodoc:
|
179
|
+
PROGRAM_SCHEDULER_STATE_RUNNING = 1 # :nodoc:
|
180
|
+
|
181
|
+
# Creates an object with the unique device ID <tt>uid</tt> and adds it to
|
182
|
+
# the IP Connection <tt>ipcon</tt>.
|
183
|
+
def initialize(uid, ipcon)
|
184
|
+
super uid, ipcon
|
185
|
+
|
186
|
+
@api_version = [2, 0, 0]
|
187
|
+
|
188
|
+
@response_expected[FUNCTION_CREATE_SESSION] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
189
|
+
@response_expected[FUNCTION_EXPIRE_SESSION] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
190
|
+
@response_expected[FUNCTION_EXPIRE_SESSION_UNCHECKED] = RESPONSE_EXPECTED_FALSE
|
191
|
+
@response_expected[FUNCTION_KEEP_SESSION_ALIVE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
192
|
+
@response_expected[FUNCTION_RELEASE_OBJECT] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
193
|
+
@response_expected[FUNCTION_RELEASE_OBJECT_UNCHECKED] = RESPONSE_EXPECTED_FALSE
|
194
|
+
@response_expected[FUNCTION_ALLOCATE_STRING] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
195
|
+
@response_expected[FUNCTION_TRUNCATE_STRING] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
196
|
+
@response_expected[FUNCTION_GET_STRING_LENGTH] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
197
|
+
@response_expected[FUNCTION_SET_STRING_CHUNK] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
198
|
+
@response_expected[FUNCTION_GET_STRING_CHUNK] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
199
|
+
@response_expected[FUNCTION_ALLOCATE_LIST] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
200
|
+
@response_expected[FUNCTION_GET_LIST_LENGTH] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
201
|
+
@response_expected[FUNCTION_GET_LIST_ITEM] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
202
|
+
@response_expected[FUNCTION_APPEND_TO_LIST] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
203
|
+
@response_expected[FUNCTION_REMOVE_FROM_LIST] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
204
|
+
@response_expected[FUNCTION_OPEN_FILE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
205
|
+
@response_expected[FUNCTION_CREATE_PIPE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
206
|
+
@response_expected[FUNCTION_GET_FILE_INFO] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
207
|
+
@response_expected[FUNCTION_READ_FILE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
208
|
+
@response_expected[FUNCTION_READ_FILE_ASYNC] = RESPONSE_EXPECTED_FALSE
|
209
|
+
@response_expected[FUNCTION_ABORT_ASYNC_FILE_READ] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
210
|
+
@response_expected[FUNCTION_WRITE_FILE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
211
|
+
@response_expected[FUNCTION_WRITE_FILE_UNCHECKED] = RESPONSE_EXPECTED_FALSE
|
212
|
+
@response_expected[FUNCTION_WRITE_FILE_ASYNC] = RESPONSE_EXPECTED_FALSE
|
213
|
+
@response_expected[FUNCTION_SET_FILE_POSITION] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
214
|
+
@response_expected[FUNCTION_GET_FILE_POSITION] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
215
|
+
@response_expected[FUNCTION_SET_FILE_EVENTS] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
216
|
+
@response_expected[FUNCTION_GET_FILE_EVENTS] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
217
|
+
@response_expected[CALLBACK_ASYNC_FILE_READ] = RESPONSE_EXPECTED_ALWAYS_FALSE
|
218
|
+
@response_expected[CALLBACK_ASYNC_FILE_WRITE] = RESPONSE_EXPECTED_ALWAYS_FALSE
|
219
|
+
@response_expected[CALLBACK_FILE_EVENTS_OCCURRED] = RESPONSE_EXPECTED_ALWAYS_FALSE
|
220
|
+
@response_expected[FUNCTION_OPEN_DIRECTORY] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
221
|
+
@response_expected[FUNCTION_GET_DIRECTORY_NAME] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
222
|
+
@response_expected[FUNCTION_GET_NEXT_DIRECTORY_ENTRY] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
223
|
+
@response_expected[FUNCTION_REWIND_DIRECTORY] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
224
|
+
@response_expected[FUNCTION_CREATE_DIRECTORY] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
225
|
+
@response_expected[FUNCTION_GET_PROCESSES] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
226
|
+
@response_expected[FUNCTION_SPAWN_PROCESS] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
227
|
+
@response_expected[FUNCTION_KILL_PROCESS] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
228
|
+
@response_expected[FUNCTION_GET_PROCESS_COMMAND] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
229
|
+
@response_expected[FUNCTION_GET_PROCESS_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
230
|
+
@response_expected[FUNCTION_GET_PROCESS_STDIO] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
231
|
+
@response_expected[FUNCTION_GET_PROCESS_STATE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
232
|
+
@response_expected[CALLBACK_PROCESS_STATE_CHANGED] = RESPONSE_EXPECTED_ALWAYS_FALSE
|
233
|
+
@response_expected[FUNCTION_GET_PROGRAMS] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
234
|
+
@response_expected[FUNCTION_DEFINE_PROGRAM] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
235
|
+
@response_expected[FUNCTION_PURGE_PROGRAM] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
236
|
+
@response_expected[FUNCTION_GET_PROGRAM_IDENTIFIER] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
237
|
+
@response_expected[FUNCTION_GET_PROGRAM_ROOT_DIRECTORY] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
238
|
+
@response_expected[FUNCTION_SET_PROGRAM_COMMAND] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
239
|
+
@response_expected[FUNCTION_GET_PROGRAM_COMMAND] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
240
|
+
@response_expected[FUNCTION_SET_PROGRAM_STDIO_REDIRECTION] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
241
|
+
@response_expected[FUNCTION_GET_PROGRAM_STDIO_REDIRECTION] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
242
|
+
@response_expected[FUNCTION_SET_PROGRAM_SCHEDULE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
243
|
+
@response_expected[FUNCTION_GET_PROGRAM_SCHEDULE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
244
|
+
@response_expected[FUNCTION_GET_PROGRAM_SCHEDULER_STATE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
245
|
+
@response_expected[FUNCTION_CONTINUE_PROGRAM_SCHEDULE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
246
|
+
@response_expected[FUNCTION_START_PROGRAM] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
247
|
+
@response_expected[FUNCTION_GET_LAST_SPAWNED_PROGRAM_PROCESS] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
248
|
+
@response_expected[FUNCTION_GET_CUSTOM_PROGRAM_OPTION_NAMES] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
249
|
+
@response_expected[FUNCTION_SET_CUSTOM_PROGRAM_OPTION_VALUE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
250
|
+
@response_expected[FUNCTION_GET_CUSTOM_PROGRAM_OPTION_VALUE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
251
|
+
@response_expected[FUNCTION_REMOVE_CUSTOM_PROGRAM_OPTION] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
252
|
+
@response_expected[CALLBACK_PROGRAM_SCHEDULER_STATE_CHANGED] = RESPONSE_EXPECTED_ALWAYS_FALSE
|
253
|
+
@response_expected[CALLBACK_PROGRAM_PROCESS_SPAWNED] = RESPONSE_EXPECTED_ALWAYS_FALSE
|
254
|
+
@response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
255
|
+
|
256
|
+
@callback_formats[CALLBACK_ASYNC_FILE_READ] = 'S C C60 C'
|
257
|
+
@callback_formats[CALLBACK_ASYNC_FILE_WRITE] = 'S C C'
|
258
|
+
@callback_formats[CALLBACK_FILE_EVENTS_OCCURRED] = 'S S'
|
259
|
+
@callback_formats[CALLBACK_PROCESS_STATE_CHANGED] = 'S C Q C'
|
260
|
+
@callback_formats[CALLBACK_PROGRAM_SCHEDULER_STATE_CHANGED] = 'S'
|
261
|
+
@callback_formats[CALLBACK_PROGRAM_PROCESS_SPAWNED] = 'S'
|
262
|
+
end
|
263
|
+
|
264
|
+
#
|
265
|
+
def create_session(lifetime)
|
266
|
+
send_request(FUNCTION_CREATE_SESSION, [lifetime], 'L', 3, 'C S')
|
267
|
+
end
|
268
|
+
|
269
|
+
#
|
270
|
+
def expire_session(session_id)
|
271
|
+
send_request(FUNCTION_EXPIRE_SESSION, [session_id], 'S', 1, 'C')
|
272
|
+
end
|
273
|
+
|
274
|
+
#
|
275
|
+
def expire_session_unchecked(session_id)
|
276
|
+
send_request(FUNCTION_EXPIRE_SESSION_UNCHECKED, [session_id], 'S', 0, '')
|
277
|
+
end
|
278
|
+
|
279
|
+
#
|
280
|
+
def keep_session_alive(session_id, lifetime)
|
281
|
+
send_request(FUNCTION_KEEP_SESSION_ALIVE, [session_id, lifetime], 'S L', 1, 'C')
|
282
|
+
end
|
283
|
+
|
284
|
+
# Decreases the reference count of an object by one and returns the resulting
|
285
|
+
# error code. If the reference count reaches zero the object gets destroyed.
|
286
|
+
def release_object(object_id, session_id)
|
287
|
+
send_request(FUNCTION_RELEASE_OBJECT, [object_id, session_id], 'S S', 1, 'C')
|
288
|
+
end
|
289
|
+
|
290
|
+
#
|
291
|
+
def release_object_unchecked(object_id, session_id)
|
292
|
+
send_request(FUNCTION_RELEASE_OBJECT_UNCHECKED, [object_id, session_id], 'S S', 0, '')
|
293
|
+
end
|
294
|
+
|
295
|
+
# Allocates a new string object, reserves ``length_to_reserve`` bytes memory
|
296
|
+
# for it and sets up to the first 60 bytes. Set ``length_to_reserve`` to the
|
297
|
+
# length of the string that should be stored in the string object.
|
298
|
+
#
|
299
|
+
# Returns the object ID of the new string object and the resulting error code.
|
300
|
+
def allocate_string(length_to_reserve, buffer, session_id)
|
301
|
+
send_request(FUNCTION_ALLOCATE_STRING, [length_to_reserve, buffer, session_id], 'L Z58 S', 3, 'C S')
|
302
|
+
end
|
303
|
+
|
304
|
+
# Truncates a string object to ``length`` bytes and returns the resulting
|
305
|
+
# error code.
|
306
|
+
def truncate_string(string_id, length)
|
307
|
+
send_request(FUNCTION_TRUNCATE_STRING, [string_id, length], 'S L', 1, 'C')
|
308
|
+
end
|
309
|
+
|
310
|
+
# Returns the length of a string object in bytes and the resulting error code.
|
311
|
+
def get_string_length(string_id)
|
312
|
+
send_request(FUNCTION_GET_STRING_LENGTH, [string_id], 'S', 5, 'C L')
|
313
|
+
end
|
314
|
+
|
315
|
+
# Sets a chunk of up to 58 bytes in a string object beginning at ``offset``.
|
316
|
+
#
|
317
|
+
# Returns the resulting error code.
|
318
|
+
def set_string_chunk(string_id, offset, buffer)
|
319
|
+
send_request(FUNCTION_SET_STRING_CHUNK, [string_id, offset, buffer], 'S L Z58', 1, 'C')
|
320
|
+
end
|
321
|
+
|
322
|
+
# Returns a chunk up to 63 bytes from a string object beginning at ``offset`` and
|
323
|
+
# returns the resulting error code.
|
324
|
+
def get_string_chunk(string_id, offset)
|
325
|
+
send_request(FUNCTION_GET_STRING_CHUNK, [string_id, offset], 'S L', 64, 'C Z63')
|
326
|
+
end
|
327
|
+
|
328
|
+
# Allocates a new list object and reserves memory for ``length_to_reserve``
|
329
|
+
# items. Set ``length_to_reserve`` to the number of items that should be stored
|
330
|
+
# in the list object.
|
331
|
+
#
|
332
|
+
# Returns the object ID of the new list object and the resulting error code.
|
333
|
+
#
|
334
|
+
# When a list object gets destroyed then the reference count of each object in
|
335
|
+
# the list object is decreased by one.
|
336
|
+
def allocate_list(length_to_reserve, session_id)
|
337
|
+
send_request(FUNCTION_ALLOCATE_LIST, [length_to_reserve, session_id], 'S S', 3, 'C S')
|
338
|
+
end
|
339
|
+
|
340
|
+
# Returns the length of a list object in items and the resulting error code.
|
341
|
+
def get_list_length(list_id)
|
342
|
+
send_request(FUNCTION_GET_LIST_LENGTH, [list_id], 'S', 3, 'C S')
|
343
|
+
end
|
344
|
+
|
345
|
+
# Returns the object ID and type of the object stored at ``index`` in a list
|
346
|
+
# object and returns the resulting error code.
|
347
|
+
#
|
348
|
+
# Possible object types are:
|
349
|
+
#
|
350
|
+
# * String = 0
|
351
|
+
# * List = 1
|
352
|
+
# * File = 2
|
353
|
+
# * Directory = 3
|
354
|
+
# * Process = 4
|
355
|
+
# * Program = 5
|
356
|
+
def get_list_item(list_id, index, session_id)
|
357
|
+
send_request(FUNCTION_GET_LIST_ITEM, [list_id, index, session_id], 'S S S', 4, 'C S C')
|
358
|
+
end
|
359
|
+
|
360
|
+
# Appends an object to a list object and increases the reference count of the
|
361
|
+
# appended object by one.
|
362
|
+
#
|
363
|
+
# Returns the resulting error code.
|
364
|
+
def append_to_list(list_id, item_object_id)
|
365
|
+
send_request(FUNCTION_APPEND_TO_LIST, [list_id, item_object_id], 'S S', 1, 'C')
|
366
|
+
end
|
367
|
+
|
368
|
+
# Removes the object stored at ``index`` from a list object and decreases the
|
369
|
+
# reference count of the removed object by one.
|
370
|
+
#
|
371
|
+
# Returns the resulting error code.
|
372
|
+
def remove_from_list(list_id, index)
|
373
|
+
send_request(FUNCTION_REMOVE_FROM_LIST, [list_id, index], 'S S', 1, 'C')
|
374
|
+
end
|
375
|
+
|
376
|
+
# Opens an existing file or creates a new file and allocates a new file object
|
377
|
+
# for it.
|
378
|
+
#
|
379
|
+
# FIXME: name has to be absolute
|
380
|
+
#
|
381
|
+
# The reference count of the name string object is increased by one. When the
|
382
|
+
# file object gets destroyed then the reference count of the name string object is
|
383
|
+
# decreased by one. Also the name string object is locked and cannot be modified
|
384
|
+
# while the file object holds a reference to it.
|
385
|
+
#
|
386
|
+
# The ``flags`` parameter takes a ORed combination of the following possible file
|
387
|
+
# flags (in hexadecimal notation):
|
388
|
+
#
|
389
|
+
# * ReadOnly = 0x0001 (O_RDONLY)
|
390
|
+
# * WriteOnly = 0x0002 (O_WRONLY)
|
391
|
+
# * ReadWrite = 0x0004 (O_RDWR)
|
392
|
+
# * Append = 0x0008 (O_APPEND)
|
393
|
+
# * Create = 0x0010 (O_CREAT)
|
394
|
+
# * Exclusive = 0x0020 (O_EXCL)
|
395
|
+
# * NonBlocking = 0x0040 (O_NONBLOCK)
|
396
|
+
# * Truncate = 0x0080 (O_TRUNC)
|
397
|
+
# * Temporary = 0x0100
|
398
|
+
# * Replace = 0x0200
|
399
|
+
#
|
400
|
+
# FIXME: explain *Temporary* and *Replace* flag
|
401
|
+
#
|
402
|
+
# The ``permissions`` parameter takes a ORed combination of the following
|
403
|
+
# possible file permissions (in octal notation) that match the common UNIX
|
404
|
+
# permission bits:
|
405
|
+
#
|
406
|
+
# * UserRead = 00400
|
407
|
+
# * UserWrite = 00200
|
408
|
+
# * UserExecute = 00100
|
409
|
+
# * GroupRead = 00040
|
410
|
+
# * GroupWrite = 00020
|
411
|
+
# * GroupExecute = 00010
|
412
|
+
# * OthersRead = 00004
|
413
|
+
# * OthersWrite = 00002
|
414
|
+
# * OthersExecute = 00001
|
415
|
+
#
|
416
|
+
# Returns the object ID of the new file object and the resulting error code.
|
417
|
+
def open_file(name_string_id, flags, permissions, uid, gid, session_id)
|
418
|
+
send_request(FUNCTION_OPEN_FILE, [name_string_id, flags, permissions, uid, gid, session_id], 'S L S L L S', 3, 'C S')
|
419
|
+
end
|
420
|
+
|
421
|
+
# Creates a new pipe and allocates a new file object for it.
|
422
|
+
#
|
423
|
+
# The ``flags`` parameter takes a ORed combination of the following possible
|
424
|
+
# pipe flags (in hexadecimal notation):
|
425
|
+
#
|
426
|
+
# * NonBlockingRead = 0x0001
|
427
|
+
# * NonBlockingWrite = 0x0002
|
428
|
+
#
|
429
|
+
# The length of the pipe buffer can be specified with the ``length`` parameter
|
430
|
+
# in bytes. If length is set to zero, then the default pipe buffer length is used.
|
431
|
+
#
|
432
|
+
# Returns the object ID of the new file object and the resulting error code.
|
433
|
+
def create_pipe(flags, length, session_id)
|
434
|
+
send_request(FUNCTION_CREATE_PIPE, [flags, length, session_id], 'L Q S', 3, 'C S')
|
435
|
+
end
|
436
|
+
|
437
|
+
# Returns various information about a file and the resulting error code.
|
438
|
+
#
|
439
|
+
# Possible file types are:
|
440
|
+
#
|
441
|
+
# * Unknown = 0
|
442
|
+
# * Regular = 1
|
443
|
+
# * Directory = 2
|
444
|
+
# * Character = 3
|
445
|
+
# * Block = 4
|
446
|
+
# * FIFO = 5
|
447
|
+
# * Symlink = 6
|
448
|
+
# * Socket = 7
|
449
|
+
# * Pipe = 8
|
450
|
+
#
|
451
|
+
# If the file type is *Pipe* then the returned name string object is invalid,
|
452
|
+
# because a pipe has no name. Otherwise the returned name string object was used
|
453
|
+
# to open or create the file object, as passed to BrickRED#open_file.
|
454
|
+
#
|
455
|
+
# The returned flags were used to open or create the file object, as passed to
|
456
|
+
# BrickRED#open_file or BrickRED#create_pipe. See the respective function for a list
|
457
|
+
# of possible file and pipe flags.
|
458
|
+
#
|
459
|
+
# FIXME: everything except flags and length is invalid if file type is *Pipe*
|
460
|
+
def get_file_info(file_id, session_id)
|
461
|
+
send_request(FUNCTION_GET_FILE_INFO, [file_id, session_id], 'S S', 50, 'C C S L S L L Q Q Q Q')
|
462
|
+
end
|
463
|
+
|
464
|
+
# Reads up to 62 bytes from a file object.
|
465
|
+
#
|
466
|
+
# Returns the bytes read, the actual number of bytes read and the resulting
|
467
|
+
# error code.
|
468
|
+
#
|
469
|
+
# If there is not data to be read, either because the file position reached
|
470
|
+
# end-of-file or because there is not data in the pipe, then zero bytes are
|
471
|
+
# returned.
|
472
|
+
#
|
473
|
+
# If the file object was created by BrickRED#open_file without the *NonBlocking*
|
474
|
+
# flag or by BrickRED#create_pipe without the *NonBlockingRead* flag then the
|
475
|
+
# error code *NotSupported* is returned.
|
476
|
+
def read_file(file_id, length_to_read)
|
477
|
+
send_request(FUNCTION_READ_FILE, [file_id, length_to_read], 'S C', 64, 'C C62 C')
|
478
|
+
end
|
479
|
+
|
480
|
+
# Reads up to 2\ :sup:`63`\ - 1 bytes from a file object asynchronously.
|
481
|
+
#
|
482
|
+
# Reports the bytes read (in 60 byte chunks), the actual number of bytes read and
|
483
|
+
# the resulting error code via the CALLBACK_ASYNC_FILE_READ callback.
|
484
|
+
#
|
485
|
+
# If there is not data to be read, either because the file position reached
|
486
|
+
# end-of-file or because there is not data in the pipe, then zero bytes are
|
487
|
+
# reported.
|
488
|
+
#
|
489
|
+
# If the file object was created by BrickRED#open_file without the *NonBlocking*
|
490
|
+
# flag or by BrickRED#create_pipe without the *NonBlockingRead* flag then the error
|
491
|
+
# code *NotSupported* is reported via the CALLBACK_ASYNC_FILE_READ callback.
|
492
|
+
def read_file_async(file_id, length_to_read)
|
493
|
+
send_request(FUNCTION_READ_FILE_ASYNC, [file_id, length_to_read], 'S Q', 0, '')
|
494
|
+
end
|
495
|
+
|
496
|
+
# Aborts a BrickRED#read_file_async operation in progress.
|
497
|
+
#
|
498
|
+
# Returns the resulting error code.
|
499
|
+
#
|
500
|
+
# On success the CALLBACK_ASYNC_FILE_READ callback will report *OperationAborted*.
|
501
|
+
def abort_async_file_read(file_id)
|
502
|
+
send_request(FUNCTION_ABORT_ASYNC_FILE_READ, [file_id], 'S', 1, 'C')
|
503
|
+
end
|
504
|
+
|
505
|
+
# Writes up to 61 bytes to a file object.
|
506
|
+
#
|
507
|
+
# Returns the actual number of bytes written and the resulting error code.
|
508
|
+
#
|
509
|
+
# If the file object was created by BrickRED#open_file without the *NonBlocking*
|
510
|
+
# flag or by BrickRED#create_pipe without the *NonBlockingWrite* flag then the
|
511
|
+
# error code *NotSupported* is returned.
|
512
|
+
def write_file(file_id, buffer, length_to_write)
|
513
|
+
send_request(FUNCTION_WRITE_FILE, [file_id, buffer, length_to_write], 'S C61 C', 2, 'C C')
|
514
|
+
end
|
515
|
+
|
516
|
+
# Writes up to 61 bytes to a file object.
|
517
|
+
#
|
518
|
+
# Does neither report the actual number of bytes written nor the resulting error
|
519
|
+
# code.
|
520
|
+
#
|
521
|
+
# If the file object was created by BrickRED#open_file without the *NonBlocking*
|
522
|
+
# flag or by BrickRED#create_pipe without the *NonBlockingWrite* flag then the
|
523
|
+
# write operation will fail silently.
|
524
|
+
def write_file_unchecked(file_id, buffer, length_to_write)
|
525
|
+
send_request(FUNCTION_WRITE_FILE_UNCHECKED, [file_id, buffer, length_to_write], 'S C61 C', 0, '')
|
526
|
+
end
|
527
|
+
|
528
|
+
# Writes up to 61 bytes to a file object.
|
529
|
+
#
|
530
|
+
# Reports the actual number of bytes written and the resulting error code via the
|
531
|
+
# CALLBACK_ASYNC_FILE_WRITE callback.
|
532
|
+
#
|
533
|
+
# If the file object was created by BrickRED#open_file without the *NonBlocking*
|
534
|
+
# flag or by BrickRED#create_pipe without the *NonBlockingWrite* flag then the
|
535
|
+
# error code *NotSupported* is reported via the CALLBACK_ASYNC_FILE_WRITE callback.
|
536
|
+
def write_file_async(file_id, buffer, length_to_write)
|
537
|
+
send_request(FUNCTION_WRITE_FILE_ASYNC, [file_id, buffer, length_to_write], 'S C61 C', 0, '')
|
538
|
+
end
|
539
|
+
|
540
|
+
# Set the current seek position of a file object in bytes relative to ``origin``.
|
541
|
+
#
|
542
|
+
# Possible file origins are:
|
543
|
+
#
|
544
|
+
# * Beginning = 0
|
545
|
+
# * Current = 1
|
546
|
+
# * End = 2
|
547
|
+
#
|
548
|
+
# Returns the resulting absolute seek position and error code.
|
549
|
+
#
|
550
|
+
# If the file object was created by BrickRED#create_pipe then it has no seek
|
551
|
+
# position and the error code *InvalidSeek* is returned.
|
552
|
+
def set_file_position(file_id, offset, origin)
|
553
|
+
send_request(FUNCTION_SET_FILE_POSITION, [file_id, offset, origin], 'S q C', 9, 'C Q')
|
554
|
+
end
|
555
|
+
|
556
|
+
# Returns the current seek position of a file object in bytes and returns the
|
557
|
+
# resulting error code.
|
558
|
+
#
|
559
|
+
# If the file object was created by BrickRED#create_pipe then it has no seek
|
560
|
+
# position and the error code *InvalidSeek* is returned.
|
561
|
+
def get_file_position(file_id)
|
562
|
+
send_request(FUNCTION_GET_FILE_POSITION, [file_id], 'S', 9, 'C Q')
|
563
|
+
end
|
564
|
+
|
565
|
+
#
|
566
|
+
def set_file_events(file_id, events)
|
567
|
+
send_request(FUNCTION_SET_FILE_EVENTS, [file_id, events], 'S S', 1, 'C')
|
568
|
+
end
|
569
|
+
|
570
|
+
#
|
571
|
+
def get_file_events(file_id)
|
572
|
+
send_request(FUNCTION_GET_FILE_EVENTS, [file_id], 'S', 3, 'C S')
|
573
|
+
end
|
574
|
+
|
575
|
+
# Opens an existing directory and allocates a new directory object for it.
|
576
|
+
#
|
577
|
+
# FIXME: name has to be absolute
|
578
|
+
#
|
579
|
+
# The reference count of the name string object is increased by one. When the
|
580
|
+
# directory object is destroyed then the reference count of the name string
|
581
|
+
# object is decreased by one. Also the name string object is locked and cannot be
|
582
|
+
# modified while the directory object holds a reference to it.
|
583
|
+
#
|
584
|
+
# Returns the object ID of the new directory object and the resulting error code.
|
585
|
+
def open_directory(name_string_id, session_id)
|
586
|
+
send_request(FUNCTION_OPEN_DIRECTORY, [name_string_id, session_id], 'S S', 3, 'C S')
|
587
|
+
end
|
588
|
+
|
589
|
+
# Returns the name of a directory object, as passed to BrickRED#open_directory, and
|
590
|
+
# the resulting error code.
|
591
|
+
def get_directory_name(directory_id, session_id)
|
592
|
+
send_request(FUNCTION_GET_DIRECTORY_NAME, [directory_id, session_id], 'S S', 3, 'C S')
|
593
|
+
end
|
594
|
+
|
595
|
+
# Returns the next entry in a directory object and the resulting error code.
|
596
|
+
#
|
597
|
+
# If there is not next entry then error code *NoMoreData* is returned. To rewind
|
598
|
+
# a directory object call BrickRED#rewind_directory.
|
599
|
+
#
|
600
|
+
# Possible directory entry types are:
|
601
|
+
#
|
602
|
+
# * Unknown = 0
|
603
|
+
# * Regular = 1
|
604
|
+
# * Directory = 2
|
605
|
+
# * Character = 3
|
606
|
+
# * Block = 4
|
607
|
+
# * FIFO = 5
|
608
|
+
# * Symlink = 6
|
609
|
+
# * Socket = 7
|
610
|
+
def get_next_directory_entry(directory_id, session_id)
|
611
|
+
send_request(FUNCTION_GET_NEXT_DIRECTORY_ENTRY, [directory_id, session_id], 'S S', 4, 'C S C')
|
612
|
+
end
|
613
|
+
|
614
|
+
# Rewinds a directory object and returns the resulting error code.
|
615
|
+
def rewind_directory(directory_id)
|
616
|
+
send_request(FUNCTION_REWIND_DIRECTORY, [directory_id], 'S', 1, 'C')
|
617
|
+
end
|
618
|
+
|
619
|
+
# FIXME: name has to be absolute
|
620
|
+
def create_directory(name_string_id, flags, permissions, uid, gid)
|
621
|
+
send_request(FUNCTION_CREATE_DIRECTORY, [name_string_id, flags, permissions, uid, gid], 'S L S L L', 1, 'C')
|
622
|
+
end
|
623
|
+
|
624
|
+
#
|
625
|
+
def get_processes(session_id)
|
626
|
+
send_request(FUNCTION_GET_PROCESSES, [session_id], 'S', 3, 'C S')
|
627
|
+
end
|
628
|
+
|
629
|
+
#
|
630
|
+
def spawn_process(executable_string_id, arguments_list_id, environment_list_id, working_directory_string_id, uid, gid, stdin_file_id, stdout_file_id, stderr_file_id, session_id)
|
631
|
+
send_request(FUNCTION_SPAWN_PROCESS, [executable_string_id, arguments_list_id, environment_list_id, working_directory_string_id, uid, gid, stdin_file_id, stdout_file_id, stderr_file_id, session_id], 'S S S S L L S S S S', 3, 'C S')
|
632
|
+
end
|
633
|
+
|
634
|
+
# Sends a UNIX signal to a process object and returns the resulting error code.
|
635
|
+
#
|
636
|
+
# Possible UNIX signals are:
|
637
|
+
#
|
638
|
+
# * Interrupt = 2
|
639
|
+
# * Quit = 3
|
640
|
+
# * Abort = 6
|
641
|
+
# * Kill = 9
|
642
|
+
# * User1 = 10
|
643
|
+
# * User2 = 12
|
644
|
+
# * Terminate = 15
|
645
|
+
# * Continue = 18
|
646
|
+
# * Stop = 19
|
647
|
+
def kill_process(process_id, signal)
|
648
|
+
send_request(FUNCTION_KILL_PROCESS, [process_id, signal], 'S C', 1, 'C')
|
649
|
+
end
|
650
|
+
|
651
|
+
# Returns the executable, arguments, environment and working directory used to
|
652
|
+
# spawn a process object, as passed to BrickRED#spawn_process, and the resulting
|
653
|
+
# error code.
|
654
|
+
def get_process_command(process_id, session_id)
|
655
|
+
send_request(FUNCTION_GET_PROCESS_COMMAND, [process_id, session_id], 'S S', 9, 'C S S S S')
|
656
|
+
end
|
657
|
+
|
658
|
+
# Returns the process ID and the user and group ID used to spawn a process object,
|
659
|
+
# as passed to BrickRED#spawn_process, and the resulting error code.
|
660
|
+
#
|
661
|
+
# The process ID is only valid if the state is *Running* or *Stopped*, see
|
662
|
+
# BrickRED#get_process_state.
|
663
|
+
def get_process_identity(process_id)
|
664
|
+
send_request(FUNCTION_GET_PROCESS_IDENTITY, [process_id], 'S', 13, 'C L L L')
|
665
|
+
end
|
666
|
+
|
667
|
+
# Returns the stdin, stdout and stderr files used to spawn a process object, as
|
668
|
+
# passed to BrickRED#spawn_process, and the resulting error code.
|
669
|
+
def get_process_stdio(process_id, session_id)
|
670
|
+
send_request(FUNCTION_GET_PROCESS_STDIO, [process_id, session_id], 'S S', 7, 'C S S S')
|
671
|
+
end
|
672
|
+
|
673
|
+
# Returns the current state, timestamp and exit code of a process object, and
|
674
|
+
# the resulting error code.
|
675
|
+
#
|
676
|
+
# Possible process states are:
|
677
|
+
#
|
678
|
+
# * Unknown = 0
|
679
|
+
# * Running = 1
|
680
|
+
# * Error = 2
|
681
|
+
# * Exited = 3
|
682
|
+
# * Killed = 4
|
683
|
+
# * Stopped = 5
|
684
|
+
#
|
685
|
+
# The timestamp represents the UNIX time since when the process is in its current
|
686
|
+
# state.
|
687
|
+
#
|
688
|
+
# The exit code is only valid if the state is *Error*, *Exited*, *Killed* or
|
689
|
+
# *Stopped* and has different meanings depending on the state:
|
690
|
+
#
|
691
|
+
# * Error: error code for error occurred while spawning the process (see below)
|
692
|
+
# * Exited: exit status of the process
|
693
|
+
# * Killed: UNIX signal number used to kill the process
|
694
|
+
# * Stopped: UNIX signal number used to stop the process
|
695
|
+
#
|
696
|
+
# Possible exit/error codes in *Error* state are:
|
697
|
+
#
|
698
|
+
# * InternalError = 125
|
699
|
+
# * CannotExecute = 126
|
700
|
+
# * DoesNotExist = 127
|
701
|
+
#
|
702
|
+
# The *CannotExecute* error can be caused by the executable being opened for
|
703
|
+
# writing.
|
704
|
+
def get_process_state(process_id)
|
705
|
+
send_request(FUNCTION_GET_PROCESS_STATE, [process_id], 'S', 11, 'C C Q C')
|
706
|
+
end
|
707
|
+
|
708
|
+
#
|
709
|
+
def get_programs(session_id)
|
710
|
+
send_request(FUNCTION_GET_PROGRAMS, [session_id], 'S', 3, 'C S')
|
711
|
+
end
|
712
|
+
|
713
|
+
#
|
714
|
+
def define_program(identifier_string_id, session_id)
|
715
|
+
send_request(FUNCTION_DEFINE_PROGRAM, [identifier_string_id, session_id], 'S S', 3, 'C S')
|
716
|
+
end
|
717
|
+
|
718
|
+
#
|
719
|
+
def purge_program(program_id, cookie)
|
720
|
+
send_request(FUNCTION_PURGE_PROGRAM, [program_id, cookie], 'S L', 1, 'C')
|
721
|
+
end
|
722
|
+
|
723
|
+
#
|
724
|
+
def get_program_identifier(program_id, session_id)
|
725
|
+
send_request(FUNCTION_GET_PROGRAM_IDENTIFIER, [program_id, session_id], 'S S', 3, 'C S')
|
726
|
+
end
|
727
|
+
|
728
|
+
# FIXME: root directory is absolute: <home>/programs/<identifier>
|
729
|
+
def get_program_root_directory(program_id, session_id)
|
730
|
+
send_request(FUNCTION_GET_PROGRAM_ROOT_DIRECTORY, [program_id, session_id], 'S S', 3, 'C S')
|
731
|
+
end
|
732
|
+
|
733
|
+
# FIXME: working directory is relative to <home>/programs/<identifier>/bin
|
734
|
+
def set_program_command(program_id, executable_string_id, arguments_list_id, environment_list_id, working_directory_string_id)
|
735
|
+
send_request(FUNCTION_SET_PROGRAM_COMMAND, [program_id, executable_string_id, arguments_list_id, environment_list_id, working_directory_string_id], 'S S S S S', 1, 'C')
|
736
|
+
end
|
737
|
+
|
738
|
+
# FIXME: working directory is relative to <home>/programs/<identifier>/bin
|
739
|
+
def get_program_command(program_id, session_id)
|
740
|
+
send_request(FUNCTION_GET_PROGRAM_COMMAND, [program_id, session_id], 'S S', 9, 'C S S S S')
|
741
|
+
end
|
742
|
+
|
743
|
+
# FIXME: stdio file names are relative to <home>/programs/<identifier>/bin
|
744
|
+
def set_program_stdio_redirection(program_id, stdin_redirection, stdin_file_name_string_id, stdout_redirection, stdout_file_name_string_id, stderr_redirection, stderr_file_name_string_id)
|
745
|
+
send_request(FUNCTION_SET_PROGRAM_STDIO_REDIRECTION, [program_id, stdin_redirection, stdin_file_name_string_id, stdout_redirection, stdout_file_name_string_id, stderr_redirection, stderr_file_name_string_id], 'S C S C S C S', 1, 'C')
|
746
|
+
end
|
747
|
+
|
748
|
+
# FIXME: stdio file names are relative to <home>/programs/<identifier>/bin
|
749
|
+
def get_program_stdio_redirection(program_id, session_id)
|
750
|
+
send_request(FUNCTION_GET_PROGRAM_STDIO_REDIRECTION, [program_id, session_id], 'S S', 10, 'C C S C S C S')
|
751
|
+
end
|
752
|
+
|
753
|
+
#
|
754
|
+
def set_program_schedule(program_id, start_mode, continue_after_error, start_interval, start_fields_string_id)
|
755
|
+
send_request(FUNCTION_SET_PROGRAM_SCHEDULE, [program_id, start_mode, continue_after_error, start_interval, start_fields_string_id], 'S C ? L S', 1, 'C')
|
756
|
+
end
|
757
|
+
|
758
|
+
#
|
759
|
+
def get_program_schedule(program_id, session_id)
|
760
|
+
send_request(FUNCTION_GET_PROGRAM_SCHEDULE, [program_id, session_id], 'S S', 9, 'C C ? L S')
|
761
|
+
end
|
762
|
+
|
763
|
+
# FIXME: message is currently vaild in error-occurred state only
|
764
|
+
def get_program_scheduler_state(program_id, session_id)
|
765
|
+
send_request(FUNCTION_GET_PROGRAM_SCHEDULER_STATE, [program_id, session_id], 'S S', 12, 'C C Q S')
|
766
|
+
end
|
767
|
+
|
768
|
+
#
|
769
|
+
def continue_program_schedule(program_id)
|
770
|
+
send_request(FUNCTION_CONTINUE_PROGRAM_SCHEDULE, [program_id], 'S', 1, 'C')
|
771
|
+
end
|
772
|
+
|
773
|
+
#
|
774
|
+
def start_program(program_id)
|
775
|
+
send_request(FUNCTION_START_PROGRAM, [program_id], 'S', 1, 'C')
|
776
|
+
end
|
777
|
+
|
778
|
+
#
|
779
|
+
def get_last_spawned_program_process(program_id, session_id)
|
780
|
+
send_request(FUNCTION_GET_LAST_SPAWNED_PROGRAM_PROCESS, [program_id, session_id], 'S S', 11, 'C S Q')
|
781
|
+
end
|
782
|
+
|
783
|
+
#
|
784
|
+
def get_custom_program_option_names(program_id, session_id)
|
785
|
+
send_request(FUNCTION_GET_CUSTOM_PROGRAM_OPTION_NAMES, [program_id, session_id], 'S S', 3, 'C S')
|
786
|
+
end
|
787
|
+
|
788
|
+
#
|
789
|
+
def set_custom_program_option_value(program_id, name_string_id, value_string_id)
|
790
|
+
send_request(FUNCTION_SET_CUSTOM_PROGRAM_OPTION_VALUE, [program_id, name_string_id, value_string_id], 'S S S', 1, 'C')
|
791
|
+
end
|
792
|
+
|
793
|
+
#
|
794
|
+
def get_custom_program_option_value(program_id, name_string_id, session_id)
|
795
|
+
send_request(FUNCTION_GET_CUSTOM_PROGRAM_OPTION_VALUE, [program_id, name_string_id, session_id], 'S S S', 3, 'C S')
|
796
|
+
end
|
797
|
+
|
798
|
+
#
|
799
|
+
def remove_custom_program_option(program_id, name_string_id)
|
800
|
+
send_request(FUNCTION_REMOVE_CUSTOM_PROGRAM_OPTION, [program_id, name_string_id], 'S S', 1, 'C')
|
801
|
+
end
|
802
|
+
|
803
|
+
# Returns the UID, the UID where the Brick is connected to,
|
804
|
+
# the position, the hardware and firmware version as well as the
|
805
|
+
# device identifier.
|
806
|
+
#
|
807
|
+
# The position can be '0'-'8' (stack position).
|
808
|
+
#
|
809
|
+
# The device identifier numbers can be found :ref:`here <device_identifier>`.
|
810
|
+
# |device_identifier_constant|
|
811
|
+
def get_identity
|
812
|
+
send_request(FUNCTION_GET_IDENTITY, [], '', 25, 'Z8 Z8 k C3 C3 S')
|
813
|
+
end
|
814
|
+
|
815
|
+
# Registers a callback with ID <tt>id</tt> to the block <tt>block</tt>.
|
816
|
+
def register_callback(id, &block)
|
817
|
+
callback = block
|
818
|
+
@registered_callbacks[id] = callback
|
819
|
+
end
|
820
|
+
end
|
821
|
+
end
|