mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-14 14:58:36 -07:00
Merge branch 'dev' of https://github.com/DarkFlippers/unleashed-firmware into xfw-dev
This commit is contained in:
65
applications/external/swd_probe/swd_probe_app.c
vendored
65
applications/external/swd_probe/swd_probe_app.c
vendored
@@ -682,7 +682,7 @@ static bool swd_apscan_test(AppFSM* const ctx, uint32_t ap) {
|
||||
static void swd_script_log(ScriptContext* ctx, FuriLogLevel level, const char* format, ...) {
|
||||
bool commandline = false;
|
||||
ScriptContext* cur = ctx;
|
||||
char buffer[256];
|
||||
FuriString* buffer = furi_string_alloc();
|
||||
va_list argp;
|
||||
va_start(argp, format);
|
||||
|
||||
@@ -707,17 +707,19 @@ static void swd_script_log(ScriptContext* ctx, FuriLogLevel level, const char* f
|
||||
break;
|
||||
}
|
||||
|
||||
strcpy(buffer, prefix);
|
||||
size_t pos = strlen(buffer);
|
||||
vsnprintf(&buffer[pos], sizeof(buffer) - pos - 2, format, argp);
|
||||
strcat(buffer, "\n");
|
||||
if(!usb_uart_tx_data(ctx->app->uart, (uint8_t*)buffer, strlen(buffer))) {
|
||||
furi_string_cat_str(buffer, prefix);
|
||||
furi_string_cat_printf(buffer, format, argp);
|
||||
furi_string_cat_str(buffer, "\n");
|
||||
|
||||
if(!usb_uart_tx_data(
|
||||
ctx->app->uart, (uint8_t*)furi_string_get_cstr(buffer), furi_string_size(buffer))) {
|
||||
DBGS("Sending via USB failed");
|
||||
}
|
||||
} else {
|
||||
LOG(buffer);
|
||||
LOG(furi_string_get_cstr(buffer));
|
||||
}
|
||||
va_end(argp);
|
||||
furi_string_free(buffer);
|
||||
}
|
||||
|
||||
/* read characters until newline was read */
|
||||
@@ -942,41 +944,44 @@ static bool swd_scriptfunc_goto(ScriptContext* ctx) {
|
||||
return true;
|
||||
}
|
||||
|
||||
#include <toolbox/path.h>
|
||||
|
||||
static bool swd_scriptfunc_call(ScriptContext* ctx) {
|
||||
DBGS("call");
|
||||
|
||||
swd_script_skip_whitespace(ctx);
|
||||
|
||||
/* fetch previous file directory */
|
||||
char filename[MAX_FILE_LENGTH];
|
||||
strncpy(filename, ctx->filename, sizeof(filename));
|
||||
char* path = strrchr(filename, '/');
|
||||
path[1] = '\000';
|
||||
FuriString* filepath = furi_string_alloc();
|
||||
path_extract_dirname(ctx->filename, filepath);
|
||||
// strncpy(filename, ctx->filename, sizeof(filename));
|
||||
|
||||
/* append filename */
|
||||
if(!swd_script_get_string(ctx, &path[1], sizeof(filename) - strlen(path))) {
|
||||
swd_script_log(ctx, FuriLogLevelError, "failed to parse filename");
|
||||
return false;
|
||||
}
|
||||
char filename[MAX_FILE_LENGTH] = {};
|
||||
bool success = false;
|
||||
do {
|
||||
/* append filename */
|
||||
if(!swd_script_get_string(ctx, filename, sizeof(filename))) {
|
||||
swd_script_log(ctx, FuriLogLevelError, "failed to parse filename");
|
||||
break;
|
||||
}
|
||||
|
||||
swd_script_seek_newline(ctx);
|
||||
swd_script_seek_newline(ctx);
|
||||
/* append extension */
|
||||
furi_string_cat_str(filepath, ".swd");
|
||||
|
||||
/* append extension */
|
||||
if(strlen(filename) + 5 >= sizeof(filename)) {
|
||||
swd_script_log(ctx, FuriLogLevelError, "name too long");
|
||||
return false;
|
||||
}
|
||||
bool ret = swd_execute_script(ctx->app, furi_string_get_cstr(filepath));
|
||||
|
||||
strcat(filename, ".swd");
|
||||
if(!ret) {
|
||||
swd_script_log(
|
||||
ctx, FuriLogLevelError, "failed to exec '%s'", furi_string_get_cstr(filepath));
|
||||
break;
|
||||
}
|
||||
|
||||
bool ret = swd_execute_script(ctx->app, filename);
|
||||
success = true;
|
||||
} while(false);
|
||||
furi_string_free(filepath);
|
||||
|
||||
if(!ret) {
|
||||
swd_script_log(ctx, FuriLogLevelError, "failed to exec '%s'", filename);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return success;
|
||||
}
|
||||
|
||||
static bool swd_scriptfunc_status(ScriptContext* ctx) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#ifndef __ARHA_FLIPPERAPP_DEMO
|
||||
#define __ARHA_FLIPPERAPP_DEMO
|
||||
#ifndef __SWD_PROBE_APP_H
|
||||
#define __SWD_PROBE_APP_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
@@ -17,10 +17,6 @@
|
||||
#include <storage/storage.h>
|
||||
#include <notification/notification.h>
|
||||
#include <notification/notification_messages.h>
|
||||
#include <lib/subghz/receiver.h>
|
||||
#include <lib/subghz/transmitter.h>
|
||||
#include <lib/subghz/subghz_file_encoder_worker.h>
|
||||
#include <notification/notification.h>
|
||||
|
||||
#include "usb_uart.h"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user