tinkerforge 2.1.22 → 2.1.27
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.
- checksums.yaml +5 -5
- data/lib/tinkerforge/brick_dc.rb +157 -76
- data/lib/tinkerforge/brick_hat.rb +115 -32
- data/lib/tinkerforge/brick_hat_zero.rb +119 -21
- data/lib/tinkerforge/brick_imu.rb +192 -87
- data/lib/tinkerforge/brick_imu_v2.rb +220 -119
- data/lib/tinkerforge/brick_master.rb +498 -198
- data/lib/tinkerforge/brick_red.rb +197 -74
- data/lib/tinkerforge/brick_servo.rb +187 -103
- data/lib/tinkerforge/brick_silent_stepper.rb +249 -169
- data/lib/tinkerforge/brick_stepper.rb +214 -102
- data/lib/tinkerforge/bricklet_accelerometer.rb +61 -36
- data/lib/tinkerforge/bricklet_accelerometer_v2.rb +167 -48
- data/lib/tinkerforge/bricklet_air_quality.rb +123 -76
- data/lib/tinkerforge/bricklet_ambient_light.rb +62 -46
- data/lib/tinkerforge/bricklet_ambient_light_v2.rb +41 -28
- data/lib/tinkerforge/bricklet_ambient_light_v3.rb +61 -28
- data/lib/tinkerforge/bricklet_analog_in.rb +66 -45
- data/lib/tinkerforge/bricklet_analog_in_v2.rb +60 -43
- data/lib/tinkerforge/bricklet_analog_in_v3.rb +68 -32
- data/lib/tinkerforge/bricklet_analog_out.rb +25 -16
- data/lib/tinkerforge/bricklet_analog_out_v2.rb +21 -10
- data/lib/tinkerforge/bricklet_analog_out_v3.rb +55 -22
- data/lib/tinkerforge/bricklet_barometer.rb +108 -58
- data/lib/tinkerforge/bricklet_barometer_v2.rb +109 -67
- data/lib/tinkerforge/bricklet_can.rb +84 -24
- data/lib/tinkerforge/bricklet_can_v2.rb +173 -72
- data/lib/tinkerforge/bricklet_co2.rb +36 -25
- data/lib/tinkerforge/bricklet_co2_v2.rb +119 -60
- data/lib/tinkerforge/bricklet_color.rb +77 -49
- data/lib/tinkerforge/bricklet_color_v2.rb +493 -0
- data/lib/tinkerforge/bricklet_compass.rb +397 -0
- data/lib/tinkerforge/bricklet_current12.rb +61 -40
- data/lib/tinkerforge/bricklet_current25.rb +61 -40
- data/lib/tinkerforge/bricklet_distance_ir.rb +60 -38
- data/lib/tinkerforge/bricklet_distance_ir_v2.rb +85 -45
- data/lib/tinkerforge/bricklet_distance_us.rb +43 -30
- data/lib/tinkerforge/bricklet_distance_us_v2.rb +335 -0
- data/lib/tinkerforge/bricklet_dmx.rb +92 -48
- data/lib/tinkerforge/bricklet_dual_button.rb +23 -12
- data/lib/tinkerforge/bricklet_dual_button_v2.rb +64 -29
- data/lib/tinkerforge/bricklet_dual_relay.rb +27 -14
- data/lib/tinkerforge/bricklet_dust_detector.rb +43 -30
- data/lib/tinkerforge/bricklet_e_paper_296x128.rb +115 -63
- data/lib/tinkerforge/bricklet_energy_monitor.rb +416 -0
- data/lib/tinkerforge/bricklet_gps.rb +72 -48
- data/lib/tinkerforge/bricklet_gps_v2.rb +124 -73
- data/lib/tinkerforge/bricklet_hall_effect.rb +43 -28
- data/lib/tinkerforge/bricklet_hall_effect_v2.rb +76 -44
- data/lib/tinkerforge/bricklet_humidity.rb +54 -38
- data/lib/tinkerforge/bricklet_humidity_v2.rb +86 -49
- data/lib/tinkerforge/bricklet_imu_v3.rb +784 -0
- data/lib/tinkerforge/bricklet_industrial_analog_out.rb +41 -18
- data/lib/tinkerforge/bricklet_industrial_analog_out_v2.rb +84 -40
- data/lib/tinkerforge/bricklet_industrial_counter.rb +102 -59
- data/lib/tinkerforge/bricklet_industrial_digital_in_4.rb +51 -24
- data/lib/tinkerforge/bricklet_industrial_digital_in_4_v2.rb +79 -40
- data/lib/tinkerforge/bricklet_industrial_digital_out_4.rb +36 -15
- data/lib/tinkerforge/bricklet_industrial_digital_out_4_v2.rb +75 -33
- data/lib/tinkerforge/bricklet_industrial_dual_0_20ma.rb +43 -29
- data/lib/tinkerforge/bricklet_industrial_dual_0_20ma_v2.rb +81 -44
- data/lib/tinkerforge/bricklet_industrial_dual_ac_relay.rb +325 -0
- data/lib/tinkerforge/bricklet_industrial_dual_analog_in.rb +51 -30
- data/lib/tinkerforge/bricklet_industrial_dual_analog_in_v2.rb +139 -40
- data/lib/tinkerforge/bricklet_industrial_dual_relay.rb +63 -28
- data/lib/tinkerforge/bricklet_industrial_quad_relay.rb +36 -15
- data/lib/tinkerforge/bricklet_industrial_quad_relay_v2.rb +67 -28
- data/lib/tinkerforge/bricklet_io16.rb +57 -32
- data/lib/tinkerforge/bricklet_io16_v2.rb +93 -48
- data/lib/tinkerforge/bricklet_io4.rb +56 -31
- data/lib/tinkerforge/bricklet_io4_v2.rb +109 -57
- data/lib/tinkerforge/bricklet_isolator.rb +111 -35
- data/lib/tinkerforge/bricklet_joystick.rb +63 -42
- data/lib/tinkerforge/bricklet_joystick_v2.rb +71 -35
- data/lib/tinkerforge/bricklet_laser_range_finder.rb +87 -59
- data/lib/tinkerforge/bricklet_laser_range_finder_v2.rb +101 -53
- data/lib/tinkerforge/bricklet_lcd_128x64.rb +241 -131
- data/lib/tinkerforge/bricklet_lcd_16x2.rb +49 -25
- data/lib/tinkerforge/bricklet_lcd_20x4.rb +59 -29
- data/lib/tinkerforge/bricklet_led_strip.rb +69 -47
- data/lib/tinkerforge/bricklet_led_strip_v2.rb +105 -48
- data/lib/tinkerforge/bricklet_line.rb +35 -22
- data/lib/tinkerforge/bricklet_linear_poti.rb +53 -35
- data/lib/tinkerforge/bricklet_linear_poti_v2.rb +55 -24
- data/lib/tinkerforge/bricklet_load_cell.rb +64 -40
- data/lib/tinkerforge/bricklet_load_cell_v2.rb +81 -41
- data/lib/tinkerforge/bricklet_moisture.rb +43 -30
- data/lib/tinkerforge/bricklet_motion_detector.rb +21 -10
- data/lib/tinkerforge/bricklet_motion_detector_v2.rb +62 -29
- data/lib/tinkerforge/bricklet_motorized_linear_poti.rb +71 -32
- data/lib/tinkerforge/bricklet_multi_touch.rb +30 -17
- data/lib/tinkerforge/bricklet_multi_touch_v2.rb +371 -0
- data/lib/tinkerforge/bricklet_nfc.rb +130 -80
- data/lib/tinkerforge/bricklet_nfc_rfid.rb +32 -13
- data/lib/tinkerforge/bricklet_oled_128x64.rb +30 -17
- data/lib/tinkerforge/bricklet_oled_128x64_v2.rb +97 -40
- data/lib/tinkerforge/bricklet_oled_64x48.rb +30 -17
- data/lib/tinkerforge/bricklet_one_wire.rb +65 -24
- data/lib/tinkerforge/bricklet_outdoor_weather.rb +84 -41
- data/lib/tinkerforge/bricklet_particulate_matter.rb +85 -37
- data/lib/tinkerforge/bricklet_piezo_buzzer.rb +19 -13
- data/lib/tinkerforge/bricklet_piezo_speaker.rb +22 -19
- data/lib/tinkerforge/bricklet_piezo_speaker_v2.rb +84 -57
- data/lib/tinkerforge/bricklet_ptc.rb +76 -51
- data/lib/tinkerforge/bricklet_ptc_v2.rb +96 -54
- data/lib/tinkerforge/bricklet_real_time_clock.rb +45 -36
- data/lib/tinkerforge/bricklet_real_time_clock_v2.rb +78 -47
- data/lib/tinkerforge/bricklet_remote_switch.rb +38 -29
- data/lib/tinkerforge/bricklet_remote_switch_v2.rb +86 -49
- data/lib/tinkerforge/bricklet_rgb_led.rb +17 -8
- data/lib/tinkerforge/bricklet_rgb_led_button.rb +61 -30
- data/lib/tinkerforge/bricklet_rgb_led_matrix.rb +78 -33
- data/lib/tinkerforge/bricklet_rgb_led_v2.rb +51 -20
- data/lib/tinkerforge/bricklet_rotary_encoder.rb +40 -25
- data/lib/tinkerforge/bricklet_rotary_encoder_v2.rb +60 -27
- data/lib/tinkerforge/bricklet_rotary_poti.rb +55 -37
- data/lib/tinkerforge/bricklet_rotary_poti_v2.rb +290 -0
- data/lib/tinkerforge/bricklet_rs232.rb +89 -28
- data/lib/tinkerforge/bricklet_rs232_v2.rb +121 -47
- data/lib/tinkerforge/bricklet_rs485.rb +303 -207
- data/lib/tinkerforge/bricklet_segment_display_4x7.rb +24 -14
- data/lib/tinkerforge/bricklet_segment_display_4x7_v2.rb +75 -36
- data/lib/tinkerforge/bricklet_solid_state_relay.rb +24 -13
- data/lib/tinkerforge/bricklet_solid_state_relay_v2.rb +58 -25
- data/lib/tinkerforge/bricklet_sound_intensity.rb +36 -24
- data/lib/tinkerforge/bricklet_sound_pressure_level.rb +77 -41
- data/lib/tinkerforge/bricklet_temperature.rb +43 -28
- data/lib/tinkerforge/bricklet_temperature_ir.rb +63 -47
- data/lib/tinkerforge/bricklet_temperature_ir_v2.rb +75 -53
- data/lib/tinkerforge/bricklet_temperature_v2.rb +62 -31
- data/lib/tinkerforge/bricklet_thermal_imaging.rb +118 -68
- data/lib/tinkerforge/bricklet_thermocouple.rb +46 -30
- data/lib/tinkerforge/bricklet_thermocouple_v2.rb +65 -30
- data/lib/tinkerforge/bricklet_tilt.rb +23 -10
- data/lib/tinkerforge/bricklet_uv_light.rb +37 -24
- data/lib/tinkerforge/bricklet_uv_light_v2.rb +87 -46
- data/lib/tinkerforge/bricklet_voltage.rb +54 -37
- data/lib/tinkerforge/bricklet_voltage_current.rb +94 -85
- data/lib/tinkerforge/bricklet_voltage_current_v2.rb +103 -77
- data/lib/tinkerforge/bricklet_xmc1400_breakout.rb +410 -0
- data/lib/tinkerforge/device_display_names.rb +165 -0
- data/lib/tinkerforge/ip_connection.rb +155 -33
- data/lib/tinkerforge/version.rb +1 -1
- metadata +14 -4
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
# -*- ruby encoding: utf-8 -*-
|
|
2
2
|
#############################################################
|
|
3
|
-
# This file was automatically generated on
|
|
3
|
+
# This file was automatically generated on 2020-11-02. #
|
|
4
4
|
# #
|
|
5
|
-
# Ruby Bindings Version 2.1.
|
|
5
|
+
# Ruby Bindings Version 2.1.27 #
|
|
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 #
|
|
9
9
|
# to the generators git repository on tinkerforge.com #
|
|
10
10
|
#############################################################
|
|
11
11
|
|
|
12
|
+
require_relative './ip_connection'
|
|
13
|
+
|
|
12
14
|
module Tinkerforge
|
|
13
15
|
# Executes user programs and controls other Bricks/Bricklets standalone
|
|
14
16
|
class BrickRED < Device
|
|
@@ -212,7 +214,7 @@ module Tinkerforge
|
|
|
212
214
|
# Creates an object with the unique device ID <tt>uid</tt> and adds it to
|
|
213
215
|
# the IP Connection <tt>ipcon</tt>.
|
|
214
216
|
def initialize(uid, ipcon)
|
|
215
|
-
super uid, ipcon
|
|
217
|
+
super uid, ipcon, DEVICE_IDENTIFIER, DEVICE_DISPLAY_NAME
|
|
216
218
|
|
|
217
219
|
@api_version = [2, 0, 0]
|
|
218
220
|
|
|
@@ -278,44 +280,57 @@ module Tinkerforge
|
|
|
278
280
|
@response_expected[FUNCTION_REMOVE_CUSTOM_PROGRAM_OPTION] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
279
281
|
@response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
280
282
|
|
|
281
|
-
@callback_formats[CALLBACK_ASYNC_FILE_READ] = 'S C C60 C'
|
|
282
|
-
@callback_formats[CALLBACK_ASYNC_FILE_WRITE] = 'S C C'
|
|
283
|
-
@callback_formats[CALLBACK_FILE_EVENTS_OCCURRED] = 'S S'
|
|
284
|
-
@callback_formats[CALLBACK_PROCESS_STATE_CHANGED] = 'S C Q C'
|
|
285
|
-
@callback_formats[CALLBACK_PROGRAM_SCHEDULER_STATE_CHANGED] = 'S'
|
|
286
|
-
@callback_formats[CALLBACK_PROGRAM_PROCESS_SPAWNED] = 'S'
|
|
283
|
+
@callback_formats[CALLBACK_ASYNC_FILE_READ] = [72, 'S C C60 C']
|
|
284
|
+
@callback_formats[CALLBACK_ASYNC_FILE_WRITE] = [12, 'S C C']
|
|
285
|
+
@callback_formats[CALLBACK_FILE_EVENTS_OCCURRED] = [12, 'S S']
|
|
286
|
+
@callback_formats[CALLBACK_PROCESS_STATE_CHANGED] = [20, 'S C Q C']
|
|
287
|
+
@callback_formats[CALLBACK_PROGRAM_SCHEDULER_STATE_CHANGED] = [10, 'S']
|
|
288
|
+
@callback_formats[CALLBACK_PROGRAM_PROCESS_SPAWNED] = [10, 'S']
|
|
287
289
|
|
|
290
|
+
@ipcon.add_device self
|
|
288
291
|
end
|
|
289
292
|
|
|
290
293
|
#
|
|
291
294
|
def create_session(lifetime)
|
|
292
|
-
|
|
295
|
+
check_validity
|
|
296
|
+
|
|
297
|
+
send_request FUNCTION_CREATE_SESSION, [lifetime], 'L', 11, 'C S'
|
|
293
298
|
end
|
|
294
299
|
|
|
295
300
|
#
|
|
296
301
|
def expire_session(session_id)
|
|
297
|
-
|
|
302
|
+
check_validity
|
|
303
|
+
|
|
304
|
+
send_request FUNCTION_EXPIRE_SESSION, [session_id], 'S', 9, 'C'
|
|
298
305
|
end
|
|
299
306
|
|
|
300
307
|
#
|
|
301
308
|
def expire_session_unchecked(session_id)
|
|
302
|
-
|
|
309
|
+
check_validity
|
|
310
|
+
|
|
311
|
+
send_request FUNCTION_EXPIRE_SESSION_UNCHECKED, [session_id], 'S', 8, ''
|
|
303
312
|
end
|
|
304
313
|
|
|
305
314
|
#
|
|
306
315
|
def keep_session_alive(session_id, lifetime)
|
|
307
|
-
|
|
316
|
+
check_validity
|
|
317
|
+
|
|
318
|
+
send_request FUNCTION_KEEP_SESSION_ALIVE, [session_id, lifetime], 'S L', 9, 'C'
|
|
308
319
|
end
|
|
309
320
|
|
|
310
321
|
# Decreases the reference count of an object by one and returns the resulting
|
|
311
322
|
# error code. If the reference count reaches zero the object gets destroyed.
|
|
312
323
|
def release_object(object_id, session_id)
|
|
313
|
-
|
|
324
|
+
check_validity
|
|
325
|
+
|
|
326
|
+
send_request FUNCTION_RELEASE_OBJECT, [object_id, session_id], 'S S', 9, 'C'
|
|
314
327
|
end
|
|
315
328
|
|
|
316
329
|
#
|
|
317
330
|
def release_object_unchecked(object_id, session_id)
|
|
318
|
-
|
|
331
|
+
check_validity
|
|
332
|
+
|
|
333
|
+
send_request FUNCTION_RELEASE_OBJECT_UNCHECKED, [object_id, session_id], 'S S', 8, ''
|
|
319
334
|
end
|
|
320
335
|
|
|
321
336
|
# Allocates a new string object, reserves ``length_to_reserve`` bytes memory
|
|
@@ -324,31 +339,41 @@ module Tinkerforge
|
|
|
324
339
|
#
|
|
325
340
|
# Returns the object ID of the new string object and the resulting error code.
|
|
326
341
|
def allocate_string(length_to_reserve, buffer, session_id)
|
|
327
|
-
|
|
342
|
+
check_validity
|
|
343
|
+
|
|
344
|
+
send_request FUNCTION_ALLOCATE_STRING, [length_to_reserve, buffer, session_id], 'L Z58 S', 11, 'C S'
|
|
328
345
|
end
|
|
329
346
|
|
|
330
347
|
# Truncates a string object to ``length`` bytes and returns the resulting
|
|
331
348
|
# error code.
|
|
332
349
|
def truncate_string(string_id, length)
|
|
333
|
-
|
|
350
|
+
check_validity
|
|
351
|
+
|
|
352
|
+
send_request FUNCTION_TRUNCATE_STRING, [string_id, length], 'S L', 9, 'C'
|
|
334
353
|
end
|
|
335
354
|
|
|
336
|
-
# Returns the length of a string object
|
|
355
|
+
# Returns the length of a string object and the resulting error code.
|
|
337
356
|
def get_string_length(string_id)
|
|
338
|
-
|
|
357
|
+
check_validity
|
|
358
|
+
|
|
359
|
+
send_request FUNCTION_GET_STRING_LENGTH, [string_id], 'S', 13, 'C L'
|
|
339
360
|
end
|
|
340
361
|
|
|
341
362
|
# Sets a chunk of up to 58 bytes in a string object beginning at ``offset``.
|
|
342
363
|
#
|
|
343
364
|
# Returns the resulting error code.
|
|
344
365
|
def set_string_chunk(string_id, offset, buffer)
|
|
345
|
-
|
|
366
|
+
check_validity
|
|
367
|
+
|
|
368
|
+
send_request FUNCTION_SET_STRING_CHUNK, [string_id, offset, buffer], 'S L Z58', 9, 'C'
|
|
346
369
|
end
|
|
347
370
|
|
|
348
371
|
# Returns a chunk up to 63 bytes from a string object beginning at ``offset`` and
|
|
349
372
|
# returns the resulting error code.
|
|
350
373
|
def get_string_chunk(string_id, offset)
|
|
351
|
-
|
|
374
|
+
check_validity
|
|
375
|
+
|
|
376
|
+
send_request FUNCTION_GET_STRING_CHUNK, [string_id, offset], 'S L', 72, 'C Z63'
|
|
352
377
|
end
|
|
353
378
|
|
|
354
379
|
# Allocates a new list object and reserves memory for ``length_to_reserve``
|
|
@@ -360,12 +385,16 @@ module Tinkerforge
|
|
|
360
385
|
# When a list object gets destroyed then the reference count of each object in
|
|
361
386
|
# the list object is decreased by one.
|
|
362
387
|
def allocate_list(length_to_reserve, session_id)
|
|
363
|
-
|
|
388
|
+
check_validity
|
|
389
|
+
|
|
390
|
+
send_request FUNCTION_ALLOCATE_LIST, [length_to_reserve, session_id], 'S S', 11, 'C S'
|
|
364
391
|
end
|
|
365
392
|
|
|
366
393
|
# Returns the length of a list object in items and the resulting error code.
|
|
367
394
|
def get_list_length(list_id)
|
|
368
|
-
|
|
395
|
+
check_validity
|
|
396
|
+
|
|
397
|
+
send_request FUNCTION_GET_LIST_LENGTH, [list_id], 'S', 11, 'C S'
|
|
369
398
|
end
|
|
370
399
|
|
|
371
400
|
# Returns the object ID and type of the object stored at ``index`` in a list
|
|
@@ -380,7 +409,9 @@ module Tinkerforge
|
|
|
380
409
|
# * Process = 4
|
|
381
410
|
# * Program = 5
|
|
382
411
|
def get_list_item(list_id, index, session_id)
|
|
383
|
-
|
|
412
|
+
check_validity
|
|
413
|
+
|
|
414
|
+
send_request FUNCTION_GET_LIST_ITEM, [list_id, index, session_id], 'S S S', 12, 'C S C'
|
|
384
415
|
end
|
|
385
416
|
|
|
386
417
|
# Appends an object to a list object and increases the reference count of the
|
|
@@ -388,7 +419,9 @@ module Tinkerforge
|
|
|
388
419
|
#
|
|
389
420
|
# Returns the resulting error code.
|
|
390
421
|
def append_to_list(list_id, item_object_id)
|
|
391
|
-
|
|
422
|
+
check_validity
|
|
423
|
+
|
|
424
|
+
send_request FUNCTION_APPEND_TO_LIST, [list_id, item_object_id], 'S S', 9, 'C'
|
|
392
425
|
end
|
|
393
426
|
|
|
394
427
|
# Removes the object stored at ``index`` from a list object and decreases the
|
|
@@ -396,7 +429,9 @@ module Tinkerforge
|
|
|
396
429
|
#
|
|
397
430
|
# Returns the resulting error code.
|
|
398
431
|
def remove_from_list(list_id, index)
|
|
399
|
-
|
|
432
|
+
check_validity
|
|
433
|
+
|
|
434
|
+
send_request FUNCTION_REMOVE_FROM_LIST, [list_id, index], 'S S', 9, 'C'
|
|
400
435
|
end
|
|
401
436
|
|
|
402
437
|
# Opens an existing file or creates a new file and allocates a new file object
|
|
@@ -441,7 +476,9 @@ module Tinkerforge
|
|
|
441
476
|
#
|
|
442
477
|
# Returns the object ID of the new file object and the resulting error code.
|
|
443
478
|
def open_file(name_string_id, flags, permissions, uid, gid, session_id)
|
|
444
|
-
|
|
479
|
+
check_validity
|
|
480
|
+
|
|
481
|
+
send_request FUNCTION_OPEN_FILE, [name_string_id, flags, permissions, uid, gid, session_id], 'S L S L L S', 11, 'C S'
|
|
445
482
|
end
|
|
446
483
|
|
|
447
484
|
# Creates a new pipe and allocates a new file object for it.
|
|
@@ -457,7 +494,9 @@ module Tinkerforge
|
|
|
457
494
|
#
|
|
458
495
|
# Returns the object ID of the new file object and the resulting error code.
|
|
459
496
|
def create_pipe(flags, length, session_id)
|
|
460
|
-
|
|
497
|
+
check_validity
|
|
498
|
+
|
|
499
|
+
send_request FUNCTION_CREATE_PIPE, [flags, length, session_id], 'L Q S', 11, 'C S'
|
|
461
500
|
end
|
|
462
501
|
|
|
463
502
|
# Returns various information about a file and the resulting error code.
|
|
@@ -484,7 +523,9 @@ module Tinkerforge
|
|
|
484
523
|
#
|
|
485
524
|
# FIXME: everything except flags and length is invalid if file type is *Pipe*
|
|
486
525
|
def get_file_info(file_id, session_id)
|
|
487
|
-
|
|
526
|
+
check_validity
|
|
527
|
+
|
|
528
|
+
send_request FUNCTION_GET_FILE_INFO, [file_id, session_id], 'S S', 58, 'C C S L S L L Q Q Q Q'
|
|
488
529
|
end
|
|
489
530
|
|
|
490
531
|
# Reads up to 62 bytes from a file object.
|
|
@@ -500,7 +541,9 @@ module Tinkerforge
|
|
|
500
541
|
# flag or by BrickRED#create_pipe without the *NonBlockingRead* flag then the
|
|
501
542
|
# error code *NotSupported* is returned.
|
|
502
543
|
def read_file(file_id, length_to_read)
|
|
503
|
-
|
|
544
|
+
check_validity
|
|
545
|
+
|
|
546
|
+
send_request FUNCTION_READ_FILE, [file_id, length_to_read], 'S C', 72, 'C C62 C'
|
|
504
547
|
end
|
|
505
548
|
|
|
506
549
|
# Reads up to 2\ :sup:`63`\ - 1 bytes from a file object asynchronously.
|
|
@@ -516,7 +559,9 @@ module Tinkerforge
|
|
|
516
559
|
# flag or by BrickRED#create_pipe without the *NonBlockingRead* flag then the error
|
|
517
560
|
# code *NotSupported* is reported via the CALLBACK_ASYNC_FILE_READ callback.
|
|
518
561
|
def read_file_async(file_id, length_to_read)
|
|
519
|
-
|
|
562
|
+
check_validity
|
|
563
|
+
|
|
564
|
+
send_request FUNCTION_READ_FILE_ASYNC, [file_id, length_to_read], 'S Q', 8, ''
|
|
520
565
|
end
|
|
521
566
|
|
|
522
567
|
# Aborts a BrickRED#read_file_async operation in progress.
|
|
@@ -525,7 +570,9 @@ module Tinkerforge
|
|
|
525
570
|
#
|
|
526
571
|
# On success the CALLBACK_ASYNC_FILE_READ callback will report *OperationAborted*.
|
|
527
572
|
def abort_async_file_read(file_id)
|
|
528
|
-
|
|
573
|
+
check_validity
|
|
574
|
+
|
|
575
|
+
send_request FUNCTION_ABORT_ASYNC_FILE_READ, [file_id], 'S', 9, 'C'
|
|
529
576
|
end
|
|
530
577
|
|
|
531
578
|
# Writes up to 61 bytes to a file object.
|
|
@@ -536,7 +583,9 @@ module Tinkerforge
|
|
|
536
583
|
# flag or by BrickRED#create_pipe without the *NonBlockingWrite* flag then the
|
|
537
584
|
# error code *NotSupported* is returned.
|
|
538
585
|
def write_file(file_id, buffer, length_to_write)
|
|
539
|
-
|
|
586
|
+
check_validity
|
|
587
|
+
|
|
588
|
+
send_request FUNCTION_WRITE_FILE, [file_id, buffer, length_to_write], 'S C61 C', 10, 'C C'
|
|
540
589
|
end
|
|
541
590
|
|
|
542
591
|
# Writes up to 61 bytes to a file object.
|
|
@@ -548,7 +597,9 @@ module Tinkerforge
|
|
|
548
597
|
# flag or by BrickRED#create_pipe without the *NonBlockingWrite* flag then the
|
|
549
598
|
# write operation will fail silently.
|
|
550
599
|
def write_file_unchecked(file_id, buffer, length_to_write)
|
|
551
|
-
|
|
600
|
+
check_validity
|
|
601
|
+
|
|
602
|
+
send_request FUNCTION_WRITE_FILE_UNCHECKED, [file_id, buffer, length_to_write], 'S C61 C', 8, ''
|
|
552
603
|
end
|
|
553
604
|
|
|
554
605
|
# Writes up to 61 bytes to a file object.
|
|
@@ -560,10 +611,12 @@ module Tinkerforge
|
|
|
560
611
|
# flag or by BrickRED#create_pipe without the *NonBlockingWrite* flag then the
|
|
561
612
|
# error code *NotSupported* is reported via the CALLBACK_ASYNC_FILE_WRITE callback.
|
|
562
613
|
def write_file_async(file_id, buffer, length_to_write)
|
|
563
|
-
|
|
614
|
+
check_validity
|
|
615
|
+
|
|
616
|
+
send_request FUNCTION_WRITE_FILE_ASYNC, [file_id, buffer, length_to_write], 'S C61 C', 8, ''
|
|
564
617
|
end
|
|
565
618
|
|
|
566
|
-
# Set the current seek position of a file object
|
|
619
|
+
# Set the current seek position of a file object relative to ``origin``.
|
|
567
620
|
#
|
|
568
621
|
# Possible file origins are:
|
|
569
622
|
#
|
|
@@ -576,26 +629,34 @@ module Tinkerforge
|
|
|
576
629
|
# If the file object was created by BrickRED#create_pipe then it has no seek
|
|
577
630
|
# position and the error code *InvalidSeek* is returned.
|
|
578
631
|
def set_file_position(file_id, offset, origin)
|
|
579
|
-
|
|
632
|
+
check_validity
|
|
633
|
+
|
|
634
|
+
send_request FUNCTION_SET_FILE_POSITION, [file_id, offset, origin], 'S q C', 17, 'C Q'
|
|
580
635
|
end
|
|
581
636
|
|
|
582
|
-
# Returns the current seek position of a file object
|
|
637
|
+
# Returns the current seek position of a file object and returns the
|
|
583
638
|
# resulting error code.
|
|
584
639
|
#
|
|
585
640
|
# If the file object was created by BrickRED#create_pipe then it has no seek
|
|
586
641
|
# position and the error code *InvalidSeek* is returned.
|
|
587
642
|
def get_file_position(file_id)
|
|
588
|
-
|
|
643
|
+
check_validity
|
|
644
|
+
|
|
645
|
+
send_request FUNCTION_GET_FILE_POSITION, [file_id], 'S', 17, 'C Q'
|
|
589
646
|
end
|
|
590
647
|
|
|
591
648
|
#
|
|
592
649
|
def set_file_events(file_id, events)
|
|
593
|
-
|
|
650
|
+
check_validity
|
|
651
|
+
|
|
652
|
+
send_request FUNCTION_SET_FILE_EVENTS, [file_id, events], 'S S', 9, 'C'
|
|
594
653
|
end
|
|
595
654
|
|
|
596
655
|
#
|
|
597
656
|
def get_file_events(file_id)
|
|
598
|
-
|
|
657
|
+
check_validity
|
|
658
|
+
|
|
659
|
+
send_request FUNCTION_GET_FILE_EVENTS, [file_id], 'S', 11, 'C S'
|
|
599
660
|
end
|
|
600
661
|
|
|
601
662
|
# Opens an existing directory and allocates a new directory object for it.
|
|
@@ -609,13 +670,17 @@ module Tinkerforge
|
|
|
609
670
|
#
|
|
610
671
|
# Returns the object ID of the new directory object and the resulting error code.
|
|
611
672
|
def open_directory(name_string_id, session_id)
|
|
612
|
-
|
|
673
|
+
check_validity
|
|
674
|
+
|
|
675
|
+
send_request FUNCTION_OPEN_DIRECTORY, [name_string_id, session_id], 'S S', 11, 'C S'
|
|
613
676
|
end
|
|
614
677
|
|
|
615
678
|
# Returns the name of a directory object, as passed to BrickRED#open_directory, and
|
|
616
679
|
# the resulting error code.
|
|
617
680
|
def get_directory_name(directory_id, session_id)
|
|
618
|
-
|
|
681
|
+
check_validity
|
|
682
|
+
|
|
683
|
+
send_request FUNCTION_GET_DIRECTORY_NAME, [directory_id, session_id], 'S S', 11, 'C S'
|
|
619
684
|
end
|
|
620
685
|
|
|
621
686
|
# Returns the next entry in a directory object and the resulting error code.
|
|
@@ -634,27 +699,37 @@ module Tinkerforge
|
|
|
634
699
|
# * Symlink = 6
|
|
635
700
|
# * Socket = 7
|
|
636
701
|
def get_next_directory_entry(directory_id, session_id)
|
|
637
|
-
|
|
702
|
+
check_validity
|
|
703
|
+
|
|
704
|
+
send_request FUNCTION_GET_NEXT_DIRECTORY_ENTRY, [directory_id, session_id], 'S S', 12, 'C S C'
|
|
638
705
|
end
|
|
639
706
|
|
|
640
707
|
# Rewinds a directory object and returns the resulting error code.
|
|
641
708
|
def rewind_directory(directory_id)
|
|
642
|
-
|
|
709
|
+
check_validity
|
|
710
|
+
|
|
711
|
+
send_request FUNCTION_REWIND_DIRECTORY, [directory_id], 'S', 9, 'C'
|
|
643
712
|
end
|
|
644
713
|
|
|
645
714
|
# FIXME: name has to be absolute
|
|
646
715
|
def create_directory(name_string_id, flags, permissions, uid, gid)
|
|
647
|
-
|
|
716
|
+
check_validity
|
|
717
|
+
|
|
718
|
+
send_request FUNCTION_CREATE_DIRECTORY, [name_string_id, flags, permissions, uid, gid], 'S L S L L', 9, 'C'
|
|
648
719
|
end
|
|
649
720
|
|
|
650
721
|
#
|
|
651
722
|
def get_processes(session_id)
|
|
652
|
-
|
|
723
|
+
check_validity
|
|
724
|
+
|
|
725
|
+
send_request FUNCTION_GET_PROCESSES, [session_id], 'S', 11, 'C S'
|
|
653
726
|
end
|
|
654
727
|
|
|
655
728
|
#
|
|
656
729
|
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)
|
|
657
|
-
|
|
730
|
+
check_validity
|
|
731
|
+
|
|
732
|
+
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', 11, 'C S'
|
|
658
733
|
end
|
|
659
734
|
|
|
660
735
|
# Sends a UNIX signal to a process object and returns the resulting error code.
|
|
@@ -671,14 +746,18 @@ module Tinkerforge
|
|
|
671
746
|
# * Continue = 18
|
|
672
747
|
# * Stop = 19
|
|
673
748
|
def kill_process(process_id, signal)
|
|
674
|
-
|
|
749
|
+
check_validity
|
|
750
|
+
|
|
751
|
+
send_request FUNCTION_KILL_PROCESS, [process_id, signal], 'S C', 9, 'C'
|
|
675
752
|
end
|
|
676
753
|
|
|
677
754
|
# Returns the executable, arguments, environment and working directory used to
|
|
678
755
|
# spawn a process object, as passed to BrickRED#spawn_process, and the resulting
|
|
679
756
|
# error code.
|
|
680
757
|
def get_process_command(process_id, session_id)
|
|
681
|
-
|
|
758
|
+
check_validity
|
|
759
|
+
|
|
760
|
+
send_request FUNCTION_GET_PROCESS_COMMAND, [process_id, session_id], 'S S', 17, 'C S S S S'
|
|
682
761
|
end
|
|
683
762
|
|
|
684
763
|
# Returns the process ID and the user and group ID used to spawn a process object,
|
|
@@ -687,13 +766,17 @@ module Tinkerforge
|
|
|
687
766
|
# The process ID is only valid if the state is *Running* or *Stopped*, see
|
|
688
767
|
# BrickRED#get_process_state.
|
|
689
768
|
def get_process_identity(process_id)
|
|
690
|
-
|
|
769
|
+
check_validity
|
|
770
|
+
|
|
771
|
+
send_request FUNCTION_GET_PROCESS_IDENTITY, [process_id], 'S', 21, 'C L L L'
|
|
691
772
|
end
|
|
692
773
|
|
|
693
774
|
# Returns the stdin, stdout and stderr files used to spawn a process object, as
|
|
694
775
|
# passed to BrickRED#spawn_process, and the resulting error code.
|
|
695
776
|
def get_process_stdio(process_id, session_id)
|
|
696
|
-
|
|
777
|
+
check_validity
|
|
778
|
+
|
|
779
|
+
send_request FUNCTION_GET_PROCESS_STDIO, [process_id, session_id], 'S S', 15, 'C S S S'
|
|
697
780
|
end
|
|
698
781
|
|
|
699
782
|
# Returns the current state, timestamp and exit code of a process object, and
|
|
@@ -728,114 +811,154 @@ module Tinkerforge
|
|
|
728
811
|
# The *CannotExecute* error can be caused by the executable being opened for
|
|
729
812
|
# writing.
|
|
730
813
|
def get_process_state(process_id)
|
|
731
|
-
|
|
814
|
+
check_validity
|
|
815
|
+
|
|
816
|
+
send_request FUNCTION_GET_PROCESS_STATE, [process_id], 'S', 19, 'C C Q C'
|
|
732
817
|
end
|
|
733
818
|
|
|
734
819
|
#
|
|
735
820
|
def get_programs(session_id)
|
|
736
|
-
|
|
821
|
+
check_validity
|
|
822
|
+
|
|
823
|
+
send_request FUNCTION_GET_PROGRAMS, [session_id], 'S', 11, 'C S'
|
|
737
824
|
end
|
|
738
825
|
|
|
739
826
|
#
|
|
740
827
|
def define_program(identifier_string_id, session_id)
|
|
741
|
-
|
|
828
|
+
check_validity
|
|
829
|
+
|
|
830
|
+
send_request FUNCTION_DEFINE_PROGRAM, [identifier_string_id, session_id], 'S S', 11, 'C S'
|
|
742
831
|
end
|
|
743
832
|
|
|
744
833
|
#
|
|
745
834
|
def purge_program(program_id, cookie)
|
|
746
|
-
|
|
835
|
+
check_validity
|
|
836
|
+
|
|
837
|
+
send_request FUNCTION_PURGE_PROGRAM, [program_id, cookie], 'S L', 9, 'C'
|
|
747
838
|
end
|
|
748
839
|
|
|
749
840
|
#
|
|
750
841
|
def get_program_identifier(program_id, session_id)
|
|
751
|
-
|
|
842
|
+
check_validity
|
|
843
|
+
|
|
844
|
+
send_request FUNCTION_GET_PROGRAM_IDENTIFIER, [program_id, session_id], 'S S', 11, 'C S'
|
|
752
845
|
end
|
|
753
846
|
|
|
754
847
|
# FIXME: root directory is absolute: <home>/programs/<identifier>
|
|
755
848
|
def get_program_root_directory(program_id, session_id)
|
|
756
|
-
|
|
849
|
+
check_validity
|
|
850
|
+
|
|
851
|
+
send_request FUNCTION_GET_PROGRAM_ROOT_DIRECTORY, [program_id, session_id], 'S S', 11, 'C S'
|
|
757
852
|
end
|
|
758
853
|
|
|
759
854
|
# FIXME: working directory is relative to <home>/programs/<identifier>/bin
|
|
760
855
|
def set_program_command(program_id, executable_string_id, arguments_list_id, environment_list_id, working_directory_string_id)
|
|
761
|
-
|
|
856
|
+
check_validity
|
|
857
|
+
|
|
858
|
+
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', 9, 'C'
|
|
762
859
|
end
|
|
763
860
|
|
|
764
861
|
# FIXME: working directory is relative to <home>/programs/<identifier>/bin
|
|
765
862
|
def get_program_command(program_id, session_id)
|
|
766
|
-
|
|
863
|
+
check_validity
|
|
864
|
+
|
|
865
|
+
send_request FUNCTION_GET_PROGRAM_COMMAND, [program_id, session_id], 'S S', 17, 'C S S S S'
|
|
767
866
|
end
|
|
768
867
|
|
|
769
868
|
# FIXME: stdio file names are relative to <home>/programs/<identifier>/bin
|
|
770
869
|
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)
|
|
771
|
-
|
|
870
|
+
check_validity
|
|
871
|
+
|
|
872
|
+
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', 9, 'C'
|
|
772
873
|
end
|
|
773
874
|
|
|
774
875
|
# FIXME: stdio file names are relative to <home>/programs/<identifier>/bin
|
|
775
876
|
def get_program_stdio_redirection(program_id, session_id)
|
|
776
|
-
|
|
877
|
+
check_validity
|
|
878
|
+
|
|
879
|
+
send_request FUNCTION_GET_PROGRAM_STDIO_REDIRECTION, [program_id, session_id], 'S S', 18, 'C C S C S C S'
|
|
777
880
|
end
|
|
778
881
|
|
|
779
882
|
#
|
|
780
883
|
def set_program_schedule(program_id, start_mode, continue_after_error, start_interval, start_fields_string_id)
|
|
781
|
-
|
|
884
|
+
check_validity
|
|
885
|
+
|
|
886
|
+
send_request FUNCTION_SET_PROGRAM_SCHEDULE, [program_id, start_mode, continue_after_error, start_interval, start_fields_string_id], 'S C ? L S', 9, 'C'
|
|
782
887
|
end
|
|
783
888
|
|
|
784
889
|
#
|
|
785
890
|
def get_program_schedule(program_id, session_id)
|
|
786
|
-
|
|
891
|
+
check_validity
|
|
892
|
+
|
|
893
|
+
send_request FUNCTION_GET_PROGRAM_SCHEDULE, [program_id, session_id], 'S S', 17, 'C C ? L S'
|
|
787
894
|
end
|
|
788
895
|
|
|
789
896
|
# FIXME: message is currently valid in error-occurred state only
|
|
790
897
|
def get_program_scheduler_state(program_id, session_id)
|
|
791
|
-
|
|
898
|
+
check_validity
|
|
899
|
+
|
|
900
|
+
send_request FUNCTION_GET_PROGRAM_SCHEDULER_STATE, [program_id, session_id], 'S S', 20, 'C C Q S'
|
|
792
901
|
end
|
|
793
902
|
|
|
794
903
|
#
|
|
795
904
|
def continue_program_schedule(program_id)
|
|
796
|
-
|
|
905
|
+
check_validity
|
|
906
|
+
|
|
907
|
+
send_request FUNCTION_CONTINUE_PROGRAM_SCHEDULE, [program_id], 'S', 9, 'C'
|
|
797
908
|
end
|
|
798
909
|
|
|
799
910
|
#
|
|
800
911
|
def start_program(program_id)
|
|
801
|
-
|
|
912
|
+
check_validity
|
|
913
|
+
|
|
914
|
+
send_request FUNCTION_START_PROGRAM, [program_id], 'S', 9, 'C'
|
|
802
915
|
end
|
|
803
916
|
|
|
804
917
|
#
|
|
805
918
|
def get_last_spawned_program_process(program_id, session_id)
|
|
806
|
-
|
|
919
|
+
check_validity
|
|
920
|
+
|
|
921
|
+
send_request FUNCTION_GET_LAST_SPAWNED_PROGRAM_PROCESS, [program_id, session_id], 'S S', 19, 'C S Q'
|
|
807
922
|
end
|
|
808
923
|
|
|
809
924
|
#
|
|
810
925
|
def get_custom_program_option_names(program_id, session_id)
|
|
811
|
-
|
|
926
|
+
check_validity
|
|
927
|
+
|
|
928
|
+
send_request FUNCTION_GET_CUSTOM_PROGRAM_OPTION_NAMES, [program_id, session_id], 'S S', 11, 'C S'
|
|
812
929
|
end
|
|
813
930
|
|
|
814
931
|
#
|
|
815
932
|
def set_custom_program_option_value(program_id, name_string_id, value_string_id)
|
|
816
|
-
|
|
933
|
+
check_validity
|
|
934
|
+
|
|
935
|
+
send_request FUNCTION_SET_CUSTOM_PROGRAM_OPTION_VALUE, [program_id, name_string_id, value_string_id], 'S S S', 9, 'C'
|
|
817
936
|
end
|
|
818
937
|
|
|
819
938
|
#
|
|
820
939
|
def get_custom_program_option_value(program_id, name_string_id, session_id)
|
|
821
|
-
|
|
940
|
+
check_validity
|
|
941
|
+
|
|
942
|
+
send_request FUNCTION_GET_CUSTOM_PROGRAM_OPTION_VALUE, [program_id, name_string_id, session_id], 'S S S', 11, 'C S'
|
|
822
943
|
end
|
|
823
944
|
|
|
824
945
|
#
|
|
825
946
|
def remove_custom_program_option(program_id, name_string_id)
|
|
826
|
-
|
|
947
|
+
check_validity
|
|
948
|
+
|
|
949
|
+
send_request FUNCTION_REMOVE_CUSTOM_PROGRAM_OPTION, [program_id, name_string_id], 'S S', 9, 'C'
|
|
827
950
|
end
|
|
828
951
|
|
|
829
952
|
# Returns the UID, the UID where the Brick is connected to,
|
|
830
953
|
# the position, the hardware and firmware version as well as the
|
|
831
954
|
# device identifier.
|
|
832
955
|
#
|
|
833
|
-
# The position
|
|
956
|
+
# The position is the position in the stack from '0' (bottom) to '8' (top).
|
|
834
957
|
#
|
|
835
958
|
# The device identifier numbers can be found :ref:`here <device_identifier>`.
|
|
836
959
|
# |device_identifier_constant|
|
|
837
960
|
def get_identity
|
|
838
|
-
send_request FUNCTION_GET_IDENTITY, [], '',
|
|
961
|
+
send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S'
|
|
839
962
|
end
|
|
840
963
|
|
|
841
964
|
# Registers a callback with ID <tt>id</tt> to the block <tt>block</tt>.
|