2022-06-10 00:04:36 +09:00
|
|
|
#include "cli_command_gpio.h"
|
|
|
|
|
|
|
|
|
|
#include <furi.h>
|
|
|
|
|
#include <furi_hal.h>
|
|
|
|
|
#include <lib/toolbox/args.h>
|
[FL-3954, FL-3955] New CLI architecture (#4111)
* feat: FuriThread stdin
* ci: fix f18
* feat: stdio callback context
* feat: FuriPipe
* POTENTIALLY EXPLOSIVE pipe welding
* fix: non-explosive welding
* Revert welding
* docs: furi_pipe
* feat: pipe event loop integration
* update f18 sdk
* f18
* docs: make doxygen happy
* fix: event loop not triggering when pipe attached to stdio
* fix: partial stdout in pipe
* allow simultaneous in and out subscription in event loop
* feat: vcp i/o
* feat: cli ansi stuffs and history
* feat: more line editing
* working but slow cli rewrite
* restore previous speed after 4 days of debugging 🥲
* fix: cli_app_should_stop
* fix: cli and event_loop memory leaks
* style: remove commented out code
* ci: fix pvs warnings
* fix: unit tests, event_loop crash
* ci: fix build
* ci: silence pvs warning
* feat: cli gpio
* ci: fix formatting
* Fix memory leak during event loop unsubscription
* Event better memory leak fix
* feat: cli completions
* Merge remote-tracking branch 'origin/dev' into portasynthinca3/3928-cli-threads
* merge fixups
* temporarily exclude speaker_debug app
* pvs and unit tests fixups
* feat: commands in fals
* move commands out of flash, code cleanup
* ci: fix errors
* fix: run commands in buffer when stopping session
* speedup cli file transfer
* fix f18
* separate cli_shell into modules
* fix pvs warning
* fix qflipper refusing to connect
* remove temp debug logs
* remove erroneous conclusion
* Fix memory leak during event loop unsubscription
* Event better memory leak fix
* unit test for the fix
* improve thread stdio callback signatures
* pipe stdout timeout
* update api symbols
* fix f18, formatting
* fix pvs warnings
* increase stack size, hope to fix unit tests
* cli: revert flag changes
* cli: fix formatting
* cli, fbt: loopback perf benchmark
* thread, event_loop: subscribing to thread flags
* cli: signal internal events using thread flags, improve performance
* fix f18, formatting
* event_loop: fix crash
* storage_cli: increase write_chunk buffer size again
* cli: explanation for order=0
* thread, event_loop: thread flags callback refactor
* cli: increase stack size
* cli: rename cli_app_should_stop -> cli_is_pipe_broken_or_is_etx_next_char
* cli: use plain array instead of mlib for history
* cli: prepend file name to static fns
* cli: fix formatting
* cli_shell: increase stack size
* cli: fix rpc lockup
* cli: better lockup fix
* cli: fix f18
* fix merge
---------
Co-authored-by: Georgii Surkov <georgii.surkov@outlook.com>
Co-authored-by: あく <alleteam@gmail.com>
2025-04-02 22:10:10 +04:00
|
|
|
#include <toolbox/pipe.h>
|
2022-06-10 00:04:36 +09:00
|
|
|
|
2024-03-19 23:43:52 +09:00
|
|
|
void cli_command_gpio_print_usage(void) {
|
2022-06-10 00:04:36 +09:00
|
|
|
printf("Usage:\r\n");
|
|
|
|
|
printf("gpio <cmd> <args>\r\n");
|
|
|
|
|
printf("Cmd list:\r\n");
|
|
|
|
|
printf("\tmode <pin_name> <0|1>\t - Set gpio mode: 0 - input, 1 - output\r\n");
|
|
|
|
|
printf("\tset <pin_name> <0|1>\t - Set gpio value\r\n");
|
|
|
|
|
printf("\tread <pin_name>\t - Read gpio value\r\n");
|
|
|
|
|
}
|
|
|
|
|
|
2022-10-06 01:15:23 +10:00
|
|
|
static bool pin_name_to_int(FuriString* pin_name, size_t* result) {
|
2022-12-26 15:13:30 +03:00
|
|
|
bool is_debug_mode = furi_hal_rtc_is_flag_set(FuriHalRtcFlagDebug);
|
2023-02-07 19:33:05 +03:00
|
|
|
for(size_t i = 0; i < gpio_pins_count; i++) {
|
|
|
|
|
if(furi_string_equal(pin_name, gpio_pins[i].name)) {
|
|
|
|
|
if(!gpio_pins[i].debug || is_debug_mode) {
|
2022-06-10 00:04:36 +09:00
|
|
|
*result = i;
|
2022-12-26 15:13:30 +03:00
|
|
|
return true;
|
2022-06-10 00:04:36 +09:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-26 15:13:30 +03:00
|
|
|
return false;
|
2022-06-10 00:04:36 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void gpio_print_pins(void) {
|
|
|
|
|
printf("Wrong pin name. Available pins: ");
|
2022-12-26 15:13:30 +03:00
|
|
|
bool is_debug_mode = furi_hal_rtc_is_flag_set(FuriHalRtcFlagDebug);
|
2023-02-07 19:33:05 +03:00
|
|
|
for(size_t i = 0; i < gpio_pins_count; i++) {
|
|
|
|
|
if(!gpio_pins[i].debug || is_debug_mode) {
|
|
|
|
|
printf("%s ", gpio_pins[i].name);
|
2022-06-10 00:04:36 +09:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-06 00:07:24 +09:00
|
|
|
typedef enum {
|
|
|
|
|
GpioParseReturnOk,
|
|
|
|
|
GpioParseReturnCmdSyntaxError,
|
|
|
|
|
GpioParseReturnPinError,
|
|
|
|
|
GpioParseReturnValueError
|
|
|
|
|
} GpioParseReturn;
|
|
|
|
|
|
|
|
|
|
static GpioParseReturn gpio_command_parse(FuriString* args, size_t* pin_num, uint8_t* value) {
|
2022-12-26 15:13:30 +03:00
|
|
|
GpioParseReturn ret = GpioParseReturnOk;
|
|
|
|
|
FuriString* pin_name = furi_string_alloc();
|
|
|
|
|
|
|
|
|
|
do {
|
|
|
|
|
if(!args_read_string_and_trim(args, pin_name)) {
|
|
|
|
|
ret = GpioParseReturnCmdSyntaxError;
|
|
|
|
|
break;
|
|
|
|
|
} else if(!pin_name_to_int(pin_name, pin_num)) {
|
|
|
|
|
ret = GpioParseReturnPinError;
|
|
|
|
|
break;
|
|
|
|
|
}
|
2022-06-10 00:04:36 +09:00
|
|
|
|
2022-12-26 15:13:30 +03:00
|
|
|
int pin_mode; //-V779
|
|
|
|
|
if(!args_read_int_and_trim(args, &pin_mode) || pin_mode < 0 || pin_mode > 1) {
|
|
|
|
|
ret = GpioParseReturnValueError;
|
|
|
|
|
break;
|
|
|
|
|
}
|
2022-06-10 00:04:36 +09:00
|
|
|
|
2022-12-26 15:13:30 +03:00
|
|
|
*value = pin_mode;
|
|
|
|
|
} while(false);
|
2022-06-10 00:04:36 +09:00
|
|
|
|
2022-10-06 01:15:23 +10:00
|
|
|
furi_string_free(pin_name);
|
2022-12-26 15:13:30 +03:00
|
|
|
return ret;
|
2022-06-10 00:04:36 +09:00
|
|
|
}
|
|
|
|
|
|
[FL-3954, FL-3955] New CLI architecture (#4111)
* feat: FuriThread stdin
* ci: fix f18
* feat: stdio callback context
* feat: FuriPipe
* POTENTIALLY EXPLOSIVE pipe welding
* fix: non-explosive welding
* Revert welding
* docs: furi_pipe
* feat: pipe event loop integration
* update f18 sdk
* f18
* docs: make doxygen happy
* fix: event loop not triggering when pipe attached to stdio
* fix: partial stdout in pipe
* allow simultaneous in and out subscription in event loop
* feat: vcp i/o
* feat: cli ansi stuffs and history
* feat: more line editing
* working but slow cli rewrite
* restore previous speed after 4 days of debugging 🥲
* fix: cli_app_should_stop
* fix: cli and event_loop memory leaks
* style: remove commented out code
* ci: fix pvs warnings
* fix: unit tests, event_loop crash
* ci: fix build
* ci: silence pvs warning
* feat: cli gpio
* ci: fix formatting
* Fix memory leak during event loop unsubscription
* Event better memory leak fix
* feat: cli completions
* Merge remote-tracking branch 'origin/dev' into portasynthinca3/3928-cli-threads
* merge fixups
* temporarily exclude speaker_debug app
* pvs and unit tests fixups
* feat: commands in fals
* move commands out of flash, code cleanup
* ci: fix errors
* fix: run commands in buffer when stopping session
* speedup cli file transfer
* fix f18
* separate cli_shell into modules
* fix pvs warning
* fix qflipper refusing to connect
* remove temp debug logs
* remove erroneous conclusion
* Fix memory leak during event loop unsubscription
* Event better memory leak fix
* unit test for the fix
* improve thread stdio callback signatures
* pipe stdout timeout
* update api symbols
* fix f18, formatting
* fix pvs warnings
* increase stack size, hope to fix unit tests
* cli: revert flag changes
* cli: fix formatting
* cli, fbt: loopback perf benchmark
* thread, event_loop: subscribing to thread flags
* cli: signal internal events using thread flags, improve performance
* fix f18, formatting
* event_loop: fix crash
* storage_cli: increase write_chunk buffer size again
* cli: explanation for order=0
* thread, event_loop: thread flags callback refactor
* cli: increase stack size
* cli: rename cli_app_should_stop -> cli_is_pipe_broken_or_is_etx_next_char
* cli: use plain array instead of mlib for history
* cli: prepend file name to static fns
* cli: fix formatting
* cli_shell: increase stack size
* cli: fix rpc lockup
* cli: better lockup fix
* cli: fix f18
* fix merge
---------
Co-authored-by: Georgii Surkov <georgii.surkov@outlook.com>
Co-authored-by: あく <alleteam@gmail.com>
2025-04-02 22:10:10 +04:00
|
|
|
void cli_command_gpio_mode(PipeSide* pipe, FuriString* args, void* context) {
|
|
|
|
|
UNUSED(pipe);
|
2022-06-10 00:04:36 +09:00
|
|
|
UNUSED(context);
|
|
|
|
|
|
|
|
|
|
size_t num = 0;
|
|
|
|
|
uint8_t value = 255;
|
|
|
|
|
|
2022-11-06 00:07:24 +09:00
|
|
|
GpioParseReturn err = gpio_command_parse(args, &num, &value);
|
2022-06-10 00:04:36 +09:00
|
|
|
|
2022-11-06 00:07:24 +09:00
|
|
|
if(err == GpioParseReturnCmdSyntaxError) {
|
2022-10-06 01:15:23 +10:00
|
|
|
cli_print_usage("gpio mode", "<pin_name> <0|1>", furi_string_get_cstr(args));
|
2022-06-10 00:04:36 +09:00
|
|
|
return;
|
2022-12-26 15:13:30 +03:00
|
|
|
} else if(err == GpioParseReturnPinError) { //-V547
|
2022-06-10 00:04:36 +09:00
|
|
|
gpio_print_pins();
|
|
|
|
|
return;
|
2022-11-06 00:07:24 +09:00
|
|
|
} else if(err == GpioParseReturnValueError) {
|
2022-06-10 00:04:36 +09:00
|
|
|
printf("Value is invalid. Enter 1 for input or 0 for output");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2023-02-07 19:33:05 +03:00
|
|
|
if(gpio_pins[num].debug) { //-V779
|
2022-06-10 00:04:36 +09:00
|
|
|
printf(
|
2022-11-23 08:15:08 -05:00
|
|
|
"Changing this pin mode may damage hardware. Are you sure you want to continue? (y/n)?\r\n");
|
[FL-3954, FL-3955] New CLI architecture (#4111)
* feat: FuriThread stdin
* ci: fix f18
* feat: stdio callback context
* feat: FuriPipe
* POTENTIALLY EXPLOSIVE pipe welding
* fix: non-explosive welding
* Revert welding
* docs: furi_pipe
* feat: pipe event loop integration
* update f18 sdk
* f18
* docs: make doxygen happy
* fix: event loop not triggering when pipe attached to stdio
* fix: partial stdout in pipe
* allow simultaneous in and out subscription in event loop
* feat: vcp i/o
* feat: cli ansi stuffs and history
* feat: more line editing
* working but slow cli rewrite
* restore previous speed after 4 days of debugging 🥲
* fix: cli_app_should_stop
* fix: cli and event_loop memory leaks
* style: remove commented out code
* ci: fix pvs warnings
* fix: unit tests, event_loop crash
* ci: fix build
* ci: silence pvs warning
* feat: cli gpio
* ci: fix formatting
* Fix memory leak during event loop unsubscription
* Event better memory leak fix
* feat: cli completions
* Merge remote-tracking branch 'origin/dev' into portasynthinca3/3928-cli-threads
* merge fixups
* temporarily exclude speaker_debug app
* pvs and unit tests fixups
* feat: commands in fals
* move commands out of flash, code cleanup
* ci: fix errors
* fix: run commands in buffer when stopping session
* speedup cli file transfer
* fix f18
* separate cli_shell into modules
* fix pvs warning
* fix qflipper refusing to connect
* remove temp debug logs
* remove erroneous conclusion
* Fix memory leak during event loop unsubscription
* Event better memory leak fix
* unit test for the fix
* improve thread stdio callback signatures
* pipe stdout timeout
* update api symbols
* fix f18, formatting
* fix pvs warnings
* increase stack size, hope to fix unit tests
* cli: revert flag changes
* cli: fix formatting
* cli, fbt: loopback perf benchmark
* thread, event_loop: subscribing to thread flags
* cli: signal internal events using thread flags, improve performance
* fix f18, formatting
* event_loop: fix crash
* storage_cli: increase write_chunk buffer size again
* cli: explanation for order=0
* thread, event_loop: thread flags callback refactor
* cli: increase stack size
* cli: rename cli_app_should_stop -> cli_is_pipe_broken_or_is_etx_next_char
* cli: use plain array instead of mlib for history
* cli: prepend file name to static fns
* cli: fix formatting
* cli_shell: increase stack size
* cli: fix rpc lockup
* cli: better lockup fix
* cli: fix f18
* fix merge
---------
Co-authored-by: Georgii Surkov <georgii.surkov@outlook.com>
Co-authored-by: あく <alleteam@gmail.com>
2025-04-02 22:10:10 +04:00
|
|
|
char c = getchar();
|
2022-06-10 00:04:36 +09:00
|
|
|
if(c != 'y' && c != 'Y') {
|
|
|
|
|
printf("Cancelled.\r\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(value == 1) { // output
|
2023-02-07 19:33:05 +03:00
|
|
|
furi_hal_gpio_write(gpio_pins[num].pin, false);
|
|
|
|
|
furi_hal_gpio_init_simple(gpio_pins[num].pin, GpioModeOutputPushPull);
|
|
|
|
|
printf("Pin %s is now an output (low)", gpio_pins[num].name);
|
2022-06-10 00:04:36 +09:00
|
|
|
} else { // input
|
2023-02-07 19:33:05 +03:00
|
|
|
furi_hal_gpio_init_simple(gpio_pins[num].pin, GpioModeInput);
|
|
|
|
|
printf("Pin %s is now an input", gpio_pins[num].name);
|
2022-06-10 00:04:36 +09:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
[FL-3954, FL-3955] New CLI architecture (#4111)
* feat: FuriThread stdin
* ci: fix f18
* feat: stdio callback context
* feat: FuriPipe
* POTENTIALLY EXPLOSIVE pipe welding
* fix: non-explosive welding
* Revert welding
* docs: furi_pipe
* feat: pipe event loop integration
* update f18 sdk
* f18
* docs: make doxygen happy
* fix: event loop not triggering when pipe attached to stdio
* fix: partial stdout in pipe
* allow simultaneous in and out subscription in event loop
* feat: vcp i/o
* feat: cli ansi stuffs and history
* feat: more line editing
* working but slow cli rewrite
* restore previous speed after 4 days of debugging 🥲
* fix: cli_app_should_stop
* fix: cli and event_loop memory leaks
* style: remove commented out code
* ci: fix pvs warnings
* fix: unit tests, event_loop crash
* ci: fix build
* ci: silence pvs warning
* feat: cli gpio
* ci: fix formatting
* Fix memory leak during event loop unsubscription
* Event better memory leak fix
* feat: cli completions
* Merge remote-tracking branch 'origin/dev' into portasynthinca3/3928-cli-threads
* merge fixups
* temporarily exclude speaker_debug app
* pvs and unit tests fixups
* feat: commands in fals
* move commands out of flash, code cleanup
* ci: fix errors
* fix: run commands in buffer when stopping session
* speedup cli file transfer
* fix f18
* separate cli_shell into modules
* fix pvs warning
* fix qflipper refusing to connect
* remove temp debug logs
* remove erroneous conclusion
* Fix memory leak during event loop unsubscription
* Event better memory leak fix
* unit test for the fix
* improve thread stdio callback signatures
* pipe stdout timeout
* update api symbols
* fix f18, formatting
* fix pvs warnings
* increase stack size, hope to fix unit tests
* cli: revert flag changes
* cli: fix formatting
* cli, fbt: loopback perf benchmark
* thread, event_loop: subscribing to thread flags
* cli: signal internal events using thread flags, improve performance
* fix f18, formatting
* event_loop: fix crash
* storage_cli: increase write_chunk buffer size again
* cli: explanation for order=0
* thread, event_loop: thread flags callback refactor
* cli: increase stack size
* cli: rename cli_app_should_stop -> cli_is_pipe_broken_or_is_etx_next_char
* cli: use plain array instead of mlib for history
* cli: prepend file name to static fns
* cli: fix formatting
* cli_shell: increase stack size
* cli: fix rpc lockup
* cli: better lockup fix
* cli: fix f18
* fix merge
---------
Co-authored-by: Georgii Surkov <georgii.surkov@outlook.com>
Co-authored-by: あく <alleteam@gmail.com>
2025-04-02 22:10:10 +04:00
|
|
|
void cli_command_gpio_read(PipeSide* pipe, FuriString* args, void* context) {
|
|
|
|
|
UNUSED(pipe);
|
2022-06-10 00:04:36 +09:00
|
|
|
UNUSED(context);
|
|
|
|
|
|
|
|
|
|
size_t num = 0;
|
|
|
|
|
if(!pin_name_to_int(args, &num)) {
|
|
|
|
|
gpio_print_pins();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-26 15:13:30 +03:00
|
|
|
if(LL_GPIO_MODE_INPUT != //-V779
|
2023-02-07 19:33:05 +03:00
|
|
|
LL_GPIO_GetPinMode(gpio_pins[num].pin->port, gpio_pins[num].pin->pin)) {
|
|
|
|
|
printf("Err: pin %s is not set as an input.", gpio_pins[num].name);
|
2022-06-10 00:04:36 +09:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2023-02-07 19:33:05 +03:00
|
|
|
uint8_t val = !!furi_hal_gpio_read(gpio_pins[num].pin);
|
2022-06-10 00:04:36 +09:00
|
|
|
|
2023-02-07 19:33:05 +03:00
|
|
|
printf("Pin %s <= %u", gpio_pins[num].name, val);
|
2022-06-10 00:04:36 +09:00
|
|
|
}
|
|
|
|
|
|
[FL-3954, FL-3955] New CLI architecture (#4111)
* feat: FuriThread stdin
* ci: fix f18
* feat: stdio callback context
* feat: FuriPipe
* POTENTIALLY EXPLOSIVE pipe welding
* fix: non-explosive welding
* Revert welding
* docs: furi_pipe
* feat: pipe event loop integration
* update f18 sdk
* f18
* docs: make doxygen happy
* fix: event loop not triggering when pipe attached to stdio
* fix: partial stdout in pipe
* allow simultaneous in and out subscription in event loop
* feat: vcp i/o
* feat: cli ansi stuffs and history
* feat: more line editing
* working but slow cli rewrite
* restore previous speed after 4 days of debugging 🥲
* fix: cli_app_should_stop
* fix: cli and event_loop memory leaks
* style: remove commented out code
* ci: fix pvs warnings
* fix: unit tests, event_loop crash
* ci: fix build
* ci: silence pvs warning
* feat: cli gpio
* ci: fix formatting
* Fix memory leak during event loop unsubscription
* Event better memory leak fix
* feat: cli completions
* Merge remote-tracking branch 'origin/dev' into portasynthinca3/3928-cli-threads
* merge fixups
* temporarily exclude speaker_debug app
* pvs and unit tests fixups
* feat: commands in fals
* move commands out of flash, code cleanup
* ci: fix errors
* fix: run commands in buffer when stopping session
* speedup cli file transfer
* fix f18
* separate cli_shell into modules
* fix pvs warning
* fix qflipper refusing to connect
* remove temp debug logs
* remove erroneous conclusion
* Fix memory leak during event loop unsubscription
* Event better memory leak fix
* unit test for the fix
* improve thread stdio callback signatures
* pipe stdout timeout
* update api symbols
* fix f18, formatting
* fix pvs warnings
* increase stack size, hope to fix unit tests
* cli: revert flag changes
* cli: fix formatting
* cli, fbt: loopback perf benchmark
* thread, event_loop: subscribing to thread flags
* cli: signal internal events using thread flags, improve performance
* fix f18, formatting
* event_loop: fix crash
* storage_cli: increase write_chunk buffer size again
* cli: explanation for order=0
* thread, event_loop: thread flags callback refactor
* cli: increase stack size
* cli: rename cli_app_should_stop -> cli_is_pipe_broken_or_is_etx_next_char
* cli: use plain array instead of mlib for history
* cli: prepend file name to static fns
* cli: fix formatting
* cli_shell: increase stack size
* cli: fix rpc lockup
* cli: better lockup fix
* cli: fix f18
* fix merge
---------
Co-authored-by: Georgii Surkov <georgii.surkov@outlook.com>
Co-authored-by: あく <alleteam@gmail.com>
2025-04-02 22:10:10 +04:00
|
|
|
void cli_command_gpio_set(PipeSide* pipe, FuriString* args, void* context) {
|
|
|
|
|
UNUSED(pipe);
|
2022-06-10 00:04:36 +09:00
|
|
|
UNUSED(context);
|
|
|
|
|
|
|
|
|
|
size_t num = 0;
|
|
|
|
|
uint8_t value = 0;
|
2022-11-06 00:07:24 +09:00
|
|
|
GpioParseReturn err = gpio_command_parse(args, &num, &value);
|
2022-06-10 00:04:36 +09:00
|
|
|
|
2022-11-06 00:07:24 +09:00
|
|
|
if(err == GpioParseReturnCmdSyntaxError) {
|
2022-10-06 01:15:23 +10:00
|
|
|
cli_print_usage("gpio set", "<pin_name> <0|1>", furi_string_get_cstr(args));
|
2022-06-10 00:04:36 +09:00
|
|
|
return;
|
2022-12-26 15:13:30 +03:00
|
|
|
} else if(err == GpioParseReturnPinError) { //-V547
|
2022-06-10 00:04:36 +09:00
|
|
|
gpio_print_pins();
|
|
|
|
|
return;
|
2022-11-06 00:07:24 +09:00
|
|
|
} else if(err == GpioParseReturnValueError) {
|
2022-06-10 00:04:36 +09:00
|
|
|
printf("Value is invalid. Enter 1 for high or 0 for low");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-26 15:13:30 +03:00
|
|
|
if(LL_GPIO_MODE_OUTPUT != //-V779
|
2023-02-07 19:33:05 +03:00
|
|
|
LL_GPIO_GetPinMode(gpio_pins[num].pin->port, gpio_pins[num].pin->pin)) {
|
|
|
|
|
printf("Err: pin %s is not set as an output.", gpio_pins[num].name);
|
2022-06-10 00:04:36 +09:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Extra check if debug pins used
|
2023-02-07 19:33:05 +03:00
|
|
|
if(gpio_pins[num].debug) {
|
2022-06-10 00:04:36 +09:00
|
|
|
printf(
|
|
|
|
|
"Setting this pin may damage hardware. Are you sure you want to continue? (y/n)?\r\n");
|
[FL-3954, FL-3955] New CLI architecture (#4111)
* feat: FuriThread stdin
* ci: fix f18
* feat: stdio callback context
* feat: FuriPipe
* POTENTIALLY EXPLOSIVE pipe welding
* fix: non-explosive welding
* Revert welding
* docs: furi_pipe
* feat: pipe event loop integration
* update f18 sdk
* f18
* docs: make doxygen happy
* fix: event loop not triggering when pipe attached to stdio
* fix: partial stdout in pipe
* allow simultaneous in and out subscription in event loop
* feat: vcp i/o
* feat: cli ansi stuffs and history
* feat: more line editing
* working but slow cli rewrite
* restore previous speed after 4 days of debugging 🥲
* fix: cli_app_should_stop
* fix: cli and event_loop memory leaks
* style: remove commented out code
* ci: fix pvs warnings
* fix: unit tests, event_loop crash
* ci: fix build
* ci: silence pvs warning
* feat: cli gpio
* ci: fix formatting
* Fix memory leak during event loop unsubscription
* Event better memory leak fix
* feat: cli completions
* Merge remote-tracking branch 'origin/dev' into portasynthinca3/3928-cli-threads
* merge fixups
* temporarily exclude speaker_debug app
* pvs and unit tests fixups
* feat: commands in fals
* move commands out of flash, code cleanup
* ci: fix errors
* fix: run commands in buffer when stopping session
* speedup cli file transfer
* fix f18
* separate cli_shell into modules
* fix pvs warning
* fix qflipper refusing to connect
* remove temp debug logs
* remove erroneous conclusion
* Fix memory leak during event loop unsubscription
* Event better memory leak fix
* unit test for the fix
* improve thread stdio callback signatures
* pipe stdout timeout
* update api symbols
* fix f18, formatting
* fix pvs warnings
* increase stack size, hope to fix unit tests
* cli: revert flag changes
* cli: fix formatting
* cli, fbt: loopback perf benchmark
* thread, event_loop: subscribing to thread flags
* cli: signal internal events using thread flags, improve performance
* fix f18, formatting
* event_loop: fix crash
* storage_cli: increase write_chunk buffer size again
* cli: explanation for order=0
* thread, event_loop: thread flags callback refactor
* cli: increase stack size
* cli: rename cli_app_should_stop -> cli_is_pipe_broken_or_is_etx_next_char
* cli: use plain array instead of mlib for history
* cli: prepend file name to static fns
* cli: fix formatting
* cli_shell: increase stack size
* cli: fix rpc lockup
* cli: better lockup fix
* cli: fix f18
* fix merge
---------
Co-authored-by: Georgii Surkov <georgii.surkov@outlook.com>
Co-authored-by: あく <alleteam@gmail.com>
2025-04-02 22:10:10 +04:00
|
|
|
char c = getchar();
|
2022-06-10 00:04:36 +09:00
|
|
|
if(c != 'y' && c != 'Y') {
|
|
|
|
|
printf("Cancelled.\r\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-02-07 19:33:05 +03:00
|
|
|
furi_hal_gpio_write(gpio_pins[num].pin, !!value);
|
|
|
|
|
printf("Pin %s => %u", gpio_pins[num].name, !!value);
|
2022-06-10 00:04:36 +09:00
|
|
|
}
|
|
|
|
|
|
[FL-3954, FL-3955] New CLI architecture (#4111)
* feat: FuriThread stdin
* ci: fix f18
* feat: stdio callback context
* feat: FuriPipe
* POTENTIALLY EXPLOSIVE pipe welding
* fix: non-explosive welding
* Revert welding
* docs: furi_pipe
* feat: pipe event loop integration
* update f18 sdk
* f18
* docs: make doxygen happy
* fix: event loop not triggering when pipe attached to stdio
* fix: partial stdout in pipe
* allow simultaneous in and out subscription in event loop
* feat: vcp i/o
* feat: cli ansi stuffs and history
* feat: more line editing
* working but slow cli rewrite
* restore previous speed after 4 days of debugging 🥲
* fix: cli_app_should_stop
* fix: cli and event_loop memory leaks
* style: remove commented out code
* ci: fix pvs warnings
* fix: unit tests, event_loop crash
* ci: fix build
* ci: silence pvs warning
* feat: cli gpio
* ci: fix formatting
* Fix memory leak during event loop unsubscription
* Event better memory leak fix
* feat: cli completions
* Merge remote-tracking branch 'origin/dev' into portasynthinca3/3928-cli-threads
* merge fixups
* temporarily exclude speaker_debug app
* pvs and unit tests fixups
* feat: commands in fals
* move commands out of flash, code cleanup
* ci: fix errors
* fix: run commands in buffer when stopping session
* speedup cli file transfer
* fix f18
* separate cli_shell into modules
* fix pvs warning
* fix qflipper refusing to connect
* remove temp debug logs
* remove erroneous conclusion
* Fix memory leak during event loop unsubscription
* Event better memory leak fix
* unit test for the fix
* improve thread stdio callback signatures
* pipe stdout timeout
* update api symbols
* fix f18, formatting
* fix pvs warnings
* increase stack size, hope to fix unit tests
* cli: revert flag changes
* cli: fix formatting
* cli, fbt: loopback perf benchmark
* thread, event_loop: subscribing to thread flags
* cli: signal internal events using thread flags, improve performance
* fix f18, formatting
* event_loop: fix crash
* storage_cli: increase write_chunk buffer size again
* cli: explanation for order=0
* thread, event_loop: thread flags callback refactor
* cli: increase stack size
* cli: rename cli_app_should_stop -> cli_is_pipe_broken_or_is_etx_next_char
* cli: use plain array instead of mlib for history
* cli: prepend file name to static fns
* cli: fix formatting
* cli_shell: increase stack size
* cli: fix rpc lockup
* cli: better lockup fix
* cli: fix f18
* fix merge
---------
Co-authored-by: Georgii Surkov <georgii.surkov@outlook.com>
Co-authored-by: あく <alleteam@gmail.com>
2025-04-02 22:10:10 +04:00
|
|
|
void cli_command_gpio(PipeSide* pipe, FuriString* args, void* context) {
|
2022-10-06 01:15:23 +10:00
|
|
|
FuriString* cmd;
|
|
|
|
|
cmd = furi_string_alloc();
|
2022-06-10 00:04:36 +09:00
|
|
|
|
|
|
|
|
do {
|
|
|
|
|
if(!args_read_string_and_trim(args, cmd)) {
|
|
|
|
|
cli_command_gpio_print_usage();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2022-10-06 01:15:23 +10:00
|
|
|
if(furi_string_cmp_str(cmd, "mode") == 0) {
|
[FL-3954, FL-3955] New CLI architecture (#4111)
* feat: FuriThread stdin
* ci: fix f18
* feat: stdio callback context
* feat: FuriPipe
* POTENTIALLY EXPLOSIVE pipe welding
* fix: non-explosive welding
* Revert welding
* docs: furi_pipe
* feat: pipe event loop integration
* update f18 sdk
* f18
* docs: make doxygen happy
* fix: event loop not triggering when pipe attached to stdio
* fix: partial stdout in pipe
* allow simultaneous in and out subscription in event loop
* feat: vcp i/o
* feat: cli ansi stuffs and history
* feat: more line editing
* working but slow cli rewrite
* restore previous speed after 4 days of debugging 🥲
* fix: cli_app_should_stop
* fix: cli and event_loop memory leaks
* style: remove commented out code
* ci: fix pvs warnings
* fix: unit tests, event_loop crash
* ci: fix build
* ci: silence pvs warning
* feat: cli gpio
* ci: fix formatting
* Fix memory leak during event loop unsubscription
* Event better memory leak fix
* feat: cli completions
* Merge remote-tracking branch 'origin/dev' into portasynthinca3/3928-cli-threads
* merge fixups
* temporarily exclude speaker_debug app
* pvs and unit tests fixups
* feat: commands in fals
* move commands out of flash, code cleanup
* ci: fix errors
* fix: run commands in buffer when stopping session
* speedup cli file transfer
* fix f18
* separate cli_shell into modules
* fix pvs warning
* fix qflipper refusing to connect
* remove temp debug logs
* remove erroneous conclusion
* Fix memory leak during event loop unsubscription
* Event better memory leak fix
* unit test for the fix
* improve thread stdio callback signatures
* pipe stdout timeout
* update api symbols
* fix f18, formatting
* fix pvs warnings
* increase stack size, hope to fix unit tests
* cli: revert flag changes
* cli: fix formatting
* cli, fbt: loopback perf benchmark
* thread, event_loop: subscribing to thread flags
* cli: signal internal events using thread flags, improve performance
* fix f18, formatting
* event_loop: fix crash
* storage_cli: increase write_chunk buffer size again
* cli: explanation for order=0
* thread, event_loop: thread flags callback refactor
* cli: increase stack size
* cli: rename cli_app_should_stop -> cli_is_pipe_broken_or_is_etx_next_char
* cli: use plain array instead of mlib for history
* cli: prepend file name to static fns
* cli: fix formatting
* cli_shell: increase stack size
* cli: fix rpc lockup
* cli: better lockup fix
* cli: fix f18
* fix merge
---------
Co-authored-by: Georgii Surkov <georgii.surkov@outlook.com>
Co-authored-by: あく <alleteam@gmail.com>
2025-04-02 22:10:10 +04:00
|
|
|
cli_command_gpio_mode(pipe, args, context);
|
2022-06-10 00:04:36 +09:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2022-10-06 01:15:23 +10:00
|
|
|
if(furi_string_cmp_str(cmd, "set") == 0) {
|
[FL-3954, FL-3955] New CLI architecture (#4111)
* feat: FuriThread stdin
* ci: fix f18
* feat: stdio callback context
* feat: FuriPipe
* POTENTIALLY EXPLOSIVE pipe welding
* fix: non-explosive welding
* Revert welding
* docs: furi_pipe
* feat: pipe event loop integration
* update f18 sdk
* f18
* docs: make doxygen happy
* fix: event loop not triggering when pipe attached to stdio
* fix: partial stdout in pipe
* allow simultaneous in and out subscription in event loop
* feat: vcp i/o
* feat: cli ansi stuffs and history
* feat: more line editing
* working but slow cli rewrite
* restore previous speed after 4 days of debugging 🥲
* fix: cli_app_should_stop
* fix: cli and event_loop memory leaks
* style: remove commented out code
* ci: fix pvs warnings
* fix: unit tests, event_loop crash
* ci: fix build
* ci: silence pvs warning
* feat: cli gpio
* ci: fix formatting
* Fix memory leak during event loop unsubscription
* Event better memory leak fix
* feat: cli completions
* Merge remote-tracking branch 'origin/dev' into portasynthinca3/3928-cli-threads
* merge fixups
* temporarily exclude speaker_debug app
* pvs and unit tests fixups
* feat: commands in fals
* move commands out of flash, code cleanup
* ci: fix errors
* fix: run commands in buffer when stopping session
* speedup cli file transfer
* fix f18
* separate cli_shell into modules
* fix pvs warning
* fix qflipper refusing to connect
* remove temp debug logs
* remove erroneous conclusion
* Fix memory leak during event loop unsubscription
* Event better memory leak fix
* unit test for the fix
* improve thread stdio callback signatures
* pipe stdout timeout
* update api symbols
* fix f18, formatting
* fix pvs warnings
* increase stack size, hope to fix unit tests
* cli: revert flag changes
* cli: fix formatting
* cli, fbt: loopback perf benchmark
* thread, event_loop: subscribing to thread flags
* cli: signal internal events using thread flags, improve performance
* fix f18, formatting
* event_loop: fix crash
* storage_cli: increase write_chunk buffer size again
* cli: explanation for order=0
* thread, event_loop: thread flags callback refactor
* cli: increase stack size
* cli: rename cli_app_should_stop -> cli_is_pipe_broken_or_is_etx_next_char
* cli: use plain array instead of mlib for history
* cli: prepend file name to static fns
* cli: fix formatting
* cli_shell: increase stack size
* cli: fix rpc lockup
* cli: better lockup fix
* cli: fix f18
* fix merge
---------
Co-authored-by: Georgii Surkov <georgii.surkov@outlook.com>
Co-authored-by: あく <alleteam@gmail.com>
2025-04-02 22:10:10 +04:00
|
|
|
cli_command_gpio_set(pipe, args, context);
|
2022-06-10 00:04:36 +09:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2022-10-06 01:15:23 +10:00
|
|
|
if(furi_string_cmp_str(cmd, "read") == 0) {
|
[FL-3954, FL-3955] New CLI architecture (#4111)
* feat: FuriThread stdin
* ci: fix f18
* feat: stdio callback context
* feat: FuriPipe
* POTENTIALLY EXPLOSIVE pipe welding
* fix: non-explosive welding
* Revert welding
* docs: furi_pipe
* feat: pipe event loop integration
* update f18 sdk
* f18
* docs: make doxygen happy
* fix: event loop not triggering when pipe attached to stdio
* fix: partial stdout in pipe
* allow simultaneous in and out subscription in event loop
* feat: vcp i/o
* feat: cli ansi stuffs and history
* feat: more line editing
* working but slow cli rewrite
* restore previous speed after 4 days of debugging 🥲
* fix: cli_app_should_stop
* fix: cli and event_loop memory leaks
* style: remove commented out code
* ci: fix pvs warnings
* fix: unit tests, event_loop crash
* ci: fix build
* ci: silence pvs warning
* feat: cli gpio
* ci: fix formatting
* Fix memory leak during event loop unsubscription
* Event better memory leak fix
* feat: cli completions
* Merge remote-tracking branch 'origin/dev' into portasynthinca3/3928-cli-threads
* merge fixups
* temporarily exclude speaker_debug app
* pvs and unit tests fixups
* feat: commands in fals
* move commands out of flash, code cleanup
* ci: fix errors
* fix: run commands in buffer when stopping session
* speedup cli file transfer
* fix f18
* separate cli_shell into modules
* fix pvs warning
* fix qflipper refusing to connect
* remove temp debug logs
* remove erroneous conclusion
* Fix memory leak during event loop unsubscription
* Event better memory leak fix
* unit test for the fix
* improve thread stdio callback signatures
* pipe stdout timeout
* update api symbols
* fix f18, formatting
* fix pvs warnings
* increase stack size, hope to fix unit tests
* cli: revert flag changes
* cli: fix formatting
* cli, fbt: loopback perf benchmark
* thread, event_loop: subscribing to thread flags
* cli: signal internal events using thread flags, improve performance
* fix f18, formatting
* event_loop: fix crash
* storage_cli: increase write_chunk buffer size again
* cli: explanation for order=0
* thread, event_loop: thread flags callback refactor
* cli: increase stack size
* cli: rename cli_app_should_stop -> cli_is_pipe_broken_or_is_etx_next_char
* cli: use plain array instead of mlib for history
* cli: prepend file name to static fns
* cli: fix formatting
* cli_shell: increase stack size
* cli: fix rpc lockup
* cli: better lockup fix
* cli: fix f18
* fix merge
---------
Co-authored-by: Georgii Surkov <georgii.surkov@outlook.com>
Co-authored-by: あく <alleteam@gmail.com>
2025-04-02 22:10:10 +04:00
|
|
|
cli_command_gpio_read(pipe, args, context);
|
2022-06-10 00:04:36 +09:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
cli_command_gpio_print_usage();
|
|
|
|
|
} while(false);
|
|
|
|
|
|
2022-10-06 01:15:23 +10:00
|
|
|
furi_string_free(cmd);
|
2022-06-10 00:04:36 +09:00
|
|
|
}
|