Class: Tinkerforge::BrickRED
- Defined in:
- lib/tinkerforge/brick_red.rb
Overview
Executes user programs and controls other Bricks/Bricklets standalone
Constant Summary collapse
- DEVICE_IDENTIFIER =
:nodoc:
17
- DEVICE_DISPLAY_NAME =
:nodoc:
'RED Brick'
- CALLBACK_ASYNC_FILE_READ =
This callback reports the result of a call to the BrickRED#read_file_async function.
30
- CALLBACK_ASYNC_FILE_WRITE =
This callback reports the result of a call to the BrickRED#write_file_async function.
31
- CALLBACK_FILE_EVENTS_OCCURRED =
32
- CALLBACK_PROCESS_STATE_CHANGED =
45
- CALLBACK_PROGRAM_SCHEDULER_STATE_CHANGED =
65
- CALLBACK_PROGRAM_PROCESS_SPAWNED =
66
- FUNCTION_CREATE_SESSION =
:nodoc:
1
- FUNCTION_EXPIRE_SESSION =
:nodoc:
2
- FUNCTION_EXPIRE_SESSION_UNCHECKED =
:nodoc:
3
- FUNCTION_KEEP_SESSION_ALIVE =
:nodoc:
4
- FUNCTION_RELEASE_OBJECT =
:nodoc:
5
- FUNCTION_RELEASE_OBJECT_UNCHECKED =
:nodoc:
6
- FUNCTION_ALLOCATE_STRING =
:nodoc:
7
- FUNCTION_TRUNCATE_STRING =
:nodoc:
8
- FUNCTION_GET_STRING_LENGTH =
:nodoc:
9
- FUNCTION_SET_STRING_CHUNK =
:nodoc:
10
- FUNCTION_GET_STRING_CHUNK =
:nodoc:
11
- FUNCTION_ALLOCATE_LIST =
:nodoc:
12
- FUNCTION_GET_LIST_LENGTH =
:nodoc:
13
- FUNCTION_GET_LIST_ITEM =
:nodoc:
14
- FUNCTION_APPEND_TO_LIST =
:nodoc:
15
- FUNCTION_REMOVE_FROM_LIST =
:nodoc:
16
- FUNCTION_OPEN_FILE =
:nodoc:
17
- FUNCTION_CREATE_PIPE =
:nodoc:
18
- FUNCTION_GET_FILE_INFO =
:nodoc:
19
- FUNCTION_READ_FILE =
:nodoc:
20
- FUNCTION_READ_FILE_ASYNC =
:nodoc:
21
- FUNCTION_ABORT_ASYNC_FILE_READ =
:nodoc:
22
- FUNCTION_WRITE_FILE =
:nodoc:
23
- FUNCTION_WRITE_FILE_UNCHECKED =
:nodoc:
24
- FUNCTION_WRITE_FILE_ASYNC =
:nodoc:
25
- FUNCTION_SET_FILE_POSITION =
:nodoc:
26
- FUNCTION_GET_FILE_POSITION =
:nodoc:
27
- FUNCTION_SET_FILE_EVENTS =
:nodoc:
28
- FUNCTION_GET_FILE_EVENTS =
:nodoc:
29
- FUNCTION_OPEN_DIRECTORY =
:nodoc:
33
- FUNCTION_GET_DIRECTORY_NAME =
:nodoc:
34
- FUNCTION_GET_NEXT_DIRECTORY_ENTRY =
:nodoc:
35
- FUNCTION_REWIND_DIRECTORY =
:nodoc:
36
- FUNCTION_CREATE_DIRECTORY =
:nodoc:
37
- FUNCTION_GET_PROCESSES =
:nodoc:
38
- FUNCTION_SPAWN_PROCESS =
:nodoc:
39
- FUNCTION_KILL_PROCESS =
:nodoc:
40
- FUNCTION_GET_PROCESS_COMMAND =
:nodoc:
41
- FUNCTION_GET_PROCESS_IDENTITY =
:nodoc:
42
- FUNCTION_GET_PROCESS_STDIO =
:nodoc:
43
- FUNCTION_GET_PROCESS_STATE =
:nodoc:
44
- FUNCTION_GET_PROGRAMS =
:nodoc:
46
- FUNCTION_DEFINE_PROGRAM =
:nodoc:
47
- FUNCTION_PURGE_PROGRAM =
:nodoc:
48
- FUNCTION_GET_PROGRAM_IDENTIFIER =
:nodoc:
49
- FUNCTION_GET_PROGRAM_ROOT_DIRECTORY =
:nodoc:
50
- FUNCTION_SET_PROGRAM_COMMAND =
:nodoc:
51
- FUNCTION_GET_PROGRAM_COMMAND =
:nodoc:
52
- FUNCTION_SET_PROGRAM_STDIO_REDIRECTION =
:nodoc:
53
- FUNCTION_GET_PROGRAM_STDIO_REDIRECTION =
:nodoc:
54
- FUNCTION_SET_PROGRAM_SCHEDULE =
:nodoc:
55
- FUNCTION_GET_PROGRAM_SCHEDULE =
:nodoc:
56
- FUNCTION_GET_PROGRAM_SCHEDULER_STATE =
:nodoc:
57
- FUNCTION_CONTINUE_PROGRAM_SCHEDULE =
:nodoc:
58
- FUNCTION_START_PROGRAM =
:nodoc:
59
- FUNCTION_GET_LAST_SPAWNED_PROGRAM_PROCESS =
:nodoc:
60
- FUNCTION_GET_CUSTOM_PROGRAM_OPTION_NAMES =
:nodoc:
61
- FUNCTION_SET_CUSTOM_PROGRAM_OPTION_VALUE =
:nodoc:
62
- FUNCTION_GET_CUSTOM_PROGRAM_OPTION_VALUE =
:nodoc:
63
- FUNCTION_REMOVE_CUSTOM_PROGRAM_OPTION =
:nodoc:
64
- FUNCTION_GET_IDENTITY =
:nodoc:
255
- ERROR_CODE_SUCCESS =
:nodoc:
0
- ERROR_CODE_UNKNOWN_ERROR =
:nodoc:
1
- ERROR_CODE_INVALID_OPERATION =
:nodoc:
2
- ERROR_CODE_OPERATION_ABORTED =
:nodoc:
3
- ERROR_CODE_INTERNAL_ERROR =
:nodoc:
4
- ERROR_CODE_UNKNOWN_SESSION_ID =
:nodoc:
5
- ERROR_CODE_NO_FREE_SESSION_ID =
:nodoc:
6
- ERROR_CODE_UNKNOWN_OBJECT_ID =
:nodoc:
7
- ERROR_CODE_NO_FREE_OBJECT_ID =
:nodoc:
8
- ERROR_CODE_OBJECT_IS_LOCKED =
:nodoc:
9
- ERROR_CODE_NO_MORE_DATA =
:nodoc:
10
- ERROR_CODE_WRONG_LIST_ITEM_TYPE =
:nodoc:
11
- ERROR_CODE_PROGRAM_IS_PURGED =
:nodoc:
12
- ERROR_CODE_INVALID_PARAMETER =
:nodoc:
128
- ERROR_CODE_NO_FREE_MEMORY =
:nodoc:
129
- ERROR_CODE_NO_FREE_SPACE =
:nodoc:
130
- ERROR_CODE_ACCESS_DENIED =
:nodoc:
121
- ERROR_CODE_ALREADY_EXISTS =
:nodoc:
132
- ERROR_CODE_DOES_NOT_EXIST =
:nodoc:
133
- ERROR_CODE_INTERRUPTED =
:nodoc:
134
- ERROR_CODE_IS_DIRECTORY =
:nodoc:
135
- ERROR_CODE_NOT_A_DIRECTORY =
:nodoc:
136
- ERROR_CODE_WOULD_BLOCK =
:nodoc:
137
- ERROR_CODE_OVERFLOW =
:nodoc:
138
- ERROR_CODE_BAD_FILE_DESCRIPTOR =
:nodoc:
139
- ERROR_CODE_OUT_OF_RANGE =
:nodoc:
140
- ERROR_CODE_NAME_TOO_LONG =
:nodoc:
141
- ERROR_CODE_INVALID_SEEK =
:nodoc:
142
- ERROR_CODE_NOT_SUPPORTED =
:nodoc:
143
- ERROR_CODE_TOO_MANY_OPEN_FILES =
:nodoc:
144
- OBJECT_TYPE_STRING =
:nodoc:
0
- OBJECT_TYPE_LIST =
:nodoc:
1
- OBJECT_TYPE_FILE =
:nodoc:
2
- OBJECT_TYPE_DIRECTORY =
:nodoc:
3
- OBJECT_TYPE_PROCESS =
:nodoc:
4
- OBJECT_TYPE_PROGRAM =
:nodoc:
5
- FILE_FLAG_READ_ONLY =
:nodoc:
1
- FILE_FLAG_WRITE_ONLY =
:nodoc:
2
- FILE_FLAG_READ_WRITE =
:nodoc:
4
- FILE_FLAG_APPEND =
:nodoc:
8
- FILE_FLAG_CREATE =
:nodoc:
16
- FILE_FLAG_EXCLUSIVE =
:nodoc:
32
- FILE_FLAG_NON_BLOCKING =
:nodoc:
64
- FILE_FLAG_TRUNCATE =
:nodoc:
128
- FILE_FLAG_TEMPORARY =
:nodoc:
256
- FILE_FLAG_REPLACE =
:nodoc:
512
- FILE_PERMISSION_USER_ALL =
:nodoc:
448
- FILE_PERMISSION_USER_READ =
:nodoc:
256
- FILE_PERMISSION_USER_WRITE =
:nodoc:
128
- FILE_PERMISSION_USER_EXECUTE =
:nodoc:
64
- FILE_PERMISSION_GROUP_ALL =
:nodoc:
56
- FILE_PERMISSION_GROUP_READ =
:nodoc:
32
- FILE_PERMISSION_GROUP_WRITE =
:nodoc:
16
- FILE_PERMISSION_GROUP_EXECUTE =
:nodoc:
8
- FILE_PERMISSION_OTHERS_ALL =
:nodoc:
7
- FILE_PERMISSION_OTHERS_READ =
:nodoc:
4
- FILE_PERMISSION_OTHERS_WRITE =
:nodoc:
2
- FILE_PERMISSION_OTHERS_EXECUTE =
:nodoc:
1
- PIPE_FLAG_NON_BLOCKING_READ =
:nodoc:
1
- PIPE_FLAG_NON_BLOCKING_WRITE =
:nodoc:
2
- FILE_TYPE_UNKNOWN =
:nodoc:
0
- FILE_TYPE_REGULAR =
:nodoc:
1
- FILE_TYPE_DIRECTORY =
:nodoc:
2
- FILE_TYPE_CHARACTER =
:nodoc:
3
- FILE_TYPE_BLOCK =
:nodoc:
4
- FILE_TYPE_FIFO =
:nodoc:
5
- FILE_TYPE_SYMLINK =
:nodoc:
6
- FILE_TYPE_SOCKET =
:nodoc:
7
- FILE_TYPE_PIPE =
:nodoc:
8
- FILE_ORIGIN_BEGINNING =
:nodoc:
0
- FILE_ORIGIN_CURRENT =
:nodoc:
1
- FILE_ORIGIN_END =
:nodoc:
2
- FILE_EVENT_READABLE =
:nodoc:
1
- FILE_EVENT_WRITABLE =
:nodoc:
2
- DIRECTORY_ENTRY_TYPE_UNKNOWN =
:nodoc:
0
- DIRECTORY_ENTRY_TYPE_REGULAR =
:nodoc:
1
- DIRECTORY_ENTRY_TYPE_DIRECTORY =
:nodoc:
2
- DIRECTORY_ENTRY_TYPE_CHARACTER =
:nodoc:
3
- DIRECTORY_ENTRY_TYPE_BLOCK =
:nodoc:
4
- DIRECTORY_ENTRY_TYPE_FIFO =
:nodoc:
5
- DIRECTORY_ENTRY_TYPE_SYMLINK =
:nodoc:
6
- DIRECTORY_ENTRY_TYPE_SOCKET =
:nodoc:
7
- DIRECTORY_FLAG_RECURSIVE =
:nodoc:
1
- DIRECTORY_FLAG_EXCLUSIVE =
:nodoc:
2
- PROCESS_SIGNAL_INTERRUPT =
:nodoc:
2
- PROCESS_SIGNAL_QUIT =
:nodoc:
3
- PROCESS_SIGNAL_ABORT =
:nodoc:
6
- PROCESS_SIGNAL_KILL =
:nodoc:
9
- PROCESS_SIGNAL_USER1 =
:nodoc:
10
- PROCESS_SIGNAL_USER2 =
:nodoc:
12
- PROCESS_SIGNAL_TERMINATE =
:nodoc:
15
- PROCESS_SIGNAL_CONTINUE =
:nodoc:
18
- PROCESS_SIGNAL_STOP =
:nodoc:
19
- PROCESS_STATE_UNKNOWN =
:nodoc:
0
- PROCESS_STATE_RUNNING =
:nodoc:
1
- PROCESS_STATE_ERROR =
:nodoc:
2
- PROCESS_STATE_EXITED =
:nodoc:
3
- PROCESS_STATE_KILLED =
:nodoc:
4
- PROCESS_STATE_STOPPED =
:nodoc:
5
- PROGRAM_STDIO_REDIRECTION_DEV_NULL =
:nodoc:
0
- PROGRAM_STDIO_REDIRECTION_PIPE =
:nodoc:
1
- PROGRAM_STDIO_REDIRECTION_FILE =
:nodoc:
2
- PROGRAM_STDIO_REDIRECTION_INDIVIDUAL_LOG =
:nodoc:
3
- PROGRAM_STDIO_REDIRECTION_CONTINUOUS_LOG =
:nodoc:
4
- PROGRAM_STDIO_REDIRECTION_STDOUT =
:nodoc:
5
- PROGRAM_START_MODE_NEVER =
:nodoc:
0
- PROGRAM_START_MODE_ALWAYS =
:nodoc:
1
- PROGRAM_START_MODE_INTERVAL =
:nodoc:
2
- PROGRAM_START_MODE_CRON =
:nodoc:
3
- PROGRAM_SCHEDULER_STATE_STOPPED =
:nodoc:
0
- PROGRAM_SCHEDULER_STATE_RUNNING =
:nodoc:
1
Constants inherited from Device
Device::DEVICE_IDENTIFIER_CHECK_MATCH, Device::DEVICE_IDENTIFIER_CHECK_MISMATCH, Device::DEVICE_IDENTIFIER_CHECK_PENDING, Device::RESPONSE_EXPECTED_ALWAYS_TRUE, Device::RESPONSE_EXPECTED_FALSE, Device::RESPONSE_EXPECTED_INVALID_FUNCTION_ID, Device::RESPONSE_EXPECTED_TRUE
Instance Attribute Summary
Attributes inherited from Device
#callback_formats, #expected_response_function_id, #expected_response_sequence_number, #high_level_callbacks, #registered_callbacks, #replaced, #uid
Instance Method Summary collapse
-
#abort_async_file_read(file_id) ⇒ Object
Aborts a BrickRED#read_file_async operation in progress.
-
#allocate_list(length_to_reserve, session_id) ⇒ Object
Allocates a new list object and reserves memory for “length_to_reserve“ items.
-
#allocate_string(length_to_reserve, buffer, session_id) ⇒ Object
Allocates a new string object, reserves “length_to_reserve“ bytes memory for it and sets up to the first 60 bytes.
-
#append_to_list(list_id, item_object_id) ⇒ Object
Appends an object to a list object and increases the reference count of the appended object by one.
- #continue_program_schedule(program_id) ⇒ Object
-
#create_directory(name_string_id, flags, permissions, uid, gid) ⇒ Object
FIXME: name has to be absolute.
-
#create_pipe(flags, length, session_id) ⇒ Object
Creates a new pipe and allocates a new file object for it.
- #create_session(lifetime) ⇒ Object
- #define_program(identifier_string_id, session_id) ⇒ Object
- #expire_session(session_id) ⇒ Object
- #expire_session_unchecked(session_id) ⇒ Object
- #get_custom_program_option_names(program_id, session_id) ⇒ Object
- #get_custom_program_option_value(program_id, name_string_id, session_id) ⇒ Object
-
#get_directory_name(directory_id, session_id) ⇒ Object
Returns the name of a directory object, as passed to BrickRED#open_directory, and the resulting error code.
- #get_file_events(file_id) ⇒ Object
-
#get_file_info(file_id, session_id) ⇒ Object
Returns various information about a file and the resulting error code.
-
#get_file_position(file_id) ⇒ Object
Returns the current seek position of a file object and returns the resulting error code.
-
#get_identity ⇒ Object
Returns the UID, the UID where the Brick is connected to, the position, the hardware and firmware version as well as the device identifier.
- #get_last_spawned_program_process(program_id, session_id) ⇒ Object
-
#get_list_item(list_id, index, session_id) ⇒ Object
Returns the object ID and type of the object stored at “index“ in a list object and returns the resulting error code.
-
#get_list_length(list_id) ⇒ Object
Returns the length of a list object in items and the resulting error code.
-
#get_next_directory_entry(directory_id, session_id) ⇒ Object
Returns the next entry in a directory object and the resulting error code.
-
#get_process_command(process_id, session_id) ⇒ Object
Returns the executable, arguments, environment and working directory used to spawn a process object, as passed to BrickRED#spawn_process, and the resulting error code.
-
#get_process_identity(process_id) ⇒ Object
Returns the process ID and the user and group ID used to spawn a process object, as passed to BrickRED#spawn_process, and the resulting error code.
-
#get_process_state(process_id) ⇒ Object
Returns the current state, timestamp and exit code of a process object, and the resulting error code.
-
#get_process_stdio(process_id, session_id) ⇒ Object
Returns the stdin, stdout and stderr files used to spawn a process object, as passed to BrickRED#spawn_process, and the resulting error code.
- #get_processes(session_id) ⇒ Object
-
#get_program_command(program_id, session_id) ⇒ Object
FIXME: working directory is relative to <home>/programs/<identifier>/bin.
- #get_program_identifier(program_id, session_id) ⇒ Object
-
#get_program_root_directory(program_id, session_id) ⇒ Object
FIXME: root directory is absolute: <home>/programs/<identifier>.
- #get_program_schedule(program_id, session_id) ⇒ Object
-
#get_program_scheduler_state(program_id, session_id) ⇒ Object
FIXME: message is currently valid in error-occurred state only.
-
#get_program_stdio_redirection(program_id, session_id) ⇒ Object
FIXME: stdio file names are relative to <home>/programs/<identifier>/bin.
- #get_programs(session_id) ⇒ Object
-
#get_string_chunk(string_id, offset) ⇒ Object
Returns a chunk up to 63 bytes from a string object beginning at “offset“ and returns the resulting error code.
-
#get_string_length(string_id) ⇒ Object
Returns the length of a string object and the resulting error code.
-
#initialize(uid, ipcon) ⇒ BrickRED
constructor
Creates an object with the unique device ID
uid
and adds it to the IP Connectionipcon
. - #keep_session_alive(session_id, lifetime) ⇒ Object
-
#kill_process(process_id, signal) ⇒ Object
Sends a UNIX signal to a process object and returns the resulting error code.
-
#open_directory(name_string_id, session_id) ⇒ Object
Opens an existing directory and allocates a new directory object for it.
-
#open_file(name_string_id, flags, permissions, uid, gid, session_id) ⇒ Object
Opens an existing file or creates a new file and allocates a new file object for it.
- #purge_program(program_id, cookie) ⇒ Object
-
#read_file(file_id, length_to_read) ⇒ Object
Reads up to 62 bytes from a file object.
-
#read_file_async(file_id, length_to_read) ⇒ Object
Reads up to 2\ :sup:‘63`\ - 1 bytes from a file object asynchronously.
-
#register_callback(id, &block) ⇒ Object
Registers a callback with ID
id
to the blockblock
. -
#release_object(object_id, session_id) ⇒ Object
Decreases the reference count of an object by one and returns the resulting error code.
- #release_object_unchecked(object_id, session_id) ⇒ Object
- #remove_custom_program_option(program_id, name_string_id) ⇒ Object
-
#remove_from_list(list_id, index) ⇒ Object
Removes the object stored at “index“ from a list object and decreases the reference count of the removed object by one.
-
#rewind_directory(directory_id) ⇒ Object
Rewinds a directory object and returns the resulting error code.
- #set_custom_program_option_value(program_id, name_string_id, value_string_id) ⇒ Object
- #set_file_events(file_id, events) ⇒ Object
-
#set_file_position(file_id, offset, origin) ⇒ Object
Set the current seek position of a file object relative to “origin“.
-
#set_program_command(program_id, executable_string_id, arguments_list_id, environment_list_id, working_directory_string_id) ⇒ Object
FIXME: working directory is relative to <home>/programs/<identifier>/bin.
- #set_program_schedule(program_id, start_mode, continue_after_error, start_interval, start_fields_string_id) ⇒ Object
-
#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) ⇒ Object
FIXME: stdio file names are relative to <home>/programs/<identifier>/bin.
-
#set_string_chunk(string_id, offset, buffer) ⇒ Object
Sets a chunk of up to 58 bytes in a string object beginning at “offset“.
- #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) ⇒ Object
- #start_program(program_id) ⇒ Object
-
#truncate_string(string_id, length) ⇒ Object
Truncates a string object to “length“ bytes and returns the resulting error code.
-
#write_file(file_id, buffer, length_to_write) ⇒ Object
Writes up to 61 bytes to a file object.
-
#write_file_async(file_id, buffer, length_to_write) ⇒ Object
Writes up to 61 bytes to a file object.
-
#write_file_unchecked(file_id, buffer, length_to_write) ⇒ Object
Writes up to 61 bytes to a file object.
Methods inherited from Device
#check_validity, #dequeue_response, #enqueue_response, #get_api_version, #get_response_expected, #send_request, #set_response_expected, #set_response_expected_all
Constructor Details
#initialize(uid, ipcon) ⇒ BrickRED
Creates an object with the unique device ID uid
and adds it to the IP Connection ipcon
.
Instance Method Details
#abort_async_file_read(file_id) ⇒ Object
Aborts a BrickRED#read_file_async operation in progress.
Returns the resulting error code.
On success the CALLBACK_ASYNC_FILE_READ callback will report OperationAborted.
572 573 574 575 576 |
# File 'lib/tinkerforge/brick_red.rb', line 572 def abort_async_file_read(file_id) check_validity send_request FUNCTION_ABORT_ASYNC_FILE_READ, [file_id], 'S', 9, 'C' end |
#allocate_list(length_to_reserve, session_id) ⇒ Object
Allocates a new list object and reserves memory for “length_to_reserve“ items. Set “length_to_reserve“ to the number of items that should be stored in the list object.
Returns the object ID of the new list object and the resulting error code.
When a list object gets destroyed then the reference count of each object in the list object is decreased by one.
387 388 389 390 391 |
# File 'lib/tinkerforge/brick_red.rb', line 387 def allocate_list(length_to_reserve, session_id) check_validity send_request FUNCTION_ALLOCATE_LIST, [length_to_reserve, session_id], 'S S', 11, 'C S' end |
#allocate_string(length_to_reserve, buffer, session_id) ⇒ Object
Allocates a new string object, reserves “length_to_reserve“ bytes memory for it and sets up to the first 60 bytes. Set “length_to_reserve“ to the length of the string that should be stored in the string object.
Returns the object ID of the new string object and the resulting error code.
341 342 343 344 345 |
# File 'lib/tinkerforge/brick_red.rb', line 341 def allocate_string(length_to_reserve, buffer, session_id) check_validity send_request FUNCTION_ALLOCATE_STRING, [length_to_reserve, buffer, session_id], 'L Z58 S', 11, 'C S' end |
#append_to_list(list_id, item_object_id) ⇒ Object
Appends an object to a list object and increases the reference count of the appended object by one.
Returns the resulting error code.
421 422 423 424 425 |
# File 'lib/tinkerforge/brick_red.rb', line 421 def append_to_list(list_id, item_object_id) check_validity send_request FUNCTION_APPEND_TO_LIST, [list_id, item_object_id], 'S S', 9, 'C' end |
#continue_program_schedule(program_id) ⇒ Object
904 905 906 907 908 |
# File 'lib/tinkerforge/brick_red.rb', line 904 def continue_program_schedule(program_id) check_validity send_request FUNCTION_CONTINUE_PROGRAM_SCHEDULE, [program_id], 'S', 9, 'C' end |
#create_directory(name_string_id, flags, permissions, uid, gid) ⇒ Object
FIXME: name has to be absolute
715 716 717 718 719 |
# File 'lib/tinkerforge/brick_red.rb', line 715 def create_directory(name_string_id, flags, , uid, gid) check_validity send_request FUNCTION_CREATE_DIRECTORY, [name_string_id, flags, , uid, gid], 'S L S L L', 9, 'C' end |
#create_pipe(flags, length, session_id) ⇒ Object
Creates a new pipe and allocates a new file object for it.
The “flags“ parameter takes a ORed combination of the following possible pipe flags (in hexadecimal notation):
-
NonBlockingRead = 0x0001
-
NonBlockingWrite = 0x0002
The length of the pipe buffer can be specified with the “length“ parameter in bytes. If length is set to zero, then the default pipe buffer length is used.
Returns the object ID of the new file object and the resulting error code.
496 497 498 499 500 |
# File 'lib/tinkerforge/brick_red.rb', line 496 def create_pipe(flags, length, session_id) check_validity send_request FUNCTION_CREATE_PIPE, [flags, length, session_id], 'L Q S', 11, 'C S' end |
#create_session(lifetime) ⇒ Object
294 295 296 297 298 |
# File 'lib/tinkerforge/brick_red.rb', line 294 def create_session(lifetime) check_validity send_request FUNCTION_CREATE_SESSION, [lifetime], 'L', 11, 'C S' end |
#define_program(identifier_string_id, session_id) ⇒ Object
827 828 829 830 831 |
# File 'lib/tinkerforge/brick_red.rb', line 827 def define_program(identifier_string_id, session_id) check_validity send_request FUNCTION_DEFINE_PROGRAM, [identifier_string_id, session_id], 'S S', 11, 'C S' end |
#expire_session(session_id) ⇒ Object
301 302 303 304 305 |
# File 'lib/tinkerforge/brick_red.rb', line 301 def expire_session(session_id) check_validity send_request FUNCTION_EXPIRE_SESSION, [session_id], 'S', 9, 'C' end |
#expire_session_unchecked(session_id) ⇒ Object
308 309 310 311 312 |
# File 'lib/tinkerforge/brick_red.rb', line 308 def expire_session_unchecked(session_id) check_validity send_request FUNCTION_EXPIRE_SESSION_UNCHECKED, [session_id], 'S', 8, '' end |
#get_custom_program_option_names(program_id, session_id) ⇒ Object
925 926 927 928 929 |
# File 'lib/tinkerforge/brick_red.rb', line 925 def get_custom_program_option_names(program_id, session_id) check_validity send_request FUNCTION_GET_CUSTOM_PROGRAM_OPTION_NAMES, [program_id, session_id], 'S S', 11, 'C S' end |
#get_custom_program_option_value(program_id, name_string_id, session_id) ⇒ Object
939 940 941 942 943 |
# File 'lib/tinkerforge/brick_red.rb', line 939 def get_custom_program_option_value(program_id, name_string_id, session_id) check_validity send_request FUNCTION_GET_CUSTOM_PROGRAM_OPTION_VALUE, [program_id, name_string_id, session_id], 'S S S', 11, 'C S' end |
#get_directory_name(directory_id, session_id) ⇒ Object
Returns the name of a directory object, as passed to BrickRED#open_directory, and the resulting error code.
680 681 682 683 684 |
# File 'lib/tinkerforge/brick_red.rb', line 680 def get_directory_name(directory_id, session_id) check_validity send_request FUNCTION_GET_DIRECTORY_NAME, [directory_id, session_id], 'S S', 11, 'C S' end |
#get_file_events(file_id) ⇒ Object
656 657 658 659 660 |
# File 'lib/tinkerforge/brick_red.rb', line 656 def get_file_events(file_id) check_validity send_request FUNCTION_GET_FILE_EVENTS, [file_id], 'S', 11, 'C S' end |
#get_file_info(file_id, session_id) ⇒ Object
Returns various information about a file and the resulting error code.
Possible file types are:
-
Unknown = 0
-
Regular = 1
-
Directory = 2
-
Character = 3
-
Block = 4
-
FIFO = 5
-
Symlink = 6
-
Socket = 7
-
Pipe = 8
If the file type is Pipe then the returned name string object is invalid, because a pipe has no name. Otherwise the returned name string object was used to open or create the file object, as passed to BrickRED#open_file.
The returned flags were used to open or create the file object, as passed to BrickRED#open_file or BrickRED#create_pipe. See the respective function for a list of possible file and pipe flags.
FIXME: everything except flags and length is invalid if file type is Pipe
525 526 527 528 529 |
# File 'lib/tinkerforge/brick_red.rb', line 525 def get_file_info(file_id, session_id) check_validity send_request FUNCTION_GET_FILE_INFO, [file_id, session_id], 'S S', 58, 'C C S L S L L Q Q Q Q' end |
#get_file_position(file_id) ⇒ Object
Returns the current seek position of a file object and returns the resulting error code.
If the file object was created by BrickRED#create_pipe then it has no seek position and the error code InvalidSeek is returned.
642 643 644 645 646 |
# File 'lib/tinkerforge/brick_red.rb', line 642 def get_file_position(file_id) check_validity send_request FUNCTION_GET_FILE_POSITION, [file_id], 'S', 17, 'C Q' end |
#get_identity ⇒ Object
Returns the UID, the UID where the Brick is connected to, the position, the hardware and firmware version as well as the device identifier.
The position is the position in the stack from ‘0’ (bottom) to ‘8’ (top).
The device identifier numbers can be found :ref:‘here <device_identifier>`. |device_identifier_constant|
960 961 962 |
# File 'lib/tinkerforge/brick_red.rb', line 960 def get_identity send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S' end |
#get_last_spawned_program_process(program_id, session_id) ⇒ Object
918 919 920 921 922 |
# File 'lib/tinkerforge/brick_red.rb', line 918 def get_last_spawned_program_process(program_id, session_id) check_validity send_request FUNCTION_GET_LAST_SPAWNED_PROGRAM_PROCESS, [program_id, session_id], 'S S', 19, 'C S Q' end |
#get_list_item(list_id, index, session_id) ⇒ Object
Returns the object ID and type of the object stored at “index“ in a list object and returns the resulting error code.
Possible object types are:
-
String = 0
-
List = 1
-
File = 2
-
Directory = 3
-
Process = 4
-
Program = 5
411 412 413 414 415 |
# File 'lib/tinkerforge/brick_red.rb', line 411 def get_list_item(list_id, index, session_id) check_validity send_request FUNCTION_GET_LIST_ITEM, [list_id, index, session_id], 'S S S', 12, 'C S C' end |
#get_list_length(list_id) ⇒ Object
Returns the length of a list object in items and the resulting error code.
394 395 396 397 398 |
# File 'lib/tinkerforge/brick_red.rb', line 394 def get_list_length(list_id) check_validity send_request FUNCTION_GET_LIST_LENGTH, [list_id], 'S', 11, 'C S' end |
#get_next_directory_entry(directory_id, session_id) ⇒ Object
Returns the next entry in a directory object and the resulting error code.
If there is not next entry then error code NoMoreData is returned. To rewind a directory object call BrickRED#rewind_directory.
Possible directory entry types are:
-
Unknown = 0
-
Regular = 1
-
Directory = 2
-
Character = 3
-
Block = 4
-
FIFO = 5
-
Symlink = 6
-
Socket = 7
701 702 703 704 705 |
# File 'lib/tinkerforge/brick_red.rb', line 701 def get_next_directory_entry(directory_id, session_id) check_validity send_request FUNCTION_GET_NEXT_DIRECTORY_ENTRY, [directory_id, session_id], 'S S', 12, 'C S C' end |
#get_process_command(process_id, session_id) ⇒ Object
Returns the executable, arguments, environment and working directory used to spawn a process object, as passed to BrickRED#spawn_process, and the resulting error code.
757 758 759 760 761 |
# File 'lib/tinkerforge/brick_red.rb', line 757 def get_process_command(process_id, session_id) check_validity send_request FUNCTION_GET_PROCESS_COMMAND, [process_id, session_id], 'S S', 17, 'C S S S S' end |
#get_process_identity(process_id) ⇒ Object
Returns the process ID and the user and group ID used to spawn a process object, as passed to BrickRED#spawn_process, and the resulting error code.
The process ID is only valid if the state is Running or Stopped, see BrickRED#get_process_state.
768 769 770 771 772 |
# File 'lib/tinkerforge/brick_red.rb', line 768 def get_process_identity(process_id) check_validity send_request FUNCTION_GET_PROCESS_IDENTITY, [process_id], 'S', 21, 'C L L L' end |
#get_process_state(process_id) ⇒ Object
Returns the current state, timestamp and exit code of a process object, and the resulting error code.
Possible process states are:
-
Unknown = 0
-
Running = 1
-
Error = 2
-
Exited = 3
-
Killed = 4
-
Stopped = 5
The timestamp represents the UNIX time since when the process is in its current state.
The exit code is only valid if the state is Error, Exited, Killed or Stopped and has different meanings depending on the state:
-
Error: error code for error occurred while spawning the process (see below)
-
Exited: exit status of the process
-
Killed: UNIX signal number used to kill the process
-
Stopped: UNIX signal number used to stop the process
Possible exit/error codes in Error state are:
-
InternalError = 125
-
CannotExecute = 126
-
DoesNotExist = 127
The CannotExecute error can be caused by the executable being opened for writing.
813 814 815 816 817 |
# File 'lib/tinkerforge/brick_red.rb', line 813 def get_process_state(process_id) check_validity send_request FUNCTION_GET_PROCESS_STATE, [process_id], 'S', 19, 'C C Q C' end |
#get_process_stdio(process_id, session_id) ⇒ Object
Returns the stdin, stdout and stderr files used to spawn a process object, as passed to BrickRED#spawn_process, and the resulting error code.
776 777 778 779 780 |
# File 'lib/tinkerforge/brick_red.rb', line 776 def get_process_stdio(process_id, session_id) check_validity send_request FUNCTION_GET_PROCESS_STDIO, [process_id, session_id], 'S S', 15, 'C S S S' end |
#get_processes(session_id) ⇒ Object
722 723 724 725 726 |
# File 'lib/tinkerforge/brick_red.rb', line 722 def get_processes(session_id) check_validity send_request FUNCTION_GET_PROCESSES, [session_id], 'S', 11, 'C S' end |
#get_program_command(program_id, session_id) ⇒ Object
FIXME: working directory is relative to <home>/programs/<identifier>/bin
862 863 864 865 866 |
# File 'lib/tinkerforge/brick_red.rb', line 862 def get_program_command(program_id, session_id) check_validity send_request FUNCTION_GET_PROGRAM_COMMAND, [program_id, session_id], 'S S', 17, 'C S S S S' end |
#get_program_identifier(program_id, session_id) ⇒ Object
841 842 843 844 845 |
# File 'lib/tinkerforge/brick_red.rb', line 841 def get_program_identifier(program_id, session_id) check_validity send_request FUNCTION_GET_PROGRAM_IDENTIFIER, [program_id, session_id], 'S S', 11, 'C S' end |
#get_program_root_directory(program_id, session_id) ⇒ Object
FIXME: root directory is absolute: <home>/programs/<identifier>
848 849 850 851 852 |
# File 'lib/tinkerforge/brick_red.rb', line 848 def get_program_root_directory(program_id, session_id) check_validity send_request FUNCTION_GET_PROGRAM_ROOT_DIRECTORY, [program_id, session_id], 'S S', 11, 'C S' end |
#get_program_schedule(program_id, session_id) ⇒ Object
890 891 892 893 894 |
# File 'lib/tinkerforge/brick_red.rb', line 890 def get_program_schedule(program_id, session_id) check_validity send_request FUNCTION_GET_PROGRAM_SCHEDULE, [program_id, session_id], 'S S', 17, 'C C ? L S' end |
#get_program_scheduler_state(program_id, session_id) ⇒ Object
FIXME: message is currently valid in error-occurred state only
897 898 899 900 901 |
# File 'lib/tinkerforge/brick_red.rb', line 897 def get_program_scheduler_state(program_id, session_id) check_validity send_request FUNCTION_GET_PROGRAM_SCHEDULER_STATE, [program_id, session_id], 'S S', 20, 'C C Q S' end |
#get_program_stdio_redirection(program_id, session_id) ⇒ Object
FIXME: stdio file names are relative to <home>/programs/<identifier>/bin
876 877 878 879 880 |
# File 'lib/tinkerforge/brick_red.rb', line 876 def get_program_stdio_redirection(program_id, session_id) check_validity send_request FUNCTION_GET_PROGRAM_STDIO_REDIRECTION, [program_id, session_id], 'S S', 18, 'C C S C S C S' end |
#get_programs(session_id) ⇒ Object
820 821 822 823 824 |
# File 'lib/tinkerforge/brick_red.rb', line 820 def get_programs(session_id) check_validity send_request FUNCTION_GET_PROGRAMS, [session_id], 'S', 11, 'C S' end |
#get_string_chunk(string_id, offset) ⇒ Object
Returns a chunk up to 63 bytes from a string object beginning at “offset“ and returns the resulting error code.
373 374 375 376 377 |
# File 'lib/tinkerforge/brick_red.rb', line 373 def get_string_chunk(string_id, offset) check_validity send_request FUNCTION_GET_STRING_CHUNK, [string_id, offset], 'S L', 72, 'C Z63' end |
#get_string_length(string_id) ⇒ Object
Returns the length of a string object and the resulting error code.
356 357 358 359 360 |
# File 'lib/tinkerforge/brick_red.rb', line 356 def get_string_length(string_id) check_validity send_request FUNCTION_GET_STRING_LENGTH, [string_id], 'S', 13, 'C L' end |
#keep_session_alive(session_id, lifetime) ⇒ Object
315 316 317 318 319 |
# File 'lib/tinkerforge/brick_red.rb', line 315 def keep_session_alive(session_id, lifetime) check_validity send_request FUNCTION_KEEP_SESSION_ALIVE, [session_id, lifetime], 'S L', 9, 'C' end |
#kill_process(process_id, signal) ⇒ Object
Sends a UNIX signal to a process object and returns the resulting error code.
Possible UNIX signals are:
-
Interrupt = 2
-
Quit = 3
-
Abort = 6
-
Kill = 9
-
User1 = 10
-
User2 = 12
-
Terminate = 15
-
Continue = 18
-
Stop = 19
748 749 750 751 752 |
# File 'lib/tinkerforge/brick_red.rb', line 748 def kill_process(process_id, signal) check_validity send_request FUNCTION_KILL_PROCESS, [process_id, signal], 'S C', 9, 'C' end |
#open_directory(name_string_id, session_id) ⇒ Object
Opens an existing directory and allocates a new directory object for it.
FIXME: name has to be absolute
The reference count of the name string object is increased by one. When the directory object is destroyed then the reference count of the name string object is decreased by one. Also the name string object is locked and cannot be modified while the directory object holds a reference to it.
Returns the object ID of the new directory object and the resulting error code.
672 673 674 675 676 |
# File 'lib/tinkerforge/brick_red.rb', line 672 def open_directory(name_string_id, session_id) check_validity send_request FUNCTION_OPEN_DIRECTORY, [name_string_id, session_id], 'S S', 11, 'C S' end |
#open_file(name_string_id, flags, permissions, uid, gid, session_id) ⇒ Object
Opens an existing file or creates a new file and allocates a new file object for it.
FIXME: name has to be absolute
The reference count of the name string object is increased by one. When the file object gets destroyed then the reference count of the name string object is decreased by one. Also the name string object is locked and cannot be modified while the file object holds a reference to it.
The “flags“ parameter takes a ORed combination of the following possible file flags (in hexadecimal notation):
-
ReadOnly = 0x0001 (O_RDONLY)
-
WriteOnly = 0x0002 (O_WRONLY)
-
ReadWrite = 0x0004 (O_RDWR)
-
Append = 0x0008 (O_APPEND)
-
Create = 0x0010 (O_CREAT)
-
Exclusive = 0x0020 (O_EXCL)
-
NonBlocking = 0x0040 (O_NONBLOCK)
-
Truncate = 0x0080 (O_TRUNC)
-
Temporary = 0x0100
-
Replace = 0x0200
FIXME: explain Temporary and Replace flag
The “permissions“ parameter takes a ORed combination of the following possible file permissions (in octal notation) that match the common UNIX permission bits:
-
UserRead = 00400
-
UserWrite = 00200
-
UserExecute = 00100
-
GroupRead = 00040
-
GroupWrite = 00020
-
GroupExecute = 00010
-
OthersRead = 00004
-
OthersWrite = 00002
-
OthersExecute = 00001
Returns the object ID of the new file object and the resulting error code.
478 479 480 481 482 |
# File 'lib/tinkerforge/brick_red.rb', line 478 def open_file(name_string_id, flags, , uid, gid, session_id) check_validity send_request FUNCTION_OPEN_FILE, [name_string_id, flags, , uid, gid, session_id], 'S L S L L S', 11, 'C S' end |
#purge_program(program_id, cookie) ⇒ Object
834 835 836 837 838 |
# File 'lib/tinkerforge/brick_red.rb', line 834 def purge_program(program_id, ) check_validity send_request FUNCTION_PURGE_PROGRAM, [program_id, ], 'S L', 9, 'C' end |
#read_file(file_id, length_to_read) ⇒ Object
Reads up to 62 bytes from a file object.
Returns the bytes read, the actual number of bytes read and the resulting error code.
If there is not data to be read, either because the file position reached end-of-file or because there is not data in the pipe, then zero bytes are returned.
If the file object was created by BrickRED#open_file without the NonBlocking flag or by BrickRED#create_pipe without the NonBlockingRead flag then the error code NotSupported is returned.
543 544 545 546 547 |
# File 'lib/tinkerforge/brick_red.rb', line 543 def read_file(file_id, length_to_read) check_validity send_request FUNCTION_READ_FILE, [file_id, length_to_read], 'S C', 72, 'C C62 C' end |
#read_file_async(file_id, length_to_read) ⇒ Object
Reads up to 2\ :sup:‘63`\ - 1 bytes from a file object asynchronously.
Reports the bytes read (in 60 byte chunks), the actual number of bytes read and the resulting error code via the CALLBACK_ASYNC_FILE_READ callback.
If there is not data to be read, either because the file position reached end-of-file or because there is not data in the pipe, then zero bytes are reported.
If the file object was created by BrickRED#open_file without the NonBlocking flag or by BrickRED#create_pipe without the NonBlockingRead flag then the error code NotSupported is reported via the CALLBACK_ASYNC_FILE_READ callback.
561 562 563 564 565 |
# File 'lib/tinkerforge/brick_red.rb', line 561 def read_file_async(file_id, length_to_read) check_validity send_request FUNCTION_READ_FILE_ASYNC, [file_id, length_to_read], 'S Q', 8, '' end |
#register_callback(id, &block) ⇒ Object
Registers a callback with ID id
to the block block
.
965 966 967 968 |
# File 'lib/tinkerforge/brick_red.rb', line 965 def register_callback(id, &block) callback = block @registered_callbacks[id] = callback end |
#release_object(object_id, session_id) ⇒ Object
Decreases the reference count of an object by one and returns the resulting error code. If the reference count reaches zero the object gets destroyed.
323 324 325 326 327 |
# File 'lib/tinkerforge/brick_red.rb', line 323 def release_object(object_id, session_id) check_validity send_request FUNCTION_RELEASE_OBJECT, [object_id, session_id], 'S S', 9, 'C' end |
#release_object_unchecked(object_id, session_id) ⇒ Object
330 331 332 333 334 |
# File 'lib/tinkerforge/brick_red.rb', line 330 def release_object_unchecked(object_id, session_id) check_validity send_request FUNCTION_RELEASE_OBJECT_UNCHECKED, [object_id, session_id], 'S S', 8, '' end |
#remove_custom_program_option(program_id, name_string_id) ⇒ Object
946 947 948 949 950 |
# File 'lib/tinkerforge/brick_red.rb', line 946 def remove_custom_program_option(program_id, name_string_id) check_validity send_request FUNCTION_REMOVE_CUSTOM_PROGRAM_OPTION, [program_id, name_string_id], 'S S', 9, 'C' end |
#remove_from_list(list_id, index) ⇒ Object
Removes the object stored at “index“ from a list object and decreases the reference count of the removed object by one.
Returns the resulting error code.
431 432 433 434 435 |
# File 'lib/tinkerforge/brick_red.rb', line 431 def remove_from_list(list_id, index) check_validity send_request FUNCTION_REMOVE_FROM_LIST, [list_id, index], 'S S', 9, 'C' end |
#rewind_directory(directory_id) ⇒ Object
Rewinds a directory object and returns the resulting error code.
708 709 710 711 712 |
# File 'lib/tinkerforge/brick_red.rb', line 708 def rewind_directory(directory_id) check_validity send_request FUNCTION_REWIND_DIRECTORY, [directory_id], 'S', 9, 'C' end |
#set_custom_program_option_value(program_id, name_string_id, value_string_id) ⇒ Object
932 933 934 935 936 |
# File 'lib/tinkerforge/brick_red.rb', line 932 def set_custom_program_option_value(program_id, name_string_id, value_string_id) check_validity send_request FUNCTION_SET_CUSTOM_PROGRAM_OPTION_VALUE, [program_id, name_string_id, value_string_id], 'S S S', 9, 'C' end |
#set_file_events(file_id, events) ⇒ Object
649 650 651 652 653 |
# File 'lib/tinkerforge/brick_red.rb', line 649 def set_file_events(file_id, events) check_validity send_request FUNCTION_SET_FILE_EVENTS, [file_id, events], 'S S', 9, 'C' end |
#set_file_position(file_id, offset, origin) ⇒ Object
Set the current seek position of a file object relative to “origin“.
Possible file origins are:
-
Beginning = 0
-
Current = 1
-
End = 2
Returns the resulting absolute seek position and error code.
If the file object was created by BrickRED#create_pipe then it has no seek position and the error code InvalidSeek is returned.
631 632 633 634 635 |
# File 'lib/tinkerforge/brick_red.rb', line 631 def set_file_position(file_id, offset, origin) check_validity send_request FUNCTION_SET_FILE_POSITION, [file_id, offset, origin], 'S q C', 17, 'C Q' end |
#set_program_command(program_id, executable_string_id, arguments_list_id, environment_list_id, working_directory_string_id) ⇒ Object
FIXME: working directory is relative to <home>/programs/<identifier>/bin
855 856 857 858 859 |
# File 'lib/tinkerforge/brick_red.rb', line 855 def set_program_command(program_id, executable_string_id, arguments_list_id, environment_list_id, working_directory_string_id) check_validity 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' end |
#set_program_schedule(program_id, start_mode, continue_after_error, start_interval, start_fields_string_id) ⇒ Object
883 884 885 886 887 |
# File 'lib/tinkerforge/brick_red.rb', line 883 def set_program_schedule(program_id, start_mode, continue_after_error, start_interval, start_fields_string_id) check_validity 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' end |
#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) ⇒ Object
FIXME: stdio file names are relative to <home>/programs/<identifier>/bin
869 870 871 872 873 |
# File 'lib/tinkerforge/brick_red.rb', line 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) check_validity 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' end |
#set_string_chunk(string_id, offset, buffer) ⇒ Object
Sets a chunk of up to 58 bytes in a string object beginning at “offset“.
Returns the resulting error code.
365 366 367 368 369 |
# File 'lib/tinkerforge/brick_red.rb', line 365 def set_string_chunk(string_id, offset, buffer) check_validity send_request FUNCTION_SET_STRING_CHUNK, [string_id, offset, buffer], 'S L Z58', 9, 'C' end |
#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) ⇒ Object
729 730 731 732 733 |
# File 'lib/tinkerforge/brick_red.rb', line 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) check_validity 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' end |
#start_program(program_id) ⇒ Object
911 912 913 914 915 |
# File 'lib/tinkerforge/brick_red.rb', line 911 def start_program(program_id) check_validity send_request FUNCTION_START_PROGRAM, [program_id], 'S', 9, 'C' end |
#truncate_string(string_id, length) ⇒ Object
Truncates a string object to “length“ bytes and returns the resulting error code.
349 350 351 352 353 |
# File 'lib/tinkerforge/brick_red.rb', line 349 def truncate_string(string_id, length) check_validity send_request FUNCTION_TRUNCATE_STRING, [string_id, length], 'S L', 9, 'C' end |
#write_file(file_id, buffer, length_to_write) ⇒ Object
Writes up to 61 bytes to a file object.
Returns the actual number of bytes written and the resulting error code.
If the file object was created by BrickRED#open_file without the NonBlocking flag or by BrickRED#create_pipe without the NonBlockingWrite flag then the error code NotSupported is returned.
585 586 587 588 589 |
# File 'lib/tinkerforge/brick_red.rb', line 585 def write_file(file_id, buffer, length_to_write) check_validity send_request FUNCTION_WRITE_FILE, [file_id, buffer, length_to_write], 'S C61 C', 10, 'C C' end |
#write_file_async(file_id, buffer, length_to_write) ⇒ Object
Writes up to 61 bytes to a file object.
Reports the actual number of bytes written and the resulting error code via the CALLBACK_ASYNC_FILE_WRITE callback.
If the file object was created by BrickRED#open_file without the NonBlocking flag or by BrickRED#create_pipe without the NonBlockingWrite flag then the error code NotSupported is reported via the CALLBACK_ASYNC_FILE_WRITE callback.
613 614 615 616 617 |
# File 'lib/tinkerforge/brick_red.rb', line 613 def write_file_async(file_id, buffer, length_to_write) check_validity send_request FUNCTION_WRITE_FILE_ASYNC, [file_id, buffer, length_to_write], 'S C61 C', 8, '' end |
#write_file_unchecked(file_id, buffer, length_to_write) ⇒ Object
Writes up to 61 bytes to a file object.
Does neither report the actual number of bytes written nor the resulting error code.
If the file object was created by BrickRED#open_file without the NonBlocking flag or by BrickRED#create_pipe without the NonBlockingWrite flag then the write operation will fail silently.
599 600 601 602 603 |
# File 'lib/tinkerforge/brick_red.rb', line 599 def write_file_unchecked(file_id, buffer, length_to_write) check_validity send_request FUNCTION_WRITE_FILE_UNCHECKED, [file_id, buffer, length_to_write], 'S C61 C', 8, '' end |