tinkerforge_async/bindings/red_brick.rs
1/* ***********************************************************
2 * This file was automatically generated on 2024-02-16. *
3 * *
4 * Rust Bindings Version 2.0.20 *
5 * *
6 * If you have a bugfix for this file and want to commit it, *
7 * please fix the bug in the generator. You can find a link *
8 * to the generators git repository on tinkerforge.com *
9 *************************************************************/
10
11//! Executes user programs and controls other Bricks/Bricklets standalone.
12//!
13//! See also the documentation [here](https://www.tinkerforge.com/en/doc/Software/Bricks/RED_Brick_Rust.html).
14#[allow(unused_imports)]
15use crate::{
16 base58::Uid, byte_converter::*, converting_receiver::BrickletError, device::*, error::TinkerforgeError,
17 ip_connection::async_io::AsyncIpConnection, low_level_traits::LowLevelRead,
18};
19#[allow(unused_imports)]
20use futures_core::Stream;
21#[allow(unused_imports)]
22use tokio_stream::StreamExt;
23pub enum RedBrickFunction {
24 CreateSession,
25 ExpireSession,
26 ExpireSessionUnchecked,
27 KeepSessionAlive,
28 ReleaseObject,
29 ReleaseObjectUnchecked,
30 AllocateString,
31 TruncateString,
32 GetStringLength,
33 SetStringChunk,
34 GetStringChunk,
35 AllocateList,
36 GetListLength,
37 GetListItem,
38 AppendToList,
39 RemoveFromList,
40 OpenFile,
41 CreatePipe,
42 GetFileInfo,
43 ReadFile,
44 ReadFileAsync,
45 AbortAsyncFileRead,
46 WriteFile,
47 WriteFileUnchecked,
48 WriteFileAsync,
49 SetFilePosition,
50 GetFilePosition,
51 SetFileEvents,
52 GetFileEvents,
53 OpenDirectory,
54 GetDirectoryName,
55 GetNextDirectoryEntry,
56 RewindDirectory,
57 CreateDirectory,
58 GetProcesses,
59 SpawnProcess,
60 KillProcess,
61 GetProcessCommand,
62 GetProcessIdentity,
63 GetProcessStdio,
64 GetProcessState,
65 GetPrograms,
66 DefineProgram,
67 PurgeProgram,
68 GetProgramIdentifier,
69 GetProgramRootDirectory,
70 SetProgramCommand,
71 GetProgramCommand,
72 SetProgramStdioRedirection,
73 GetProgramStdioRedirection,
74 SetProgramSchedule,
75 GetProgramSchedule,
76 GetProgramSchedulerState,
77 ContinueProgramSchedule,
78 StartProgram,
79 GetLastSpawnedProgramProcess,
80 GetCustomProgramOptionNames,
81 SetCustomProgramOptionValue,
82 GetCustomProgramOptionValue,
83 RemoveCustomProgramOption,
84 GetIdentity,
85 CallbackAsyncFileRead,
86 CallbackAsyncFileWrite,
87 CallbackFileEventsOccurred,
88 CallbackProcessStateChanged,
89 CallbackProgramSchedulerStateChanged,
90 CallbackProgramProcessSpawned,
91}
92impl From<RedBrickFunction> for u8 {
93 fn from(fun: RedBrickFunction) -> Self {
94 match fun {
95 RedBrickFunction::CreateSession => 1,
96 RedBrickFunction::ExpireSession => 2,
97 RedBrickFunction::ExpireSessionUnchecked => 3,
98 RedBrickFunction::KeepSessionAlive => 4,
99 RedBrickFunction::ReleaseObject => 5,
100 RedBrickFunction::ReleaseObjectUnchecked => 6,
101 RedBrickFunction::AllocateString => 7,
102 RedBrickFunction::TruncateString => 8,
103 RedBrickFunction::GetStringLength => 9,
104 RedBrickFunction::SetStringChunk => 10,
105 RedBrickFunction::GetStringChunk => 11,
106 RedBrickFunction::AllocateList => 12,
107 RedBrickFunction::GetListLength => 13,
108 RedBrickFunction::GetListItem => 14,
109 RedBrickFunction::AppendToList => 15,
110 RedBrickFunction::RemoveFromList => 16,
111 RedBrickFunction::OpenFile => 17,
112 RedBrickFunction::CreatePipe => 18,
113 RedBrickFunction::GetFileInfo => 19,
114 RedBrickFunction::ReadFile => 20,
115 RedBrickFunction::ReadFileAsync => 21,
116 RedBrickFunction::AbortAsyncFileRead => 22,
117 RedBrickFunction::WriteFile => 23,
118 RedBrickFunction::WriteFileUnchecked => 24,
119 RedBrickFunction::WriteFileAsync => 25,
120 RedBrickFunction::SetFilePosition => 26,
121 RedBrickFunction::GetFilePosition => 27,
122 RedBrickFunction::SetFileEvents => 28,
123 RedBrickFunction::GetFileEvents => 29,
124 RedBrickFunction::OpenDirectory => 33,
125 RedBrickFunction::GetDirectoryName => 34,
126 RedBrickFunction::GetNextDirectoryEntry => 35,
127 RedBrickFunction::RewindDirectory => 36,
128 RedBrickFunction::CreateDirectory => 37,
129 RedBrickFunction::GetProcesses => 38,
130 RedBrickFunction::SpawnProcess => 39,
131 RedBrickFunction::KillProcess => 40,
132 RedBrickFunction::GetProcessCommand => 41,
133 RedBrickFunction::GetProcessIdentity => 42,
134 RedBrickFunction::GetProcessStdio => 43,
135 RedBrickFunction::GetProcessState => 44,
136 RedBrickFunction::GetPrograms => 46,
137 RedBrickFunction::DefineProgram => 47,
138 RedBrickFunction::PurgeProgram => 48,
139 RedBrickFunction::GetProgramIdentifier => 49,
140 RedBrickFunction::GetProgramRootDirectory => 50,
141 RedBrickFunction::SetProgramCommand => 51,
142 RedBrickFunction::GetProgramCommand => 52,
143 RedBrickFunction::SetProgramStdioRedirection => 53,
144 RedBrickFunction::GetProgramStdioRedirection => 54,
145 RedBrickFunction::SetProgramSchedule => 55,
146 RedBrickFunction::GetProgramSchedule => 56,
147 RedBrickFunction::GetProgramSchedulerState => 57,
148 RedBrickFunction::ContinueProgramSchedule => 58,
149 RedBrickFunction::StartProgram => 59,
150 RedBrickFunction::GetLastSpawnedProgramProcess => 60,
151 RedBrickFunction::GetCustomProgramOptionNames => 61,
152 RedBrickFunction::SetCustomProgramOptionValue => 62,
153 RedBrickFunction::GetCustomProgramOptionValue => 63,
154 RedBrickFunction::RemoveCustomProgramOption => 64,
155 RedBrickFunction::GetIdentity => 255,
156 RedBrickFunction::CallbackAsyncFileRead => 30,
157 RedBrickFunction::CallbackAsyncFileWrite => 31,
158 RedBrickFunction::CallbackFileEventsOccurred => 32,
159 RedBrickFunction::CallbackProcessStateChanged => 45,
160 RedBrickFunction::CallbackProgramSchedulerStateChanged => 65,
161 RedBrickFunction::CallbackProgramProcessSpawned => 66,
162 }
163 }
164}
165pub const RED_BRICK_ERROR_CODE_SUCCESS: u8 = 0;
166pub const RED_BRICK_ERROR_CODE_UNKNOWN_ERROR: u8 = 1;
167pub const RED_BRICK_ERROR_CODE_INVALID_OPERATION: u8 = 2;
168pub const RED_BRICK_ERROR_CODE_OPERATION_ABORTED: u8 = 3;
169pub const RED_BRICK_ERROR_CODE_INTERNAL_ERROR: u8 = 4;
170pub const RED_BRICK_ERROR_CODE_UNKNOWN_SESSION_ID: u8 = 5;
171pub const RED_BRICK_ERROR_CODE_NO_FREE_SESSION_ID: u8 = 6;
172pub const RED_BRICK_ERROR_CODE_UNKNOWN_OBJECT_ID: u8 = 7;
173pub const RED_BRICK_ERROR_CODE_NO_FREE_OBJECT_ID: u8 = 8;
174pub const RED_BRICK_ERROR_CODE_OBJECT_IS_LOCKED: u8 = 9;
175pub const RED_BRICK_ERROR_CODE_NO_MORE_DATA: u8 = 10;
176pub const RED_BRICK_ERROR_CODE_WRONG_LIST_ITEM_TYPE: u8 = 11;
177pub const RED_BRICK_ERROR_CODE_PROGRAM_IS_PURGED: u8 = 12;
178pub const RED_BRICK_ERROR_CODE_INVALID_PARAMETER: u8 = 128;
179pub const RED_BRICK_ERROR_CODE_NO_FREE_MEMORY: u8 = 129;
180pub const RED_BRICK_ERROR_CODE_NO_FREE_SPACE: u8 = 130;
181pub const RED_BRICK_ERROR_CODE_ACCESS_DENIED: u8 = 121;
182pub const RED_BRICK_ERROR_CODE_ALREADY_EXISTS: u8 = 132;
183pub const RED_BRICK_ERROR_CODE_DOES_NOT_EXIST: u8 = 133;
184pub const RED_BRICK_ERROR_CODE_INTERRUPTED: u8 = 134;
185pub const RED_BRICK_ERROR_CODE_IS_DIRECTORY: u8 = 135;
186pub const RED_BRICK_ERROR_CODE_NOT_A_DIRECTORY: u8 = 136;
187pub const RED_BRICK_ERROR_CODE_WOULD_BLOCK: u8 = 137;
188pub const RED_BRICK_ERROR_CODE_OVERFLOW: u8 = 138;
189pub const RED_BRICK_ERROR_CODE_BAD_FILE_DESCRIPTOR: u8 = 139;
190pub const RED_BRICK_ERROR_CODE_OUT_OF_RANGE: u8 = 140;
191pub const RED_BRICK_ERROR_CODE_NAME_TOO_LONG: u8 = 141;
192pub const RED_BRICK_ERROR_CODE_INVALID_SEEK: u8 = 142;
193pub const RED_BRICK_ERROR_CODE_NOT_SUPPORTED: u8 = 143;
194pub const RED_BRICK_ERROR_CODE_TOO_MANY_OPEN_FILES: u8 = 144;
195pub const RED_BRICK_OBJECT_TYPE_STRING: u8 = 0;
196pub const RED_BRICK_OBJECT_TYPE_LIST: u8 = 1;
197pub const RED_BRICK_OBJECT_TYPE_FILE: u8 = 2;
198pub const RED_BRICK_OBJECT_TYPE_DIRECTORY: u8 = 3;
199pub const RED_BRICK_OBJECT_TYPE_PROCESS: u8 = 4;
200pub const RED_BRICK_OBJECT_TYPE_PROGRAM: u8 = 5;
201pub const RED_BRICK_FILE_FLAG_READ_ONLY: u32 = 1;
202pub const RED_BRICK_FILE_FLAG_WRITE_ONLY: u32 = 2;
203pub const RED_BRICK_FILE_FLAG_READ_WRITE: u32 = 4;
204pub const RED_BRICK_FILE_FLAG_APPEND: u32 = 8;
205pub const RED_BRICK_FILE_FLAG_CREATE: u32 = 16;
206pub const RED_BRICK_FILE_FLAG_EXCLUSIVE: u32 = 32;
207pub const RED_BRICK_FILE_FLAG_NON_BLOCKING: u32 = 64;
208pub const RED_BRICK_FILE_FLAG_TRUNCATE: u32 = 128;
209pub const RED_BRICK_FILE_FLAG_TEMPORARY: u32 = 256;
210pub const RED_BRICK_FILE_FLAG_REPLACE: u32 = 512;
211pub const RED_BRICK_FILE_PERMISSION_USER_ALL: u16 = 448;
212pub const RED_BRICK_FILE_PERMISSION_USER_READ: u16 = 256;
213pub const RED_BRICK_FILE_PERMISSION_USER_WRITE: u16 = 128;
214pub const RED_BRICK_FILE_PERMISSION_USER_EXECUTE: u16 = 64;
215pub const RED_BRICK_FILE_PERMISSION_GROUP_ALL: u16 = 56;
216pub const RED_BRICK_FILE_PERMISSION_GROUP_READ: u16 = 32;
217pub const RED_BRICK_FILE_PERMISSION_GROUP_WRITE: u16 = 16;
218pub const RED_BRICK_FILE_PERMISSION_GROUP_EXECUTE: u16 = 8;
219pub const RED_BRICK_FILE_PERMISSION_OTHERS_ALL: u16 = 7;
220pub const RED_BRICK_FILE_PERMISSION_OTHERS_READ: u16 = 4;
221pub const RED_BRICK_FILE_PERMISSION_OTHERS_WRITE: u16 = 2;
222pub const RED_BRICK_FILE_PERMISSION_OTHERS_EXECUTE: u16 = 1;
223pub const RED_BRICK_PIPE_FLAG_NON_BLOCKING_READ: u32 = 1;
224pub const RED_BRICK_PIPE_FLAG_NON_BLOCKING_WRITE: u32 = 2;
225pub const RED_BRICK_FILE_TYPE_UNKNOWN: u8 = 0;
226pub const RED_BRICK_FILE_TYPE_REGULAR: u8 = 1;
227pub const RED_BRICK_FILE_TYPE_DIRECTORY: u8 = 2;
228pub const RED_BRICK_FILE_TYPE_CHARACTER: u8 = 3;
229pub const RED_BRICK_FILE_TYPE_BLOCK: u8 = 4;
230pub const RED_BRICK_FILE_TYPE_FIFO: u8 = 5;
231pub const RED_BRICK_FILE_TYPE_SYMLINK: u8 = 6;
232pub const RED_BRICK_FILE_TYPE_SOCKET: u8 = 7;
233pub const RED_BRICK_FILE_TYPE_PIPE: u8 = 8;
234pub const RED_BRICK_FILE_ORIGIN_BEGINNING: u8 = 0;
235pub const RED_BRICK_FILE_ORIGIN_CURRENT: u8 = 1;
236pub const RED_BRICK_FILE_ORIGIN_END: u8 = 2;
237pub const RED_BRICK_FILE_EVENT_READABLE: u16 = 1;
238pub const RED_BRICK_FILE_EVENT_WRITABLE: u16 = 2;
239pub const RED_BRICK_DIRECTORY_ENTRY_TYPE_UNKNOWN: u8 = 0;
240pub const RED_BRICK_DIRECTORY_ENTRY_TYPE_REGULAR: u8 = 1;
241pub const RED_BRICK_DIRECTORY_ENTRY_TYPE_DIRECTORY: u8 = 2;
242pub const RED_BRICK_DIRECTORY_ENTRY_TYPE_CHARACTER: u8 = 3;
243pub const RED_BRICK_DIRECTORY_ENTRY_TYPE_BLOCK: u8 = 4;
244pub const RED_BRICK_DIRECTORY_ENTRY_TYPE_FIFO: u8 = 5;
245pub const RED_BRICK_DIRECTORY_ENTRY_TYPE_SYMLINK: u8 = 6;
246pub const RED_BRICK_DIRECTORY_ENTRY_TYPE_SOCKET: u8 = 7;
247pub const RED_BRICK_DIRECTORY_FLAG_RECURSIVE: u32 = 1;
248pub const RED_BRICK_DIRECTORY_FLAG_EXCLUSIVE: u32 = 2;
249pub const RED_BRICK_PROCESS_SIGNAL_INTERRUPT: u8 = 2;
250pub const RED_BRICK_PROCESS_SIGNAL_QUIT: u8 = 3;
251pub const RED_BRICK_PROCESS_SIGNAL_ABORT: u8 = 6;
252pub const RED_BRICK_PROCESS_SIGNAL_KILL: u8 = 9;
253pub const RED_BRICK_PROCESS_SIGNAL_USER1: u8 = 10;
254pub const RED_BRICK_PROCESS_SIGNAL_USER2: u8 = 12;
255pub const RED_BRICK_PROCESS_SIGNAL_TERMINATE: u8 = 15;
256pub const RED_BRICK_PROCESS_SIGNAL_CONTINUE: u8 = 18;
257pub const RED_BRICK_PROCESS_SIGNAL_STOP: u8 = 19;
258pub const RED_BRICK_PROCESS_STATE_UNKNOWN: u8 = 0;
259pub const RED_BRICK_PROCESS_STATE_RUNNING: u8 = 1;
260pub const RED_BRICK_PROCESS_STATE_ERROR: u8 = 2;
261pub const RED_BRICK_PROCESS_STATE_EXITED: u8 = 3;
262pub const RED_BRICK_PROCESS_STATE_KILLED: u8 = 4;
263pub const RED_BRICK_PROCESS_STATE_STOPPED: u8 = 5;
264pub const RED_BRICK_PROGRAM_STDIO_REDIRECTION_DEV_NULL: u8 = 0;
265pub const RED_BRICK_PROGRAM_STDIO_REDIRECTION_PIPE: u8 = 1;
266pub const RED_BRICK_PROGRAM_STDIO_REDIRECTION_FILE: u8 = 2;
267pub const RED_BRICK_PROGRAM_STDIO_REDIRECTION_INDIVIDUAL_LOG: u8 = 3;
268pub const RED_BRICK_PROGRAM_STDIO_REDIRECTION_CONTINUOUS_LOG: u8 = 4;
269pub const RED_BRICK_PROGRAM_STDIO_REDIRECTION_STDOUT: u8 = 5;
270pub const RED_BRICK_PROGRAM_START_MODE_NEVER: u8 = 0;
271pub const RED_BRICK_PROGRAM_START_MODE_ALWAYS: u8 = 1;
272pub const RED_BRICK_PROGRAM_START_MODE_INTERVAL: u8 = 2;
273pub const RED_BRICK_PROGRAM_START_MODE_CRON: u8 = 3;
274pub const RED_BRICK_PROGRAM_SCHEDULER_STATE_STOPPED: u8 = 0;
275pub const RED_BRICK_PROGRAM_SCHEDULER_STATE_RUNNING: u8 = 1;
276
277#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
278pub struct CreateSession {
279 pub error_code: u8,
280 pub session_id: u16,
281}
282impl FromByteSlice for CreateSession {
283 fn bytes_expected() -> usize {
284 3
285 }
286 fn from_le_byte_slice(bytes: &[u8]) -> CreateSession {
287 CreateSession { error_code: <u8>::from_le_byte_slice(&bytes[0..1]), session_id: <u16>::from_le_byte_slice(&bytes[1..3]) }
288 }
289}
290
291#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
292pub struct AllocateString {
293 pub error_code: u8,
294 pub string_id: u16,
295}
296impl FromByteSlice for AllocateString {
297 fn bytes_expected() -> usize {
298 3
299 }
300 fn from_le_byte_slice(bytes: &[u8]) -> AllocateString {
301 AllocateString { error_code: <u8>::from_le_byte_slice(&bytes[0..1]), string_id: <u16>::from_le_byte_slice(&bytes[1..3]) }
302 }
303}
304
305#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
306pub struct StringLength {
307 pub error_code: u8,
308 pub length: u32,
309}
310impl FromByteSlice for StringLength {
311 fn bytes_expected() -> usize {
312 5
313 }
314 fn from_le_byte_slice(bytes: &[u8]) -> StringLength {
315 StringLength { error_code: <u8>::from_le_byte_slice(&bytes[0..1]), length: <u32>::from_le_byte_slice(&bytes[1..5]) }
316 }
317}
318
319#[derive(Clone)]
320pub struct StringChunk {
321 pub error_code: u8,
322 pub buffer: String,
323}
324impl FromByteSlice for StringChunk {
325 fn bytes_expected() -> usize {
326 64
327 }
328 fn from_le_byte_slice(bytes: &[u8]) -> StringChunk {
329 StringChunk { error_code: <u8>::from_le_byte_slice(&bytes[0..1]), buffer: <String>::from_le_byte_slice(&bytes[1..64]) }
330 }
331}
332
333#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
334pub struct AllocateList {
335 pub error_code: u8,
336 pub list_id: u16,
337}
338impl FromByteSlice for AllocateList {
339 fn bytes_expected() -> usize {
340 3
341 }
342 fn from_le_byte_slice(bytes: &[u8]) -> AllocateList {
343 AllocateList { error_code: <u8>::from_le_byte_slice(&bytes[0..1]), list_id: <u16>::from_le_byte_slice(&bytes[1..3]) }
344 }
345}
346
347#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
348pub struct ListLength {
349 pub error_code: u8,
350 pub length: u16,
351}
352impl FromByteSlice for ListLength {
353 fn bytes_expected() -> usize {
354 3
355 }
356 fn from_le_byte_slice(bytes: &[u8]) -> ListLength {
357 ListLength { error_code: <u8>::from_le_byte_slice(&bytes[0..1]), length: <u16>::from_le_byte_slice(&bytes[1..3]) }
358 }
359}
360
361#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
362pub struct ListItem {
363 pub error_code: u8,
364 pub item_object_id: u16,
365 pub type_: u8,
366}
367impl FromByteSlice for ListItem {
368 fn bytes_expected() -> usize {
369 4
370 }
371 fn from_le_byte_slice(bytes: &[u8]) -> ListItem {
372 ListItem {
373 error_code: <u8>::from_le_byte_slice(&bytes[0..1]),
374 item_object_id: <u16>::from_le_byte_slice(&bytes[1..3]),
375 type_: <u8>::from_le_byte_slice(&bytes[3..4]),
376 }
377 }
378}
379
380#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
381pub struct OpenFile {
382 pub error_code: u8,
383 pub file_id: u16,
384}
385impl FromByteSlice for OpenFile {
386 fn bytes_expected() -> usize {
387 3
388 }
389 fn from_le_byte_slice(bytes: &[u8]) -> OpenFile {
390 OpenFile { error_code: <u8>::from_le_byte_slice(&bytes[0..1]), file_id: <u16>::from_le_byte_slice(&bytes[1..3]) }
391 }
392}
393
394#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
395pub struct CreatePipe {
396 pub error_code: u8,
397 pub file_id: u16,
398}
399impl FromByteSlice for CreatePipe {
400 fn bytes_expected() -> usize {
401 3
402 }
403 fn from_le_byte_slice(bytes: &[u8]) -> CreatePipe {
404 CreatePipe { error_code: <u8>::from_le_byte_slice(&bytes[0..1]), file_id: <u16>::from_le_byte_slice(&bytes[1..3]) }
405 }
406}
407
408#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
409pub struct FileInfo {
410 pub error_code: u8,
411 pub type_: u8,
412 pub name_string_id: u16,
413 pub flags: u32,
414 pub permissions: u16,
415 pub uid: u32,
416 pub gid: u32,
417 pub length: u64,
418 pub access_timestamp: u64,
419 pub modification_timestamp: u64,
420 pub status_change_timestamp: u64,
421}
422impl FromByteSlice for FileInfo {
423 fn bytes_expected() -> usize {
424 50
425 }
426 fn from_le_byte_slice(bytes: &[u8]) -> FileInfo {
427 FileInfo {
428 error_code: <u8>::from_le_byte_slice(&bytes[0..1]),
429 type_: <u8>::from_le_byte_slice(&bytes[1..2]),
430 name_string_id: <u16>::from_le_byte_slice(&bytes[2..4]),
431 flags: <u32>::from_le_byte_slice(&bytes[4..8]),
432 permissions: <u16>::from_le_byte_slice(&bytes[8..10]),
433 uid: <u32>::from_le_byte_slice(&bytes[10..14]),
434 gid: <u32>::from_le_byte_slice(&bytes[14..18]),
435 length: <u64>::from_le_byte_slice(&bytes[18..26]),
436 access_timestamp: <u64>::from_le_byte_slice(&bytes[26..34]),
437 modification_timestamp: <u64>::from_le_byte_slice(&bytes[34..42]),
438 status_change_timestamp: <u64>::from_le_byte_slice(&bytes[42..50]),
439 }
440 }
441}
442
443#[derive(Clone, Copy)]
444pub struct ReadFile {
445 pub error_code: u8,
446 pub buffer: [u8; 62],
447 pub length_read: u8,
448}
449impl FromByteSlice for ReadFile {
450 fn bytes_expected() -> usize {
451 64
452 }
453 fn from_le_byte_slice(bytes: &[u8]) -> ReadFile {
454 ReadFile {
455 error_code: <u8>::from_le_byte_slice(&bytes[0..1]),
456 buffer: <[u8; 62]>::from_le_byte_slice(&bytes[1..63]),
457 length_read: <u8>::from_le_byte_slice(&bytes[63..64]),
458 }
459 }
460}
461
462#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
463pub struct WriteFile {
464 pub error_code: u8,
465 pub length_written: u8,
466}
467impl FromByteSlice for WriteFile {
468 fn bytes_expected() -> usize {
469 2
470 }
471 fn from_le_byte_slice(bytes: &[u8]) -> WriteFile {
472 WriteFile { error_code: <u8>::from_le_byte_slice(&bytes[0..1]), length_written: <u8>::from_le_byte_slice(&bytes[1..2]) }
473 }
474}
475
476#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
477pub struct SetFilePosition {
478 pub error_code: u8,
479 pub position: u64,
480}
481impl FromByteSlice for SetFilePosition {
482 fn bytes_expected() -> usize {
483 9
484 }
485 fn from_le_byte_slice(bytes: &[u8]) -> SetFilePosition {
486 SetFilePosition { error_code: <u8>::from_le_byte_slice(&bytes[0..1]), position: <u64>::from_le_byte_slice(&bytes[1..9]) }
487 }
488}
489
490#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
491pub struct FilePosition {
492 pub error_code: u8,
493 pub position: u64,
494}
495impl FromByteSlice for FilePosition {
496 fn bytes_expected() -> usize {
497 9
498 }
499 fn from_le_byte_slice(bytes: &[u8]) -> FilePosition {
500 FilePosition { error_code: <u8>::from_le_byte_slice(&bytes[0..1]), position: <u64>::from_le_byte_slice(&bytes[1..9]) }
501 }
502}
503
504#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
505pub struct FileEvents {
506 pub error_code: u8,
507 pub events: u16,
508}
509impl FromByteSlice for FileEvents {
510 fn bytes_expected() -> usize {
511 3
512 }
513 fn from_le_byte_slice(bytes: &[u8]) -> FileEvents {
514 FileEvents { error_code: <u8>::from_le_byte_slice(&bytes[0..1]), events: <u16>::from_le_byte_slice(&bytes[1..3]) }
515 }
516}
517
518#[derive(Clone, Copy)]
519pub struct AsyncFileReadEvent {
520 pub file_id: u16,
521 pub error_code: u8,
522 pub buffer: [u8; 60],
523 pub length_read: u8,
524}
525impl FromByteSlice for AsyncFileReadEvent {
526 fn bytes_expected() -> usize {
527 64
528 }
529 fn from_le_byte_slice(bytes: &[u8]) -> AsyncFileReadEvent {
530 AsyncFileReadEvent {
531 file_id: <u16>::from_le_byte_slice(&bytes[0..2]),
532 error_code: <u8>::from_le_byte_slice(&bytes[2..3]),
533 buffer: <[u8; 60]>::from_le_byte_slice(&bytes[3..63]),
534 length_read: <u8>::from_le_byte_slice(&bytes[63..64]),
535 }
536 }
537}
538
539#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
540pub struct AsyncFileWriteEvent {
541 pub file_id: u16,
542 pub error_code: u8,
543 pub length_written: u8,
544}
545impl FromByteSlice for AsyncFileWriteEvent {
546 fn bytes_expected() -> usize {
547 4
548 }
549 fn from_le_byte_slice(bytes: &[u8]) -> AsyncFileWriteEvent {
550 AsyncFileWriteEvent {
551 file_id: <u16>::from_le_byte_slice(&bytes[0..2]),
552 error_code: <u8>::from_le_byte_slice(&bytes[2..3]),
553 length_written: <u8>::from_le_byte_slice(&bytes[3..4]),
554 }
555 }
556}
557
558#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
559pub struct FileEventsOccurredEvent {
560 pub file_id: u16,
561 pub events: u16,
562}
563impl FromByteSlice for FileEventsOccurredEvent {
564 fn bytes_expected() -> usize {
565 4
566 }
567 fn from_le_byte_slice(bytes: &[u8]) -> FileEventsOccurredEvent {
568 FileEventsOccurredEvent { file_id: <u16>::from_le_byte_slice(&bytes[0..2]), events: <u16>::from_le_byte_slice(&bytes[2..4]) }
569 }
570}
571
572#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
573pub struct OpenDirectory {
574 pub error_code: u8,
575 pub directory_id: u16,
576}
577impl FromByteSlice for OpenDirectory {
578 fn bytes_expected() -> usize {
579 3
580 }
581 fn from_le_byte_slice(bytes: &[u8]) -> OpenDirectory {
582 OpenDirectory { error_code: <u8>::from_le_byte_slice(&bytes[0..1]), directory_id: <u16>::from_le_byte_slice(&bytes[1..3]) }
583 }
584}
585
586#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
587pub struct DirectoryName {
588 pub error_code: u8,
589 pub name_string_id: u16,
590}
591impl FromByteSlice for DirectoryName {
592 fn bytes_expected() -> usize {
593 3
594 }
595 fn from_le_byte_slice(bytes: &[u8]) -> DirectoryName {
596 DirectoryName { error_code: <u8>::from_le_byte_slice(&bytes[0..1]), name_string_id: <u16>::from_le_byte_slice(&bytes[1..3]) }
597 }
598}
599
600#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
601pub struct NextDirectoryEntry {
602 pub error_code: u8,
603 pub name_string_id: u16,
604 pub type_: u8,
605}
606impl FromByteSlice for NextDirectoryEntry {
607 fn bytes_expected() -> usize {
608 4
609 }
610 fn from_le_byte_slice(bytes: &[u8]) -> NextDirectoryEntry {
611 NextDirectoryEntry {
612 error_code: <u8>::from_le_byte_slice(&bytes[0..1]),
613 name_string_id: <u16>::from_le_byte_slice(&bytes[1..3]),
614 type_: <u8>::from_le_byte_slice(&bytes[3..4]),
615 }
616 }
617}
618
619#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
620pub struct Processes {
621 pub error_code: u8,
622 pub processes_list_id: u16,
623}
624impl FromByteSlice for Processes {
625 fn bytes_expected() -> usize {
626 3
627 }
628 fn from_le_byte_slice(bytes: &[u8]) -> Processes {
629 Processes { error_code: <u8>::from_le_byte_slice(&bytes[0..1]), processes_list_id: <u16>::from_le_byte_slice(&bytes[1..3]) }
630 }
631}
632
633#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
634pub struct SpawnProcess {
635 pub error_code: u8,
636 pub process_id: u16,
637}
638impl FromByteSlice for SpawnProcess {
639 fn bytes_expected() -> usize {
640 3
641 }
642 fn from_le_byte_slice(bytes: &[u8]) -> SpawnProcess {
643 SpawnProcess { error_code: <u8>::from_le_byte_slice(&bytes[0..1]), process_id: <u16>::from_le_byte_slice(&bytes[1..3]) }
644 }
645}
646
647#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
648pub struct ProcessCommand {
649 pub error_code: u8,
650 pub executable_string_id: u16,
651 pub arguments_list_id: u16,
652 pub environment_list_id: u16,
653 pub working_directory_string_id: u16,
654}
655impl FromByteSlice for ProcessCommand {
656 fn bytes_expected() -> usize {
657 9
658 }
659 fn from_le_byte_slice(bytes: &[u8]) -> ProcessCommand {
660 ProcessCommand {
661 error_code: <u8>::from_le_byte_slice(&bytes[0..1]),
662 executable_string_id: <u16>::from_le_byte_slice(&bytes[1..3]),
663 arguments_list_id: <u16>::from_le_byte_slice(&bytes[3..5]),
664 environment_list_id: <u16>::from_le_byte_slice(&bytes[5..7]),
665 working_directory_string_id: <u16>::from_le_byte_slice(&bytes[7..9]),
666 }
667 }
668}
669
670#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
671pub struct ProcessIdentity {
672 pub error_code: u8,
673 pub pid: u32,
674 pub uid: u32,
675 pub gid: u32,
676}
677impl FromByteSlice for ProcessIdentity {
678 fn bytes_expected() -> usize {
679 13
680 }
681 fn from_le_byte_slice(bytes: &[u8]) -> ProcessIdentity {
682 ProcessIdentity {
683 error_code: <u8>::from_le_byte_slice(&bytes[0..1]),
684 pid: <u32>::from_le_byte_slice(&bytes[1..5]),
685 uid: <u32>::from_le_byte_slice(&bytes[5..9]),
686 gid: <u32>::from_le_byte_slice(&bytes[9..13]),
687 }
688 }
689}
690
691#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
692pub struct ProcessStdio {
693 pub error_code: u8,
694 pub stdin_file_id: u16,
695 pub stdout_file_id: u16,
696 pub stderr_file_id: u16,
697}
698impl FromByteSlice for ProcessStdio {
699 fn bytes_expected() -> usize {
700 7
701 }
702 fn from_le_byte_slice(bytes: &[u8]) -> ProcessStdio {
703 ProcessStdio {
704 error_code: <u8>::from_le_byte_slice(&bytes[0..1]),
705 stdin_file_id: <u16>::from_le_byte_slice(&bytes[1..3]),
706 stdout_file_id: <u16>::from_le_byte_slice(&bytes[3..5]),
707 stderr_file_id: <u16>::from_le_byte_slice(&bytes[5..7]),
708 }
709 }
710}
711
712#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
713pub struct ProcessState {
714 pub error_code: u8,
715 pub state: u8,
716 pub timestamp: u64,
717 pub exit_code: u8,
718}
719impl FromByteSlice for ProcessState {
720 fn bytes_expected() -> usize {
721 11
722 }
723 fn from_le_byte_slice(bytes: &[u8]) -> ProcessState {
724 ProcessState {
725 error_code: <u8>::from_le_byte_slice(&bytes[0..1]),
726 state: <u8>::from_le_byte_slice(&bytes[1..2]),
727 timestamp: <u64>::from_le_byte_slice(&bytes[2..10]),
728 exit_code: <u8>::from_le_byte_slice(&bytes[10..11]),
729 }
730 }
731}
732
733#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
734pub struct ProcessStateChangedEvent {
735 pub process_id: u16,
736 pub state: u8,
737 pub timestamp: u64,
738 pub exit_code: u8,
739}
740impl FromByteSlice for ProcessStateChangedEvent {
741 fn bytes_expected() -> usize {
742 12
743 }
744 fn from_le_byte_slice(bytes: &[u8]) -> ProcessStateChangedEvent {
745 ProcessStateChangedEvent {
746 process_id: <u16>::from_le_byte_slice(&bytes[0..2]),
747 state: <u8>::from_le_byte_slice(&bytes[2..3]),
748 timestamp: <u64>::from_le_byte_slice(&bytes[3..11]),
749 exit_code: <u8>::from_le_byte_slice(&bytes[11..12]),
750 }
751 }
752}
753
754#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
755pub struct Programs {
756 pub error_code: u8,
757 pub programs_list_id: u16,
758}
759impl FromByteSlice for Programs {
760 fn bytes_expected() -> usize {
761 3
762 }
763 fn from_le_byte_slice(bytes: &[u8]) -> Programs {
764 Programs { error_code: <u8>::from_le_byte_slice(&bytes[0..1]), programs_list_id: <u16>::from_le_byte_slice(&bytes[1..3]) }
765 }
766}
767
768#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
769pub struct DefineProgram {
770 pub error_code: u8,
771 pub program_id: u16,
772}
773impl FromByteSlice for DefineProgram {
774 fn bytes_expected() -> usize {
775 3
776 }
777 fn from_le_byte_slice(bytes: &[u8]) -> DefineProgram {
778 DefineProgram { error_code: <u8>::from_le_byte_slice(&bytes[0..1]), program_id: <u16>::from_le_byte_slice(&bytes[1..3]) }
779 }
780}
781
782#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
783pub struct ProgramIdentifier {
784 pub error_code: u8,
785 pub identifier_string_id: u16,
786}
787impl FromByteSlice for ProgramIdentifier {
788 fn bytes_expected() -> usize {
789 3
790 }
791 fn from_le_byte_slice(bytes: &[u8]) -> ProgramIdentifier {
792 ProgramIdentifier {
793 error_code: <u8>::from_le_byte_slice(&bytes[0..1]),
794 identifier_string_id: <u16>::from_le_byte_slice(&bytes[1..3]),
795 }
796 }
797}
798
799#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
800pub struct ProgramRootDirectory {
801 pub error_code: u8,
802 pub root_directory_string_id: u16,
803}
804impl FromByteSlice for ProgramRootDirectory {
805 fn bytes_expected() -> usize {
806 3
807 }
808 fn from_le_byte_slice(bytes: &[u8]) -> ProgramRootDirectory {
809 ProgramRootDirectory {
810 error_code: <u8>::from_le_byte_slice(&bytes[0..1]),
811 root_directory_string_id: <u16>::from_le_byte_slice(&bytes[1..3]),
812 }
813 }
814}
815
816#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
817pub struct ProgramCommand {
818 pub error_code: u8,
819 pub executable_string_id: u16,
820 pub arguments_list_id: u16,
821 pub environment_list_id: u16,
822 pub working_directory_string_id: u16,
823}
824impl FromByteSlice for ProgramCommand {
825 fn bytes_expected() -> usize {
826 9
827 }
828 fn from_le_byte_slice(bytes: &[u8]) -> ProgramCommand {
829 ProgramCommand {
830 error_code: <u8>::from_le_byte_slice(&bytes[0..1]),
831 executable_string_id: <u16>::from_le_byte_slice(&bytes[1..3]),
832 arguments_list_id: <u16>::from_le_byte_slice(&bytes[3..5]),
833 environment_list_id: <u16>::from_le_byte_slice(&bytes[5..7]),
834 working_directory_string_id: <u16>::from_le_byte_slice(&bytes[7..9]),
835 }
836 }
837}
838
839#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
840pub struct ProgramStdioRedirection {
841 pub error_code: u8,
842 pub stdin_redirection: u8,
843 pub stdin_file_name_string_id: u16,
844 pub stdout_redirection: u8,
845 pub stdout_file_name_string_id: u16,
846 pub stderr_redirection: u8,
847 pub stderr_file_name_string_id: u16,
848}
849impl FromByteSlice for ProgramStdioRedirection {
850 fn bytes_expected() -> usize {
851 10
852 }
853 fn from_le_byte_slice(bytes: &[u8]) -> ProgramStdioRedirection {
854 ProgramStdioRedirection {
855 error_code: <u8>::from_le_byte_slice(&bytes[0..1]),
856 stdin_redirection: <u8>::from_le_byte_slice(&bytes[1..2]),
857 stdin_file_name_string_id: <u16>::from_le_byte_slice(&bytes[2..4]),
858 stdout_redirection: <u8>::from_le_byte_slice(&bytes[4..5]),
859 stdout_file_name_string_id: <u16>::from_le_byte_slice(&bytes[5..7]),
860 stderr_redirection: <u8>::from_le_byte_slice(&bytes[7..8]),
861 stderr_file_name_string_id: <u16>::from_le_byte_slice(&bytes[8..10]),
862 }
863 }
864}
865
866#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
867pub struct ProgramSchedule {
868 pub error_code: u8,
869 pub start_mode: u8,
870 pub continue_after_error: bool,
871 pub start_interval: u32,
872 pub start_fields_string_id: u16,
873}
874impl FromByteSlice for ProgramSchedule {
875 fn bytes_expected() -> usize {
876 9
877 }
878 fn from_le_byte_slice(bytes: &[u8]) -> ProgramSchedule {
879 ProgramSchedule {
880 error_code: <u8>::from_le_byte_slice(&bytes[0..1]),
881 start_mode: <u8>::from_le_byte_slice(&bytes[1..2]),
882 continue_after_error: <bool>::from_le_byte_slice(&bytes[2..3]),
883 start_interval: <u32>::from_le_byte_slice(&bytes[3..7]),
884 start_fields_string_id: <u16>::from_le_byte_slice(&bytes[7..9]),
885 }
886 }
887}
888
889#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
890pub struct ProgramSchedulerState {
891 pub error_code: u8,
892 pub state: u8,
893 pub timestamp: u64,
894 pub message_string_id: u16,
895}
896impl FromByteSlice for ProgramSchedulerState {
897 fn bytes_expected() -> usize {
898 12
899 }
900 fn from_le_byte_slice(bytes: &[u8]) -> ProgramSchedulerState {
901 ProgramSchedulerState {
902 error_code: <u8>::from_le_byte_slice(&bytes[0..1]),
903 state: <u8>::from_le_byte_slice(&bytes[1..2]),
904 timestamp: <u64>::from_le_byte_slice(&bytes[2..10]),
905 message_string_id: <u16>::from_le_byte_slice(&bytes[10..12]),
906 }
907 }
908}
909
910#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
911pub struct LastSpawnedProgramProcess {
912 pub error_code: u8,
913 pub process_id: u16,
914 pub timestamp: u64,
915}
916impl FromByteSlice for LastSpawnedProgramProcess {
917 fn bytes_expected() -> usize {
918 11
919 }
920 fn from_le_byte_slice(bytes: &[u8]) -> LastSpawnedProgramProcess {
921 LastSpawnedProgramProcess {
922 error_code: <u8>::from_le_byte_slice(&bytes[0..1]),
923 process_id: <u16>::from_le_byte_slice(&bytes[1..3]),
924 timestamp: <u64>::from_le_byte_slice(&bytes[3..11]),
925 }
926 }
927}
928
929#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
930pub struct CustomProgramOptionNames {
931 pub error_code: u8,
932 pub names_list_id: u16,
933}
934impl FromByteSlice for CustomProgramOptionNames {
935 fn bytes_expected() -> usize {
936 3
937 }
938 fn from_le_byte_slice(bytes: &[u8]) -> CustomProgramOptionNames {
939 CustomProgramOptionNames {
940 error_code: <u8>::from_le_byte_slice(&bytes[0..1]),
941 names_list_id: <u16>::from_le_byte_slice(&bytes[1..3]),
942 }
943 }
944}
945
946#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
947pub struct CustomProgramOptionValue {
948 pub error_code: u8,
949 pub value_string_id: u16,
950}
951impl FromByteSlice for CustomProgramOptionValue {
952 fn bytes_expected() -> usize {
953 3
954 }
955 fn from_le_byte_slice(bytes: &[u8]) -> CustomProgramOptionValue {
956 CustomProgramOptionValue {
957 error_code: <u8>::from_le_byte_slice(&bytes[0..1]),
958 value_string_id: <u16>::from_le_byte_slice(&bytes[1..3]),
959 }
960 }
961}
962
963#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)]
964pub struct Identity {
965 pub uid: String,
966 pub connected_uid: String,
967 pub position: char,
968 pub hardware_version: [u8; 3],
969 pub firmware_version: [u8; 3],
970 pub device_identifier: u16,
971}
972impl FromByteSlice for Identity {
973 fn bytes_expected() -> usize {
974 25
975 }
976 fn from_le_byte_slice(bytes: &[u8]) -> Identity {
977 Identity {
978 uid: <String>::from_le_byte_slice(&bytes[0..8]),
979 connected_uid: <String>::from_le_byte_slice(&bytes[8..16]),
980 position: <char>::from_le_byte_slice(&bytes[16..17]),
981 hardware_version: <[u8; 3]>::from_le_byte_slice(&bytes[17..20]),
982 firmware_version: <[u8; 3]>::from_le_byte_slice(&bytes[20..23]),
983 device_identifier: <u16>::from_le_byte_slice(&bytes[23..25]),
984 }
985 }
986}
987
988/// Executes user programs and controls other Bricks/Bricklets standalone
989#[derive(Clone)]
990pub struct RedBrick {
991 device: Device,
992}
993impl RedBrick {
994 pub const DEVICE_IDENTIFIER: u16 = 17;
995 pub const DEVICE_DISPLAY_NAME: &'static str = "RED Brick";
996 /// Creates an object with the unique device ID `uid`. This object can then be used after the IP Connection `ip_connection` is connected.
997 pub fn new(uid: Uid, connection: AsyncIpConnection) -> RedBrick {
998 let mut result = RedBrick { device: Device::new([2, 0, 10], uid, connection, Self::DEVICE_DISPLAY_NAME) };
999 result.device.response_expected[u8::from(RedBrickFunction::CreateSession) as usize] = ResponseExpectedFlag::AlwaysTrue;
1000 result.device.response_expected[u8::from(RedBrickFunction::ExpireSession) as usize] = ResponseExpectedFlag::AlwaysTrue;
1001 result.device.response_expected[u8::from(RedBrickFunction::ExpireSessionUnchecked) as usize] = ResponseExpectedFlag::False;
1002 result.device.response_expected[u8::from(RedBrickFunction::KeepSessionAlive) as usize] = ResponseExpectedFlag::AlwaysTrue;
1003 result.device.response_expected[u8::from(RedBrickFunction::ReleaseObject) as usize] = ResponseExpectedFlag::AlwaysTrue;
1004 result.device.response_expected[u8::from(RedBrickFunction::ReleaseObjectUnchecked) as usize] = ResponseExpectedFlag::False;
1005 result.device.response_expected[u8::from(RedBrickFunction::AllocateString) as usize] = ResponseExpectedFlag::AlwaysTrue;
1006 result.device.response_expected[u8::from(RedBrickFunction::TruncateString) as usize] = ResponseExpectedFlag::AlwaysTrue;
1007 result.device.response_expected[u8::from(RedBrickFunction::GetStringLength) as usize] = ResponseExpectedFlag::AlwaysTrue;
1008 result.device.response_expected[u8::from(RedBrickFunction::SetStringChunk) as usize] = ResponseExpectedFlag::AlwaysTrue;
1009 result.device.response_expected[u8::from(RedBrickFunction::GetStringChunk) as usize] = ResponseExpectedFlag::AlwaysTrue;
1010 result.device.response_expected[u8::from(RedBrickFunction::AllocateList) as usize] = ResponseExpectedFlag::AlwaysTrue;
1011 result.device.response_expected[u8::from(RedBrickFunction::GetListLength) as usize] = ResponseExpectedFlag::AlwaysTrue;
1012 result.device.response_expected[u8::from(RedBrickFunction::GetListItem) as usize] = ResponseExpectedFlag::AlwaysTrue;
1013 result.device.response_expected[u8::from(RedBrickFunction::AppendToList) as usize] = ResponseExpectedFlag::AlwaysTrue;
1014 result.device.response_expected[u8::from(RedBrickFunction::RemoveFromList) as usize] = ResponseExpectedFlag::AlwaysTrue;
1015 result.device.response_expected[u8::from(RedBrickFunction::OpenFile) as usize] = ResponseExpectedFlag::AlwaysTrue;
1016 result.device.response_expected[u8::from(RedBrickFunction::CreatePipe) as usize] = ResponseExpectedFlag::AlwaysTrue;
1017 result.device.response_expected[u8::from(RedBrickFunction::GetFileInfo) as usize] = ResponseExpectedFlag::AlwaysTrue;
1018 result.device.response_expected[u8::from(RedBrickFunction::ReadFile) as usize] = ResponseExpectedFlag::AlwaysTrue;
1019 result.device.response_expected[u8::from(RedBrickFunction::ReadFileAsync) as usize] = ResponseExpectedFlag::False;
1020 result.device.response_expected[u8::from(RedBrickFunction::AbortAsyncFileRead) as usize] = ResponseExpectedFlag::AlwaysTrue;
1021 result.device.response_expected[u8::from(RedBrickFunction::WriteFile) as usize] = ResponseExpectedFlag::AlwaysTrue;
1022 result.device.response_expected[u8::from(RedBrickFunction::WriteFileUnchecked) as usize] = ResponseExpectedFlag::False;
1023 result.device.response_expected[u8::from(RedBrickFunction::WriteFileAsync) as usize] = ResponseExpectedFlag::False;
1024 result.device.response_expected[u8::from(RedBrickFunction::SetFilePosition) as usize] = ResponseExpectedFlag::AlwaysTrue;
1025 result.device.response_expected[u8::from(RedBrickFunction::GetFilePosition) as usize] = ResponseExpectedFlag::AlwaysTrue;
1026 result.device.response_expected[u8::from(RedBrickFunction::SetFileEvents) as usize] = ResponseExpectedFlag::AlwaysTrue;
1027 result.device.response_expected[u8::from(RedBrickFunction::GetFileEvents) as usize] = ResponseExpectedFlag::AlwaysTrue;
1028 result.device.response_expected[u8::from(RedBrickFunction::OpenDirectory) as usize] = ResponseExpectedFlag::AlwaysTrue;
1029 result.device.response_expected[u8::from(RedBrickFunction::GetDirectoryName) as usize] = ResponseExpectedFlag::AlwaysTrue;
1030 result.device.response_expected[u8::from(RedBrickFunction::GetNextDirectoryEntry) as usize] = ResponseExpectedFlag::AlwaysTrue;
1031 result.device.response_expected[u8::from(RedBrickFunction::RewindDirectory) as usize] = ResponseExpectedFlag::AlwaysTrue;
1032 result.device.response_expected[u8::from(RedBrickFunction::CreateDirectory) as usize] = ResponseExpectedFlag::AlwaysTrue;
1033 result.device.response_expected[u8::from(RedBrickFunction::GetProcesses) as usize] = ResponseExpectedFlag::AlwaysTrue;
1034 result.device.response_expected[u8::from(RedBrickFunction::SpawnProcess) as usize] = ResponseExpectedFlag::AlwaysTrue;
1035 result.device.response_expected[u8::from(RedBrickFunction::KillProcess) as usize] = ResponseExpectedFlag::AlwaysTrue;
1036 result.device.response_expected[u8::from(RedBrickFunction::GetProcessCommand) as usize] = ResponseExpectedFlag::AlwaysTrue;
1037 result.device.response_expected[u8::from(RedBrickFunction::GetProcessIdentity) as usize] = ResponseExpectedFlag::AlwaysTrue;
1038 result.device.response_expected[u8::from(RedBrickFunction::GetProcessStdio) as usize] = ResponseExpectedFlag::AlwaysTrue;
1039 result.device.response_expected[u8::from(RedBrickFunction::GetProcessState) as usize] = ResponseExpectedFlag::AlwaysTrue;
1040 result.device.response_expected[u8::from(RedBrickFunction::GetPrograms) as usize] = ResponseExpectedFlag::AlwaysTrue;
1041 result.device.response_expected[u8::from(RedBrickFunction::DefineProgram) as usize] = ResponseExpectedFlag::AlwaysTrue;
1042 result.device.response_expected[u8::from(RedBrickFunction::PurgeProgram) as usize] = ResponseExpectedFlag::AlwaysTrue;
1043 result.device.response_expected[u8::from(RedBrickFunction::GetProgramIdentifier) as usize] = ResponseExpectedFlag::AlwaysTrue;
1044 result.device.response_expected[u8::from(RedBrickFunction::GetProgramRootDirectory) as usize] = ResponseExpectedFlag::AlwaysTrue;
1045 result.device.response_expected[u8::from(RedBrickFunction::SetProgramCommand) as usize] = ResponseExpectedFlag::AlwaysTrue;
1046 result.device.response_expected[u8::from(RedBrickFunction::GetProgramCommand) as usize] = ResponseExpectedFlag::AlwaysTrue;
1047 result.device.response_expected[u8::from(RedBrickFunction::SetProgramStdioRedirection) as usize] = ResponseExpectedFlag::AlwaysTrue;
1048 result.device.response_expected[u8::from(RedBrickFunction::GetProgramStdioRedirection) as usize] = ResponseExpectedFlag::AlwaysTrue;
1049 result.device.response_expected[u8::from(RedBrickFunction::SetProgramSchedule) as usize] = ResponseExpectedFlag::AlwaysTrue;
1050 result.device.response_expected[u8::from(RedBrickFunction::GetProgramSchedule) as usize] = ResponseExpectedFlag::AlwaysTrue;
1051 result.device.response_expected[u8::from(RedBrickFunction::GetProgramSchedulerState) as usize] = ResponseExpectedFlag::AlwaysTrue;
1052 result.device.response_expected[u8::from(RedBrickFunction::ContinueProgramSchedule) as usize] = ResponseExpectedFlag::AlwaysTrue;
1053 result.device.response_expected[u8::from(RedBrickFunction::StartProgram) as usize] = ResponseExpectedFlag::AlwaysTrue;
1054 result.device.response_expected[u8::from(RedBrickFunction::GetLastSpawnedProgramProcess) as usize] =
1055 ResponseExpectedFlag::AlwaysTrue;
1056 result.device.response_expected[u8::from(RedBrickFunction::GetCustomProgramOptionNames) as usize] =
1057 ResponseExpectedFlag::AlwaysTrue;
1058 result.device.response_expected[u8::from(RedBrickFunction::SetCustomProgramOptionValue) as usize] =
1059 ResponseExpectedFlag::AlwaysTrue;
1060 result.device.response_expected[u8::from(RedBrickFunction::GetCustomProgramOptionValue) as usize] =
1061 ResponseExpectedFlag::AlwaysTrue;
1062 result.device.response_expected[u8::from(RedBrickFunction::RemoveCustomProgramOption) as usize] = ResponseExpectedFlag::AlwaysTrue;
1063 result.device.response_expected[u8::from(RedBrickFunction::GetIdentity) as usize] = ResponseExpectedFlag::AlwaysTrue;
1064 result
1065 }
1066
1067 /// Returns the response expected flag for the function specified by the function ID parameter.
1068 /// It is true if the function is expected to send a response, false otherwise.
1069 ///
1070 /// For getter functions this is enabled by default and cannot be disabled, because those
1071 /// functions will always send a response. For callback configuration functions it is enabled
1072 /// by default too, but can be disabled by [`set_response_expected`](crate::red_brick::RedBrick::set_response_expected).
1073 /// For setter functions it is disabled by default and can be enabled.
1074 ///
1075 /// Enabling the response expected flag for a setter function allows to detect timeouts
1076 /// and other error conditions calls of this setter as well. The device will then send a response
1077 /// for this purpose. If this flag is disabled for a setter function then no response is sent
1078 /// and errors are silently ignored, because they cannot be detected.
1079 ///
1080 /// See [`set_response_expected`](crate::red_brick::RedBrick::set_response_expected) for the list of function ID constants available for this function.
1081 pub fn get_response_expected(&mut self, fun: RedBrickFunction) -> Result<bool, GetResponseExpectedError> {
1082 self.device.get_response_expected(u8::from(fun))
1083 }
1084
1085 /// Changes the response expected flag of the function specified by the function ID parameter.
1086 /// This flag can only be changed for setter (default value: false) and callback configuration
1087 /// functions (default value: true). For getter functions it is always enabled.
1088 ///
1089 /// Enabling the response expected flag for a setter function allows to detect timeouts and
1090 /// other error conditions calls of this setter as well. The device will then send a response
1091 /// for this purpose. If this flag is disabled for a setter function then no response is sent
1092 /// and errors are silently ignored, because they cannot be detected.
1093 pub fn set_response_expected(&mut self, fun: RedBrickFunction, response_expected: bool) -> Result<(), SetResponseExpectedError> {
1094 self.device.set_response_expected(u8::from(fun), response_expected)
1095 }
1096
1097 /// Changes the response expected flag for all setter and callback configuration functions of this device at once.
1098 pub fn set_response_expected_all(&mut self, response_expected: bool) {
1099 self.device.set_response_expected_all(response_expected)
1100 }
1101
1102 /// Returns the version of the API definition (major, minor, revision) implemented by this API bindings.
1103 /// This is neither the release version of this API bindings nor does it tell you anything about the represented Brick or Bricklet.
1104 pub fn get_api_version(&self) -> [u8; 3] {
1105 self.device.api_version
1106 }
1107
1108 /// This receiver reports the result of a call to the [`read_file_async`]
1109 /// function.
1110 ///
1111 /// [`read_file_async`]: #method.read_file_async
1112 pub async fn get_async_file_read_callback_receiver(&mut self) -> impl Stream<Item = AsyncFileReadEvent> {
1113 self.device
1114 .get_callback_receiver(u8::from(RedBrickFunction::CallbackAsyncFileRead))
1115 .await
1116 .map(|p| AsyncFileReadEvent::from_le_byte_slice(p.body()))
1117 }
1118
1119 /// This receiver reports the result of a call to the [`write_file_async`]
1120 /// function.
1121 pub async fn get_async_file_write_callback_receiver(&mut self) -> impl Stream<Item = AsyncFileWriteEvent> {
1122 self.device
1123 .get_callback_receiver(u8::from(RedBrickFunction::CallbackAsyncFileWrite))
1124 .await
1125 .map(|p| AsyncFileWriteEvent::from_le_byte_slice(p.body()))
1126 }
1127
1128 ///
1129 pub async fn get_file_events_occurred_callback_receiver(&mut self) -> impl Stream<Item = FileEventsOccurredEvent> {
1130 self.device
1131 .get_callback_receiver(u8::from(RedBrickFunction::CallbackFileEventsOccurred))
1132 .await
1133 .map(|p| FileEventsOccurredEvent::from_le_byte_slice(p.body()))
1134 }
1135
1136 ///
1137 pub async fn get_process_state_changed_callback_receiver(&mut self) -> impl Stream<Item = ProcessStateChangedEvent> {
1138 self.device
1139 .get_callback_receiver(u8::from(RedBrickFunction::CallbackProcessStateChanged))
1140 .await
1141 .map(|p| ProcessStateChangedEvent::from_le_byte_slice(p.body()))
1142 }
1143
1144 ///
1145 pub async fn get_program_scheduler_state_changed_callback_receiver(&mut self) -> impl Stream<Item = u16> {
1146 self.device
1147 .get_callback_receiver(u8::from(RedBrickFunction::CallbackProgramSchedulerStateChanged))
1148 .await
1149 .map(|p| u16::from_le_byte_slice(p.body()))
1150 }
1151
1152 ///
1153 pub async fn get_program_process_spawned_callback_receiver(&mut self) -> impl Stream<Item = u16> {
1154 self.device
1155 .get_callback_receiver(u8::from(RedBrickFunction::CallbackProgramProcessSpawned))
1156 .await
1157 .map(|p| u16::from_le_byte_slice(p.body()))
1158 }
1159
1160 ///
1161 ///
1162 /// Associated constants:
1163 /// * RED_BRICK_ERROR_CODE_SUCCESS
1164 /// * RED_BRICK_ERROR_CODE_UNKNOWN_ERROR
1165 /// * RED_BRICK_ERROR_CODE_INVALID_OPERATION
1166 /// * RED_BRICK_ERROR_CODE_OPERATION_ABORTED
1167 /// * RED_BRICK_ERROR_CODE_INTERNAL_ERROR
1168 /// * RED_BRICK_ERROR_CODE_UNKNOWN_SESSION_ID
1169 /// * RED_BRICK_ERROR_CODE_NO_FREE_SESSION_ID
1170 /// * RED_BRICK_ERROR_CODE_UNKNOWN_OBJECT_ID
1171 /// * RED_BRICK_ERROR_CODE_NO_FREE_OBJECT_ID
1172 /// * RED_BRICK_ERROR_CODE_OBJECT_IS_LOCKED
1173 /// * RED_BRICK_ERROR_CODE_NO_MORE_DATA
1174 /// * RED_BRICK_ERROR_CODE_WRONG_LIST_ITEM_TYPE
1175 /// * RED_BRICK_ERROR_CODE_PROGRAM_IS_PURGED
1176 /// * RED_BRICK_ERROR_CODE_INVALID_PARAMETER
1177 /// * RED_BRICK_ERROR_CODE_NO_FREE_MEMORY
1178 /// * RED_BRICK_ERROR_CODE_NO_FREE_SPACE
1179 /// * RED_BRICK_ERROR_CODE_ACCESS_DENIED
1180 /// * RED_BRICK_ERROR_CODE_ALREADY_EXISTS
1181 /// * RED_BRICK_ERROR_CODE_DOES_NOT_EXIST
1182 /// * RED_BRICK_ERROR_CODE_INTERRUPTED
1183 /// * RED_BRICK_ERROR_CODE_IS_DIRECTORY
1184 /// * RED_BRICK_ERROR_CODE_NOT_A_DIRECTORY
1185 /// * RED_BRICK_ERROR_CODE_WOULD_BLOCK
1186 /// * RED_BRICK_ERROR_CODE_OVERFLOW
1187 /// * RED_BRICK_ERROR_CODE_BAD_FILE_DESCRIPTOR
1188 /// * RED_BRICK_ERROR_CODE_OUT_OF_RANGE
1189 /// * RED_BRICK_ERROR_CODE_NAME_TOO_LONG
1190 /// * RED_BRICK_ERROR_CODE_INVALID_SEEK
1191 /// * RED_BRICK_ERROR_CODE_NOT_SUPPORTED
1192 /// * RED_BRICK_ERROR_CODE_TOO_MANY_OPEN_FILES
1193 pub async fn create_session(&mut self, lifetime: u32) -> Result<CreateSession, TinkerforgeError> {
1194 let mut payload = [0; 4];
1195 lifetime.write_to_slice(&mut payload[0..4]);
1196
1197 #[allow(unused_variables)]
1198 let result = self.device.get(u8::from(RedBrickFunction::CreateSession), &payload).await?;
1199 Ok(CreateSession::from_le_byte_slice(result.body()))
1200 }
1201
1202 ///
1203 ///
1204 /// Associated constants:
1205 /// * RED_BRICK_ERROR_CODE_SUCCESS
1206 /// * RED_BRICK_ERROR_CODE_UNKNOWN_ERROR
1207 /// * RED_BRICK_ERROR_CODE_INVALID_OPERATION
1208 /// * RED_BRICK_ERROR_CODE_OPERATION_ABORTED
1209 /// * RED_BRICK_ERROR_CODE_INTERNAL_ERROR
1210 /// * RED_BRICK_ERROR_CODE_UNKNOWN_SESSION_ID
1211 /// * RED_BRICK_ERROR_CODE_NO_FREE_SESSION_ID
1212 /// * RED_BRICK_ERROR_CODE_UNKNOWN_OBJECT_ID
1213 /// * RED_BRICK_ERROR_CODE_NO_FREE_OBJECT_ID
1214 /// * RED_BRICK_ERROR_CODE_OBJECT_IS_LOCKED
1215 /// * RED_BRICK_ERROR_CODE_NO_MORE_DATA
1216 /// * RED_BRICK_ERROR_CODE_WRONG_LIST_ITEM_TYPE
1217 /// * RED_BRICK_ERROR_CODE_PROGRAM_IS_PURGED
1218 /// * RED_BRICK_ERROR_CODE_INVALID_PARAMETER
1219 /// * RED_BRICK_ERROR_CODE_NO_FREE_MEMORY
1220 /// * RED_BRICK_ERROR_CODE_NO_FREE_SPACE
1221 /// * RED_BRICK_ERROR_CODE_ACCESS_DENIED
1222 /// * RED_BRICK_ERROR_CODE_ALREADY_EXISTS
1223 /// * RED_BRICK_ERROR_CODE_DOES_NOT_EXIST
1224 /// * RED_BRICK_ERROR_CODE_INTERRUPTED
1225 /// * RED_BRICK_ERROR_CODE_IS_DIRECTORY
1226 /// * RED_BRICK_ERROR_CODE_NOT_A_DIRECTORY
1227 /// * RED_BRICK_ERROR_CODE_WOULD_BLOCK
1228 /// * RED_BRICK_ERROR_CODE_OVERFLOW
1229 /// * RED_BRICK_ERROR_CODE_BAD_FILE_DESCRIPTOR
1230 /// * RED_BRICK_ERROR_CODE_OUT_OF_RANGE
1231 /// * RED_BRICK_ERROR_CODE_NAME_TOO_LONG
1232 /// * RED_BRICK_ERROR_CODE_INVALID_SEEK
1233 /// * RED_BRICK_ERROR_CODE_NOT_SUPPORTED
1234 /// * RED_BRICK_ERROR_CODE_TOO_MANY_OPEN_FILES
1235 pub async fn expire_session(&mut self, session_id: u16) -> Result<u8, TinkerforgeError> {
1236 let mut payload = [0; 2];
1237 session_id.write_to_slice(&mut payload[0..2]);
1238
1239 #[allow(unused_variables)]
1240 let result = self.device.get(u8::from(RedBrickFunction::ExpireSession), &payload).await?;
1241 Ok(u8::from_le_byte_slice(result.body()))
1242 }
1243
1244 ///
1245 pub async fn expire_session_unchecked(&mut self, session_id: u16) -> Result<(), TinkerforgeError> {
1246 let mut payload = [0; 2];
1247 session_id.write_to_slice(&mut payload[0..2]);
1248
1249 #[allow(unused_variables)]
1250 let result = self.device.set(u8::from(RedBrickFunction::ExpireSessionUnchecked), &payload).await?;
1251 Ok(())
1252 }
1253
1254 ///
1255 ///
1256 /// Associated constants:
1257 /// * RED_BRICK_ERROR_CODE_SUCCESS
1258 /// * RED_BRICK_ERROR_CODE_UNKNOWN_ERROR
1259 /// * RED_BRICK_ERROR_CODE_INVALID_OPERATION
1260 /// * RED_BRICK_ERROR_CODE_OPERATION_ABORTED
1261 /// * RED_BRICK_ERROR_CODE_INTERNAL_ERROR
1262 /// * RED_BRICK_ERROR_CODE_UNKNOWN_SESSION_ID
1263 /// * RED_BRICK_ERROR_CODE_NO_FREE_SESSION_ID
1264 /// * RED_BRICK_ERROR_CODE_UNKNOWN_OBJECT_ID
1265 /// * RED_BRICK_ERROR_CODE_NO_FREE_OBJECT_ID
1266 /// * RED_BRICK_ERROR_CODE_OBJECT_IS_LOCKED
1267 /// * RED_BRICK_ERROR_CODE_NO_MORE_DATA
1268 /// * RED_BRICK_ERROR_CODE_WRONG_LIST_ITEM_TYPE
1269 /// * RED_BRICK_ERROR_CODE_PROGRAM_IS_PURGED
1270 /// * RED_BRICK_ERROR_CODE_INVALID_PARAMETER
1271 /// * RED_BRICK_ERROR_CODE_NO_FREE_MEMORY
1272 /// * RED_BRICK_ERROR_CODE_NO_FREE_SPACE
1273 /// * RED_BRICK_ERROR_CODE_ACCESS_DENIED
1274 /// * RED_BRICK_ERROR_CODE_ALREADY_EXISTS
1275 /// * RED_BRICK_ERROR_CODE_DOES_NOT_EXIST
1276 /// * RED_BRICK_ERROR_CODE_INTERRUPTED
1277 /// * RED_BRICK_ERROR_CODE_IS_DIRECTORY
1278 /// * RED_BRICK_ERROR_CODE_NOT_A_DIRECTORY
1279 /// * RED_BRICK_ERROR_CODE_WOULD_BLOCK
1280 /// * RED_BRICK_ERROR_CODE_OVERFLOW
1281 /// * RED_BRICK_ERROR_CODE_BAD_FILE_DESCRIPTOR
1282 /// * RED_BRICK_ERROR_CODE_OUT_OF_RANGE
1283 /// * RED_BRICK_ERROR_CODE_NAME_TOO_LONG
1284 /// * RED_BRICK_ERROR_CODE_INVALID_SEEK
1285 /// * RED_BRICK_ERROR_CODE_NOT_SUPPORTED
1286 /// * RED_BRICK_ERROR_CODE_TOO_MANY_OPEN_FILES
1287 pub async fn keep_session_alive(&mut self, session_id: u16, lifetime: u32) -> Result<u8, TinkerforgeError> {
1288 let mut payload = [0; 6];
1289 session_id.write_to_slice(&mut payload[0..2]);
1290 lifetime.write_to_slice(&mut payload[2..6]);
1291
1292 #[allow(unused_variables)]
1293 let result = self.device.get(u8::from(RedBrickFunction::KeepSessionAlive), &payload).await?;
1294 Ok(u8::from_le_byte_slice(result.body()))
1295 }
1296
1297 /// Decreases the reference count of an object by one and returns the resulting
1298 /// error code. If the reference count reaches zero the object gets destroyed.
1299 ///
1300 /// Associated constants:
1301 /// * RED_BRICK_ERROR_CODE_SUCCESS
1302 /// * RED_BRICK_ERROR_CODE_UNKNOWN_ERROR
1303 /// * RED_BRICK_ERROR_CODE_INVALID_OPERATION
1304 /// * RED_BRICK_ERROR_CODE_OPERATION_ABORTED
1305 /// * RED_BRICK_ERROR_CODE_INTERNAL_ERROR
1306 /// * RED_BRICK_ERROR_CODE_UNKNOWN_SESSION_ID
1307 /// * RED_BRICK_ERROR_CODE_NO_FREE_SESSION_ID
1308 /// * RED_BRICK_ERROR_CODE_UNKNOWN_OBJECT_ID
1309 /// * RED_BRICK_ERROR_CODE_NO_FREE_OBJECT_ID
1310 /// * RED_BRICK_ERROR_CODE_OBJECT_IS_LOCKED
1311 /// * RED_BRICK_ERROR_CODE_NO_MORE_DATA
1312 /// * RED_BRICK_ERROR_CODE_WRONG_LIST_ITEM_TYPE
1313 /// * RED_BRICK_ERROR_CODE_PROGRAM_IS_PURGED
1314 /// * RED_BRICK_ERROR_CODE_INVALID_PARAMETER
1315 /// * RED_BRICK_ERROR_CODE_NO_FREE_MEMORY
1316 /// * RED_BRICK_ERROR_CODE_NO_FREE_SPACE
1317 /// * RED_BRICK_ERROR_CODE_ACCESS_DENIED
1318 /// * RED_BRICK_ERROR_CODE_ALREADY_EXISTS
1319 /// * RED_BRICK_ERROR_CODE_DOES_NOT_EXIST
1320 /// * RED_BRICK_ERROR_CODE_INTERRUPTED
1321 /// * RED_BRICK_ERROR_CODE_IS_DIRECTORY
1322 /// * RED_BRICK_ERROR_CODE_NOT_A_DIRECTORY
1323 /// * RED_BRICK_ERROR_CODE_WOULD_BLOCK
1324 /// * RED_BRICK_ERROR_CODE_OVERFLOW
1325 /// * RED_BRICK_ERROR_CODE_BAD_FILE_DESCRIPTOR
1326 /// * RED_BRICK_ERROR_CODE_OUT_OF_RANGE
1327 /// * RED_BRICK_ERROR_CODE_NAME_TOO_LONG
1328 /// * RED_BRICK_ERROR_CODE_INVALID_SEEK
1329 /// * RED_BRICK_ERROR_CODE_NOT_SUPPORTED
1330 /// * RED_BRICK_ERROR_CODE_TOO_MANY_OPEN_FILES
1331 pub async fn release_object(&mut self, object_id: u16, session_id: u16) -> Result<u8, TinkerforgeError> {
1332 let mut payload = [0; 4];
1333 object_id.write_to_slice(&mut payload[0..2]);
1334 session_id.write_to_slice(&mut payload[2..4]);
1335
1336 #[allow(unused_variables)]
1337 let result = self.device.get(u8::from(RedBrickFunction::ReleaseObject), &payload).await?;
1338 Ok(u8::from_le_byte_slice(result.body()))
1339 }
1340
1341 ///
1342 pub async fn release_object_unchecked(&mut self, object_id: u16, session_id: u16) -> Result<(), TinkerforgeError> {
1343 let mut payload = [0; 4];
1344 object_id.write_to_slice(&mut payload[0..2]);
1345 session_id.write_to_slice(&mut payload[2..4]);
1346
1347 #[allow(unused_variables)]
1348 let result = self.device.set(u8::from(RedBrickFunction::ReleaseObjectUnchecked), &payload).await?;
1349 Ok(())
1350 }
1351
1352 /// Allocates a new string object, reserves ``length_to_reserve`` bytes memory
1353 /// for it and sets up to the first 60 bytes. Set ``length_to_reserve`` to the
1354 /// length of the string that should be stored in the string object.
1355 ///
1356 /// Returns the object ID of the new string object and the resulting error code.
1357 ///
1358 /// Associated constants:
1359 /// * RED_BRICK_ERROR_CODE_SUCCESS
1360 /// * RED_BRICK_ERROR_CODE_UNKNOWN_ERROR
1361 /// * RED_BRICK_ERROR_CODE_INVALID_OPERATION
1362 /// * RED_BRICK_ERROR_CODE_OPERATION_ABORTED
1363 /// * RED_BRICK_ERROR_CODE_INTERNAL_ERROR
1364 /// * RED_BRICK_ERROR_CODE_UNKNOWN_SESSION_ID
1365 /// * RED_BRICK_ERROR_CODE_NO_FREE_SESSION_ID
1366 /// * RED_BRICK_ERROR_CODE_UNKNOWN_OBJECT_ID
1367 /// * RED_BRICK_ERROR_CODE_NO_FREE_OBJECT_ID
1368 /// * RED_BRICK_ERROR_CODE_OBJECT_IS_LOCKED
1369 /// * RED_BRICK_ERROR_CODE_NO_MORE_DATA
1370 /// * RED_BRICK_ERROR_CODE_WRONG_LIST_ITEM_TYPE
1371 /// * RED_BRICK_ERROR_CODE_PROGRAM_IS_PURGED
1372 /// * RED_BRICK_ERROR_CODE_INVALID_PARAMETER
1373 /// * RED_BRICK_ERROR_CODE_NO_FREE_MEMORY
1374 /// * RED_BRICK_ERROR_CODE_NO_FREE_SPACE
1375 /// * RED_BRICK_ERROR_CODE_ACCESS_DENIED
1376 /// * RED_BRICK_ERROR_CODE_ALREADY_EXISTS
1377 /// * RED_BRICK_ERROR_CODE_DOES_NOT_EXIST
1378 /// * RED_BRICK_ERROR_CODE_INTERRUPTED
1379 /// * RED_BRICK_ERROR_CODE_IS_DIRECTORY
1380 /// * RED_BRICK_ERROR_CODE_NOT_A_DIRECTORY
1381 /// * RED_BRICK_ERROR_CODE_WOULD_BLOCK
1382 /// * RED_BRICK_ERROR_CODE_OVERFLOW
1383 /// * RED_BRICK_ERROR_CODE_BAD_FILE_DESCRIPTOR
1384 /// * RED_BRICK_ERROR_CODE_OUT_OF_RANGE
1385 /// * RED_BRICK_ERROR_CODE_NAME_TOO_LONG
1386 /// * RED_BRICK_ERROR_CODE_INVALID_SEEK
1387 /// * RED_BRICK_ERROR_CODE_NOT_SUPPORTED
1388 /// * RED_BRICK_ERROR_CODE_TOO_MANY_OPEN_FILES
1389 pub async fn allocate_string(
1390 &mut self,
1391 length_to_reserve: u32,
1392 buffer: String,
1393 session_id: u16,
1394 ) -> Result<AllocateString, TinkerforgeError> {
1395 let mut payload = [0; 64];
1396 length_to_reserve.write_to_slice(&mut payload[0..4]);
1397 buffer.try_write_to_slice(58, &mut payload)?;
1398 session_id.write_to_slice(&mut payload[62..64]);
1399
1400 #[allow(unused_variables)]
1401 let result = self.device.get(u8::from(RedBrickFunction::AllocateString), &payload).await?;
1402 Ok(AllocateString::from_le_byte_slice(result.body()))
1403 }
1404
1405 /// Truncates a string object to ``length`` bytes and returns the resulting
1406 /// error code.
1407 ///
1408 /// Associated constants:
1409 /// * RED_BRICK_ERROR_CODE_SUCCESS
1410 /// * RED_BRICK_ERROR_CODE_UNKNOWN_ERROR
1411 /// * RED_BRICK_ERROR_CODE_INVALID_OPERATION
1412 /// * RED_BRICK_ERROR_CODE_OPERATION_ABORTED
1413 /// * RED_BRICK_ERROR_CODE_INTERNAL_ERROR
1414 /// * RED_BRICK_ERROR_CODE_UNKNOWN_SESSION_ID
1415 /// * RED_BRICK_ERROR_CODE_NO_FREE_SESSION_ID
1416 /// * RED_BRICK_ERROR_CODE_UNKNOWN_OBJECT_ID
1417 /// * RED_BRICK_ERROR_CODE_NO_FREE_OBJECT_ID
1418 /// * RED_BRICK_ERROR_CODE_OBJECT_IS_LOCKED
1419 /// * RED_BRICK_ERROR_CODE_NO_MORE_DATA
1420 /// * RED_BRICK_ERROR_CODE_WRONG_LIST_ITEM_TYPE
1421 /// * RED_BRICK_ERROR_CODE_PROGRAM_IS_PURGED
1422 /// * RED_BRICK_ERROR_CODE_INVALID_PARAMETER
1423 /// * RED_BRICK_ERROR_CODE_NO_FREE_MEMORY
1424 /// * RED_BRICK_ERROR_CODE_NO_FREE_SPACE
1425 /// * RED_BRICK_ERROR_CODE_ACCESS_DENIED
1426 /// * RED_BRICK_ERROR_CODE_ALREADY_EXISTS
1427 /// * RED_BRICK_ERROR_CODE_DOES_NOT_EXIST
1428 /// * RED_BRICK_ERROR_CODE_INTERRUPTED
1429 /// * RED_BRICK_ERROR_CODE_IS_DIRECTORY
1430 /// * RED_BRICK_ERROR_CODE_NOT_A_DIRECTORY
1431 /// * RED_BRICK_ERROR_CODE_WOULD_BLOCK
1432 /// * RED_BRICK_ERROR_CODE_OVERFLOW
1433 /// * RED_BRICK_ERROR_CODE_BAD_FILE_DESCRIPTOR
1434 /// * RED_BRICK_ERROR_CODE_OUT_OF_RANGE
1435 /// * RED_BRICK_ERROR_CODE_NAME_TOO_LONG
1436 /// * RED_BRICK_ERROR_CODE_INVALID_SEEK
1437 /// * RED_BRICK_ERROR_CODE_NOT_SUPPORTED
1438 /// * RED_BRICK_ERROR_CODE_TOO_MANY_OPEN_FILES
1439 pub async fn truncate_string(&mut self, string_id: u16, length: u32) -> Result<u8, TinkerforgeError> {
1440 let mut payload = [0; 6];
1441 string_id.write_to_slice(&mut payload[0..2]);
1442 length.write_to_slice(&mut payload[2..6]);
1443
1444 #[allow(unused_variables)]
1445 let result = self.device.get(u8::from(RedBrickFunction::TruncateString), &payload).await?;
1446 Ok(u8::from_le_byte_slice(result.body()))
1447 }
1448
1449 /// Returns the length of a string object and the resulting error code.
1450 ///
1451 /// Associated constants:
1452 /// * RED_BRICK_ERROR_CODE_SUCCESS
1453 /// * RED_BRICK_ERROR_CODE_UNKNOWN_ERROR
1454 /// * RED_BRICK_ERROR_CODE_INVALID_OPERATION
1455 /// * RED_BRICK_ERROR_CODE_OPERATION_ABORTED
1456 /// * RED_BRICK_ERROR_CODE_INTERNAL_ERROR
1457 /// * RED_BRICK_ERROR_CODE_UNKNOWN_SESSION_ID
1458 /// * RED_BRICK_ERROR_CODE_NO_FREE_SESSION_ID
1459 /// * RED_BRICK_ERROR_CODE_UNKNOWN_OBJECT_ID
1460 /// * RED_BRICK_ERROR_CODE_NO_FREE_OBJECT_ID
1461 /// * RED_BRICK_ERROR_CODE_OBJECT_IS_LOCKED
1462 /// * RED_BRICK_ERROR_CODE_NO_MORE_DATA
1463 /// * RED_BRICK_ERROR_CODE_WRONG_LIST_ITEM_TYPE
1464 /// * RED_BRICK_ERROR_CODE_PROGRAM_IS_PURGED
1465 /// * RED_BRICK_ERROR_CODE_INVALID_PARAMETER
1466 /// * RED_BRICK_ERROR_CODE_NO_FREE_MEMORY
1467 /// * RED_BRICK_ERROR_CODE_NO_FREE_SPACE
1468 /// * RED_BRICK_ERROR_CODE_ACCESS_DENIED
1469 /// * RED_BRICK_ERROR_CODE_ALREADY_EXISTS
1470 /// * RED_BRICK_ERROR_CODE_DOES_NOT_EXIST
1471 /// * RED_BRICK_ERROR_CODE_INTERRUPTED
1472 /// * RED_BRICK_ERROR_CODE_IS_DIRECTORY
1473 /// * RED_BRICK_ERROR_CODE_NOT_A_DIRECTORY
1474 /// * RED_BRICK_ERROR_CODE_WOULD_BLOCK
1475 /// * RED_BRICK_ERROR_CODE_OVERFLOW
1476 /// * RED_BRICK_ERROR_CODE_BAD_FILE_DESCRIPTOR
1477 /// * RED_BRICK_ERROR_CODE_OUT_OF_RANGE
1478 /// * RED_BRICK_ERROR_CODE_NAME_TOO_LONG
1479 /// * RED_BRICK_ERROR_CODE_INVALID_SEEK
1480 /// * RED_BRICK_ERROR_CODE_NOT_SUPPORTED
1481 /// * RED_BRICK_ERROR_CODE_TOO_MANY_OPEN_FILES
1482 pub async fn get_string_length(&mut self, string_id: u16) -> Result<StringLength, TinkerforgeError> {
1483 let mut payload = [0; 2];
1484 string_id.write_to_slice(&mut payload[0..2]);
1485
1486 #[allow(unused_variables)]
1487 let result = self.device.get(u8::from(RedBrickFunction::GetStringLength), &payload).await?;
1488 Ok(StringLength::from_le_byte_slice(result.body()))
1489 }
1490
1491 /// Sets a chunk of up to 58 bytes in a string object beginning at ``offset``.
1492 ///
1493 /// Returns the resulting error code.
1494 ///
1495 /// Associated constants:
1496 /// * RED_BRICK_ERROR_CODE_SUCCESS
1497 /// * RED_BRICK_ERROR_CODE_UNKNOWN_ERROR
1498 /// * RED_BRICK_ERROR_CODE_INVALID_OPERATION
1499 /// * RED_BRICK_ERROR_CODE_OPERATION_ABORTED
1500 /// * RED_BRICK_ERROR_CODE_INTERNAL_ERROR
1501 /// * RED_BRICK_ERROR_CODE_UNKNOWN_SESSION_ID
1502 /// * RED_BRICK_ERROR_CODE_NO_FREE_SESSION_ID
1503 /// * RED_BRICK_ERROR_CODE_UNKNOWN_OBJECT_ID
1504 /// * RED_BRICK_ERROR_CODE_NO_FREE_OBJECT_ID
1505 /// * RED_BRICK_ERROR_CODE_OBJECT_IS_LOCKED
1506 /// * RED_BRICK_ERROR_CODE_NO_MORE_DATA
1507 /// * RED_BRICK_ERROR_CODE_WRONG_LIST_ITEM_TYPE
1508 /// * RED_BRICK_ERROR_CODE_PROGRAM_IS_PURGED
1509 /// * RED_BRICK_ERROR_CODE_INVALID_PARAMETER
1510 /// * RED_BRICK_ERROR_CODE_NO_FREE_MEMORY
1511 /// * RED_BRICK_ERROR_CODE_NO_FREE_SPACE
1512 /// * RED_BRICK_ERROR_CODE_ACCESS_DENIED
1513 /// * RED_BRICK_ERROR_CODE_ALREADY_EXISTS
1514 /// * RED_BRICK_ERROR_CODE_DOES_NOT_EXIST
1515 /// * RED_BRICK_ERROR_CODE_INTERRUPTED
1516 /// * RED_BRICK_ERROR_CODE_IS_DIRECTORY
1517 /// * RED_BRICK_ERROR_CODE_NOT_A_DIRECTORY
1518 /// * RED_BRICK_ERROR_CODE_WOULD_BLOCK
1519 /// * RED_BRICK_ERROR_CODE_OVERFLOW
1520 /// * RED_BRICK_ERROR_CODE_BAD_FILE_DESCRIPTOR
1521 /// * RED_BRICK_ERROR_CODE_OUT_OF_RANGE
1522 /// * RED_BRICK_ERROR_CODE_NAME_TOO_LONG
1523 /// * RED_BRICK_ERROR_CODE_INVALID_SEEK
1524 /// * RED_BRICK_ERROR_CODE_NOT_SUPPORTED
1525 /// * RED_BRICK_ERROR_CODE_TOO_MANY_OPEN_FILES
1526 pub async fn set_string_chunk(&mut self, string_id: u16, offset: u32, buffer: String) -> Result<u8, TinkerforgeError> {
1527 let mut payload = [0; 64];
1528 string_id.write_to_slice(&mut payload[0..2]);
1529 offset.write_to_slice(&mut payload[2..6]);
1530 buffer.try_write_to_slice(58, &mut payload)?;
1531
1532 #[allow(unused_variables)]
1533 let result = self.device.get(u8::from(RedBrickFunction::SetStringChunk), &payload).await?;
1534 Ok(u8::from_le_byte_slice(result.body()))
1535 }
1536
1537 /// Returns a chunk up to 63 bytes from a string object beginning at ``offset`` and
1538 /// returns the resulting error code.
1539 ///
1540 /// Associated constants:
1541 /// * RED_BRICK_ERROR_CODE_SUCCESS
1542 /// * RED_BRICK_ERROR_CODE_UNKNOWN_ERROR
1543 /// * RED_BRICK_ERROR_CODE_INVALID_OPERATION
1544 /// * RED_BRICK_ERROR_CODE_OPERATION_ABORTED
1545 /// * RED_BRICK_ERROR_CODE_INTERNAL_ERROR
1546 /// * RED_BRICK_ERROR_CODE_UNKNOWN_SESSION_ID
1547 /// * RED_BRICK_ERROR_CODE_NO_FREE_SESSION_ID
1548 /// * RED_BRICK_ERROR_CODE_UNKNOWN_OBJECT_ID
1549 /// * RED_BRICK_ERROR_CODE_NO_FREE_OBJECT_ID
1550 /// * RED_BRICK_ERROR_CODE_OBJECT_IS_LOCKED
1551 /// * RED_BRICK_ERROR_CODE_NO_MORE_DATA
1552 /// * RED_BRICK_ERROR_CODE_WRONG_LIST_ITEM_TYPE
1553 /// * RED_BRICK_ERROR_CODE_PROGRAM_IS_PURGED
1554 /// * RED_BRICK_ERROR_CODE_INVALID_PARAMETER
1555 /// * RED_BRICK_ERROR_CODE_NO_FREE_MEMORY
1556 /// * RED_BRICK_ERROR_CODE_NO_FREE_SPACE
1557 /// * RED_BRICK_ERROR_CODE_ACCESS_DENIED
1558 /// * RED_BRICK_ERROR_CODE_ALREADY_EXISTS
1559 /// * RED_BRICK_ERROR_CODE_DOES_NOT_EXIST
1560 /// * RED_BRICK_ERROR_CODE_INTERRUPTED
1561 /// * RED_BRICK_ERROR_CODE_IS_DIRECTORY
1562 /// * RED_BRICK_ERROR_CODE_NOT_A_DIRECTORY
1563 /// * RED_BRICK_ERROR_CODE_WOULD_BLOCK
1564 /// * RED_BRICK_ERROR_CODE_OVERFLOW
1565 /// * RED_BRICK_ERROR_CODE_BAD_FILE_DESCRIPTOR
1566 /// * RED_BRICK_ERROR_CODE_OUT_OF_RANGE
1567 /// * RED_BRICK_ERROR_CODE_NAME_TOO_LONG
1568 /// * RED_BRICK_ERROR_CODE_INVALID_SEEK
1569 /// * RED_BRICK_ERROR_CODE_NOT_SUPPORTED
1570 /// * RED_BRICK_ERROR_CODE_TOO_MANY_OPEN_FILES
1571 pub async fn get_string_chunk(&mut self, string_id: u16, offset: u32) -> Result<StringChunk, TinkerforgeError> {
1572 let mut payload = [0; 6];
1573 string_id.write_to_slice(&mut payload[0..2]);
1574 offset.write_to_slice(&mut payload[2..6]);
1575
1576 #[allow(unused_variables)]
1577 let result = self.device.get(u8::from(RedBrickFunction::GetStringChunk), &payload).await?;
1578 Ok(StringChunk::from_le_byte_slice(result.body()))
1579 }
1580
1581 /// Allocates a new list object and reserves memory for ``length_to_reserve``
1582 /// items. Set ``length_to_reserve`` to the number of items that should be stored
1583 /// in the list object.
1584 ///
1585 /// Returns the object ID of the new list object and the resulting error code.
1586 ///
1587 /// When a list object gets destroyed then the reference count of each object in
1588 /// the list object is decreased by one.
1589 ///
1590 /// Associated constants:
1591 /// * RED_BRICK_ERROR_CODE_SUCCESS
1592 /// * RED_BRICK_ERROR_CODE_UNKNOWN_ERROR
1593 /// * RED_BRICK_ERROR_CODE_INVALID_OPERATION
1594 /// * RED_BRICK_ERROR_CODE_OPERATION_ABORTED
1595 /// * RED_BRICK_ERROR_CODE_INTERNAL_ERROR
1596 /// * RED_BRICK_ERROR_CODE_UNKNOWN_SESSION_ID
1597 /// * RED_BRICK_ERROR_CODE_NO_FREE_SESSION_ID
1598 /// * RED_BRICK_ERROR_CODE_UNKNOWN_OBJECT_ID
1599 /// * RED_BRICK_ERROR_CODE_NO_FREE_OBJECT_ID
1600 /// * RED_BRICK_ERROR_CODE_OBJECT_IS_LOCKED
1601 /// * RED_BRICK_ERROR_CODE_NO_MORE_DATA
1602 /// * RED_BRICK_ERROR_CODE_WRONG_LIST_ITEM_TYPE
1603 /// * RED_BRICK_ERROR_CODE_PROGRAM_IS_PURGED
1604 /// * RED_BRICK_ERROR_CODE_INVALID_PARAMETER
1605 /// * RED_BRICK_ERROR_CODE_NO_FREE_MEMORY
1606 /// * RED_BRICK_ERROR_CODE_NO_FREE_SPACE
1607 /// * RED_BRICK_ERROR_CODE_ACCESS_DENIED
1608 /// * RED_BRICK_ERROR_CODE_ALREADY_EXISTS
1609 /// * RED_BRICK_ERROR_CODE_DOES_NOT_EXIST
1610 /// * RED_BRICK_ERROR_CODE_INTERRUPTED
1611 /// * RED_BRICK_ERROR_CODE_IS_DIRECTORY
1612 /// * RED_BRICK_ERROR_CODE_NOT_A_DIRECTORY
1613 /// * RED_BRICK_ERROR_CODE_WOULD_BLOCK
1614 /// * RED_BRICK_ERROR_CODE_OVERFLOW
1615 /// * RED_BRICK_ERROR_CODE_BAD_FILE_DESCRIPTOR
1616 /// * RED_BRICK_ERROR_CODE_OUT_OF_RANGE
1617 /// * RED_BRICK_ERROR_CODE_NAME_TOO_LONG
1618 /// * RED_BRICK_ERROR_CODE_INVALID_SEEK
1619 /// * RED_BRICK_ERROR_CODE_NOT_SUPPORTED
1620 /// * RED_BRICK_ERROR_CODE_TOO_MANY_OPEN_FILES
1621 pub async fn allocate_list(&mut self, length_to_reserve: u16, session_id: u16) -> Result<AllocateList, TinkerforgeError> {
1622 let mut payload = [0; 4];
1623 length_to_reserve.write_to_slice(&mut payload[0..2]);
1624 session_id.write_to_slice(&mut payload[2..4]);
1625
1626 #[allow(unused_variables)]
1627 let result = self.device.get(u8::from(RedBrickFunction::AllocateList), &payload).await?;
1628 Ok(AllocateList::from_le_byte_slice(result.body()))
1629 }
1630
1631 /// Returns the length of a list object in items and the resulting error code.
1632 ///
1633 /// Associated constants:
1634 /// * RED_BRICK_ERROR_CODE_SUCCESS
1635 /// * RED_BRICK_ERROR_CODE_UNKNOWN_ERROR
1636 /// * RED_BRICK_ERROR_CODE_INVALID_OPERATION
1637 /// * RED_BRICK_ERROR_CODE_OPERATION_ABORTED
1638 /// * RED_BRICK_ERROR_CODE_INTERNAL_ERROR
1639 /// * RED_BRICK_ERROR_CODE_UNKNOWN_SESSION_ID
1640 /// * RED_BRICK_ERROR_CODE_NO_FREE_SESSION_ID
1641 /// * RED_BRICK_ERROR_CODE_UNKNOWN_OBJECT_ID
1642 /// * RED_BRICK_ERROR_CODE_NO_FREE_OBJECT_ID
1643 /// * RED_BRICK_ERROR_CODE_OBJECT_IS_LOCKED
1644 /// * RED_BRICK_ERROR_CODE_NO_MORE_DATA
1645 /// * RED_BRICK_ERROR_CODE_WRONG_LIST_ITEM_TYPE
1646 /// * RED_BRICK_ERROR_CODE_PROGRAM_IS_PURGED
1647 /// * RED_BRICK_ERROR_CODE_INVALID_PARAMETER
1648 /// * RED_BRICK_ERROR_CODE_NO_FREE_MEMORY
1649 /// * RED_BRICK_ERROR_CODE_NO_FREE_SPACE
1650 /// * RED_BRICK_ERROR_CODE_ACCESS_DENIED
1651 /// * RED_BRICK_ERROR_CODE_ALREADY_EXISTS
1652 /// * RED_BRICK_ERROR_CODE_DOES_NOT_EXIST
1653 /// * RED_BRICK_ERROR_CODE_INTERRUPTED
1654 /// * RED_BRICK_ERROR_CODE_IS_DIRECTORY
1655 /// * RED_BRICK_ERROR_CODE_NOT_A_DIRECTORY
1656 /// * RED_BRICK_ERROR_CODE_WOULD_BLOCK
1657 /// * RED_BRICK_ERROR_CODE_OVERFLOW
1658 /// * RED_BRICK_ERROR_CODE_BAD_FILE_DESCRIPTOR
1659 /// * RED_BRICK_ERROR_CODE_OUT_OF_RANGE
1660 /// * RED_BRICK_ERROR_CODE_NAME_TOO_LONG
1661 /// * RED_BRICK_ERROR_CODE_INVALID_SEEK
1662 /// * RED_BRICK_ERROR_CODE_NOT_SUPPORTED
1663 /// * RED_BRICK_ERROR_CODE_TOO_MANY_OPEN_FILES
1664 pub async fn get_list_length(&mut self, list_id: u16) -> Result<ListLength, TinkerforgeError> {
1665 let mut payload = [0; 2];
1666 list_id.write_to_slice(&mut payload[0..2]);
1667
1668 #[allow(unused_variables)]
1669 let result = self.device.get(u8::from(RedBrickFunction::GetListLength), &payload).await?;
1670 Ok(ListLength::from_le_byte_slice(result.body()))
1671 }
1672
1673 /// Returns the object ID and type of the object stored at ``index`` in a list
1674 /// object and returns the resulting error code.
1675 ///
1676 /// Possible object types are:
1677 ///
1678 /// * String = 0
1679 /// * List = 1
1680 /// * File = 2
1681 /// * Directory = 3
1682 /// * Process = 4
1683 /// * Program = 5
1684 ///
1685 /// Associated constants:
1686 /// * RED_BRICK_ERROR_CODE_SUCCESS
1687 /// * RED_BRICK_ERROR_CODE_UNKNOWN_ERROR
1688 /// * RED_BRICK_ERROR_CODE_INVALID_OPERATION
1689 /// * RED_BRICK_ERROR_CODE_OPERATION_ABORTED
1690 /// * RED_BRICK_ERROR_CODE_INTERNAL_ERROR
1691 /// * RED_BRICK_ERROR_CODE_UNKNOWN_SESSION_ID
1692 /// * RED_BRICK_ERROR_CODE_NO_FREE_SESSION_ID
1693 /// * RED_BRICK_ERROR_CODE_UNKNOWN_OBJECT_ID
1694 /// * RED_BRICK_ERROR_CODE_NO_FREE_OBJECT_ID
1695 /// * RED_BRICK_ERROR_CODE_OBJECT_IS_LOCKED
1696 /// * RED_BRICK_ERROR_CODE_NO_MORE_DATA
1697 /// * RED_BRICK_ERROR_CODE_WRONG_LIST_ITEM_TYPE
1698 /// * RED_BRICK_ERROR_CODE_PROGRAM_IS_PURGED
1699 /// * RED_BRICK_ERROR_CODE_INVALID_PARAMETER
1700 /// * RED_BRICK_ERROR_CODE_NO_FREE_MEMORY
1701 /// * RED_BRICK_ERROR_CODE_NO_FREE_SPACE
1702 /// * RED_BRICK_ERROR_CODE_ACCESS_DENIED
1703 /// * RED_BRICK_ERROR_CODE_ALREADY_EXISTS
1704 /// * RED_BRICK_ERROR_CODE_DOES_NOT_EXIST
1705 /// * RED_BRICK_ERROR_CODE_INTERRUPTED
1706 /// * RED_BRICK_ERROR_CODE_IS_DIRECTORY
1707 /// * RED_BRICK_ERROR_CODE_NOT_A_DIRECTORY
1708 /// * RED_BRICK_ERROR_CODE_WOULD_BLOCK
1709 /// * RED_BRICK_ERROR_CODE_OVERFLOW
1710 /// * RED_BRICK_ERROR_CODE_BAD_FILE_DESCRIPTOR
1711 /// * RED_BRICK_ERROR_CODE_OUT_OF_RANGE
1712 /// * RED_BRICK_ERROR_CODE_NAME_TOO_LONG
1713 /// * RED_BRICK_ERROR_CODE_INVALID_SEEK
1714 /// * RED_BRICK_ERROR_CODE_NOT_SUPPORTED
1715 /// * RED_BRICK_ERROR_CODE_TOO_MANY_OPEN_FILES
1716 /// * RED_BRICK_OBJECT_TYPE_STRING
1717 /// * RED_BRICK_OBJECT_TYPE_LIST
1718 /// * RED_BRICK_OBJECT_TYPE_FILE
1719 /// * RED_BRICK_OBJECT_TYPE_DIRECTORY
1720 /// * RED_BRICK_OBJECT_TYPE_PROCESS
1721 /// * RED_BRICK_OBJECT_TYPE_PROGRAM
1722 pub async fn get_list_item(&mut self, list_id: u16, index: u16, session_id: u16) -> Result<ListItem, TinkerforgeError> {
1723 let mut payload = [0; 6];
1724 list_id.write_to_slice(&mut payload[0..2]);
1725 index.write_to_slice(&mut payload[2..4]);
1726 session_id.write_to_slice(&mut payload[4..6]);
1727
1728 #[allow(unused_variables)]
1729 let result = self.device.get(u8::from(RedBrickFunction::GetListItem), &payload).await?;
1730 Ok(ListItem::from_le_byte_slice(result.body()))
1731 }
1732
1733 /// Appends an object to a list object and increases the reference count of the
1734 /// appended object by one.
1735 ///
1736 /// Returns the resulting error code.
1737 ///
1738 /// Associated constants:
1739 /// * RED_BRICK_ERROR_CODE_SUCCESS
1740 /// * RED_BRICK_ERROR_CODE_UNKNOWN_ERROR
1741 /// * RED_BRICK_ERROR_CODE_INVALID_OPERATION
1742 /// * RED_BRICK_ERROR_CODE_OPERATION_ABORTED
1743 /// * RED_BRICK_ERROR_CODE_INTERNAL_ERROR
1744 /// * RED_BRICK_ERROR_CODE_UNKNOWN_SESSION_ID
1745 /// * RED_BRICK_ERROR_CODE_NO_FREE_SESSION_ID
1746 /// * RED_BRICK_ERROR_CODE_UNKNOWN_OBJECT_ID
1747 /// * RED_BRICK_ERROR_CODE_NO_FREE_OBJECT_ID
1748 /// * RED_BRICK_ERROR_CODE_OBJECT_IS_LOCKED
1749 /// * RED_BRICK_ERROR_CODE_NO_MORE_DATA
1750 /// * RED_BRICK_ERROR_CODE_WRONG_LIST_ITEM_TYPE
1751 /// * RED_BRICK_ERROR_CODE_PROGRAM_IS_PURGED
1752 /// * RED_BRICK_ERROR_CODE_INVALID_PARAMETER
1753 /// * RED_BRICK_ERROR_CODE_NO_FREE_MEMORY
1754 /// * RED_BRICK_ERROR_CODE_NO_FREE_SPACE
1755 /// * RED_BRICK_ERROR_CODE_ACCESS_DENIED
1756 /// * RED_BRICK_ERROR_CODE_ALREADY_EXISTS
1757 /// * RED_BRICK_ERROR_CODE_DOES_NOT_EXIST
1758 /// * RED_BRICK_ERROR_CODE_INTERRUPTED
1759 /// * RED_BRICK_ERROR_CODE_IS_DIRECTORY
1760 /// * RED_BRICK_ERROR_CODE_NOT_A_DIRECTORY
1761 /// * RED_BRICK_ERROR_CODE_WOULD_BLOCK
1762 /// * RED_BRICK_ERROR_CODE_OVERFLOW
1763 /// * RED_BRICK_ERROR_CODE_BAD_FILE_DESCRIPTOR
1764 /// * RED_BRICK_ERROR_CODE_OUT_OF_RANGE
1765 /// * RED_BRICK_ERROR_CODE_NAME_TOO_LONG
1766 /// * RED_BRICK_ERROR_CODE_INVALID_SEEK
1767 /// * RED_BRICK_ERROR_CODE_NOT_SUPPORTED
1768 /// * RED_BRICK_ERROR_CODE_TOO_MANY_OPEN_FILES
1769 pub async fn append_to_list(&mut self, list_id: u16, item_object_id: u16) -> Result<u8, TinkerforgeError> {
1770 let mut payload = [0; 4];
1771 list_id.write_to_slice(&mut payload[0..2]);
1772 item_object_id.write_to_slice(&mut payload[2..4]);
1773
1774 #[allow(unused_variables)]
1775 let result = self.device.get(u8::from(RedBrickFunction::AppendToList), &payload).await?;
1776 Ok(u8::from_le_byte_slice(result.body()))
1777 }
1778
1779 /// Removes the object stored at ``index`` from a list object and decreases the
1780 /// reference count of the removed object by one.
1781 ///
1782 /// Returns the resulting error code.
1783 ///
1784 /// Associated constants:
1785 /// * RED_BRICK_ERROR_CODE_SUCCESS
1786 /// * RED_BRICK_ERROR_CODE_UNKNOWN_ERROR
1787 /// * RED_BRICK_ERROR_CODE_INVALID_OPERATION
1788 /// * RED_BRICK_ERROR_CODE_OPERATION_ABORTED
1789 /// * RED_BRICK_ERROR_CODE_INTERNAL_ERROR
1790 /// * RED_BRICK_ERROR_CODE_UNKNOWN_SESSION_ID
1791 /// * RED_BRICK_ERROR_CODE_NO_FREE_SESSION_ID
1792 /// * RED_BRICK_ERROR_CODE_UNKNOWN_OBJECT_ID
1793 /// * RED_BRICK_ERROR_CODE_NO_FREE_OBJECT_ID
1794 /// * RED_BRICK_ERROR_CODE_OBJECT_IS_LOCKED
1795 /// * RED_BRICK_ERROR_CODE_NO_MORE_DATA
1796 /// * RED_BRICK_ERROR_CODE_WRONG_LIST_ITEM_TYPE
1797 /// * RED_BRICK_ERROR_CODE_PROGRAM_IS_PURGED
1798 /// * RED_BRICK_ERROR_CODE_INVALID_PARAMETER
1799 /// * RED_BRICK_ERROR_CODE_NO_FREE_MEMORY
1800 /// * RED_BRICK_ERROR_CODE_NO_FREE_SPACE
1801 /// * RED_BRICK_ERROR_CODE_ACCESS_DENIED
1802 /// * RED_BRICK_ERROR_CODE_ALREADY_EXISTS
1803 /// * RED_BRICK_ERROR_CODE_DOES_NOT_EXIST
1804 /// * RED_BRICK_ERROR_CODE_INTERRUPTED
1805 /// * RED_BRICK_ERROR_CODE_IS_DIRECTORY
1806 /// * RED_BRICK_ERROR_CODE_NOT_A_DIRECTORY
1807 /// * RED_BRICK_ERROR_CODE_WOULD_BLOCK
1808 /// * RED_BRICK_ERROR_CODE_OVERFLOW
1809 /// * RED_BRICK_ERROR_CODE_BAD_FILE_DESCRIPTOR
1810 /// * RED_BRICK_ERROR_CODE_OUT_OF_RANGE
1811 /// * RED_BRICK_ERROR_CODE_NAME_TOO_LONG
1812 /// * RED_BRICK_ERROR_CODE_INVALID_SEEK
1813 /// * RED_BRICK_ERROR_CODE_NOT_SUPPORTED
1814 /// * RED_BRICK_ERROR_CODE_TOO_MANY_OPEN_FILES
1815 pub async fn remove_from_list(&mut self, list_id: u16, index: u16) -> Result<u8, TinkerforgeError> {
1816 let mut payload = [0; 4];
1817 list_id.write_to_slice(&mut payload[0..2]);
1818 index.write_to_slice(&mut payload[2..4]);
1819
1820 #[allow(unused_variables)]
1821 let result = self.device.get(u8::from(RedBrickFunction::RemoveFromList), &payload).await?;
1822 Ok(u8::from_le_byte_slice(result.body()))
1823 }
1824
1825 /// Opens an existing file or creates a new file and allocates a new file object
1826 /// for it.
1827 ///
1828 /// FIXME: name has to be absolute
1829 ///
1830 /// The reference count of the name string object is increased by one. When the
1831 /// file object gets destroyed then the reference count of the name string object is
1832 /// decreased by one. Also the name string object is locked and cannot be modified
1833 /// while the file object holds a reference to it.
1834 ///
1835 /// The ``flags`` parameter takes a ORed combination of the following possible file
1836 /// flags (in hexadecimal notation):
1837 ///
1838 /// * ReadOnly = 0x0001 (O_RDONLY)
1839 /// * WriteOnly = 0x0002 (O_WRONLY)
1840 /// * ReadWrite = 0x0004 (O_RDWR)
1841 /// * Append = 0x0008 (O_APPEND)
1842 /// * Create = 0x0010 (O_CREAT)
1843 /// * Exclusive = 0x0020 (O_EXCL)
1844 /// * NonBlocking = 0x0040 (O_NONBLOCK)
1845 /// * Truncate = 0x0080 (O_TRUNC)
1846 /// * Temporary = 0x0100
1847 /// * Replace = 0x0200
1848 ///
1849 /// FIXME: explain *Temporary* and *Replace* flag
1850 ///
1851 /// The ``permissions`` parameter takes a ORed combination of the following
1852 /// possible file permissions (in octal notation) that match the common UNIX
1853 /// permission bits:
1854 ///
1855 /// * UserRead = 00400
1856 /// * UserWrite = 00200
1857 /// * UserExecute = 00100
1858 /// * GroupRead = 00040
1859 /// * GroupWrite = 00020
1860 /// * GroupExecute = 00010
1861 /// * OthersRead = 00004
1862 /// * OthersWrite = 00002
1863 /// * OthersExecute = 00001
1864 ///
1865 /// Returns the object ID of the new file object and the resulting error code.
1866 ///
1867 /// Associated constants:
1868 /// * RED_BRICK_FILE_FLAG_READ_ONLY
1869 /// * RED_BRICK_FILE_FLAG_WRITE_ONLY
1870 /// * RED_BRICK_FILE_FLAG_READ_WRITE
1871 /// * RED_BRICK_FILE_FLAG_APPEND
1872 /// * RED_BRICK_FILE_FLAG_CREATE
1873 /// * RED_BRICK_FILE_FLAG_EXCLUSIVE
1874 /// * RED_BRICK_FILE_FLAG_NON_BLOCKING
1875 /// * RED_BRICK_FILE_FLAG_TRUNCATE
1876 /// * RED_BRICK_FILE_FLAG_TEMPORARY
1877 /// * RED_BRICK_FILE_FLAG_REPLACE
1878 /// * RED_BRICK_FILE_PERMISSION_USER_ALL
1879 /// * RED_BRICK_FILE_PERMISSION_USER_READ
1880 /// * RED_BRICK_FILE_PERMISSION_USER_WRITE
1881 /// * RED_BRICK_FILE_PERMISSION_USER_EXECUTE
1882 /// * RED_BRICK_FILE_PERMISSION_GROUP_ALL
1883 /// * RED_BRICK_FILE_PERMISSION_GROUP_READ
1884 /// * RED_BRICK_FILE_PERMISSION_GROUP_WRITE
1885 /// * RED_BRICK_FILE_PERMISSION_GROUP_EXECUTE
1886 /// * RED_BRICK_FILE_PERMISSION_OTHERS_ALL
1887 /// * RED_BRICK_FILE_PERMISSION_OTHERS_READ
1888 /// * RED_BRICK_FILE_PERMISSION_OTHERS_WRITE
1889 /// * RED_BRICK_FILE_PERMISSION_OTHERS_EXECUTE
1890 /// * RED_BRICK_ERROR_CODE_SUCCESS
1891 /// * RED_BRICK_ERROR_CODE_UNKNOWN_ERROR
1892 /// * RED_BRICK_ERROR_CODE_INVALID_OPERATION
1893 /// * RED_BRICK_ERROR_CODE_OPERATION_ABORTED
1894 /// * RED_BRICK_ERROR_CODE_INTERNAL_ERROR
1895 /// * RED_BRICK_ERROR_CODE_UNKNOWN_SESSION_ID
1896 /// * RED_BRICK_ERROR_CODE_NO_FREE_SESSION_ID
1897 /// * RED_BRICK_ERROR_CODE_UNKNOWN_OBJECT_ID
1898 /// * RED_BRICK_ERROR_CODE_NO_FREE_OBJECT_ID
1899 /// * RED_BRICK_ERROR_CODE_OBJECT_IS_LOCKED
1900 /// * RED_BRICK_ERROR_CODE_NO_MORE_DATA
1901 /// * RED_BRICK_ERROR_CODE_WRONG_LIST_ITEM_TYPE
1902 /// * RED_BRICK_ERROR_CODE_PROGRAM_IS_PURGED
1903 /// * RED_BRICK_ERROR_CODE_INVALID_PARAMETER
1904 /// * RED_BRICK_ERROR_CODE_NO_FREE_MEMORY
1905 /// * RED_BRICK_ERROR_CODE_NO_FREE_SPACE
1906 /// * RED_BRICK_ERROR_CODE_ACCESS_DENIED
1907 /// * RED_BRICK_ERROR_CODE_ALREADY_EXISTS
1908 /// * RED_BRICK_ERROR_CODE_DOES_NOT_EXIST
1909 /// * RED_BRICK_ERROR_CODE_INTERRUPTED
1910 /// * RED_BRICK_ERROR_CODE_IS_DIRECTORY
1911 /// * RED_BRICK_ERROR_CODE_NOT_A_DIRECTORY
1912 /// * RED_BRICK_ERROR_CODE_WOULD_BLOCK
1913 /// * RED_BRICK_ERROR_CODE_OVERFLOW
1914 /// * RED_BRICK_ERROR_CODE_BAD_FILE_DESCRIPTOR
1915 /// * RED_BRICK_ERROR_CODE_OUT_OF_RANGE
1916 /// * RED_BRICK_ERROR_CODE_NAME_TOO_LONG
1917 /// * RED_BRICK_ERROR_CODE_INVALID_SEEK
1918 /// * RED_BRICK_ERROR_CODE_NOT_SUPPORTED
1919 /// * RED_BRICK_ERROR_CODE_TOO_MANY_OPEN_FILES
1920 pub async fn open_file(
1921 &mut self,
1922 name_string_id: u16,
1923 flags: u32,
1924 permissions: u16,
1925 uid: u32,
1926 gid: u32,
1927 session_id: u16,
1928 ) -> Result<OpenFile, TinkerforgeError> {
1929 let mut payload = [0; 18];
1930 name_string_id.write_to_slice(&mut payload[0..2]);
1931 flags.write_to_slice(&mut payload[2..6]);
1932 permissions.write_to_slice(&mut payload[6..8]);
1933 uid.write_to_slice(&mut payload[8..12]);
1934 gid.write_to_slice(&mut payload[12..16]);
1935 session_id.write_to_slice(&mut payload[16..18]);
1936
1937 #[allow(unused_variables)]
1938 let result = self.device.get(u8::from(RedBrickFunction::OpenFile), &payload).await?;
1939 Ok(OpenFile::from_le_byte_slice(result.body()))
1940 }
1941
1942 /// Creates a new pipe and allocates a new file object for it.
1943 ///
1944 /// The ``flags`` parameter takes a ORed combination of the following possible
1945 /// pipe flags (in hexadecimal notation):
1946 ///
1947 /// * NonBlockingRead = 0x0001
1948 /// * NonBlockingWrite = 0x0002
1949 ///
1950 /// The length of the pipe buffer can be specified with the ``length`` parameter
1951 /// in bytes. If length is set to zero, then the default pipe buffer length is used.
1952 ///
1953 /// Returns the object ID of the new file object and the resulting error code.
1954 ///
1955 /// Associated constants:
1956 /// * RED_BRICK_PIPE_FLAG_NON_BLOCKING_READ
1957 /// * RED_BRICK_PIPE_FLAG_NON_BLOCKING_WRITE
1958 /// * RED_BRICK_ERROR_CODE_SUCCESS
1959 /// * RED_BRICK_ERROR_CODE_UNKNOWN_ERROR
1960 /// * RED_BRICK_ERROR_CODE_INVALID_OPERATION
1961 /// * RED_BRICK_ERROR_CODE_OPERATION_ABORTED
1962 /// * RED_BRICK_ERROR_CODE_INTERNAL_ERROR
1963 /// * RED_BRICK_ERROR_CODE_UNKNOWN_SESSION_ID
1964 /// * RED_BRICK_ERROR_CODE_NO_FREE_SESSION_ID
1965 /// * RED_BRICK_ERROR_CODE_UNKNOWN_OBJECT_ID
1966 /// * RED_BRICK_ERROR_CODE_NO_FREE_OBJECT_ID
1967 /// * RED_BRICK_ERROR_CODE_OBJECT_IS_LOCKED
1968 /// * RED_BRICK_ERROR_CODE_NO_MORE_DATA
1969 /// * RED_BRICK_ERROR_CODE_WRONG_LIST_ITEM_TYPE
1970 /// * RED_BRICK_ERROR_CODE_PROGRAM_IS_PURGED
1971 /// * RED_BRICK_ERROR_CODE_INVALID_PARAMETER
1972 /// * RED_BRICK_ERROR_CODE_NO_FREE_MEMORY
1973 /// * RED_BRICK_ERROR_CODE_NO_FREE_SPACE
1974 /// * RED_BRICK_ERROR_CODE_ACCESS_DENIED
1975 /// * RED_BRICK_ERROR_CODE_ALREADY_EXISTS
1976 /// * RED_BRICK_ERROR_CODE_DOES_NOT_EXIST
1977 /// * RED_BRICK_ERROR_CODE_INTERRUPTED
1978 /// * RED_BRICK_ERROR_CODE_IS_DIRECTORY
1979 /// * RED_BRICK_ERROR_CODE_NOT_A_DIRECTORY
1980 /// * RED_BRICK_ERROR_CODE_WOULD_BLOCK
1981 /// * RED_BRICK_ERROR_CODE_OVERFLOW
1982 /// * RED_BRICK_ERROR_CODE_BAD_FILE_DESCRIPTOR
1983 /// * RED_BRICK_ERROR_CODE_OUT_OF_RANGE
1984 /// * RED_BRICK_ERROR_CODE_NAME_TOO_LONG
1985 /// * RED_BRICK_ERROR_CODE_INVALID_SEEK
1986 /// * RED_BRICK_ERROR_CODE_NOT_SUPPORTED
1987 /// * RED_BRICK_ERROR_CODE_TOO_MANY_OPEN_FILES
1988 pub async fn create_pipe(&mut self, flags: u32, length: u64, session_id: u16) -> Result<CreatePipe, TinkerforgeError> {
1989 let mut payload = [0; 14];
1990 flags.write_to_slice(&mut payload[0..4]);
1991 length.write_to_slice(&mut payload[4..12]);
1992 session_id.write_to_slice(&mut payload[12..14]);
1993
1994 #[allow(unused_variables)]
1995 let result = self.device.get(u8::from(RedBrickFunction::CreatePipe), &payload).await?;
1996 Ok(CreatePipe::from_le_byte_slice(result.body()))
1997 }
1998
1999 /// Returns various information about a file and the resulting error code.
2000 ///
2001 /// Possible file types are:
2002 ///
2003 /// * Unknown = 0
2004 /// * Regular = 1
2005 /// * Directory = 2
2006 /// * Character = 3
2007 /// * Block = 4
2008 /// * FIFO = 5
2009 /// * Symlink = 6
2010 /// * Socket = 7
2011 /// * Pipe = 8
2012 ///
2013 /// If the file type is *Pipe* then the returned name string object is invalid,
2014 /// because a pipe has no name. Otherwise the returned name string object was used
2015 /// to open or create the file object, as passed to [`open_file`].
2016 ///
2017 /// The returned flags were used to open or create the file object, as passed to
2018 /// [`open_file`] or [`create_pipe`]. See the respective function for a list
2019 /// of possible file and pipe flags.
2020 ///
2021 /// FIXME: everything except flags and length is invalid if file type is *Pipe*
2022 ///
2023 /// Associated constants:
2024 /// * RED_BRICK_ERROR_CODE_SUCCESS
2025 /// * RED_BRICK_ERROR_CODE_UNKNOWN_ERROR
2026 /// * RED_BRICK_ERROR_CODE_INVALID_OPERATION
2027 /// * RED_BRICK_ERROR_CODE_OPERATION_ABORTED
2028 /// * RED_BRICK_ERROR_CODE_INTERNAL_ERROR
2029 /// * RED_BRICK_ERROR_CODE_UNKNOWN_SESSION_ID
2030 /// * RED_BRICK_ERROR_CODE_NO_FREE_SESSION_ID
2031 /// * RED_BRICK_ERROR_CODE_UNKNOWN_OBJECT_ID
2032 /// * RED_BRICK_ERROR_CODE_NO_FREE_OBJECT_ID
2033 /// * RED_BRICK_ERROR_CODE_OBJECT_IS_LOCKED
2034 /// * RED_BRICK_ERROR_CODE_NO_MORE_DATA
2035 /// * RED_BRICK_ERROR_CODE_WRONG_LIST_ITEM_TYPE
2036 /// * RED_BRICK_ERROR_CODE_PROGRAM_IS_PURGED
2037 /// * RED_BRICK_ERROR_CODE_INVALID_PARAMETER
2038 /// * RED_BRICK_ERROR_CODE_NO_FREE_MEMORY
2039 /// * RED_BRICK_ERROR_CODE_NO_FREE_SPACE
2040 /// * RED_BRICK_ERROR_CODE_ACCESS_DENIED
2041 /// * RED_BRICK_ERROR_CODE_ALREADY_EXISTS
2042 /// * RED_BRICK_ERROR_CODE_DOES_NOT_EXIST
2043 /// * RED_BRICK_ERROR_CODE_INTERRUPTED
2044 /// * RED_BRICK_ERROR_CODE_IS_DIRECTORY
2045 /// * RED_BRICK_ERROR_CODE_NOT_A_DIRECTORY
2046 /// * RED_BRICK_ERROR_CODE_WOULD_BLOCK
2047 /// * RED_BRICK_ERROR_CODE_OVERFLOW
2048 /// * RED_BRICK_ERROR_CODE_BAD_FILE_DESCRIPTOR
2049 /// * RED_BRICK_ERROR_CODE_OUT_OF_RANGE
2050 /// * RED_BRICK_ERROR_CODE_NAME_TOO_LONG
2051 /// * RED_BRICK_ERROR_CODE_INVALID_SEEK
2052 /// * RED_BRICK_ERROR_CODE_NOT_SUPPORTED
2053 /// * RED_BRICK_ERROR_CODE_TOO_MANY_OPEN_FILES
2054 /// * RED_BRICK_FILE_TYPE_UNKNOWN
2055 /// * RED_BRICK_FILE_TYPE_REGULAR
2056 /// * RED_BRICK_FILE_TYPE_DIRECTORY
2057 /// * RED_BRICK_FILE_TYPE_CHARACTER
2058 /// * RED_BRICK_FILE_TYPE_BLOCK
2059 /// * RED_BRICK_FILE_TYPE_FIFO
2060 /// * RED_BRICK_FILE_TYPE_SYMLINK
2061 /// * RED_BRICK_FILE_TYPE_SOCKET
2062 /// * RED_BRICK_FILE_TYPE_PIPE
2063 /// * RED_BRICK_FILE_FLAG_READ_ONLY
2064 /// * RED_BRICK_FILE_FLAG_WRITE_ONLY
2065 /// * RED_BRICK_FILE_FLAG_READ_WRITE
2066 /// * RED_BRICK_FILE_FLAG_APPEND
2067 /// * RED_BRICK_FILE_FLAG_CREATE
2068 /// * RED_BRICK_FILE_FLAG_EXCLUSIVE
2069 /// * RED_BRICK_FILE_FLAG_NON_BLOCKING
2070 /// * RED_BRICK_FILE_FLAG_TRUNCATE
2071 /// * RED_BRICK_FILE_FLAG_TEMPORARY
2072 /// * RED_BRICK_FILE_FLAG_REPLACE
2073 /// * RED_BRICK_FILE_PERMISSION_USER_ALL
2074 /// * RED_BRICK_FILE_PERMISSION_USER_READ
2075 /// * RED_BRICK_FILE_PERMISSION_USER_WRITE
2076 /// * RED_BRICK_FILE_PERMISSION_USER_EXECUTE
2077 /// * RED_BRICK_FILE_PERMISSION_GROUP_ALL
2078 /// * RED_BRICK_FILE_PERMISSION_GROUP_READ
2079 /// * RED_BRICK_FILE_PERMISSION_GROUP_WRITE
2080 /// * RED_BRICK_FILE_PERMISSION_GROUP_EXECUTE
2081 /// * RED_BRICK_FILE_PERMISSION_OTHERS_ALL
2082 /// * RED_BRICK_FILE_PERMISSION_OTHERS_READ
2083 /// * RED_BRICK_FILE_PERMISSION_OTHERS_WRITE
2084 /// * RED_BRICK_FILE_PERMISSION_OTHERS_EXECUTE
2085 pub async fn get_file_info(&mut self, file_id: u16, session_id: u16) -> Result<FileInfo, TinkerforgeError> {
2086 let mut payload = [0; 4];
2087 file_id.write_to_slice(&mut payload[0..2]);
2088 session_id.write_to_slice(&mut payload[2..4]);
2089
2090 #[allow(unused_variables)]
2091 let result = self.device.get(u8::from(RedBrickFunction::GetFileInfo), &payload).await?;
2092 Ok(FileInfo::from_le_byte_slice(result.body()))
2093 }
2094
2095 /// Reads up to 62 bytes from a file object.
2096 ///
2097 /// Returns the bytes read, the actual number of bytes read and the resulting
2098 /// error code.
2099 ///
2100 /// If there is not data to be read, either because the file position reached
2101 /// end-of-file or because there is not data in the pipe, then zero bytes are
2102 /// returned.
2103 ///
2104 /// If the file object was created by [`open_file`] without the *NonBlocking*
2105 /// flag or by [`create_pipe`] without the *NonBlockingRead* flag then the
2106 /// error code *NotSupported* is returned.
2107 ///
2108 /// Associated constants:
2109 /// * RED_BRICK_ERROR_CODE_SUCCESS
2110 /// * RED_BRICK_ERROR_CODE_UNKNOWN_ERROR
2111 /// * RED_BRICK_ERROR_CODE_INVALID_OPERATION
2112 /// * RED_BRICK_ERROR_CODE_OPERATION_ABORTED
2113 /// * RED_BRICK_ERROR_CODE_INTERNAL_ERROR
2114 /// * RED_BRICK_ERROR_CODE_UNKNOWN_SESSION_ID
2115 /// * RED_BRICK_ERROR_CODE_NO_FREE_SESSION_ID
2116 /// * RED_BRICK_ERROR_CODE_UNKNOWN_OBJECT_ID
2117 /// * RED_BRICK_ERROR_CODE_NO_FREE_OBJECT_ID
2118 /// * RED_BRICK_ERROR_CODE_OBJECT_IS_LOCKED
2119 /// * RED_BRICK_ERROR_CODE_NO_MORE_DATA
2120 /// * RED_BRICK_ERROR_CODE_WRONG_LIST_ITEM_TYPE
2121 /// * RED_BRICK_ERROR_CODE_PROGRAM_IS_PURGED
2122 /// * RED_BRICK_ERROR_CODE_INVALID_PARAMETER
2123 /// * RED_BRICK_ERROR_CODE_NO_FREE_MEMORY
2124 /// * RED_BRICK_ERROR_CODE_NO_FREE_SPACE
2125 /// * RED_BRICK_ERROR_CODE_ACCESS_DENIED
2126 /// * RED_BRICK_ERROR_CODE_ALREADY_EXISTS
2127 /// * RED_BRICK_ERROR_CODE_DOES_NOT_EXIST
2128 /// * RED_BRICK_ERROR_CODE_INTERRUPTED
2129 /// * RED_BRICK_ERROR_CODE_IS_DIRECTORY
2130 /// * RED_BRICK_ERROR_CODE_NOT_A_DIRECTORY
2131 /// * RED_BRICK_ERROR_CODE_WOULD_BLOCK
2132 /// * RED_BRICK_ERROR_CODE_OVERFLOW
2133 /// * RED_BRICK_ERROR_CODE_BAD_FILE_DESCRIPTOR
2134 /// * RED_BRICK_ERROR_CODE_OUT_OF_RANGE
2135 /// * RED_BRICK_ERROR_CODE_NAME_TOO_LONG
2136 /// * RED_BRICK_ERROR_CODE_INVALID_SEEK
2137 /// * RED_BRICK_ERROR_CODE_NOT_SUPPORTED
2138 /// * RED_BRICK_ERROR_CODE_TOO_MANY_OPEN_FILES
2139 pub async fn read_file(&mut self, file_id: u16, length_to_read: u8) -> Result<ReadFile, TinkerforgeError> {
2140 let mut payload = [0; 3];
2141 file_id.write_to_slice(&mut payload[0..2]);
2142 length_to_read.write_to_slice(&mut payload[2..3]);
2143
2144 #[allow(unused_variables)]
2145 let result = self.device.get(u8::from(RedBrickFunction::ReadFile), &payload).await?;
2146 Ok(ReadFile::from_le_byte_slice(result.body()))
2147 }
2148
2149 /// Reads up to 2\ :sup:`63`\ - 1 bytes from a file object asynchronously.
2150 ///
2151 /// Reports the bytes read (in 60 byte chunks), the actual number of bytes read and
2152 /// the resulting error code via the [`get_async_file_read_callback_receiver`] receiver.
2153 ///
2154 /// If there is not data to be read, either because the file position reached
2155 /// end-of-file or because there is not data in the pipe, then zero bytes are
2156 /// reported.
2157 ///
2158 /// If the file object was created by [`open_file`] without the *NonBlocking*
2159 /// flag or by [`create_pipe`] without the *NonBlockingRead* flag then the error
2160 /// code *NotSupported* is reported via the [`get_async_file_read_callback_receiver`] receiver.
2161 pub async fn read_file_async(&mut self, file_id: u16, length_to_read: u64) -> Result<(), TinkerforgeError> {
2162 let mut payload = [0; 10];
2163 file_id.write_to_slice(&mut payload[0..2]);
2164 length_to_read.write_to_slice(&mut payload[2..10]);
2165
2166 #[allow(unused_variables)]
2167 let result = self.device.set(u8::from(RedBrickFunction::ReadFileAsync), &payload).await?;
2168 Ok(())
2169 }
2170
2171 /// Aborts a [`read_file_async`] operation in progress.
2172 ///
2173 /// Returns the resulting error code.
2174 ///
2175 /// On success the [`get_async_file_read_callback_receiver`] receiver will report *OperationAborted*.
2176 ///
2177 /// Associated constants:
2178 /// * RED_BRICK_ERROR_CODE_SUCCESS
2179 /// * RED_BRICK_ERROR_CODE_UNKNOWN_ERROR
2180 /// * RED_BRICK_ERROR_CODE_INVALID_OPERATION
2181 /// * RED_BRICK_ERROR_CODE_OPERATION_ABORTED
2182 /// * RED_BRICK_ERROR_CODE_INTERNAL_ERROR
2183 /// * RED_BRICK_ERROR_CODE_UNKNOWN_SESSION_ID
2184 /// * RED_BRICK_ERROR_CODE_NO_FREE_SESSION_ID
2185 /// * RED_BRICK_ERROR_CODE_UNKNOWN_OBJECT_ID
2186 /// * RED_BRICK_ERROR_CODE_NO_FREE_OBJECT_ID
2187 /// * RED_BRICK_ERROR_CODE_OBJECT_IS_LOCKED
2188 /// * RED_BRICK_ERROR_CODE_NO_MORE_DATA
2189 /// * RED_BRICK_ERROR_CODE_WRONG_LIST_ITEM_TYPE
2190 /// * RED_BRICK_ERROR_CODE_PROGRAM_IS_PURGED
2191 /// * RED_BRICK_ERROR_CODE_INVALID_PARAMETER
2192 /// * RED_BRICK_ERROR_CODE_NO_FREE_MEMORY
2193 /// * RED_BRICK_ERROR_CODE_NO_FREE_SPACE
2194 /// * RED_BRICK_ERROR_CODE_ACCESS_DENIED
2195 /// * RED_BRICK_ERROR_CODE_ALREADY_EXISTS
2196 /// * RED_BRICK_ERROR_CODE_DOES_NOT_EXIST
2197 /// * RED_BRICK_ERROR_CODE_INTERRUPTED
2198 /// * RED_BRICK_ERROR_CODE_IS_DIRECTORY
2199 /// * RED_BRICK_ERROR_CODE_NOT_A_DIRECTORY
2200 /// * RED_BRICK_ERROR_CODE_WOULD_BLOCK
2201 /// * RED_BRICK_ERROR_CODE_OVERFLOW
2202 /// * RED_BRICK_ERROR_CODE_BAD_FILE_DESCRIPTOR
2203 /// * RED_BRICK_ERROR_CODE_OUT_OF_RANGE
2204 /// * RED_BRICK_ERROR_CODE_NAME_TOO_LONG
2205 /// * RED_BRICK_ERROR_CODE_INVALID_SEEK
2206 /// * RED_BRICK_ERROR_CODE_NOT_SUPPORTED
2207 /// * RED_BRICK_ERROR_CODE_TOO_MANY_OPEN_FILES
2208 pub async fn abort_async_file_read(&mut self, file_id: u16) -> Result<u8, TinkerforgeError> {
2209 let mut payload = [0; 2];
2210 file_id.write_to_slice(&mut payload[0..2]);
2211
2212 #[allow(unused_variables)]
2213 let result = self.device.get(u8::from(RedBrickFunction::AbortAsyncFileRead), &payload).await?;
2214 Ok(u8::from_le_byte_slice(result.body()))
2215 }
2216
2217 /// Writes up to 61 bytes to a file object.
2218 ///
2219 /// Returns the actual number of bytes written and the resulting error code.
2220 ///
2221 /// If the file object was created by [`open_file`] without the *NonBlocking*
2222 /// flag or by [`create_pipe`] without the *NonBlockingWrite* flag then the
2223 /// error code *NotSupported* is returned.
2224 ///
2225 /// Associated constants:
2226 /// * RED_BRICK_ERROR_CODE_SUCCESS
2227 /// * RED_BRICK_ERROR_CODE_UNKNOWN_ERROR
2228 /// * RED_BRICK_ERROR_CODE_INVALID_OPERATION
2229 /// * RED_BRICK_ERROR_CODE_OPERATION_ABORTED
2230 /// * RED_BRICK_ERROR_CODE_INTERNAL_ERROR
2231 /// * RED_BRICK_ERROR_CODE_UNKNOWN_SESSION_ID
2232 /// * RED_BRICK_ERROR_CODE_NO_FREE_SESSION_ID
2233 /// * RED_BRICK_ERROR_CODE_UNKNOWN_OBJECT_ID
2234 /// * RED_BRICK_ERROR_CODE_NO_FREE_OBJECT_ID
2235 /// * RED_BRICK_ERROR_CODE_OBJECT_IS_LOCKED
2236 /// * RED_BRICK_ERROR_CODE_NO_MORE_DATA
2237 /// * RED_BRICK_ERROR_CODE_WRONG_LIST_ITEM_TYPE
2238 /// * RED_BRICK_ERROR_CODE_PROGRAM_IS_PURGED
2239 /// * RED_BRICK_ERROR_CODE_INVALID_PARAMETER
2240 /// * RED_BRICK_ERROR_CODE_NO_FREE_MEMORY
2241 /// * RED_BRICK_ERROR_CODE_NO_FREE_SPACE
2242 /// * RED_BRICK_ERROR_CODE_ACCESS_DENIED
2243 /// * RED_BRICK_ERROR_CODE_ALREADY_EXISTS
2244 /// * RED_BRICK_ERROR_CODE_DOES_NOT_EXIST
2245 /// * RED_BRICK_ERROR_CODE_INTERRUPTED
2246 /// * RED_BRICK_ERROR_CODE_IS_DIRECTORY
2247 /// * RED_BRICK_ERROR_CODE_NOT_A_DIRECTORY
2248 /// * RED_BRICK_ERROR_CODE_WOULD_BLOCK
2249 /// * RED_BRICK_ERROR_CODE_OVERFLOW
2250 /// * RED_BRICK_ERROR_CODE_BAD_FILE_DESCRIPTOR
2251 /// * RED_BRICK_ERROR_CODE_OUT_OF_RANGE
2252 /// * RED_BRICK_ERROR_CODE_NAME_TOO_LONG
2253 /// * RED_BRICK_ERROR_CODE_INVALID_SEEK
2254 /// * RED_BRICK_ERROR_CODE_NOT_SUPPORTED
2255 /// * RED_BRICK_ERROR_CODE_TOO_MANY_OPEN_FILES
2256 pub async fn write_file(&mut self, file_id: u16, buffer: &[u8; 61], length_to_write: u8) -> Result<WriteFile, TinkerforgeError> {
2257 let mut payload = [0; 64];
2258 file_id.write_to_slice(&mut payload[0..2]);
2259 buffer.write_to_slice(&mut payload[2..63]);
2260 length_to_write.write_to_slice(&mut payload[63..64]);
2261
2262 #[allow(unused_variables)]
2263 let result = self.device.get(u8::from(RedBrickFunction::WriteFile), &payload).await?;
2264 Ok(WriteFile::from_le_byte_slice(result.body()))
2265 }
2266
2267 /// Writes up to 61 bytes to a file object.
2268 ///
2269 /// Does neither report the actual number of bytes written nor the resulting error
2270 /// code.
2271 ///
2272 /// If the file object was created by [`open_file`] without the *NonBlocking*
2273 /// flag or by [`create_pipe`] without the *NonBlockingWrite* flag then the
2274 /// write operation will fail silently.
2275 pub async fn write_file_unchecked(&mut self, file_id: u16, buffer: &[u8; 61], length_to_write: u8) -> Result<(), TinkerforgeError> {
2276 let mut payload = [0; 64];
2277 file_id.write_to_slice(&mut payload[0..2]);
2278 buffer.write_to_slice(&mut payload[2..63]);
2279 length_to_write.write_to_slice(&mut payload[63..64]);
2280
2281 #[allow(unused_variables)]
2282 let result = self.device.set(u8::from(RedBrickFunction::WriteFileUnchecked), &payload).await?;
2283 Ok(())
2284 }
2285
2286 /// Writes up to 61 bytes to a file object.
2287 ///
2288 /// Reports the actual number of bytes written and the resulting error code via the
2289 /// [`get_async_file_write_callback_receiver`] receiver.
2290 ///
2291 /// If the file object was created by [`open_file`] without the *NonBlocking*
2292 /// flag or by [`create_pipe`] without the *NonBlockingWrite* flag then the
2293 /// error code *NotSupported* is reported via the [`get_async_file_write_callback_receiver`] receiver.
2294 pub async fn write_file_async(&mut self, file_id: u16, buffer: &[u8; 61], length_to_write: u8) -> Result<(), TinkerforgeError> {
2295 let mut payload = [0; 64];
2296 file_id.write_to_slice(&mut payload[0..2]);
2297 buffer.write_to_slice(&mut payload[2..63]);
2298 length_to_write.write_to_slice(&mut payload[63..64]);
2299
2300 #[allow(unused_variables)]
2301 let result = self.device.set(u8::from(RedBrickFunction::WriteFileAsync), &payload).await?;
2302 Ok(())
2303 }
2304
2305 /// Set the current seek position of a file object relative to ``origin``.
2306 ///
2307 /// Possible file origins are:
2308 ///
2309 /// * Beginning = 0
2310 /// * Current = 1
2311 /// * End = 2
2312 ///
2313 /// Returns the resulting absolute seek position and error code.
2314 ///
2315 /// If the file object was created by [`create_pipe`] then it has no seek
2316 /// position and the error code *InvalidSeek* is returned.
2317 ///
2318 /// Associated constants:
2319 /// * RED_BRICK_FILE_ORIGIN_BEGINNING
2320 /// * RED_BRICK_FILE_ORIGIN_CURRENT
2321 /// * RED_BRICK_FILE_ORIGIN_END
2322 /// * RED_BRICK_ERROR_CODE_SUCCESS
2323 /// * RED_BRICK_ERROR_CODE_UNKNOWN_ERROR
2324 /// * RED_BRICK_ERROR_CODE_INVALID_OPERATION
2325 /// * RED_BRICK_ERROR_CODE_OPERATION_ABORTED
2326 /// * RED_BRICK_ERROR_CODE_INTERNAL_ERROR
2327 /// * RED_BRICK_ERROR_CODE_UNKNOWN_SESSION_ID
2328 /// * RED_BRICK_ERROR_CODE_NO_FREE_SESSION_ID
2329 /// * RED_BRICK_ERROR_CODE_UNKNOWN_OBJECT_ID
2330 /// * RED_BRICK_ERROR_CODE_NO_FREE_OBJECT_ID
2331 /// * RED_BRICK_ERROR_CODE_OBJECT_IS_LOCKED
2332 /// * RED_BRICK_ERROR_CODE_NO_MORE_DATA
2333 /// * RED_BRICK_ERROR_CODE_WRONG_LIST_ITEM_TYPE
2334 /// * RED_BRICK_ERROR_CODE_PROGRAM_IS_PURGED
2335 /// * RED_BRICK_ERROR_CODE_INVALID_PARAMETER
2336 /// * RED_BRICK_ERROR_CODE_NO_FREE_MEMORY
2337 /// * RED_BRICK_ERROR_CODE_NO_FREE_SPACE
2338 /// * RED_BRICK_ERROR_CODE_ACCESS_DENIED
2339 /// * RED_BRICK_ERROR_CODE_ALREADY_EXISTS
2340 /// * RED_BRICK_ERROR_CODE_DOES_NOT_EXIST
2341 /// * RED_BRICK_ERROR_CODE_INTERRUPTED
2342 /// * RED_BRICK_ERROR_CODE_IS_DIRECTORY
2343 /// * RED_BRICK_ERROR_CODE_NOT_A_DIRECTORY
2344 /// * RED_BRICK_ERROR_CODE_WOULD_BLOCK
2345 /// * RED_BRICK_ERROR_CODE_OVERFLOW
2346 /// * RED_BRICK_ERROR_CODE_BAD_FILE_DESCRIPTOR
2347 /// * RED_BRICK_ERROR_CODE_OUT_OF_RANGE
2348 /// * RED_BRICK_ERROR_CODE_NAME_TOO_LONG
2349 /// * RED_BRICK_ERROR_CODE_INVALID_SEEK
2350 /// * RED_BRICK_ERROR_CODE_NOT_SUPPORTED
2351 /// * RED_BRICK_ERROR_CODE_TOO_MANY_OPEN_FILES
2352 pub async fn set_file_position(&mut self, file_id: u16, offset: i64, origin: u8) -> Result<SetFilePosition, TinkerforgeError> {
2353 let mut payload = [0; 11];
2354 file_id.write_to_slice(&mut payload[0..2]);
2355 offset.write_to_slice(&mut payload[2..10]);
2356 origin.write_to_slice(&mut payload[10..11]);
2357
2358 #[allow(unused_variables)]
2359 let result = self.device.get(u8::from(RedBrickFunction::SetFilePosition), &payload).await?;
2360 Ok(SetFilePosition::from_le_byte_slice(result.body()))
2361 }
2362
2363 /// Returns the current seek position of a file object and returns the
2364 /// resulting error code.
2365 ///
2366 /// If the file object was created by [`create_pipe`] then it has no seek
2367 /// position and the error code *InvalidSeek* is returned.
2368 ///
2369 /// Associated constants:
2370 /// * RED_BRICK_ERROR_CODE_SUCCESS
2371 /// * RED_BRICK_ERROR_CODE_UNKNOWN_ERROR
2372 /// * RED_BRICK_ERROR_CODE_INVALID_OPERATION
2373 /// * RED_BRICK_ERROR_CODE_OPERATION_ABORTED
2374 /// * RED_BRICK_ERROR_CODE_INTERNAL_ERROR
2375 /// * RED_BRICK_ERROR_CODE_UNKNOWN_SESSION_ID
2376 /// * RED_BRICK_ERROR_CODE_NO_FREE_SESSION_ID
2377 /// * RED_BRICK_ERROR_CODE_UNKNOWN_OBJECT_ID
2378 /// * RED_BRICK_ERROR_CODE_NO_FREE_OBJECT_ID
2379 /// * RED_BRICK_ERROR_CODE_OBJECT_IS_LOCKED
2380 /// * RED_BRICK_ERROR_CODE_NO_MORE_DATA
2381 /// * RED_BRICK_ERROR_CODE_WRONG_LIST_ITEM_TYPE
2382 /// * RED_BRICK_ERROR_CODE_PROGRAM_IS_PURGED
2383 /// * RED_BRICK_ERROR_CODE_INVALID_PARAMETER
2384 /// * RED_BRICK_ERROR_CODE_NO_FREE_MEMORY
2385 /// * RED_BRICK_ERROR_CODE_NO_FREE_SPACE
2386 /// * RED_BRICK_ERROR_CODE_ACCESS_DENIED
2387 /// * RED_BRICK_ERROR_CODE_ALREADY_EXISTS
2388 /// * RED_BRICK_ERROR_CODE_DOES_NOT_EXIST
2389 /// * RED_BRICK_ERROR_CODE_INTERRUPTED
2390 /// * RED_BRICK_ERROR_CODE_IS_DIRECTORY
2391 /// * RED_BRICK_ERROR_CODE_NOT_A_DIRECTORY
2392 /// * RED_BRICK_ERROR_CODE_WOULD_BLOCK
2393 /// * RED_BRICK_ERROR_CODE_OVERFLOW
2394 /// * RED_BRICK_ERROR_CODE_BAD_FILE_DESCRIPTOR
2395 /// * RED_BRICK_ERROR_CODE_OUT_OF_RANGE
2396 /// * RED_BRICK_ERROR_CODE_NAME_TOO_LONG
2397 /// * RED_BRICK_ERROR_CODE_INVALID_SEEK
2398 /// * RED_BRICK_ERROR_CODE_NOT_SUPPORTED
2399 /// * RED_BRICK_ERROR_CODE_TOO_MANY_OPEN_FILES
2400 pub async fn get_file_position(&mut self, file_id: u16) -> Result<FilePosition, TinkerforgeError> {
2401 let mut payload = [0; 2];
2402 file_id.write_to_slice(&mut payload[0..2]);
2403
2404 #[allow(unused_variables)]
2405 let result = self.device.get(u8::from(RedBrickFunction::GetFilePosition), &payload).await?;
2406 Ok(FilePosition::from_le_byte_slice(result.body()))
2407 }
2408
2409 ///
2410 ///
2411 /// Associated constants:
2412 /// * RED_BRICK_FILE_EVENT_READABLE
2413 /// * RED_BRICK_FILE_EVENT_WRITABLE
2414 /// * RED_BRICK_ERROR_CODE_SUCCESS
2415 /// * RED_BRICK_ERROR_CODE_UNKNOWN_ERROR
2416 /// * RED_BRICK_ERROR_CODE_INVALID_OPERATION
2417 /// * RED_BRICK_ERROR_CODE_OPERATION_ABORTED
2418 /// * RED_BRICK_ERROR_CODE_INTERNAL_ERROR
2419 /// * RED_BRICK_ERROR_CODE_UNKNOWN_SESSION_ID
2420 /// * RED_BRICK_ERROR_CODE_NO_FREE_SESSION_ID
2421 /// * RED_BRICK_ERROR_CODE_UNKNOWN_OBJECT_ID
2422 /// * RED_BRICK_ERROR_CODE_NO_FREE_OBJECT_ID
2423 /// * RED_BRICK_ERROR_CODE_OBJECT_IS_LOCKED
2424 /// * RED_BRICK_ERROR_CODE_NO_MORE_DATA
2425 /// * RED_BRICK_ERROR_CODE_WRONG_LIST_ITEM_TYPE
2426 /// * RED_BRICK_ERROR_CODE_PROGRAM_IS_PURGED
2427 /// * RED_BRICK_ERROR_CODE_INVALID_PARAMETER
2428 /// * RED_BRICK_ERROR_CODE_NO_FREE_MEMORY
2429 /// * RED_BRICK_ERROR_CODE_NO_FREE_SPACE
2430 /// * RED_BRICK_ERROR_CODE_ACCESS_DENIED
2431 /// * RED_BRICK_ERROR_CODE_ALREADY_EXISTS
2432 /// * RED_BRICK_ERROR_CODE_DOES_NOT_EXIST
2433 /// * RED_BRICK_ERROR_CODE_INTERRUPTED
2434 /// * RED_BRICK_ERROR_CODE_IS_DIRECTORY
2435 /// * RED_BRICK_ERROR_CODE_NOT_A_DIRECTORY
2436 /// * RED_BRICK_ERROR_CODE_WOULD_BLOCK
2437 /// * RED_BRICK_ERROR_CODE_OVERFLOW
2438 /// * RED_BRICK_ERROR_CODE_BAD_FILE_DESCRIPTOR
2439 /// * RED_BRICK_ERROR_CODE_OUT_OF_RANGE
2440 /// * RED_BRICK_ERROR_CODE_NAME_TOO_LONG
2441 /// * RED_BRICK_ERROR_CODE_INVALID_SEEK
2442 /// * RED_BRICK_ERROR_CODE_NOT_SUPPORTED
2443 /// * RED_BRICK_ERROR_CODE_TOO_MANY_OPEN_FILES
2444 pub async fn set_file_events(&mut self, file_id: u16, events: u16) -> Result<u8, TinkerforgeError> {
2445 let mut payload = [0; 4];
2446 file_id.write_to_slice(&mut payload[0..2]);
2447 events.write_to_slice(&mut payload[2..4]);
2448
2449 #[allow(unused_variables)]
2450 let result = self.device.get(u8::from(RedBrickFunction::SetFileEvents), &payload).await?;
2451 Ok(u8::from_le_byte_slice(result.body()))
2452 }
2453
2454 ///
2455 ///
2456 /// Associated constants:
2457 /// * RED_BRICK_ERROR_CODE_SUCCESS
2458 /// * RED_BRICK_ERROR_CODE_UNKNOWN_ERROR
2459 /// * RED_BRICK_ERROR_CODE_INVALID_OPERATION
2460 /// * RED_BRICK_ERROR_CODE_OPERATION_ABORTED
2461 /// * RED_BRICK_ERROR_CODE_INTERNAL_ERROR
2462 /// * RED_BRICK_ERROR_CODE_UNKNOWN_SESSION_ID
2463 /// * RED_BRICK_ERROR_CODE_NO_FREE_SESSION_ID
2464 /// * RED_BRICK_ERROR_CODE_UNKNOWN_OBJECT_ID
2465 /// * RED_BRICK_ERROR_CODE_NO_FREE_OBJECT_ID
2466 /// * RED_BRICK_ERROR_CODE_OBJECT_IS_LOCKED
2467 /// * RED_BRICK_ERROR_CODE_NO_MORE_DATA
2468 /// * RED_BRICK_ERROR_CODE_WRONG_LIST_ITEM_TYPE
2469 /// * RED_BRICK_ERROR_CODE_PROGRAM_IS_PURGED
2470 /// * RED_BRICK_ERROR_CODE_INVALID_PARAMETER
2471 /// * RED_BRICK_ERROR_CODE_NO_FREE_MEMORY
2472 /// * RED_BRICK_ERROR_CODE_NO_FREE_SPACE
2473 /// * RED_BRICK_ERROR_CODE_ACCESS_DENIED
2474 /// * RED_BRICK_ERROR_CODE_ALREADY_EXISTS
2475 /// * RED_BRICK_ERROR_CODE_DOES_NOT_EXIST
2476 /// * RED_BRICK_ERROR_CODE_INTERRUPTED
2477 /// * RED_BRICK_ERROR_CODE_IS_DIRECTORY
2478 /// * RED_BRICK_ERROR_CODE_NOT_A_DIRECTORY
2479 /// * RED_BRICK_ERROR_CODE_WOULD_BLOCK
2480 /// * RED_BRICK_ERROR_CODE_OVERFLOW
2481 /// * RED_BRICK_ERROR_CODE_BAD_FILE_DESCRIPTOR
2482 /// * RED_BRICK_ERROR_CODE_OUT_OF_RANGE
2483 /// * RED_BRICK_ERROR_CODE_NAME_TOO_LONG
2484 /// * RED_BRICK_ERROR_CODE_INVALID_SEEK
2485 /// * RED_BRICK_ERROR_CODE_NOT_SUPPORTED
2486 /// * RED_BRICK_ERROR_CODE_TOO_MANY_OPEN_FILES
2487 /// * RED_BRICK_FILE_EVENT_READABLE
2488 /// * RED_BRICK_FILE_EVENT_WRITABLE
2489 pub async fn get_file_events(&mut self, file_id: u16) -> Result<FileEvents, TinkerforgeError> {
2490 let mut payload = [0; 2];
2491 file_id.write_to_slice(&mut payload[0..2]);
2492
2493 #[allow(unused_variables)]
2494 let result = self.device.get(u8::from(RedBrickFunction::GetFileEvents), &payload).await?;
2495 Ok(FileEvents::from_le_byte_slice(result.body()))
2496 }
2497
2498 /// Opens an existing directory and allocates a new directory object for it.
2499 ///
2500 /// FIXME: name has to be absolute
2501 ///
2502 /// The reference count of the name string object is increased by one. When the
2503 /// directory object is destroyed then the reference count of the name string
2504 /// object is decreased by one. Also the name string object is locked and cannot be
2505 /// modified while the directory object holds a reference to it.
2506 ///
2507 /// Returns the object ID of the new directory object and the resulting error code.
2508 ///
2509 /// Associated constants:
2510 /// * RED_BRICK_ERROR_CODE_SUCCESS
2511 /// * RED_BRICK_ERROR_CODE_UNKNOWN_ERROR
2512 /// * RED_BRICK_ERROR_CODE_INVALID_OPERATION
2513 /// * RED_BRICK_ERROR_CODE_OPERATION_ABORTED
2514 /// * RED_BRICK_ERROR_CODE_INTERNAL_ERROR
2515 /// * RED_BRICK_ERROR_CODE_UNKNOWN_SESSION_ID
2516 /// * RED_BRICK_ERROR_CODE_NO_FREE_SESSION_ID
2517 /// * RED_BRICK_ERROR_CODE_UNKNOWN_OBJECT_ID
2518 /// * RED_BRICK_ERROR_CODE_NO_FREE_OBJECT_ID
2519 /// * RED_BRICK_ERROR_CODE_OBJECT_IS_LOCKED
2520 /// * RED_BRICK_ERROR_CODE_NO_MORE_DATA
2521 /// * RED_BRICK_ERROR_CODE_WRONG_LIST_ITEM_TYPE
2522 /// * RED_BRICK_ERROR_CODE_PROGRAM_IS_PURGED
2523 /// * RED_BRICK_ERROR_CODE_INVALID_PARAMETER
2524 /// * RED_BRICK_ERROR_CODE_NO_FREE_MEMORY
2525 /// * RED_BRICK_ERROR_CODE_NO_FREE_SPACE
2526 /// * RED_BRICK_ERROR_CODE_ACCESS_DENIED
2527 /// * RED_BRICK_ERROR_CODE_ALREADY_EXISTS
2528 /// * RED_BRICK_ERROR_CODE_DOES_NOT_EXIST
2529 /// * RED_BRICK_ERROR_CODE_INTERRUPTED
2530 /// * RED_BRICK_ERROR_CODE_IS_DIRECTORY
2531 /// * RED_BRICK_ERROR_CODE_NOT_A_DIRECTORY
2532 /// * RED_BRICK_ERROR_CODE_WOULD_BLOCK
2533 /// * RED_BRICK_ERROR_CODE_OVERFLOW
2534 /// * RED_BRICK_ERROR_CODE_BAD_FILE_DESCRIPTOR
2535 /// * RED_BRICK_ERROR_CODE_OUT_OF_RANGE
2536 /// * RED_BRICK_ERROR_CODE_NAME_TOO_LONG
2537 /// * RED_BRICK_ERROR_CODE_INVALID_SEEK
2538 /// * RED_BRICK_ERROR_CODE_NOT_SUPPORTED
2539 /// * RED_BRICK_ERROR_CODE_TOO_MANY_OPEN_FILES
2540 pub async fn open_directory(&mut self, name_string_id: u16, session_id: u16) -> Result<OpenDirectory, TinkerforgeError> {
2541 let mut payload = [0; 4];
2542 name_string_id.write_to_slice(&mut payload[0..2]);
2543 session_id.write_to_slice(&mut payload[2..4]);
2544
2545 #[allow(unused_variables)]
2546 let result = self.device.get(u8::from(RedBrickFunction::OpenDirectory), &payload).await?;
2547 Ok(OpenDirectory::from_le_byte_slice(result.body()))
2548 }
2549
2550 /// Returns the name of a directory object, as passed to [`open_directory`], and
2551 /// the resulting error code.
2552 ///
2553 /// Associated constants:
2554 /// * RED_BRICK_ERROR_CODE_SUCCESS
2555 /// * RED_BRICK_ERROR_CODE_UNKNOWN_ERROR
2556 /// * RED_BRICK_ERROR_CODE_INVALID_OPERATION
2557 /// * RED_BRICK_ERROR_CODE_OPERATION_ABORTED
2558 /// * RED_BRICK_ERROR_CODE_INTERNAL_ERROR
2559 /// * RED_BRICK_ERROR_CODE_UNKNOWN_SESSION_ID
2560 /// * RED_BRICK_ERROR_CODE_NO_FREE_SESSION_ID
2561 /// * RED_BRICK_ERROR_CODE_UNKNOWN_OBJECT_ID
2562 /// * RED_BRICK_ERROR_CODE_NO_FREE_OBJECT_ID
2563 /// * RED_BRICK_ERROR_CODE_OBJECT_IS_LOCKED
2564 /// * RED_BRICK_ERROR_CODE_NO_MORE_DATA
2565 /// * RED_BRICK_ERROR_CODE_WRONG_LIST_ITEM_TYPE
2566 /// * RED_BRICK_ERROR_CODE_PROGRAM_IS_PURGED
2567 /// * RED_BRICK_ERROR_CODE_INVALID_PARAMETER
2568 /// * RED_BRICK_ERROR_CODE_NO_FREE_MEMORY
2569 /// * RED_BRICK_ERROR_CODE_NO_FREE_SPACE
2570 /// * RED_BRICK_ERROR_CODE_ACCESS_DENIED
2571 /// * RED_BRICK_ERROR_CODE_ALREADY_EXISTS
2572 /// * RED_BRICK_ERROR_CODE_DOES_NOT_EXIST
2573 /// * RED_BRICK_ERROR_CODE_INTERRUPTED
2574 /// * RED_BRICK_ERROR_CODE_IS_DIRECTORY
2575 /// * RED_BRICK_ERROR_CODE_NOT_A_DIRECTORY
2576 /// * RED_BRICK_ERROR_CODE_WOULD_BLOCK
2577 /// * RED_BRICK_ERROR_CODE_OVERFLOW
2578 /// * RED_BRICK_ERROR_CODE_BAD_FILE_DESCRIPTOR
2579 /// * RED_BRICK_ERROR_CODE_OUT_OF_RANGE
2580 /// * RED_BRICK_ERROR_CODE_NAME_TOO_LONG
2581 /// * RED_BRICK_ERROR_CODE_INVALID_SEEK
2582 /// * RED_BRICK_ERROR_CODE_NOT_SUPPORTED
2583 /// * RED_BRICK_ERROR_CODE_TOO_MANY_OPEN_FILES
2584 pub async fn get_directory_name(&mut self, directory_id: u16, session_id: u16) -> Result<DirectoryName, TinkerforgeError> {
2585 let mut payload = [0; 4];
2586 directory_id.write_to_slice(&mut payload[0..2]);
2587 session_id.write_to_slice(&mut payload[2..4]);
2588
2589 #[allow(unused_variables)]
2590 let result = self.device.get(u8::from(RedBrickFunction::GetDirectoryName), &payload).await?;
2591 Ok(DirectoryName::from_le_byte_slice(result.body()))
2592 }
2593
2594 /// Returns the next entry in a directory object and the resulting error code.
2595 ///
2596 /// If there is not next entry then error code *NoMoreData* is returned. To rewind
2597 /// a directory object call [`rewind_directory`].
2598 ///
2599 /// Possible directory entry types are:
2600 ///
2601 /// * Unknown = 0
2602 /// * Regular = 1
2603 /// * Directory = 2
2604 /// * Character = 3
2605 /// * Block = 4
2606 /// * FIFO = 5
2607 /// * Symlink = 6
2608 /// * Socket = 7
2609 ///
2610 /// Associated constants:
2611 /// * RED_BRICK_ERROR_CODE_SUCCESS
2612 /// * RED_BRICK_ERROR_CODE_UNKNOWN_ERROR
2613 /// * RED_BRICK_ERROR_CODE_INVALID_OPERATION
2614 /// * RED_BRICK_ERROR_CODE_OPERATION_ABORTED
2615 /// * RED_BRICK_ERROR_CODE_INTERNAL_ERROR
2616 /// * RED_BRICK_ERROR_CODE_UNKNOWN_SESSION_ID
2617 /// * RED_BRICK_ERROR_CODE_NO_FREE_SESSION_ID
2618 /// * RED_BRICK_ERROR_CODE_UNKNOWN_OBJECT_ID
2619 /// * RED_BRICK_ERROR_CODE_NO_FREE_OBJECT_ID
2620 /// * RED_BRICK_ERROR_CODE_OBJECT_IS_LOCKED
2621 /// * RED_BRICK_ERROR_CODE_NO_MORE_DATA
2622 /// * RED_BRICK_ERROR_CODE_WRONG_LIST_ITEM_TYPE
2623 /// * RED_BRICK_ERROR_CODE_PROGRAM_IS_PURGED
2624 /// * RED_BRICK_ERROR_CODE_INVALID_PARAMETER
2625 /// * RED_BRICK_ERROR_CODE_NO_FREE_MEMORY
2626 /// * RED_BRICK_ERROR_CODE_NO_FREE_SPACE
2627 /// * RED_BRICK_ERROR_CODE_ACCESS_DENIED
2628 /// * RED_BRICK_ERROR_CODE_ALREADY_EXISTS
2629 /// * RED_BRICK_ERROR_CODE_DOES_NOT_EXIST
2630 /// * RED_BRICK_ERROR_CODE_INTERRUPTED
2631 /// * RED_BRICK_ERROR_CODE_IS_DIRECTORY
2632 /// * RED_BRICK_ERROR_CODE_NOT_A_DIRECTORY
2633 /// * RED_BRICK_ERROR_CODE_WOULD_BLOCK
2634 /// * RED_BRICK_ERROR_CODE_OVERFLOW
2635 /// * RED_BRICK_ERROR_CODE_BAD_FILE_DESCRIPTOR
2636 /// * RED_BRICK_ERROR_CODE_OUT_OF_RANGE
2637 /// * RED_BRICK_ERROR_CODE_NAME_TOO_LONG
2638 /// * RED_BRICK_ERROR_CODE_INVALID_SEEK
2639 /// * RED_BRICK_ERROR_CODE_NOT_SUPPORTED
2640 /// * RED_BRICK_ERROR_CODE_TOO_MANY_OPEN_FILES
2641 /// * RED_BRICK_DIRECTORY_ENTRY_TYPE_UNKNOWN
2642 /// * RED_BRICK_DIRECTORY_ENTRY_TYPE_REGULAR
2643 /// * RED_BRICK_DIRECTORY_ENTRY_TYPE_DIRECTORY
2644 /// * RED_BRICK_DIRECTORY_ENTRY_TYPE_CHARACTER
2645 /// * RED_BRICK_DIRECTORY_ENTRY_TYPE_BLOCK
2646 /// * RED_BRICK_DIRECTORY_ENTRY_TYPE_FIFO
2647 /// * RED_BRICK_DIRECTORY_ENTRY_TYPE_SYMLINK
2648 /// * RED_BRICK_DIRECTORY_ENTRY_TYPE_SOCKET
2649 pub async fn get_next_directory_entry(&mut self, directory_id: u16, session_id: u16) -> Result<NextDirectoryEntry, TinkerforgeError> {
2650 let mut payload = [0; 4];
2651 directory_id.write_to_slice(&mut payload[0..2]);
2652 session_id.write_to_slice(&mut payload[2..4]);
2653
2654 #[allow(unused_variables)]
2655 let result = self.device.get(u8::from(RedBrickFunction::GetNextDirectoryEntry), &payload).await?;
2656 Ok(NextDirectoryEntry::from_le_byte_slice(result.body()))
2657 }
2658
2659 /// Rewinds a directory object and returns the resulting error code.
2660 ///
2661 /// Associated constants:
2662 /// * RED_BRICK_ERROR_CODE_SUCCESS
2663 /// * RED_BRICK_ERROR_CODE_UNKNOWN_ERROR
2664 /// * RED_BRICK_ERROR_CODE_INVALID_OPERATION
2665 /// * RED_BRICK_ERROR_CODE_OPERATION_ABORTED
2666 /// * RED_BRICK_ERROR_CODE_INTERNAL_ERROR
2667 /// * RED_BRICK_ERROR_CODE_UNKNOWN_SESSION_ID
2668 /// * RED_BRICK_ERROR_CODE_NO_FREE_SESSION_ID
2669 /// * RED_BRICK_ERROR_CODE_UNKNOWN_OBJECT_ID
2670 /// * RED_BRICK_ERROR_CODE_NO_FREE_OBJECT_ID
2671 /// * RED_BRICK_ERROR_CODE_OBJECT_IS_LOCKED
2672 /// * RED_BRICK_ERROR_CODE_NO_MORE_DATA
2673 /// * RED_BRICK_ERROR_CODE_WRONG_LIST_ITEM_TYPE
2674 /// * RED_BRICK_ERROR_CODE_PROGRAM_IS_PURGED
2675 /// * RED_BRICK_ERROR_CODE_INVALID_PARAMETER
2676 /// * RED_BRICK_ERROR_CODE_NO_FREE_MEMORY
2677 /// * RED_BRICK_ERROR_CODE_NO_FREE_SPACE
2678 /// * RED_BRICK_ERROR_CODE_ACCESS_DENIED
2679 /// * RED_BRICK_ERROR_CODE_ALREADY_EXISTS
2680 /// * RED_BRICK_ERROR_CODE_DOES_NOT_EXIST
2681 /// * RED_BRICK_ERROR_CODE_INTERRUPTED
2682 /// * RED_BRICK_ERROR_CODE_IS_DIRECTORY
2683 /// * RED_BRICK_ERROR_CODE_NOT_A_DIRECTORY
2684 /// * RED_BRICK_ERROR_CODE_WOULD_BLOCK
2685 /// * RED_BRICK_ERROR_CODE_OVERFLOW
2686 /// * RED_BRICK_ERROR_CODE_BAD_FILE_DESCRIPTOR
2687 /// * RED_BRICK_ERROR_CODE_OUT_OF_RANGE
2688 /// * RED_BRICK_ERROR_CODE_NAME_TOO_LONG
2689 /// * RED_BRICK_ERROR_CODE_INVALID_SEEK
2690 /// * RED_BRICK_ERROR_CODE_NOT_SUPPORTED
2691 /// * RED_BRICK_ERROR_CODE_TOO_MANY_OPEN_FILES
2692 pub async fn rewind_directory(&mut self, directory_id: u16) -> Result<u8, TinkerforgeError> {
2693 let mut payload = [0; 2];
2694 directory_id.write_to_slice(&mut payload[0..2]);
2695
2696 #[allow(unused_variables)]
2697 let result = self.device.get(u8::from(RedBrickFunction::RewindDirectory), &payload).await?;
2698 Ok(u8::from_le_byte_slice(result.body()))
2699 }
2700
2701 /// FIXME: name has to be absolute
2702 ///
2703 /// Associated constants:
2704 /// * RED_BRICK_DIRECTORY_FLAG_RECURSIVE
2705 /// * RED_BRICK_DIRECTORY_FLAG_EXCLUSIVE
2706 /// * RED_BRICK_FILE_PERMISSION_USER_ALL
2707 /// * RED_BRICK_FILE_PERMISSION_USER_READ
2708 /// * RED_BRICK_FILE_PERMISSION_USER_WRITE
2709 /// * RED_BRICK_FILE_PERMISSION_USER_EXECUTE
2710 /// * RED_BRICK_FILE_PERMISSION_GROUP_ALL
2711 /// * RED_BRICK_FILE_PERMISSION_GROUP_READ
2712 /// * RED_BRICK_FILE_PERMISSION_GROUP_WRITE
2713 /// * RED_BRICK_FILE_PERMISSION_GROUP_EXECUTE
2714 /// * RED_BRICK_FILE_PERMISSION_OTHERS_ALL
2715 /// * RED_BRICK_FILE_PERMISSION_OTHERS_READ
2716 /// * RED_BRICK_FILE_PERMISSION_OTHERS_WRITE
2717 /// * RED_BRICK_FILE_PERMISSION_OTHERS_EXECUTE
2718 /// * RED_BRICK_ERROR_CODE_SUCCESS
2719 /// * RED_BRICK_ERROR_CODE_UNKNOWN_ERROR
2720 /// * RED_BRICK_ERROR_CODE_INVALID_OPERATION
2721 /// * RED_BRICK_ERROR_CODE_OPERATION_ABORTED
2722 /// * RED_BRICK_ERROR_CODE_INTERNAL_ERROR
2723 /// * RED_BRICK_ERROR_CODE_UNKNOWN_SESSION_ID
2724 /// * RED_BRICK_ERROR_CODE_NO_FREE_SESSION_ID
2725 /// * RED_BRICK_ERROR_CODE_UNKNOWN_OBJECT_ID
2726 /// * RED_BRICK_ERROR_CODE_NO_FREE_OBJECT_ID
2727 /// * RED_BRICK_ERROR_CODE_OBJECT_IS_LOCKED
2728 /// * RED_BRICK_ERROR_CODE_NO_MORE_DATA
2729 /// * RED_BRICK_ERROR_CODE_WRONG_LIST_ITEM_TYPE
2730 /// * RED_BRICK_ERROR_CODE_PROGRAM_IS_PURGED
2731 /// * RED_BRICK_ERROR_CODE_INVALID_PARAMETER
2732 /// * RED_BRICK_ERROR_CODE_NO_FREE_MEMORY
2733 /// * RED_BRICK_ERROR_CODE_NO_FREE_SPACE
2734 /// * RED_BRICK_ERROR_CODE_ACCESS_DENIED
2735 /// * RED_BRICK_ERROR_CODE_ALREADY_EXISTS
2736 /// * RED_BRICK_ERROR_CODE_DOES_NOT_EXIST
2737 /// * RED_BRICK_ERROR_CODE_INTERRUPTED
2738 /// * RED_BRICK_ERROR_CODE_IS_DIRECTORY
2739 /// * RED_BRICK_ERROR_CODE_NOT_A_DIRECTORY
2740 /// * RED_BRICK_ERROR_CODE_WOULD_BLOCK
2741 /// * RED_BRICK_ERROR_CODE_OVERFLOW
2742 /// * RED_BRICK_ERROR_CODE_BAD_FILE_DESCRIPTOR
2743 /// * RED_BRICK_ERROR_CODE_OUT_OF_RANGE
2744 /// * RED_BRICK_ERROR_CODE_NAME_TOO_LONG
2745 /// * RED_BRICK_ERROR_CODE_INVALID_SEEK
2746 /// * RED_BRICK_ERROR_CODE_NOT_SUPPORTED
2747 /// * RED_BRICK_ERROR_CODE_TOO_MANY_OPEN_FILES
2748 pub async fn create_directory(
2749 &mut self,
2750 name_string_id: u16,
2751 flags: u32,
2752 permissions: u16,
2753 uid: u32,
2754 gid: u32,
2755 ) -> Result<u8, TinkerforgeError> {
2756 let mut payload = [0; 16];
2757 name_string_id.write_to_slice(&mut payload[0..2]);
2758 flags.write_to_slice(&mut payload[2..6]);
2759 permissions.write_to_slice(&mut payload[6..8]);
2760 uid.write_to_slice(&mut payload[8..12]);
2761 gid.write_to_slice(&mut payload[12..16]);
2762
2763 #[allow(unused_variables)]
2764 let result = self.device.get(u8::from(RedBrickFunction::CreateDirectory), &payload).await?;
2765 Ok(u8::from_le_byte_slice(result.body()))
2766 }
2767
2768 ///
2769 ///
2770 /// Associated constants:
2771 /// * RED_BRICK_ERROR_CODE_SUCCESS
2772 /// * RED_BRICK_ERROR_CODE_UNKNOWN_ERROR
2773 /// * RED_BRICK_ERROR_CODE_INVALID_OPERATION
2774 /// * RED_BRICK_ERROR_CODE_OPERATION_ABORTED
2775 /// * RED_BRICK_ERROR_CODE_INTERNAL_ERROR
2776 /// * RED_BRICK_ERROR_CODE_UNKNOWN_SESSION_ID
2777 /// * RED_BRICK_ERROR_CODE_NO_FREE_SESSION_ID
2778 /// * RED_BRICK_ERROR_CODE_UNKNOWN_OBJECT_ID
2779 /// * RED_BRICK_ERROR_CODE_NO_FREE_OBJECT_ID
2780 /// * RED_BRICK_ERROR_CODE_OBJECT_IS_LOCKED
2781 /// * RED_BRICK_ERROR_CODE_NO_MORE_DATA
2782 /// * RED_BRICK_ERROR_CODE_WRONG_LIST_ITEM_TYPE
2783 /// * RED_BRICK_ERROR_CODE_PROGRAM_IS_PURGED
2784 /// * RED_BRICK_ERROR_CODE_INVALID_PARAMETER
2785 /// * RED_BRICK_ERROR_CODE_NO_FREE_MEMORY
2786 /// * RED_BRICK_ERROR_CODE_NO_FREE_SPACE
2787 /// * RED_BRICK_ERROR_CODE_ACCESS_DENIED
2788 /// * RED_BRICK_ERROR_CODE_ALREADY_EXISTS
2789 /// * RED_BRICK_ERROR_CODE_DOES_NOT_EXIST
2790 /// * RED_BRICK_ERROR_CODE_INTERRUPTED
2791 /// * RED_BRICK_ERROR_CODE_IS_DIRECTORY
2792 /// * RED_BRICK_ERROR_CODE_NOT_A_DIRECTORY
2793 /// * RED_BRICK_ERROR_CODE_WOULD_BLOCK
2794 /// * RED_BRICK_ERROR_CODE_OVERFLOW
2795 /// * RED_BRICK_ERROR_CODE_BAD_FILE_DESCRIPTOR
2796 /// * RED_BRICK_ERROR_CODE_OUT_OF_RANGE
2797 /// * RED_BRICK_ERROR_CODE_NAME_TOO_LONG
2798 /// * RED_BRICK_ERROR_CODE_INVALID_SEEK
2799 /// * RED_BRICK_ERROR_CODE_NOT_SUPPORTED
2800 /// * RED_BRICK_ERROR_CODE_TOO_MANY_OPEN_FILES
2801 pub async fn get_processes(&mut self, session_id: u16) -> Result<Processes, TinkerforgeError> {
2802 let mut payload = [0; 2];
2803 session_id.write_to_slice(&mut payload[0..2]);
2804
2805 #[allow(unused_variables)]
2806 let result = self.device.get(u8::from(RedBrickFunction::GetProcesses), &payload).await?;
2807 Ok(Processes::from_le_byte_slice(result.body()))
2808 }
2809
2810 ///
2811 ///
2812 /// Associated constants:
2813 /// * RED_BRICK_ERROR_CODE_SUCCESS
2814 /// * RED_BRICK_ERROR_CODE_UNKNOWN_ERROR
2815 /// * RED_BRICK_ERROR_CODE_INVALID_OPERATION
2816 /// * RED_BRICK_ERROR_CODE_OPERATION_ABORTED
2817 /// * RED_BRICK_ERROR_CODE_INTERNAL_ERROR
2818 /// * RED_BRICK_ERROR_CODE_UNKNOWN_SESSION_ID
2819 /// * RED_BRICK_ERROR_CODE_NO_FREE_SESSION_ID
2820 /// * RED_BRICK_ERROR_CODE_UNKNOWN_OBJECT_ID
2821 /// * RED_BRICK_ERROR_CODE_NO_FREE_OBJECT_ID
2822 /// * RED_BRICK_ERROR_CODE_OBJECT_IS_LOCKED
2823 /// * RED_BRICK_ERROR_CODE_NO_MORE_DATA
2824 /// * RED_BRICK_ERROR_CODE_WRONG_LIST_ITEM_TYPE
2825 /// * RED_BRICK_ERROR_CODE_PROGRAM_IS_PURGED
2826 /// * RED_BRICK_ERROR_CODE_INVALID_PARAMETER
2827 /// * RED_BRICK_ERROR_CODE_NO_FREE_MEMORY
2828 /// * RED_BRICK_ERROR_CODE_NO_FREE_SPACE
2829 /// * RED_BRICK_ERROR_CODE_ACCESS_DENIED
2830 /// * RED_BRICK_ERROR_CODE_ALREADY_EXISTS
2831 /// * RED_BRICK_ERROR_CODE_DOES_NOT_EXIST
2832 /// * RED_BRICK_ERROR_CODE_INTERRUPTED
2833 /// * RED_BRICK_ERROR_CODE_IS_DIRECTORY
2834 /// * RED_BRICK_ERROR_CODE_NOT_A_DIRECTORY
2835 /// * RED_BRICK_ERROR_CODE_WOULD_BLOCK
2836 /// * RED_BRICK_ERROR_CODE_OVERFLOW
2837 /// * RED_BRICK_ERROR_CODE_BAD_FILE_DESCRIPTOR
2838 /// * RED_BRICK_ERROR_CODE_OUT_OF_RANGE
2839 /// * RED_BRICK_ERROR_CODE_NAME_TOO_LONG
2840 /// * RED_BRICK_ERROR_CODE_INVALID_SEEK
2841 /// * RED_BRICK_ERROR_CODE_NOT_SUPPORTED
2842 /// * RED_BRICK_ERROR_CODE_TOO_MANY_OPEN_FILES
2843 pub async fn spawn_process(
2844 &mut self,
2845 executable_string_id: u16,
2846 arguments_list_id: u16,
2847 environment_list_id: u16,
2848 working_directory_string_id: u16,
2849 uid: u32,
2850 gid: u32,
2851 stdin_file_id: u16,
2852 stdout_file_id: u16,
2853 stderr_file_id: u16,
2854 session_id: u16,
2855 ) -> Result<SpawnProcess, TinkerforgeError> {
2856 let mut payload = [0; 24];
2857 executable_string_id.write_to_slice(&mut payload[0..2]);
2858 arguments_list_id.write_to_slice(&mut payload[2..4]);
2859 environment_list_id.write_to_slice(&mut payload[4..6]);
2860 working_directory_string_id.write_to_slice(&mut payload[6..8]);
2861 uid.write_to_slice(&mut payload[8..12]);
2862 gid.write_to_slice(&mut payload[12..16]);
2863 stdin_file_id.write_to_slice(&mut payload[16..18]);
2864 stdout_file_id.write_to_slice(&mut payload[18..20]);
2865 stderr_file_id.write_to_slice(&mut payload[20..22]);
2866 session_id.write_to_slice(&mut payload[22..24]);
2867
2868 #[allow(unused_variables)]
2869 let result = self.device.get(u8::from(RedBrickFunction::SpawnProcess), &payload).await?;
2870 Ok(SpawnProcess::from_le_byte_slice(result.body()))
2871 }
2872
2873 /// Sends a UNIX signal to a process object and returns the resulting error code.
2874 ///
2875 /// Possible UNIX signals are:
2876 ///
2877 /// * Interrupt = 2
2878 /// * Quit = 3
2879 /// * Abort = 6
2880 /// * Kill = 9
2881 /// * User1 = 10
2882 /// * User2 = 12
2883 /// * Terminate = 15
2884 /// * Continue = 18
2885 /// * Stop = 19
2886 ///
2887 /// Associated constants:
2888 /// * RED_BRICK_PROCESS_SIGNAL_INTERRUPT
2889 /// * RED_BRICK_PROCESS_SIGNAL_QUIT
2890 /// * RED_BRICK_PROCESS_SIGNAL_ABORT
2891 /// * RED_BRICK_PROCESS_SIGNAL_KILL
2892 /// * RED_BRICK_PROCESS_SIGNAL_USER1
2893 /// * RED_BRICK_PROCESS_SIGNAL_USER2
2894 /// * RED_BRICK_PROCESS_SIGNAL_TERMINATE
2895 /// * RED_BRICK_PROCESS_SIGNAL_CONTINUE
2896 /// * RED_BRICK_PROCESS_SIGNAL_STOP
2897 /// * RED_BRICK_ERROR_CODE_SUCCESS
2898 /// * RED_BRICK_ERROR_CODE_UNKNOWN_ERROR
2899 /// * RED_BRICK_ERROR_CODE_INVALID_OPERATION
2900 /// * RED_BRICK_ERROR_CODE_OPERATION_ABORTED
2901 /// * RED_BRICK_ERROR_CODE_INTERNAL_ERROR
2902 /// * RED_BRICK_ERROR_CODE_UNKNOWN_SESSION_ID
2903 /// * RED_BRICK_ERROR_CODE_NO_FREE_SESSION_ID
2904 /// * RED_BRICK_ERROR_CODE_UNKNOWN_OBJECT_ID
2905 /// * RED_BRICK_ERROR_CODE_NO_FREE_OBJECT_ID
2906 /// * RED_BRICK_ERROR_CODE_OBJECT_IS_LOCKED
2907 /// * RED_BRICK_ERROR_CODE_NO_MORE_DATA
2908 /// * RED_BRICK_ERROR_CODE_WRONG_LIST_ITEM_TYPE
2909 /// * RED_BRICK_ERROR_CODE_PROGRAM_IS_PURGED
2910 /// * RED_BRICK_ERROR_CODE_INVALID_PARAMETER
2911 /// * RED_BRICK_ERROR_CODE_NO_FREE_MEMORY
2912 /// * RED_BRICK_ERROR_CODE_NO_FREE_SPACE
2913 /// * RED_BRICK_ERROR_CODE_ACCESS_DENIED
2914 /// * RED_BRICK_ERROR_CODE_ALREADY_EXISTS
2915 /// * RED_BRICK_ERROR_CODE_DOES_NOT_EXIST
2916 /// * RED_BRICK_ERROR_CODE_INTERRUPTED
2917 /// * RED_BRICK_ERROR_CODE_IS_DIRECTORY
2918 /// * RED_BRICK_ERROR_CODE_NOT_A_DIRECTORY
2919 /// * RED_BRICK_ERROR_CODE_WOULD_BLOCK
2920 /// * RED_BRICK_ERROR_CODE_OVERFLOW
2921 /// * RED_BRICK_ERROR_CODE_BAD_FILE_DESCRIPTOR
2922 /// * RED_BRICK_ERROR_CODE_OUT_OF_RANGE
2923 /// * RED_BRICK_ERROR_CODE_NAME_TOO_LONG
2924 /// * RED_BRICK_ERROR_CODE_INVALID_SEEK
2925 /// * RED_BRICK_ERROR_CODE_NOT_SUPPORTED
2926 /// * RED_BRICK_ERROR_CODE_TOO_MANY_OPEN_FILES
2927 pub async fn kill_process(&mut self, process_id: u16, signal: u8) -> Result<u8, TinkerforgeError> {
2928 let mut payload = [0; 3];
2929 process_id.write_to_slice(&mut payload[0..2]);
2930 signal.write_to_slice(&mut payload[2..3]);
2931
2932 #[allow(unused_variables)]
2933 let result = self.device.get(u8::from(RedBrickFunction::KillProcess), &payload).await?;
2934 Ok(u8::from_le_byte_slice(result.body()))
2935 }
2936
2937 /// Returns the executable, arguments, environment and working directory used to
2938 /// spawn a process object, as passed to [`spawn_process`], and the resulting
2939 /// error code.
2940 ///
2941 /// Associated constants:
2942 /// * RED_BRICK_ERROR_CODE_SUCCESS
2943 /// * RED_BRICK_ERROR_CODE_UNKNOWN_ERROR
2944 /// * RED_BRICK_ERROR_CODE_INVALID_OPERATION
2945 /// * RED_BRICK_ERROR_CODE_OPERATION_ABORTED
2946 /// * RED_BRICK_ERROR_CODE_INTERNAL_ERROR
2947 /// * RED_BRICK_ERROR_CODE_UNKNOWN_SESSION_ID
2948 /// * RED_BRICK_ERROR_CODE_NO_FREE_SESSION_ID
2949 /// * RED_BRICK_ERROR_CODE_UNKNOWN_OBJECT_ID
2950 /// * RED_BRICK_ERROR_CODE_NO_FREE_OBJECT_ID
2951 /// * RED_BRICK_ERROR_CODE_OBJECT_IS_LOCKED
2952 /// * RED_BRICK_ERROR_CODE_NO_MORE_DATA
2953 /// * RED_BRICK_ERROR_CODE_WRONG_LIST_ITEM_TYPE
2954 /// * RED_BRICK_ERROR_CODE_PROGRAM_IS_PURGED
2955 /// * RED_BRICK_ERROR_CODE_INVALID_PARAMETER
2956 /// * RED_BRICK_ERROR_CODE_NO_FREE_MEMORY
2957 /// * RED_BRICK_ERROR_CODE_NO_FREE_SPACE
2958 /// * RED_BRICK_ERROR_CODE_ACCESS_DENIED
2959 /// * RED_BRICK_ERROR_CODE_ALREADY_EXISTS
2960 /// * RED_BRICK_ERROR_CODE_DOES_NOT_EXIST
2961 /// * RED_BRICK_ERROR_CODE_INTERRUPTED
2962 /// * RED_BRICK_ERROR_CODE_IS_DIRECTORY
2963 /// * RED_BRICK_ERROR_CODE_NOT_A_DIRECTORY
2964 /// * RED_BRICK_ERROR_CODE_WOULD_BLOCK
2965 /// * RED_BRICK_ERROR_CODE_OVERFLOW
2966 /// * RED_BRICK_ERROR_CODE_BAD_FILE_DESCRIPTOR
2967 /// * RED_BRICK_ERROR_CODE_OUT_OF_RANGE
2968 /// * RED_BRICK_ERROR_CODE_NAME_TOO_LONG
2969 /// * RED_BRICK_ERROR_CODE_INVALID_SEEK
2970 /// * RED_BRICK_ERROR_CODE_NOT_SUPPORTED
2971 /// * RED_BRICK_ERROR_CODE_TOO_MANY_OPEN_FILES
2972 pub async fn get_process_command(&mut self, process_id: u16, session_id: u16) -> Result<ProcessCommand, TinkerforgeError> {
2973 let mut payload = [0; 4];
2974 process_id.write_to_slice(&mut payload[0..2]);
2975 session_id.write_to_slice(&mut payload[2..4]);
2976
2977 #[allow(unused_variables)]
2978 let result = self.device.get(u8::from(RedBrickFunction::GetProcessCommand), &payload).await?;
2979 Ok(ProcessCommand::from_le_byte_slice(result.body()))
2980 }
2981
2982 /// Returns the process ID and the user and group ID used to spawn a process object,
2983 /// as passed to [`spawn_process`], and the resulting error code.
2984 ///
2985 /// The process ID is only valid if the state is *Running* or *Stopped*, see
2986 /// [`get_process_state`].
2987 ///
2988 /// Associated constants:
2989 /// * RED_BRICK_ERROR_CODE_SUCCESS
2990 /// * RED_BRICK_ERROR_CODE_UNKNOWN_ERROR
2991 /// * RED_BRICK_ERROR_CODE_INVALID_OPERATION
2992 /// * RED_BRICK_ERROR_CODE_OPERATION_ABORTED
2993 /// * RED_BRICK_ERROR_CODE_INTERNAL_ERROR
2994 /// * RED_BRICK_ERROR_CODE_UNKNOWN_SESSION_ID
2995 /// * RED_BRICK_ERROR_CODE_NO_FREE_SESSION_ID
2996 /// * RED_BRICK_ERROR_CODE_UNKNOWN_OBJECT_ID
2997 /// * RED_BRICK_ERROR_CODE_NO_FREE_OBJECT_ID
2998 /// * RED_BRICK_ERROR_CODE_OBJECT_IS_LOCKED
2999 /// * RED_BRICK_ERROR_CODE_NO_MORE_DATA
3000 /// * RED_BRICK_ERROR_CODE_WRONG_LIST_ITEM_TYPE
3001 /// * RED_BRICK_ERROR_CODE_PROGRAM_IS_PURGED
3002 /// * RED_BRICK_ERROR_CODE_INVALID_PARAMETER
3003 /// * RED_BRICK_ERROR_CODE_NO_FREE_MEMORY
3004 /// * RED_BRICK_ERROR_CODE_NO_FREE_SPACE
3005 /// * RED_BRICK_ERROR_CODE_ACCESS_DENIED
3006 /// * RED_BRICK_ERROR_CODE_ALREADY_EXISTS
3007 /// * RED_BRICK_ERROR_CODE_DOES_NOT_EXIST
3008 /// * RED_BRICK_ERROR_CODE_INTERRUPTED
3009 /// * RED_BRICK_ERROR_CODE_IS_DIRECTORY
3010 /// * RED_BRICK_ERROR_CODE_NOT_A_DIRECTORY
3011 /// * RED_BRICK_ERROR_CODE_WOULD_BLOCK
3012 /// * RED_BRICK_ERROR_CODE_OVERFLOW
3013 /// * RED_BRICK_ERROR_CODE_BAD_FILE_DESCRIPTOR
3014 /// * RED_BRICK_ERROR_CODE_OUT_OF_RANGE
3015 /// * RED_BRICK_ERROR_CODE_NAME_TOO_LONG
3016 /// * RED_BRICK_ERROR_CODE_INVALID_SEEK
3017 /// * RED_BRICK_ERROR_CODE_NOT_SUPPORTED
3018 /// * RED_BRICK_ERROR_CODE_TOO_MANY_OPEN_FILES
3019 pub async fn get_process_identity(&mut self, process_id: u16) -> Result<ProcessIdentity, TinkerforgeError> {
3020 let mut payload = [0; 2];
3021 process_id.write_to_slice(&mut payload[0..2]);
3022
3023 #[allow(unused_variables)]
3024 let result = self.device.get(u8::from(RedBrickFunction::GetProcessIdentity), &payload).await?;
3025 Ok(ProcessIdentity::from_le_byte_slice(result.body()))
3026 }
3027
3028 /// Returns the stdin, stdout and stderr files used to spawn a process object, as
3029 /// passed to [`spawn_process`], and the resulting error code.
3030 ///
3031 /// Associated constants:
3032 /// * RED_BRICK_ERROR_CODE_SUCCESS
3033 /// * RED_BRICK_ERROR_CODE_UNKNOWN_ERROR
3034 /// * RED_BRICK_ERROR_CODE_INVALID_OPERATION
3035 /// * RED_BRICK_ERROR_CODE_OPERATION_ABORTED
3036 /// * RED_BRICK_ERROR_CODE_INTERNAL_ERROR
3037 /// * RED_BRICK_ERROR_CODE_UNKNOWN_SESSION_ID
3038 /// * RED_BRICK_ERROR_CODE_NO_FREE_SESSION_ID
3039 /// * RED_BRICK_ERROR_CODE_UNKNOWN_OBJECT_ID
3040 /// * RED_BRICK_ERROR_CODE_NO_FREE_OBJECT_ID
3041 /// * RED_BRICK_ERROR_CODE_OBJECT_IS_LOCKED
3042 /// * RED_BRICK_ERROR_CODE_NO_MORE_DATA
3043 /// * RED_BRICK_ERROR_CODE_WRONG_LIST_ITEM_TYPE
3044 /// * RED_BRICK_ERROR_CODE_PROGRAM_IS_PURGED
3045 /// * RED_BRICK_ERROR_CODE_INVALID_PARAMETER
3046 /// * RED_BRICK_ERROR_CODE_NO_FREE_MEMORY
3047 /// * RED_BRICK_ERROR_CODE_NO_FREE_SPACE
3048 /// * RED_BRICK_ERROR_CODE_ACCESS_DENIED
3049 /// * RED_BRICK_ERROR_CODE_ALREADY_EXISTS
3050 /// * RED_BRICK_ERROR_CODE_DOES_NOT_EXIST
3051 /// * RED_BRICK_ERROR_CODE_INTERRUPTED
3052 /// * RED_BRICK_ERROR_CODE_IS_DIRECTORY
3053 /// * RED_BRICK_ERROR_CODE_NOT_A_DIRECTORY
3054 /// * RED_BRICK_ERROR_CODE_WOULD_BLOCK
3055 /// * RED_BRICK_ERROR_CODE_OVERFLOW
3056 /// * RED_BRICK_ERROR_CODE_BAD_FILE_DESCRIPTOR
3057 /// * RED_BRICK_ERROR_CODE_OUT_OF_RANGE
3058 /// * RED_BRICK_ERROR_CODE_NAME_TOO_LONG
3059 /// * RED_BRICK_ERROR_CODE_INVALID_SEEK
3060 /// * RED_BRICK_ERROR_CODE_NOT_SUPPORTED
3061 /// * RED_BRICK_ERROR_CODE_TOO_MANY_OPEN_FILES
3062 pub async fn get_process_stdio(&mut self, process_id: u16, session_id: u16) -> Result<ProcessStdio, TinkerforgeError> {
3063 let mut payload = [0; 4];
3064 process_id.write_to_slice(&mut payload[0..2]);
3065 session_id.write_to_slice(&mut payload[2..4]);
3066
3067 #[allow(unused_variables)]
3068 let result = self.device.get(u8::from(RedBrickFunction::GetProcessStdio), &payload).await?;
3069 Ok(ProcessStdio::from_le_byte_slice(result.body()))
3070 }
3071
3072 /// Returns the current state, timestamp and exit code of a process object, and
3073 /// the resulting error code.
3074 ///
3075 /// Possible process states are:
3076 ///
3077 /// * Unknown = 0
3078 /// * Running = 1
3079 /// * Error = 2
3080 /// * Exited = 3
3081 /// * Killed = 4
3082 /// * Stopped = 5
3083 ///
3084 /// The timestamp represents the UNIX time since when the process is in its current
3085 /// state.
3086 ///
3087 /// The exit code is only valid if the state is *Error*, *Exited*, *Killed* or
3088 /// *Stopped* and has different meanings depending on the state:
3089 ///
3090 /// * Error: error code for error occurred while spawning the process (see below)
3091 /// * Exited: exit status of the process
3092 /// * Killed: UNIX signal number used to kill the process
3093 /// * Stopped: UNIX signal number used to stop the process
3094 ///
3095 /// Possible exit/error codes in *Error* state are:
3096 ///
3097 /// * InternalError = 125
3098 /// * CannotExecute = 126
3099 /// * DoesNotExist = 127
3100 ///
3101 /// The *CannotExecute* error can be caused by the executable being opened for
3102 /// writing.
3103 ///
3104 /// Associated constants:
3105 /// * RED_BRICK_ERROR_CODE_SUCCESS
3106 /// * RED_BRICK_ERROR_CODE_UNKNOWN_ERROR
3107 /// * RED_BRICK_ERROR_CODE_INVALID_OPERATION
3108 /// * RED_BRICK_ERROR_CODE_OPERATION_ABORTED
3109 /// * RED_BRICK_ERROR_CODE_INTERNAL_ERROR
3110 /// * RED_BRICK_ERROR_CODE_UNKNOWN_SESSION_ID
3111 /// * RED_BRICK_ERROR_CODE_NO_FREE_SESSION_ID
3112 /// * RED_BRICK_ERROR_CODE_UNKNOWN_OBJECT_ID
3113 /// * RED_BRICK_ERROR_CODE_NO_FREE_OBJECT_ID
3114 /// * RED_BRICK_ERROR_CODE_OBJECT_IS_LOCKED
3115 /// * RED_BRICK_ERROR_CODE_NO_MORE_DATA
3116 /// * RED_BRICK_ERROR_CODE_WRONG_LIST_ITEM_TYPE
3117 /// * RED_BRICK_ERROR_CODE_PROGRAM_IS_PURGED
3118 /// * RED_BRICK_ERROR_CODE_INVALID_PARAMETER
3119 /// * RED_BRICK_ERROR_CODE_NO_FREE_MEMORY
3120 /// * RED_BRICK_ERROR_CODE_NO_FREE_SPACE
3121 /// * RED_BRICK_ERROR_CODE_ACCESS_DENIED
3122 /// * RED_BRICK_ERROR_CODE_ALREADY_EXISTS
3123 /// * RED_BRICK_ERROR_CODE_DOES_NOT_EXIST
3124 /// * RED_BRICK_ERROR_CODE_INTERRUPTED
3125 /// * RED_BRICK_ERROR_CODE_IS_DIRECTORY
3126 /// * RED_BRICK_ERROR_CODE_NOT_A_DIRECTORY
3127 /// * RED_BRICK_ERROR_CODE_WOULD_BLOCK
3128 /// * RED_BRICK_ERROR_CODE_OVERFLOW
3129 /// * RED_BRICK_ERROR_CODE_BAD_FILE_DESCRIPTOR
3130 /// * RED_BRICK_ERROR_CODE_OUT_OF_RANGE
3131 /// * RED_BRICK_ERROR_CODE_NAME_TOO_LONG
3132 /// * RED_BRICK_ERROR_CODE_INVALID_SEEK
3133 /// * RED_BRICK_ERROR_CODE_NOT_SUPPORTED
3134 /// * RED_BRICK_ERROR_CODE_TOO_MANY_OPEN_FILES
3135 /// * RED_BRICK_PROCESS_STATE_UNKNOWN
3136 /// * RED_BRICK_PROCESS_STATE_RUNNING
3137 /// * RED_BRICK_PROCESS_STATE_ERROR
3138 /// * RED_BRICK_PROCESS_STATE_EXITED
3139 /// * RED_BRICK_PROCESS_STATE_KILLED
3140 /// * RED_BRICK_PROCESS_STATE_STOPPED
3141 pub async fn get_process_state(&mut self, process_id: u16) -> Result<ProcessState, TinkerforgeError> {
3142 let mut payload = [0; 2];
3143 process_id.write_to_slice(&mut payload[0..2]);
3144
3145 #[allow(unused_variables)]
3146 let result = self.device.get(u8::from(RedBrickFunction::GetProcessState), &payload).await?;
3147 Ok(ProcessState::from_le_byte_slice(result.body()))
3148 }
3149
3150 ///
3151 ///
3152 /// Associated constants:
3153 /// * RED_BRICK_ERROR_CODE_SUCCESS
3154 /// * RED_BRICK_ERROR_CODE_UNKNOWN_ERROR
3155 /// * RED_BRICK_ERROR_CODE_INVALID_OPERATION
3156 /// * RED_BRICK_ERROR_CODE_OPERATION_ABORTED
3157 /// * RED_BRICK_ERROR_CODE_INTERNAL_ERROR
3158 /// * RED_BRICK_ERROR_CODE_UNKNOWN_SESSION_ID
3159 /// * RED_BRICK_ERROR_CODE_NO_FREE_SESSION_ID
3160 /// * RED_BRICK_ERROR_CODE_UNKNOWN_OBJECT_ID
3161 /// * RED_BRICK_ERROR_CODE_NO_FREE_OBJECT_ID
3162 /// * RED_BRICK_ERROR_CODE_OBJECT_IS_LOCKED
3163 /// * RED_BRICK_ERROR_CODE_NO_MORE_DATA
3164 /// * RED_BRICK_ERROR_CODE_WRONG_LIST_ITEM_TYPE
3165 /// * RED_BRICK_ERROR_CODE_PROGRAM_IS_PURGED
3166 /// * RED_BRICK_ERROR_CODE_INVALID_PARAMETER
3167 /// * RED_BRICK_ERROR_CODE_NO_FREE_MEMORY
3168 /// * RED_BRICK_ERROR_CODE_NO_FREE_SPACE
3169 /// * RED_BRICK_ERROR_CODE_ACCESS_DENIED
3170 /// * RED_BRICK_ERROR_CODE_ALREADY_EXISTS
3171 /// * RED_BRICK_ERROR_CODE_DOES_NOT_EXIST
3172 /// * RED_BRICK_ERROR_CODE_INTERRUPTED
3173 /// * RED_BRICK_ERROR_CODE_IS_DIRECTORY
3174 /// * RED_BRICK_ERROR_CODE_NOT_A_DIRECTORY
3175 /// * RED_BRICK_ERROR_CODE_WOULD_BLOCK
3176 /// * RED_BRICK_ERROR_CODE_OVERFLOW
3177 /// * RED_BRICK_ERROR_CODE_BAD_FILE_DESCRIPTOR
3178 /// * RED_BRICK_ERROR_CODE_OUT_OF_RANGE
3179 /// * RED_BRICK_ERROR_CODE_NAME_TOO_LONG
3180 /// * RED_BRICK_ERROR_CODE_INVALID_SEEK
3181 /// * RED_BRICK_ERROR_CODE_NOT_SUPPORTED
3182 /// * RED_BRICK_ERROR_CODE_TOO_MANY_OPEN_FILES
3183 pub async fn get_programs(&mut self, session_id: u16) -> Result<Programs, TinkerforgeError> {
3184 let mut payload = [0; 2];
3185 session_id.write_to_slice(&mut payload[0..2]);
3186
3187 #[allow(unused_variables)]
3188 let result = self.device.get(u8::from(RedBrickFunction::GetPrograms), &payload).await?;
3189 Ok(Programs::from_le_byte_slice(result.body()))
3190 }
3191
3192 ///
3193 ///
3194 /// Associated constants:
3195 /// * RED_BRICK_ERROR_CODE_SUCCESS
3196 /// * RED_BRICK_ERROR_CODE_UNKNOWN_ERROR
3197 /// * RED_BRICK_ERROR_CODE_INVALID_OPERATION
3198 /// * RED_BRICK_ERROR_CODE_OPERATION_ABORTED
3199 /// * RED_BRICK_ERROR_CODE_INTERNAL_ERROR
3200 /// * RED_BRICK_ERROR_CODE_UNKNOWN_SESSION_ID
3201 /// * RED_BRICK_ERROR_CODE_NO_FREE_SESSION_ID
3202 /// * RED_BRICK_ERROR_CODE_UNKNOWN_OBJECT_ID
3203 /// * RED_BRICK_ERROR_CODE_NO_FREE_OBJECT_ID
3204 /// * RED_BRICK_ERROR_CODE_OBJECT_IS_LOCKED
3205 /// * RED_BRICK_ERROR_CODE_NO_MORE_DATA
3206 /// * RED_BRICK_ERROR_CODE_WRONG_LIST_ITEM_TYPE
3207 /// * RED_BRICK_ERROR_CODE_PROGRAM_IS_PURGED
3208 /// * RED_BRICK_ERROR_CODE_INVALID_PARAMETER
3209 /// * RED_BRICK_ERROR_CODE_NO_FREE_MEMORY
3210 /// * RED_BRICK_ERROR_CODE_NO_FREE_SPACE
3211 /// * RED_BRICK_ERROR_CODE_ACCESS_DENIED
3212 /// * RED_BRICK_ERROR_CODE_ALREADY_EXISTS
3213 /// * RED_BRICK_ERROR_CODE_DOES_NOT_EXIST
3214 /// * RED_BRICK_ERROR_CODE_INTERRUPTED
3215 /// * RED_BRICK_ERROR_CODE_IS_DIRECTORY
3216 /// * RED_BRICK_ERROR_CODE_NOT_A_DIRECTORY
3217 /// * RED_BRICK_ERROR_CODE_WOULD_BLOCK
3218 /// * RED_BRICK_ERROR_CODE_OVERFLOW
3219 /// * RED_BRICK_ERROR_CODE_BAD_FILE_DESCRIPTOR
3220 /// * RED_BRICK_ERROR_CODE_OUT_OF_RANGE
3221 /// * RED_BRICK_ERROR_CODE_NAME_TOO_LONG
3222 /// * RED_BRICK_ERROR_CODE_INVALID_SEEK
3223 /// * RED_BRICK_ERROR_CODE_NOT_SUPPORTED
3224 /// * RED_BRICK_ERROR_CODE_TOO_MANY_OPEN_FILES
3225 pub async fn define_program(&mut self, identifier_string_id: u16, session_id: u16) -> Result<DefineProgram, TinkerforgeError> {
3226 let mut payload = [0; 4];
3227 identifier_string_id.write_to_slice(&mut payload[0..2]);
3228 session_id.write_to_slice(&mut payload[2..4]);
3229
3230 #[allow(unused_variables)]
3231 let result = self.device.get(u8::from(RedBrickFunction::DefineProgram), &payload).await?;
3232 Ok(DefineProgram::from_le_byte_slice(result.body()))
3233 }
3234
3235 ///
3236 ///
3237 /// Associated constants:
3238 /// * RED_BRICK_ERROR_CODE_SUCCESS
3239 /// * RED_BRICK_ERROR_CODE_UNKNOWN_ERROR
3240 /// * RED_BRICK_ERROR_CODE_INVALID_OPERATION
3241 /// * RED_BRICK_ERROR_CODE_OPERATION_ABORTED
3242 /// * RED_BRICK_ERROR_CODE_INTERNAL_ERROR
3243 /// * RED_BRICK_ERROR_CODE_UNKNOWN_SESSION_ID
3244 /// * RED_BRICK_ERROR_CODE_NO_FREE_SESSION_ID
3245 /// * RED_BRICK_ERROR_CODE_UNKNOWN_OBJECT_ID
3246 /// * RED_BRICK_ERROR_CODE_NO_FREE_OBJECT_ID
3247 /// * RED_BRICK_ERROR_CODE_OBJECT_IS_LOCKED
3248 /// * RED_BRICK_ERROR_CODE_NO_MORE_DATA
3249 /// * RED_BRICK_ERROR_CODE_WRONG_LIST_ITEM_TYPE
3250 /// * RED_BRICK_ERROR_CODE_PROGRAM_IS_PURGED
3251 /// * RED_BRICK_ERROR_CODE_INVALID_PARAMETER
3252 /// * RED_BRICK_ERROR_CODE_NO_FREE_MEMORY
3253 /// * RED_BRICK_ERROR_CODE_NO_FREE_SPACE
3254 /// * RED_BRICK_ERROR_CODE_ACCESS_DENIED
3255 /// * RED_BRICK_ERROR_CODE_ALREADY_EXISTS
3256 /// * RED_BRICK_ERROR_CODE_DOES_NOT_EXIST
3257 /// * RED_BRICK_ERROR_CODE_INTERRUPTED
3258 /// * RED_BRICK_ERROR_CODE_IS_DIRECTORY
3259 /// * RED_BRICK_ERROR_CODE_NOT_A_DIRECTORY
3260 /// * RED_BRICK_ERROR_CODE_WOULD_BLOCK
3261 /// * RED_BRICK_ERROR_CODE_OVERFLOW
3262 /// * RED_BRICK_ERROR_CODE_BAD_FILE_DESCRIPTOR
3263 /// * RED_BRICK_ERROR_CODE_OUT_OF_RANGE
3264 /// * RED_BRICK_ERROR_CODE_NAME_TOO_LONG
3265 /// * RED_BRICK_ERROR_CODE_INVALID_SEEK
3266 /// * RED_BRICK_ERROR_CODE_NOT_SUPPORTED
3267 /// * RED_BRICK_ERROR_CODE_TOO_MANY_OPEN_FILES
3268 pub async fn purge_program(&mut self, program_id: u16, cookie: u32) -> Result<u8, TinkerforgeError> {
3269 let mut payload = [0; 6];
3270 program_id.write_to_slice(&mut payload[0..2]);
3271 cookie.write_to_slice(&mut payload[2..6]);
3272
3273 #[allow(unused_variables)]
3274 let result = self.device.get(u8::from(RedBrickFunction::PurgeProgram), &payload).await?;
3275 Ok(u8::from_le_byte_slice(result.body()))
3276 }
3277
3278 ///
3279 ///
3280 /// Associated constants:
3281 /// * RED_BRICK_ERROR_CODE_SUCCESS
3282 /// * RED_BRICK_ERROR_CODE_UNKNOWN_ERROR
3283 /// * RED_BRICK_ERROR_CODE_INVALID_OPERATION
3284 /// * RED_BRICK_ERROR_CODE_OPERATION_ABORTED
3285 /// * RED_BRICK_ERROR_CODE_INTERNAL_ERROR
3286 /// * RED_BRICK_ERROR_CODE_UNKNOWN_SESSION_ID
3287 /// * RED_BRICK_ERROR_CODE_NO_FREE_SESSION_ID
3288 /// * RED_BRICK_ERROR_CODE_UNKNOWN_OBJECT_ID
3289 /// * RED_BRICK_ERROR_CODE_NO_FREE_OBJECT_ID
3290 /// * RED_BRICK_ERROR_CODE_OBJECT_IS_LOCKED
3291 /// * RED_BRICK_ERROR_CODE_NO_MORE_DATA
3292 /// * RED_BRICK_ERROR_CODE_WRONG_LIST_ITEM_TYPE
3293 /// * RED_BRICK_ERROR_CODE_PROGRAM_IS_PURGED
3294 /// * RED_BRICK_ERROR_CODE_INVALID_PARAMETER
3295 /// * RED_BRICK_ERROR_CODE_NO_FREE_MEMORY
3296 /// * RED_BRICK_ERROR_CODE_NO_FREE_SPACE
3297 /// * RED_BRICK_ERROR_CODE_ACCESS_DENIED
3298 /// * RED_BRICK_ERROR_CODE_ALREADY_EXISTS
3299 /// * RED_BRICK_ERROR_CODE_DOES_NOT_EXIST
3300 /// * RED_BRICK_ERROR_CODE_INTERRUPTED
3301 /// * RED_BRICK_ERROR_CODE_IS_DIRECTORY
3302 /// * RED_BRICK_ERROR_CODE_NOT_A_DIRECTORY
3303 /// * RED_BRICK_ERROR_CODE_WOULD_BLOCK
3304 /// * RED_BRICK_ERROR_CODE_OVERFLOW
3305 /// * RED_BRICK_ERROR_CODE_BAD_FILE_DESCRIPTOR
3306 /// * RED_BRICK_ERROR_CODE_OUT_OF_RANGE
3307 /// * RED_BRICK_ERROR_CODE_NAME_TOO_LONG
3308 /// * RED_BRICK_ERROR_CODE_INVALID_SEEK
3309 /// * RED_BRICK_ERROR_CODE_NOT_SUPPORTED
3310 /// * RED_BRICK_ERROR_CODE_TOO_MANY_OPEN_FILES
3311 pub async fn get_program_identifier(&mut self, program_id: u16, session_id: u16) -> Result<ProgramIdentifier, TinkerforgeError> {
3312 let mut payload = [0; 4];
3313 program_id.write_to_slice(&mut payload[0..2]);
3314 session_id.write_to_slice(&mut payload[2..4]);
3315
3316 #[allow(unused_variables)]
3317 let result = self.device.get(u8::from(RedBrickFunction::GetProgramIdentifier), &payload).await?;
3318 Ok(ProgramIdentifier::from_le_byte_slice(result.body()))
3319 }
3320
3321 /// FIXME: root directory is absolute: <home>/programs/<identifier>
3322 ///
3323 /// Associated constants:
3324 /// * RED_BRICK_ERROR_CODE_SUCCESS
3325 /// * RED_BRICK_ERROR_CODE_UNKNOWN_ERROR
3326 /// * RED_BRICK_ERROR_CODE_INVALID_OPERATION
3327 /// * RED_BRICK_ERROR_CODE_OPERATION_ABORTED
3328 /// * RED_BRICK_ERROR_CODE_INTERNAL_ERROR
3329 /// * RED_BRICK_ERROR_CODE_UNKNOWN_SESSION_ID
3330 /// * RED_BRICK_ERROR_CODE_NO_FREE_SESSION_ID
3331 /// * RED_BRICK_ERROR_CODE_UNKNOWN_OBJECT_ID
3332 /// * RED_BRICK_ERROR_CODE_NO_FREE_OBJECT_ID
3333 /// * RED_BRICK_ERROR_CODE_OBJECT_IS_LOCKED
3334 /// * RED_BRICK_ERROR_CODE_NO_MORE_DATA
3335 /// * RED_BRICK_ERROR_CODE_WRONG_LIST_ITEM_TYPE
3336 /// * RED_BRICK_ERROR_CODE_PROGRAM_IS_PURGED
3337 /// * RED_BRICK_ERROR_CODE_INVALID_PARAMETER
3338 /// * RED_BRICK_ERROR_CODE_NO_FREE_MEMORY
3339 /// * RED_BRICK_ERROR_CODE_NO_FREE_SPACE
3340 /// * RED_BRICK_ERROR_CODE_ACCESS_DENIED
3341 /// * RED_BRICK_ERROR_CODE_ALREADY_EXISTS
3342 /// * RED_BRICK_ERROR_CODE_DOES_NOT_EXIST
3343 /// * RED_BRICK_ERROR_CODE_INTERRUPTED
3344 /// * RED_BRICK_ERROR_CODE_IS_DIRECTORY
3345 /// * RED_BRICK_ERROR_CODE_NOT_A_DIRECTORY
3346 /// * RED_BRICK_ERROR_CODE_WOULD_BLOCK
3347 /// * RED_BRICK_ERROR_CODE_OVERFLOW
3348 /// * RED_BRICK_ERROR_CODE_BAD_FILE_DESCRIPTOR
3349 /// * RED_BRICK_ERROR_CODE_OUT_OF_RANGE
3350 /// * RED_BRICK_ERROR_CODE_NAME_TOO_LONG
3351 /// * RED_BRICK_ERROR_CODE_INVALID_SEEK
3352 /// * RED_BRICK_ERROR_CODE_NOT_SUPPORTED
3353 /// * RED_BRICK_ERROR_CODE_TOO_MANY_OPEN_FILES
3354 pub async fn get_program_root_directory(&mut self, program_id: u16, session_id: u16) -> Result<ProgramRootDirectory, TinkerforgeError> {
3355 let mut payload = [0; 4];
3356 program_id.write_to_slice(&mut payload[0..2]);
3357 session_id.write_to_slice(&mut payload[2..4]);
3358
3359 #[allow(unused_variables)]
3360 let result = self.device.get(u8::from(RedBrickFunction::GetProgramRootDirectory), &payload).await?;
3361 Ok(ProgramRootDirectory::from_le_byte_slice(result.body()))
3362 }
3363
3364 /// FIXME: working directory is relative to <home>/programs/<identifier>/bin
3365 ///
3366 /// Associated constants:
3367 /// * RED_BRICK_ERROR_CODE_SUCCESS
3368 /// * RED_BRICK_ERROR_CODE_UNKNOWN_ERROR
3369 /// * RED_BRICK_ERROR_CODE_INVALID_OPERATION
3370 /// * RED_BRICK_ERROR_CODE_OPERATION_ABORTED
3371 /// * RED_BRICK_ERROR_CODE_INTERNAL_ERROR
3372 /// * RED_BRICK_ERROR_CODE_UNKNOWN_SESSION_ID
3373 /// * RED_BRICK_ERROR_CODE_NO_FREE_SESSION_ID
3374 /// * RED_BRICK_ERROR_CODE_UNKNOWN_OBJECT_ID
3375 /// * RED_BRICK_ERROR_CODE_NO_FREE_OBJECT_ID
3376 /// * RED_BRICK_ERROR_CODE_OBJECT_IS_LOCKED
3377 /// * RED_BRICK_ERROR_CODE_NO_MORE_DATA
3378 /// * RED_BRICK_ERROR_CODE_WRONG_LIST_ITEM_TYPE
3379 /// * RED_BRICK_ERROR_CODE_PROGRAM_IS_PURGED
3380 /// * RED_BRICK_ERROR_CODE_INVALID_PARAMETER
3381 /// * RED_BRICK_ERROR_CODE_NO_FREE_MEMORY
3382 /// * RED_BRICK_ERROR_CODE_NO_FREE_SPACE
3383 /// * RED_BRICK_ERROR_CODE_ACCESS_DENIED
3384 /// * RED_BRICK_ERROR_CODE_ALREADY_EXISTS
3385 /// * RED_BRICK_ERROR_CODE_DOES_NOT_EXIST
3386 /// * RED_BRICK_ERROR_CODE_INTERRUPTED
3387 /// * RED_BRICK_ERROR_CODE_IS_DIRECTORY
3388 /// * RED_BRICK_ERROR_CODE_NOT_A_DIRECTORY
3389 /// * RED_BRICK_ERROR_CODE_WOULD_BLOCK
3390 /// * RED_BRICK_ERROR_CODE_OVERFLOW
3391 /// * RED_BRICK_ERROR_CODE_BAD_FILE_DESCRIPTOR
3392 /// * RED_BRICK_ERROR_CODE_OUT_OF_RANGE
3393 /// * RED_BRICK_ERROR_CODE_NAME_TOO_LONG
3394 /// * RED_BRICK_ERROR_CODE_INVALID_SEEK
3395 /// * RED_BRICK_ERROR_CODE_NOT_SUPPORTED
3396 /// * RED_BRICK_ERROR_CODE_TOO_MANY_OPEN_FILES
3397 pub async fn set_program_command(
3398 &mut self,
3399 program_id: u16,
3400 executable_string_id: u16,
3401 arguments_list_id: u16,
3402 environment_list_id: u16,
3403 working_directory_string_id: u16,
3404 ) -> Result<u8, TinkerforgeError> {
3405 let mut payload = [0; 10];
3406 program_id.write_to_slice(&mut payload[0..2]);
3407 executable_string_id.write_to_slice(&mut payload[2..4]);
3408 arguments_list_id.write_to_slice(&mut payload[4..6]);
3409 environment_list_id.write_to_slice(&mut payload[6..8]);
3410 working_directory_string_id.write_to_slice(&mut payload[8..10]);
3411
3412 #[allow(unused_variables)]
3413 let result = self.device.get(u8::from(RedBrickFunction::SetProgramCommand), &payload).await?;
3414 Ok(u8::from_le_byte_slice(result.body()))
3415 }
3416
3417 /// FIXME: working directory is relative to <home>/programs/<identifier>/bin
3418 ///
3419 /// Associated constants:
3420 /// * RED_BRICK_ERROR_CODE_SUCCESS
3421 /// * RED_BRICK_ERROR_CODE_UNKNOWN_ERROR
3422 /// * RED_BRICK_ERROR_CODE_INVALID_OPERATION
3423 /// * RED_BRICK_ERROR_CODE_OPERATION_ABORTED
3424 /// * RED_BRICK_ERROR_CODE_INTERNAL_ERROR
3425 /// * RED_BRICK_ERROR_CODE_UNKNOWN_SESSION_ID
3426 /// * RED_BRICK_ERROR_CODE_NO_FREE_SESSION_ID
3427 /// * RED_BRICK_ERROR_CODE_UNKNOWN_OBJECT_ID
3428 /// * RED_BRICK_ERROR_CODE_NO_FREE_OBJECT_ID
3429 /// * RED_BRICK_ERROR_CODE_OBJECT_IS_LOCKED
3430 /// * RED_BRICK_ERROR_CODE_NO_MORE_DATA
3431 /// * RED_BRICK_ERROR_CODE_WRONG_LIST_ITEM_TYPE
3432 /// * RED_BRICK_ERROR_CODE_PROGRAM_IS_PURGED
3433 /// * RED_BRICK_ERROR_CODE_INVALID_PARAMETER
3434 /// * RED_BRICK_ERROR_CODE_NO_FREE_MEMORY
3435 /// * RED_BRICK_ERROR_CODE_NO_FREE_SPACE
3436 /// * RED_BRICK_ERROR_CODE_ACCESS_DENIED
3437 /// * RED_BRICK_ERROR_CODE_ALREADY_EXISTS
3438 /// * RED_BRICK_ERROR_CODE_DOES_NOT_EXIST
3439 /// * RED_BRICK_ERROR_CODE_INTERRUPTED
3440 /// * RED_BRICK_ERROR_CODE_IS_DIRECTORY
3441 /// * RED_BRICK_ERROR_CODE_NOT_A_DIRECTORY
3442 /// * RED_BRICK_ERROR_CODE_WOULD_BLOCK
3443 /// * RED_BRICK_ERROR_CODE_OVERFLOW
3444 /// * RED_BRICK_ERROR_CODE_BAD_FILE_DESCRIPTOR
3445 /// * RED_BRICK_ERROR_CODE_OUT_OF_RANGE
3446 /// * RED_BRICK_ERROR_CODE_NAME_TOO_LONG
3447 /// * RED_BRICK_ERROR_CODE_INVALID_SEEK
3448 /// * RED_BRICK_ERROR_CODE_NOT_SUPPORTED
3449 /// * RED_BRICK_ERROR_CODE_TOO_MANY_OPEN_FILES
3450 pub async fn get_program_command(&mut self, program_id: u16, session_id: u16) -> Result<ProgramCommand, TinkerforgeError> {
3451 let mut payload = [0; 4];
3452 program_id.write_to_slice(&mut payload[0..2]);
3453 session_id.write_to_slice(&mut payload[2..4]);
3454
3455 #[allow(unused_variables)]
3456 let result = self.device.get(u8::from(RedBrickFunction::GetProgramCommand), &payload).await?;
3457 Ok(ProgramCommand::from_le_byte_slice(result.body()))
3458 }
3459
3460 /// FIXME: stdio file names are relative to <home>/programs/<identifier>/bin
3461 ///
3462 /// Associated constants:
3463 /// * RED_BRICK_PROGRAM_STDIO_REDIRECTION_DEV_NULL
3464 /// * RED_BRICK_PROGRAM_STDIO_REDIRECTION_PIPE
3465 /// * RED_BRICK_PROGRAM_STDIO_REDIRECTION_FILE
3466 /// * RED_BRICK_PROGRAM_STDIO_REDIRECTION_INDIVIDUAL_LOG
3467 /// * RED_BRICK_PROGRAM_STDIO_REDIRECTION_CONTINUOUS_LOG
3468 /// * RED_BRICK_PROGRAM_STDIO_REDIRECTION_STDOUT
3469 /// * RED_BRICK_ERROR_CODE_SUCCESS
3470 /// * RED_BRICK_ERROR_CODE_UNKNOWN_ERROR
3471 /// * RED_BRICK_ERROR_CODE_INVALID_OPERATION
3472 /// * RED_BRICK_ERROR_CODE_OPERATION_ABORTED
3473 /// * RED_BRICK_ERROR_CODE_INTERNAL_ERROR
3474 /// * RED_BRICK_ERROR_CODE_UNKNOWN_SESSION_ID
3475 /// * RED_BRICK_ERROR_CODE_NO_FREE_SESSION_ID
3476 /// * RED_BRICK_ERROR_CODE_UNKNOWN_OBJECT_ID
3477 /// * RED_BRICK_ERROR_CODE_NO_FREE_OBJECT_ID
3478 /// * RED_BRICK_ERROR_CODE_OBJECT_IS_LOCKED
3479 /// * RED_BRICK_ERROR_CODE_NO_MORE_DATA
3480 /// * RED_BRICK_ERROR_CODE_WRONG_LIST_ITEM_TYPE
3481 /// * RED_BRICK_ERROR_CODE_PROGRAM_IS_PURGED
3482 /// * RED_BRICK_ERROR_CODE_INVALID_PARAMETER
3483 /// * RED_BRICK_ERROR_CODE_NO_FREE_MEMORY
3484 /// * RED_BRICK_ERROR_CODE_NO_FREE_SPACE
3485 /// * RED_BRICK_ERROR_CODE_ACCESS_DENIED
3486 /// * RED_BRICK_ERROR_CODE_ALREADY_EXISTS
3487 /// * RED_BRICK_ERROR_CODE_DOES_NOT_EXIST
3488 /// * RED_BRICK_ERROR_CODE_INTERRUPTED
3489 /// * RED_BRICK_ERROR_CODE_IS_DIRECTORY
3490 /// * RED_BRICK_ERROR_CODE_NOT_A_DIRECTORY
3491 /// * RED_BRICK_ERROR_CODE_WOULD_BLOCK
3492 /// * RED_BRICK_ERROR_CODE_OVERFLOW
3493 /// * RED_BRICK_ERROR_CODE_BAD_FILE_DESCRIPTOR
3494 /// * RED_BRICK_ERROR_CODE_OUT_OF_RANGE
3495 /// * RED_BRICK_ERROR_CODE_NAME_TOO_LONG
3496 /// * RED_BRICK_ERROR_CODE_INVALID_SEEK
3497 /// * RED_BRICK_ERROR_CODE_NOT_SUPPORTED
3498 /// * RED_BRICK_ERROR_CODE_TOO_MANY_OPEN_FILES
3499 pub async fn set_program_stdio_redirection(
3500 &mut self,
3501 program_id: u16,
3502 stdin_redirection: u8,
3503 stdin_file_name_string_id: u16,
3504 stdout_redirection: u8,
3505 stdout_file_name_string_id: u16,
3506 stderr_redirection: u8,
3507 stderr_file_name_string_id: u16,
3508 ) -> Result<u8, TinkerforgeError> {
3509 let mut payload = [0; 11];
3510 program_id.write_to_slice(&mut payload[0..2]);
3511 stdin_redirection.write_to_slice(&mut payload[2..3]);
3512 stdin_file_name_string_id.write_to_slice(&mut payload[3..5]);
3513 stdout_redirection.write_to_slice(&mut payload[5..6]);
3514 stdout_file_name_string_id.write_to_slice(&mut payload[6..8]);
3515 stderr_redirection.write_to_slice(&mut payload[8..9]);
3516 stderr_file_name_string_id.write_to_slice(&mut payload[9..11]);
3517
3518 #[allow(unused_variables)]
3519 let result = self.device.get(u8::from(RedBrickFunction::SetProgramStdioRedirection), &payload).await?;
3520 Ok(u8::from_le_byte_slice(result.body()))
3521 }
3522
3523 /// FIXME: stdio file names are relative to <home>/programs/<identifier>/bin
3524 ///
3525 /// Associated constants:
3526 /// * RED_BRICK_ERROR_CODE_SUCCESS
3527 /// * RED_BRICK_ERROR_CODE_UNKNOWN_ERROR
3528 /// * RED_BRICK_ERROR_CODE_INVALID_OPERATION
3529 /// * RED_BRICK_ERROR_CODE_OPERATION_ABORTED
3530 /// * RED_BRICK_ERROR_CODE_INTERNAL_ERROR
3531 /// * RED_BRICK_ERROR_CODE_UNKNOWN_SESSION_ID
3532 /// * RED_BRICK_ERROR_CODE_NO_FREE_SESSION_ID
3533 /// * RED_BRICK_ERROR_CODE_UNKNOWN_OBJECT_ID
3534 /// * RED_BRICK_ERROR_CODE_NO_FREE_OBJECT_ID
3535 /// * RED_BRICK_ERROR_CODE_OBJECT_IS_LOCKED
3536 /// * RED_BRICK_ERROR_CODE_NO_MORE_DATA
3537 /// * RED_BRICK_ERROR_CODE_WRONG_LIST_ITEM_TYPE
3538 /// * RED_BRICK_ERROR_CODE_PROGRAM_IS_PURGED
3539 /// * RED_BRICK_ERROR_CODE_INVALID_PARAMETER
3540 /// * RED_BRICK_ERROR_CODE_NO_FREE_MEMORY
3541 /// * RED_BRICK_ERROR_CODE_NO_FREE_SPACE
3542 /// * RED_BRICK_ERROR_CODE_ACCESS_DENIED
3543 /// * RED_BRICK_ERROR_CODE_ALREADY_EXISTS
3544 /// * RED_BRICK_ERROR_CODE_DOES_NOT_EXIST
3545 /// * RED_BRICK_ERROR_CODE_INTERRUPTED
3546 /// * RED_BRICK_ERROR_CODE_IS_DIRECTORY
3547 /// * RED_BRICK_ERROR_CODE_NOT_A_DIRECTORY
3548 /// * RED_BRICK_ERROR_CODE_WOULD_BLOCK
3549 /// * RED_BRICK_ERROR_CODE_OVERFLOW
3550 /// * RED_BRICK_ERROR_CODE_BAD_FILE_DESCRIPTOR
3551 /// * RED_BRICK_ERROR_CODE_OUT_OF_RANGE
3552 /// * RED_BRICK_ERROR_CODE_NAME_TOO_LONG
3553 /// * RED_BRICK_ERROR_CODE_INVALID_SEEK
3554 /// * RED_BRICK_ERROR_CODE_NOT_SUPPORTED
3555 /// * RED_BRICK_ERROR_CODE_TOO_MANY_OPEN_FILES
3556 /// * RED_BRICK_PROGRAM_STDIO_REDIRECTION_DEV_NULL
3557 /// * RED_BRICK_PROGRAM_STDIO_REDIRECTION_PIPE
3558 /// * RED_BRICK_PROGRAM_STDIO_REDIRECTION_FILE
3559 /// * RED_BRICK_PROGRAM_STDIO_REDIRECTION_INDIVIDUAL_LOG
3560 /// * RED_BRICK_PROGRAM_STDIO_REDIRECTION_CONTINUOUS_LOG
3561 /// * RED_BRICK_PROGRAM_STDIO_REDIRECTION_STDOUT
3562 pub async fn get_program_stdio_redirection(
3563 &mut self,
3564 program_id: u16,
3565 session_id: u16,
3566 ) -> Result<ProgramStdioRedirection, TinkerforgeError> {
3567 let mut payload = [0; 4];
3568 program_id.write_to_slice(&mut payload[0..2]);
3569 session_id.write_to_slice(&mut payload[2..4]);
3570
3571 #[allow(unused_variables)]
3572 let result = self.device.get(u8::from(RedBrickFunction::GetProgramStdioRedirection), &payload).await?;
3573 Ok(ProgramStdioRedirection::from_le_byte_slice(result.body()))
3574 }
3575
3576 ///
3577 ///
3578 /// Associated constants:
3579 /// * RED_BRICK_PROGRAM_START_MODE_NEVER
3580 /// * RED_BRICK_PROGRAM_START_MODE_ALWAYS
3581 /// * RED_BRICK_PROGRAM_START_MODE_INTERVAL
3582 /// * RED_BRICK_PROGRAM_START_MODE_CRON
3583 /// * RED_BRICK_ERROR_CODE_SUCCESS
3584 /// * RED_BRICK_ERROR_CODE_UNKNOWN_ERROR
3585 /// * RED_BRICK_ERROR_CODE_INVALID_OPERATION
3586 /// * RED_BRICK_ERROR_CODE_OPERATION_ABORTED
3587 /// * RED_BRICK_ERROR_CODE_INTERNAL_ERROR
3588 /// * RED_BRICK_ERROR_CODE_UNKNOWN_SESSION_ID
3589 /// * RED_BRICK_ERROR_CODE_NO_FREE_SESSION_ID
3590 /// * RED_BRICK_ERROR_CODE_UNKNOWN_OBJECT_ID
3591 /// * RED_BRICK_ERROR_CODE_NO_FREE_OBJECT_ID
3592 /// * RED_BRICK_ERROR_CODE_OBJECT_IS_LOCKED
3593 /// * RED_BRICK_ERROR_CODE_NO_MORE_DATA
3594 /// * RED_BRICK_ERROR_CODE_WRONG_LIST_ITEM_TYPE
3595 /// * RED_BRICK_ERROR_CODE_PROGRAM_IS_PURGED
3596 /// * RED_BRICK_ERROR_CODE_INVALID_PARAMETER
3597 /// * RED_BRICK_ERROR_CODE_NO_FREE_MEMORY
3598 /// * RED_BRICK_ERROR_CODE_NO_FREE_SPACE
3599 /// * RED_BRICK_ERROR_CODE_ACCESS_DENIED
3600 /// * RED_BRICK_ERROR_CODE_ALREADY_EXISTS
3601 /// * RED_BRICK_ERROR_CODE_DOES_NOT_EXIST
3602 /// * RED_BRICK_ERROR_CODE_INTERRUPTED
3603 /// * RED_BRICK_ERROR_CODE_IS_DIRECTORY
3604 /// * RED_BRICK_ERROR_CODE_NOT_A_DIRECTORY
3605 /// * RED_BRICK_ERROR_CODE_WOULD_BLOCK
3606 /// * RED_BRICK_ERROR_CODE_OVERFLOW
3607 /// * RED_BRICK_ERROR_CODE_BAD_FILE_DESCRIPTOR
3608 /// * RED_BRICK_ERROR_CODE_OUT_OF_RANGE
3609 /// * RED_BRICK_ERROR_CODE_NAME_TOO_LONG
3610 /// * RED_BRICK_ERROR_CODE_INVALID_SEEK
3611 /// * RED_BRICK_ERROR_CODE_NOT_SUPPORTED
3612 /// * RED_BRICK_ERROR_CODE_TOO_MANY_OPEN_FILES
3613 pub async fn set_program_schedule(
3614 &mut self,
3615 program_id: u16,
3616 start_mode: u8,
3617 continue_after_error: bool,
3618 start_interval: u32,
3619 start_fields_string_id: u16,
3620 ) -> Result<u8, TinkerforgeError> {
3621 let mut payload = [0; 10];
3622 program_id.write_to_slice(&mut payload[0..2]);
3623 start_mode.write_to_slice(&mut payload[2..3]);
3624 continue_after_error.write_to_slice(&mut payload[3..4]);
3625 start_interval.write_to_slice(&mut payload[4..8]);
3626 start_fields_string_id.write_to_slice(&mut payload[8..10]);
3627
3628 #[allow(unused_variables)]
3629 let result = self.device.get(u8::from(RedBrickFunction::SetProgramSchedule), &payload).await?;
3630 Ok(u8::from_le_byte_slice(result.body()))
3631 }
3632
3633 ///
3634 ///
3635 /// Associated constants:
3636 /// * RED_BRICK_ERROR_CODE_SUCCESS
3637 /// * RED_BRICK_ERROR_CODE_UNKNOWN_ERROR
3638 /// * RED_BRICK_ERROR_CODE_INVALID_OPERATION
3639 /// * RED_BRICK_ERROR_CODE_OPERATION_ABORTED
3640 /// * RED_BRICK_ERROR_CODE_INTERNAL_ERROR
3641 /// * RED_BRICK_ERROR_CODE_UNKNOWN_SESSION_ID
3642 /// * RED_BRICK_ERROR_CODE_NO_FREE_SESSION_ID
3643 /// * RED_BRICK_ERROR_CODE_UNKNOWN_OBJECT_ID
3644 /// * RED_BRICK_ERROR_CODE_NO_FREE_OBJECT_ID
3645 /// * RED_BRICK_ERROR_CODE_OBJECT_IS_LOCKED
3646 /// * RED_BRICK_ERROR_CODE_NO_MORE_DATA
3647 /// * RED_BRICK_ERROR_CODE_WRONG_LIST_ITEM_TYPE
3648 /// * RED_BRICK_ERROR_CODE_PROGRAM_IS_PURGED
3649 /// * RED_BRICK_ERROR_CODE_INVALID_PARAMETER
3650 /// * RED_BRICK_ERROR_CODE_NO_FREE_MEMORY
3651 /// * RED_BRICK_ERROR_CODE_NO_FREE_SPACE
3652 /// * RED_BRICK_ERROR_CODE_ACCESS_DENIED
3653 /// * RED_BRICK_ERROR_CODE_ALREADY_EXISTS
3654 /// * RED_BRICK_ERROR_CODE_DOES_NOT_EXIST
3655 /// * RED_BRICK_ERROR_CODE_INTERRUPTED
3656 /// * RED_BRICK_ERROR_CODE_IS_DIRECTORY
3657 /// * RED_BRICK_ERROR_CODE_NOT_A_DIRECTORY
3658 /// * RED_BRICK_ERROR_CODE_WOULD_BLOCK
3659 /// * RED_BRICK_ERROR_CODE_OVERFLOW
3660 /// * RED_BRICK_ERROR_CODE_BAD_FILE_DESCRIPTOR
3661 /// * RED_BRICK_ERROR_CODE_OUT_OF_RANGE
3662 /// * RED_BRICK_ERROR_CODE_NAME_TOO_LONG
3663 /// * RED_BRICK_ERROR_CODE_INVALID_SEEK
3664 /// * RED_BRICK_ERROR_CODE_NOT_SUPPORTED
3665 /// * RED_BRICK_ERROR_CODE_TOO_MANY_OPEN_FILES
3666 /// * RED_BRICK_PROGRAM_START_MODE_NEVER
3667 /// * RED_BRICK_PROGRAM_START_MODE_ALWAYS
3668 /// * RED_BRICK_PROGRAM_START_MODE_INTERVAL
3669 /// * RED_BRICK_PROGRAM_START_MODE_CRON
3670 pub async fn get_program_schedule(&mut self, program_id: u16, session_id: u16) -> Result<ProgramSchedule, TinkerforgeError> {
3671 let mut payload = [0; 4];
3672 program_id.write_to_slice(&mut payload[0..2]);
3673 session_id.write_to_slice(&mut payload[2..4]);
3674
3675 #[allow(unused_variables)]
3676 let result = self.device.get(u8::from(RedBrickFunction::GetProgramSchedule), &payload).await?;
3677 Ok(ProgramSchedule::from_le_byte_slice(result.body()))
3678 }
3679
3680 /// FIXME: message is currently valid in error-occurred state only
3681 ///
3682 /// Associated constants:
3683 /// * RED_BRICK_ERROR_CODE_SUCCESS
3684 /// * RED_BRICK_ERROR_CODE_UNKNOWN_ERROR
3685 /// * RED_BRICK_ERROR_CODE_INVALID_OPERATION
3686 /// * RED_BRICK_ERROR_CODE_OPERATION_ABORTED
3687 /// * RED_BRICK_ERROR_CODE_INTERNAL_ERROR
3688 /// * RED_BRICK_ERROR_CODE_UNKNOWN_SESSION_ID
3689 /// * RED_BRICK_ERROR_CODE_NO_FREE_SESSION_ID
3690 /// * RED_BRICK_ERROR_CODE_UNKNOWN_OBJECT_ID
3691 /// * RED_BRICK_ERROR_CODE_NO_FREE_OBJECT_ID
3692 /// * RED_BRICK_ERROR_CODE_OBJECT_IS_LOCKED
3693 /// * RED_BRICK_ERROR_CODE_NO_MORE_DATA
3694 /// * RED_BRICK_ERROR_CODE_WRONG_LIST_ITEM_TYPE
3695 /// * RED_BRICK_ERROR_CODE_PROGRAM_IS_PURGED
3696 /// * RED_BRICK_ERROR_CODE_INVALID_PARAMETER
3697 /// * RED_BRICK_ERROR_CODE_NO_FREE_MEMORY
3698 /// * RED_BRICK_ERROR_CODE_NO_FREE_SPACE
3699 /// * RED_BRICK_ERROR_CODE_ACCESS_DENIED
3700 /// * RED_BRICK_ERROR_CODE_ALREADY_EXISTS
3701 /// * RED_BRICK_ERROR_CODE_DOES_NOT_EXIST
3702 /// * RED_BRICK_ERROR_CODE_INTERRUPTED
3703 /// * RED_BRICK_ERROR_CODE_IS_DIRECTORY
3704 /// * RED_BRICK_ERROR_CODE_NOT_A_DIRECTORY
3705 /// * RED_BRICK_ERROR_CODE_WOULD_BLOCK
3706 /// * RED_BRICK_ERROR_CODE_OVERFLOW
3707 /// * RED_BRICK_ERROR_CODE_BAD_FILE_DESCRIPTOR
3708 /// * RED_BRICK_ERROR_CODE_OUT_OF_RANGE
3709 /// * RED_BRICK_ERROR_CODE_NAME_TOO_LONG
3710 /// * RED_BRICK_ERROR_CODE_INVALID_SEEK
3711 /// * RED_BRICK_ERROR_CODE_NOT_SUPPORTED
3712 /// * RED_BRICK_ERROR_CODE_TOO_MANY_OPEN_FILES
3713 /// * RED_BRICK_PROGRAM_SCHEDULER_STATE_STOPPED
3714 /// * RED_BRICK_PROGRAM_SCHEDULER_STATE_RUNNING
3715 pub async fn get_program_scheduler_state(
3716 &mut self,
3717 program_id: u16,
3718 session_id: u16,
3719 ) -> Result<ProgramSchedulerState, TinkerforgeError> {
3720 let mut payload = [0; 4];
3721 program_id.write_to_slice(&mut payload[0..2]);
3722 session_id.write_to_slice(&mut payload[2..4]);
3723
3724 #[allow(unused_variables)]
3725 let result = self.device.get(u8::from(RedBrickFunction::GetProgramSchedulerState), &payload).await?;
3726 Ok(ProgramSchedulerState::from_le_byte_slice(result.body()))
3727 }
3728
3729 ///
3730 ///
3731 /// Associated constants:
3732 /// * RED_BRICK_ERROR_CODE_SUCCESS
3733 /// * RED_BRICK_ERROR_CODE_UNKNOWN_ERROR
3734 /// * RED_BRICK_ERROR_CODE_INVALID_OPERATION
3735 /// * RED_BRICK_ERROR_CODE_OPERATION_ABORTED
3736 /// * RED_BRICK_ERROR_CODE_INTERNAL_ERROR
3737 /// * RED_BRICK_ERROR_CODE_UNKNOWN_SESSION_ID
3738 /// * RED_BRICK_ERROR_CODE_NO_FREE_SESSION_ID
3739 /// * RED_BRICK_ERROR_CODE_UNKNOWN_OBJECT_ID
3740 /// * RED_BRICK_ERROR_CODE_NO_FREE_OBJECT_ID
3741 /// * RED_BRICK_ERROR_CODE_OBJECT_IS_LOCKED
3742 /// * RED_BRICK_ERROR_CODE_NO_MORE_DATA
3743 /// * RED_BRICK_ERROR_CODE_WRONG_LIST_ITEM_TYPE
3744 /// * RED_BRICK_ERROR_CODE_PROGRAM_IS_PURGED
3745 /// * RED_BRICK_ERROR_CODE_INVALID_PARAMETER
3746 /// * RED_BRICK_ERROR_CODE_NO_FREE_MEMORY
3747 /// * RED_BRICK_ERROR_CODE_NO_FREE_SPACE
3748 /// * RED_BRICK_ERROR_CODE_ACCESS_DENIED
3749 /// * RED_BRICK_ERROR_CODE_ALREADY_EXISTS
3750 /// * RED_BRICK_ERROR_CODE_DOES_NOT_EXIST
3751 /// * RED_BRICK_ERROR_CODE_INTERRUPTED
3752 /// * RED_BRICK_ERROR_CODE_IS_DIRECTORY
3753 /// * RED_BRICK_ERROR_CODE_NOT_A_DIRECTORY
3754 /// * RED_BRICK_ERROR_CODE_WOULD_BLOCK
3755 /// * RED_BRICK_ERROR_CODE_OVERFLOW
3756 /// * RED_BRICK_ERROR_CODE_BAD_FILE_DESCRIPTOR
3757 /// * RED_BRICK_ERROR_CODE_OUT_OF_RANGE
3758 /// * RED_BRICK_ERROR_CODE_NAME_TOO_LONG
3759 /// * RED_BRICK_ERROR_CODE_INVALID_SEEK
3760 /// * RED_BRICK_ERROR_CODE_NOT_SUPPORTED
3761 /// * RED_BRICK_ERROR_CODE_TOO_MANY_OPEN_FILES
3762 pub async fn continue_program_schedule(&mut self, program_id: u16) -> Result<u8, TinkerforgeError> {
3763 let mut payload = [0; 2];
3764 program_id.write_to_slice(&mut payload[0..2]);
3765
3766 #[allow(unused_variables)]
3767 let result = self.device.get(u8::from(RedBrickFunction::ContinueProgramSchedule), &payload).await?;
3768 Ok(u8::from_le_byte_slice(result.body()))
3769 }
3770
3771 ///
3772 ///
3773 /// Associated constants:
3774 /// * RED_BRICK_ERROR_CODE_SUCCESS
3775 /// * RED_BRICK_ERROR_CODE_UNKNOWN_ERROR
3776 /// * RED_BRICK_ERROR_CODE_INVALID_OPERATION
3777 /// * RED_BRICK_ERROR_CODE_OPERATION_ABORTED
3778 /// * RED_BRICK_ERROR_CODE_INTERNAL_ERROR
3779 /// * RED_BRICK_ERROR_CODE_UNKNOWN_SESSION_ID
3780 /// * RED_BRICK_ERROR_CODE_NO_FREE_SESSION_ID
3781 /// * RED_BRICK_ERROR_CODE_UNKNOWN_OBJECT_ID
3782 /// * RED_BRICK_ERROR_CODE_NO_FREE_OBJECT_ID
3783 /// * RED_BRICK_ERROR_CODE_OBJECT_IS_LOCKED
3784 /// * RED_BRICK_ERROR_CODE_NO_MORE_DATA
3785 /// * RED_BRICK_ERROR_CODE_WRONG_LIST_ITEM_TYPE
3786 /// * RED_BRICK_ERROR_CODE_PROGRAM_IS_PURGED
3787 /// * RED_BRICK_ERROR_CODE_INVALID_PARAMETER
3788 /// * RED_BRICK_ERROR_CODE_NO_FREE_MEMORY
3789 /// * RED_BRICK_ERROR_CODE_NO_FREE_SPACE
3790 /// * RED_BRICK_ERROR_CODE_ACCESS_DENIED
3791 /// * RED_BRICK_ERROR_CODE_ALREADY_EXISTS
3792 /// * RED_BRICK_ERROR_CODE_DOES_NOT_EXIST
3793 /// * RED_BRICK_ERROR_CODE_INTERRUPTED
3794 /// * RED_BRICK_ERROR_CODE_IS_DIRECTORY
3795 /// * RED_BRICK_ERROR_CODE_NOT_A_DIRECTORY
3796 /// * RED_BRICK_ERROR_CODE_WOULD_BLOCK
3797 /// * RED_BRICK_ERROR_CODE_OVERFLOW
3798 /// * RED_BRICK_ERROR_CODE_BAD_FILE_DESCRIPTOR
3799 /// * RED_BRICK_ERROR_CODE_OUT_OF_RANGE
3800 /// * RED_BRICK_ERROR_CODE_NAME_TOO_LONG
3801 /// * RED_BRICK_ERROR_CODE_INVALID_SEEK
3802 /// * RED_BRICK_ERROR_CODE_NOT_SUPPORTED
3803 /// * RED_BRICK_ERROR_CODE_TOO_MANY_OPEN_FILES
3804 pub async fn start_program(&mut self, program_id: u16) -> Result<u8, TinkerforgeError> {
3805 let mut payload = [0; 2];
3806 program_id.write_to_slice(&mut payload[0..2]);
3807
3808 #[allow(unused_variables)]
3809 let result = self.device.get(u8::from(RedBrickFunction::StartProgram), &payload).await?;
3810 Ok(u8::from_le_byte_slice(result.body()))
3811 }
3812
3813 ///
3814 ///
3815 /// Associated constants:
3816 /// * RED_BRICK_ERROR_CODE_SUCCESS
3817 /// * RED_BRICK_ERROR_CODE_UNKNOWN_ERROR
3818 /// * RED_BRICK_ERROR_CODE_INVALID_OPERATION
3819 /// * RED_BRICK_ERROR_CODE_OPERATION_ABORTED
3820 /// * RED_BRICK_ERROR_CODE_INTERNAL_ERROR
3821 /// * RED_BRICK_ERROR_CODE_UNKNOWN_SESSION_ID
3822 /// * RED_BRICK_ERROR_CODE_NO_FREE_SESSION_ID
3823 /// * RED_BRICK_ERROR_CODE_UNKNOWN_OBJECT_ID
3824 /// * RED_BRICK_ERROR_CODE_NO_FREE_OBJECT_ID
3825 /// * RED_BRICK_ERROR_CODE_OBJECT_IS_LOCKED
3826 /// * RED_BRICK_ERROR_CODE_NO_MORE_DATA
3827 /// * RED_BRICK_ERROR_CODE_WRONG_LIST_ITEM_TYPE
3828 /// * RED_BRICK_ERROR_CODE_PROGRAM_IS_PURGED
3829 /// * RED_BRICK_ERROR_CODE_INVALID_PARAMETER
3830 /// * RED_BRICK_ERROR_CODE_NO_FREE_MEMORY
3831 /// * RED_BRICK_ERROR_CODE_NO_FREE_SPACE
3832 /// * RED_BRICK_ERROR_CODE_ACCESS_DENIED
3833 /// * RED_BRICK_ERROR_CODE_ALREADY_EXISTS
3834 /// * RED_BRICK_ERROR_CODE_DOES_NOT_EXIST
3835 /// * RED_BRICK_ERROR_CODE_INTERRUPTED
3836 /// * RED_BRICK_ERROR_CODE_IS_DIRECTORY
3837 /// * RED_BRICK_ERROR_CODE_NOT_A_DIRECTORY
3838 /// * RED_BRICK_ERROR_CODE_WOULD_BLOCK
3839 /// * RED_BRICK_ERROR_CODE_OVERFLOW
3840 /// * RED_BRICK_ERROR_CODE_BAD_FILE_DESCRIPTOR
3841 /// * RED_BRICK_ERROR_CODE_OUT_OF_RANGE
3842 /// * RED_BRICK_ERROR_CODE_NAME_TOO_LONG
3843 /// * RED_BRICK_ERROR_CODE_INVALID_SEEK
3844 /// * RED_BRICK_ERROR_CODE_NOT_SUPPORTED
3845 /// * RED_BRICK_ERROR_CODE_TOO_MANY_OPEN_FILES
3846 pub async fn get_last_spawned_program_process(
3847 &mut self,
3848 program_id: u16,
3849 session_id: u16,
3850 ) -> Result<LastSpawnedProgramProcess, TinkerforgeError> {
3851 let mut payload = [0; 4];
3852 program_id.write_to_slice(&mut payload[0..2]);
3853 session_id.write_to_slice(&mut payload[2..4]);
3854
3855 #[allow(unused_variables)]
3856 let result = self.device.get(u8::from(RedBrickFunction::GetLastSpawnedProgramProcess), &payload).await?;
3857 Ok(LastSpawnedProgramProcess::from_le_byte_slice(result.body()))
3858 }
3859
3860 ///
3861 ///
3862 /// Associated constants:
3863 /// * RED_BRICK_ERROR_CODE_SUCCESS
3864 /// * RED_BRICK_ERROR_CODE_UNKNOWN_ERROR
3865 /// * RED_BRICK_ERROR_CODE_INVALID_OPERATION
3866 /// * RED_BRICK_ERROR_CODE_OPERATION_ABORTED
3867 /// * RED_BRICK_ERROR_CODE_INTERNAL_ERROR
3868 /// * RED_BRICK_ERROR_CODE_UNKNOWN_SESSION_ID
3869 /// * RED_BRICK_ERROR_CODE_NO_FREE_SESSION_ID
3870 /// * RED_BRICK_ERROR_CODE_UNKNOWN_OBJECT_ID
3871 /// * RED_BRICK_ERROR_CODE_NO_FREE_OBJECT_ID
3872 /// * RED_BRICK_ERROR_CODE_OBJECT_IS_LOCKED
3873 /// * RED_BRICK_ERROR_CODE_NO_MORE_DATA
3874 /// * RED_BRICK_ERROR_CODE_WRONG_LIST_ITEM_TYPE
3875 /// * RED_BRICK_ERROR_CODE_PROGRAM_IS_PURGED
3876 /// * RED_BRICK_ERROR_CODE_INVALID_PARAMETER
3877 /// * RED_BRICK_ERROR_CODE_NO_FREE_MEMORY
3878 /// * RED_BRICK_ERROR_CODE_NO_FREE_SPACE
3879 /// * RED_BRICK_ERROR_CODE_ACCESS_DENIED
3880 /// * RED_BRICK_ERROR_CODE_ALREADY_EXISTS
3881 /// * RED_BRICK_ERROR_CODE_DOES_NOT_EXIST
3882 /// * RED_BRICK_ERROR_CODE_INTERRUPTED
3883 /// * RED_BRICK_ERROR_CODE_IS_DIRECTORY
3884 /// * RED_BRICK_ERROR_CODE_NOT_A_DIRECTORY
3885 /// * RED_BRICK_ERROR_CODE_WOULD_BLOCK
3886 /// * RED_BRICK_ERROR_CODE_OVERFLOW
3887 /// * RED_BRICK_ERROR_CODE_BAD_FILE_DESCRIPTOR
3888 /// * RED_BRICK_ERROR_CODE_OUT_OF_RANGE
3889 /// * RED_BRICK_ERROR_CODE_NAME_TOO_LONG
3890 /// * RED_BRICK_ERROR_CODE_INVALID_SEEK
3891 /// * RED_BRICK_ERROR_CODE_NOT_SUPPORTED
3892 /// * RED_BRICK_ERROR_CODE_TOO_MANY_OPEN_FILES
3893 pub async fn get_custom_program_option_names(
3894 &mut self,
3895 program_id: u16,
3896 session_id: u16,
3897 ) -> Result<CustomProgramOptionNames, TinkerforgeError> {
3898 let mut payload = [0; 4];
3899 program_id.write_to_slice(&mut payload[0..2]);
3900 session_id.write_to_slice(&mut payload[2..4]);
3901
3902 #[allow(unused_variables)]
3903 let result = self.device.get(u8::from(RedBrickFunction::GetCustomProgramOptionNames), &payload).await?;
3904 Ok(CustomProgramOptionNames::from_le_byte_slice(result.body()))
3905 }
3906
3907 ///
3908 ///
3909 /// Associated constants:
3910 /// * RED_BRICK_ERROR_CODE_SUCCESS
3911 /// * RED_BRICK_ERROR_CODE_UNKNOWN_ERROR
3912 /// * RED_BRICK_ERROR_CODE_INVALID_OPERATION
3913 /// * RED_BRICK_ERROR_CODE_OPERATION_ABORTED
3914 /// * RED_BRICK_ERROR_CODE_INTERNAL_ERROR
3915 /// * RED_BRICK_ERROR_CODE_UNKNOWN_SESSION_ID
3916 /// * RED_BRICK_ERROR_CODE_NO_FREE_SESSION_ID
3917 /// * RED_BRICK_ERROR_CODE_UNKNOWN_OBJECT_ID
3918 /// * RED_BRICK_ERROR_CODE_NO_FREE_OBJECT_ID
3919 /// * RED_BRICK_ERROR_CODE_OBJECT_IS_LOCKED
3920 /// * RED_BRICK_ERROR_CODE_NO_MORE_DATA
3921 /// * RED_BRICK_ERROR_CODE_WRONG_LIST_ITEM_TYPE
3922 /// * RED_BRICK_ERROR_CODE_PROGRAM_IS_PURGED
3923 /// * RED_BRICK_ERROR_CODE_INVALID_PARAMETER
3924 /// * RED_BRICK_ERROR_CODE_NO_FREE_MEMORY
3925 /// * RED_BRICK_ERROR_CODE_NO_FREE_SPACE
3926 /// * RED_BRICK_ERROR_CODE_ACCESS_DENIED
3927 /// * RED_BRICK_ERROR_CODE_ALREADY_EXISTS
3928 /// * RED_BRICK_ERROR_CODE_DOES_NOT_EXIST
3929 /// * RED_BRICK_ERROR_CODE_INTERRUPTED
3930 /// * RED_BRICK_ERROR_CODE_IS_DIRECTORY
3931 /// * RED_BRICK_ERROR_CODE_NOT_A_DIRECTORY
3932 /// * RED_BRICK_ERROR_CODE_WOULD_BLOCK
3933 /// * RED_BRICK_ERROR_CODE_OVERFLOW
3934 /// * RED_BRICK_ERROR_CODE_BAD_FILE_DESCRIPTOR
3935 /// * RED_BRICK_ERROR_CODE_OUT_OF_RANGE
3936 /// * RED_BRICK_ERROR_CODE_NAME_TOO_LONG
3937 /// * RED_BRICK_ERROR_CODE_INVALID_SEEK
3938 /// * RED_BRICK_ERROR_CODE_NOT_SUPPORTED
3939 /// * RED_BRICK_ERROR_CODE_TOO_MANY_OPEN_FILES
3940 pub async fn set_custom_program_option_value(
3941 &mut self,
3942 program_id: u16,
3943 name_string_id: u16,
3944 value_string_id: u16,
3945 ) -> Result<u8, TinkerforgeError> {
3946 let mut payload = [0; 6];
3947 program_id.write_to_slice(&mut payload[0..2]);
3948 name_string_id.write_to_slice(&mut payload[2..4]);
3949 value_string_id.write_to_slice(&mut payload[4..6]);
3950
3951 #[allow(unused_variables)]
3952 let result = self.device.get(u8::from(RedBrickFunction::SetCustomProgramOptionValue), &payload).await?;
3953 Ok(u8::from_le_byte_slice(result.body()))
3954 }
3955
3956 ///
3957 ///
3958 /// Associated constants:
3959 /// * RED_BRICK_ERROR_CODE_SUCCESS
3960 /// * RED_BRICK_ERROR_CODE_UNKNOWN_ERROR
3961 /// * RED_BRICK_ERROR_CODE_INVALID_OPERATION
3962 /// * RED_BRICK_ERROR_CODE_OPERATION_ABORTED
3963 /// * RED_BRICK_ERROR_CODE_INTERNAL_ERROR
3964 /// * RED_BRICK_ERROR_CODE_UNKNOWN_SESSION_ID
3965 /// * RED_BRICK_ERROR_CODE_NO_FREE_SESSION_ID
3966 /// * RED_BRICK_ERROR_CODE_UNKNOWN_OBJECT_ID
3967 /// * RED_BRICK_ERROR_CODE_NO_FREE_OBJECT_ID
3968 /// * RED_BRICK_ERROR_CODE_OBJECT_IS_LOCKED
3969 /// * RED_BRICK_ERROR_CODE_NO_MORE_DATA
3970 /// * RED_BRICK_ERROR_CODE_WRONG_LIST_ITEM_TYPE
3971 /// * RED_BRICK_ERROR_CODE_PROGRAM_IS_PURGED
3972 /// * RED_BRICK_ERROR_CODE_INVALID_PARAMETER
3973 /// * RED_BRICK_ERROR_CODE_NO_FREE_MEMORY
3974 /// * RED_BRICK_ERROR_CODE_NO_FREE_SPACE
3975 /// * RED_BRICK_ERROR_CODE_ACCESS_DENIED
3976 /// * RED_BRICK_ERROR_CODE_ALREADY_EXISTS
3977 /// * RED_BRICK_ERROR_CODE_DOES_NOT_EXIST
3978 /// * RED_BRICK_ERROR_CODE_INTERRUPTED
3979 /// * RED_BRICK_ERROR_CODE_IS_DIRECTORY
3980 /// * RED_BRICK_ERROR_CODE_NOT_A_DIRECTORY
3981 /// * RED_BRICK_ERROR_CODE_WOULD_BLOCK
3982 /// * RED_BRICK_ERROR_CODE_OVERFLOW
3983 /// * RED_BRICK_ERROR_CODE_BAD_FILE_DESCRIPTOR
3984 /// * RED_BRICK_ERROR_CODE_OUT_OF_RANGE
3985 /// * RED_BRICK_ERROR_CODE_NAME_TOO_LONG
3986 /// * RED_BRICK_ERROR_CODE_INVALID_SEEK
3987 /// * RED_BRICK_ERROR_CODE_NOT_SUPPORTED
3988 /// * RED_BRICK_ERROR_CODE_TOO_MANY_OPEN_FILES
3989 pub async fn get_custom_program_option_value(
3990 &mut self,
3991 program_id: u16,
3992 name_string_id: u16,
3993 session_id: u16,
3994 ) -> Result<CustomProgramOptionValue, TinkerforgeError> {
3995 let mut payload = [0; 6];
3996 program_id.write_to_slice(&mut payload[0..2]);
3997 name_string_id.write_to_slice(&mut payload[2..4]);
3998 session_id.write_to_slice(&mut payload[4..6]);
3999
4000 #[allow(unused_variables)]
4001 let result = self.device.get(u8::from(RedBrickFunction::GetCustomProgramOptionValue), &payload).await?;
4002 Ok(CustomProgramOptionValue::from_le_byte_slice(result.body()))
4003 }
4004
4005 ///
4006 ///
4007 /// Associated constants:
4008 /// * RED_BRICK_ERROR_CODE_SUCCESS
4009 /// * RED_BRICK_ERROR_CODE_UNKNOWN_ERROR
4010 /// * RED_BRICK_ERROR_CODE_INVALID_OPERATION
4011 /// * RED_BRICK_ERROR_CODE_OPERATION_ABORTED
4012 /// * RED_BRICK_ERROR_CODE_INTERNAL_ERROR
4013 /// * RED_BRICK_ERROR_CODE_UNKNOWN_SESSION_ID
4014 /// * RED_BRICK_ERROR_CODE_NO_FREE_SESSION_ID
4015 /// * RED_BRICK_ERROR_CODE_UNKNOWN_OBJECT_ID
4016 /// * RED_BRICK_ERROR_CODE_NO_FREE_OBJECT_ID
4017 /// * RED_BRICK_ERROR_CODE_OBJECT_IS_LOCKED
4018 /// * RED_BRICK_ERROR_CODE_NO_MORE_DATA
4019 /// * RED_BRICK_ERROR_CODE_WRONG_LIST_ITEM_TYPE
4020 /// * RED_BRICK_ERROR_CODE_PROGRAM_IS_PURGED
4021 /// * RED_BRICK_ERROR_CODE_INVALID_PARAMETER
4022 /// * RED_BRICK_ERROR_CODE_NO_FREE_MEMORY
4023 /// * RED_BRICK_ERROR_CODE_NO_FREE_SPACE
4024 /// * RED_BRICK_ERROR_CODE_ACCESS_DENIED
4025 /// * RED_BRICK_ERROR_CODE_ALREADY_EXISTS
4026 /// * RED_BRICK_ERROR_CODE_DOES_NOT_EXIST
4027 /// * RED_BRICK_ERROR_CODE_INTERRUPTED
4028 /// * RED_BRICK_ERROR_CODE_IS_DIRECTORY
4029 /// * RED_BRICK_ERROR_CODE_NOT_A_DIRECTORY
4030 /// * RED_BRICK_ERROR_CODE_WOULD_BLOCK
4031 /// * RED_BRICK_ERROR_CODE_OVERFLOW
4032 /// * RED_BRICK_ERROR_CODE_BAD_FILE_DESCRIPTOR
4033 /// * RED_BRICK_ERROR_CODE_OUT_OF_RANGE
4034 /// * RED_BRICK_ERROR_CODE_NAME_TOO_LONG
4035 /// * RED_BRICK_ERROR_CODE_INVALID_SEEK
4036 /// * RED_BRICK_ERROR_CODE_NOT_SUPPORTED
4037 /// * RED_BRICK_ERROR_CODE_TOO_MANY_OPEN_FILES
4038 pub async fn remove_custom_program_option(&mut self, program_id: u16, name_string_id: u16) -> Result<u8, TinkerforgeError> {
4039 let mut payload = [0; 4];
4040 program_id.write_to_slice(&mut payload[0..2]);
4041 name_string_id.write_to_slice(&mut payload[2..4]);
4042
4043 #[allow(unused_variables)]
4044 let result = self.device.get(u8::from(RedBrickFunction::RemoveCustomProgramOption), &payload).await?;
4045 Ok(u8::from_le_byte_slice(result.body()))
4046 }
4047
4048 /// Returns the UID, the UID where the Brick is connected to,
4049 /// the position, the hardware and firmware version as well as the
4050 /// device identifier.
4051 ///
4052 /// The position is the position in the stack from '0' (bottom) to '8' (top).
4053 ///
4054 /// The device identifier numbers can be found [here](device_identifier).
4055 /// |device_identifier_constant|
4056 pub async fn get_identity(&mut self) -> Result<Identity, TinkerforgeError> {
4057 let payload = [0; 0];
4058
4059 #[allow(unused_variables)]
4060 let result = self.device.get(u8::from(RedBrickFunction::GetIdentity), &payload).await?;
4061 Ok(Identity::from_le_byte_slice(result.body()))
4062 }
4063}