1
mirror of https://github.com/DarkFlippers/unleashed-firmware.git synced 2025-12-12 04:34:43 +04:00

Merge remote-tracking branch 'OFW/dev' into dev

This commit is contained in:
MX
2024-10-02 23:18:30 +03:00
16 changed files with 349 additions and 230 deletions

View File

@@ -1,6 +1,5 @@
#include <furi.h>
#include <gui/gui.h>
#include <gui/canvas_i.h>
#include <input/input.h>
#define BUFFER_SIZE (32U)
@@ -42,10 +41,11 @@ static DirectDraw* direct_draw_alloc(void) {
static void direct_draw_free(DirectDraw* instance) {
furi_pubsub_unsubscribe(instance->input, instance->input_subscription);
instance->canvas = NULL;
gui_direct_draw_release(instance->gui);
furi_record_close(RECORD_GUI);
furi_record_close(RECORD_INPUT_EVENTS);
free(instance);
}
static void direct_draw_block(Canvas* canvas, uint32_t size, uint32_t counter) {

View File

@@ -1091,3 +1091,49 @@ type: raw
frequency: 38000
duty_cycle: 0.330000
data: 4388 4399 572 1583 573 532 546 1585 571 1583 574 503 575 505 573 1584 572 504 574 505 573 1584 573 506 572 504 573 1584 573 1584 572 505 574 1611 545 506 573 1583 573 1585 571 1586 545 1609 547 531 547 1611 545 1608 548 1607 549 530 548 529 548 531 548 532 546 1610 546 533 545 530 547 1609 547 1610 547 1609 547 533 545 529 548 530 548 530 547 531 546 530 547 530 548 533 544 1608 548 1608 548 1610 546 1606 550 1609 547 5203 4388 4397 548 1609 547 531 547 1608 548 1608 548 530 548 530 548 1608 548 531 547 531 547 1610 546 531 547 530 548 1609 547 1611 546 532 547 1609 547 531 547 1608 548 1610 546 1609 547 1608 548 530 547 1609 547 1608 548 1609 547 531 546 530 548 530 547 530 547 1608 548 532 547 534 545 1608 548 1608 548 1609 547 530 548 531 547 531 547 532 546 531 546 531 547 532 546 530 548 1608 547 1608 548 1610 546 1608 548 1608 548
#
# Model: Panasonic CS-E9HKR
#
name: Dh
type: raw
frequency: 38000
duty_cycle: 0.330000
data: 3466 1748 445 367 502 1292 444 422 444 420 445 422 443 420 445 421 445 420 445 363 503 420 445 422 444 420 445 424 445 1292 445 421 445 451 414 421 444 421 444 421 445 422 443 423 446 1292 443 1292 445 1292 445 421 497 372 444 1293 445 420 445 421 444 421 444 421 445 421 444 421 444 420 445 422 444 420 445 421 444 421 444 421 445 422 443 356 509 420 445 421 445 429 436 421 444 421 444 414 452 420 445 421 444 421 444 423 443 421 444 421 444 421 444 423 443 420 445 424 445 1291 444 1294 444 421 444 421 444 421 444 422 444 423 445 9989 3463 1752 444 424 445 1293 443 422 444 392 473 421 444 416 449 423 443 421 444 421 444 421 444 423 443 422 443 425 444 1292 444 423 443 422 443 419 446 421 444 423 443 421 444 426 443 1292 444 1294 443 1294 443 421 444 425 444 1294 444 422 443 421 444 422 443 424 442 421 444 421 444 421 444 423 444 421 444 422 443 421 444 423 443 425 444 1293 444 421 444 421 444 1293 444 423 446 1292 445 321 546 421 444 421 444 385 480 423 443 425 444 1291 445 1293 443 422 445 422 443 421 444 421 496 370 444 422 443 421 496 370 443 421 444 1291 497 1239 444 1284 504 1237 447 1293 444 425 444 1293 496 371 494 1241 495 370 496 369 497 297 517 421 496 370 495 369 496 370 496 370 495 370 495 369 496 372 494 370 495 369 496 370 495 370 496 370 495 373 495 1240 495 1241 495 1240 497 369 496 371 494 371 443 422 496 369 496 368 497 370 496 369 496 372 497 1239 496 1241 496 1241 496 370 495 310 555 371 495 371 494 368 497 370 495 370 496 361 504 370 495 369 496 372 494 372 494 369 496 371 494 371 495 373 495 1240 497 370 495 371 495 370 495 369 496 370 495 370 495 1242 495 373 492 370 495 366 500 369 496 371 495 370 495 371 495 369 496 371 494 370 495 371 495 371 494 371 494 370 495 372 494 380 488 1241 496 374 495 1241 495 1240 495 1240 495 1241 495 1242 494 1244 494
#
name: Cool_hi
type: raw
frequency: 38000
duty_cycle: 0.330000
data: 3467 1751 442 425 444 1294 443 424 442 422 443 423 442 422 443 422 444 421 444 421 444 424 441 423 443 421 444 425 444 1294 443 424 442 423 442 422 443 425 440 423 443 423 442 427 442 1292 443 1322 415 1293 444 422 443 425 443 1295 443 424 441 421 444 423 442 424 442 425 440 423 442 423 442 424 442 292 573 421 444 423 442 422 444 422 443 422 443 423 442 425 441 423 442 425 440 421 444 424 442 422 443 422 443 422 443 424 442 422 443 422 443 422 443 424 442 421 444 426 443 1292 443 1294 444 423 442 422 443 423 442 424 442 426 442 9989 3465 1753 442 425 444 1292 445 424 442 424 441 421 444 422 443 422 444 423 442 423 442 352 513 423 443 423 442 425 443 1296 441 423 443 422 443 422 443 424 441 423 443 422 443 427 442 1293 442 1322 415 1293 444 421 444 425 443 1294 444 422 443 422 443 421 444 425 441 423 442 422 443 421 444 423 443 421 444 422 443 422 443 424 442 425 444 1261 475 422 443 422 443 1292 444 1293 442 1295 441 424 442 422 443 422 443 427 442 1322 415 1292 444 1292 444 1294 442 423 443 422 443 421 444 422 443 423 443 421 444 421 444 423 442 421 444 1291 444 1293 443 1294 442 1195 541 1293 444 425 443 1293 443 422 444 1322 414 421 444 422 443 423 443 422 443 423 442 422 443 425 441 422 443 422 443 423 442 423 443 422 443 422 443 421 444 423 444 421 444 424 444 1292 444 1293 444 1294 442 422 443 421 444 423 443 422 443 421 444 422 443 424 442 421 444 426 443 1291 444 1293 443 1293 444 422 443 421 444 422 444 421 444 422 443 421 444 423 443 423 442 421 444 422 443 423 444 421 444 421 444 421 444 422 444 425 444 1294 443 422 443 423 444 424 441 422 443 422 443 422 443 1294 443 422 443 421 444 424 442 421 444 413 452 421 444 423 443 421 444 422 443 422 443 422 444 421 444 422 443 422 443 423 443 426 443 1294 442 421 444 423 442 1293 443 1293 443 421 444 422 444 362 505
#
name: Cool_lo
type: raw
frequency: 38000
duty_cycle: 0.330000
data: 3467 1751 444 424 444 1291 446 422 444 420 445 420 445 419 446 421 445 378 487 421 444 420 445 420 446 421 444 423 446 1321 415 451 415 420 445 420 445 419 446 421 445 419 446 422 447 1290 445 1291 445 1291 446 420 445 424 445 1293 445 420 445 420 445 420 445 421 445 420 445 420 445 419 446 421 445 420 445 421 444 420 445 421 445 420 445 420 445 420 445 421 445 419 446 420 445 420 445 420 446 420 445 421 444 419 446 422 444 420 445 420 445 421 444 421 445 421 444 424 445 1290 445 1292 446 420 445 421 444 420 445 423 443 424 444 9988 3465 1751 446 423 445 1291 446 421 445 420 445 420 445 420 445 422 444 420 445 420 445 421 444 421 446 421 444 424 445 1291 446 421 445 421 444 420 445 420 445 420 446 421 444 423 446 1291 444 1293 444 1292 445 420 445 423 446 1294 444 419 446 420 445 421 444 422 444 420 445 421 444 420 445 421 445 421 444 420 445 420 445 422 444 421 444 420 445 420 445 421 444 1320 415 1291 445 1292 444 422 444 420 445 419 446 420 445 421 445 421 444 424 445 1291 446 421 445 420 445 420 445 421 444 421 445 421 444 421 444 420 445 420 445 1291 445 1292 443 1290 445 1291 446 1292 445 424 444 1293 444 421 444 1292 445 422 443 421 444 381 485 420 445 420 445 420 445 422 444 421 444 420 445 421 444 421 445 421 444 421 444 420 445 421 445 421 444 424 445 1291 444 1292 445 1291 446 420 445 419 446 422 444 421 444 420 445 420 445 421 445 420 445 423 446 1291 444 1291 446 1292 445 420 445 420 445 422 444 420 445 420 445 420 445 422 444 421 444 420 445 419 446 420 446 420 445 419 446 419 446 421 445 423 445 1293 444 419 446 421 445 420 445 419 446 420 445 420 445 1292 445 420 445 420 445 421 445 420 445 419 446 419 446 420 446 419 446 420 445 420 445 420 446 420 445 420 445 420 445 421 445 419 446 420 445 423 446 1292 445 1290 445 1290 445 1292 444 1291 445 1293 445
#
name: Heat_hi
type: raw
frequency: 38000
duty_cycle: 0.330000
data: 3463 1751 443 424 445 1293 443 422 444 420 445 421 444 421 444 422 444 421 444 421 444 421 444 353 513 422 443 425 444 1293 444 422 444 421 444 420 445 421 444 422 444 421 444 425 444 1291 444 1294 443 1293 444 421 444 424 445 1294 444 420 445 421 444 416 449 422 444 421 444 421 444 421 444 422 444 420 445 421 444 422 443 422 444 421 444 421 444 420 445 373 493 420 445 421 444 420 445 422 444 420 445 422 443 421 444 422 444 421 444 421 444 422 443 421 445 421 444 424 445 1291 444 1294 444 421 444 420 445 420 445 422 444 424 444 9991 3463 1751 445 425 444 1293 444 422 444 421 444 420 445 421 444 423 443 421 444 421 444 421 444 422 444 421 444 424 445 1293 444 422 444 420 445 422 443 421 444 424 442 421 444 425 444 1292 443 1292 445 1292 445 421 444 424 445 1293 445 421 444 421 444 421 444 422 444 421 444 421 444 422 443 422 444 423 442 421 444 423 442 423 443 425 443 1293 444 423 442 421 444 1292 444 422 443 425 443 1295 443 421 444 368 549 373 443 1293 496 1240 495 1240 495 1241 496 371 495 370 495 370 495 370 495 371 495 370 495 369 496 371 494 371 494 1240 442 1293 495 1240 496 1241 496 1240 497 373 496 1241 496 371 494 1184 553 370 495 370 495 370 496 370 443 423 494 370 443 424 495 370 442 423 442 422 443 424 442 423 442 423 442 425 440 424 442 424 441 427 442 1294 441 1294 443 1294 443 424 441 423 442 425 442 421 444 423 442 424 441 425 441 424 441 426 443 1293 442 1295 442 1295 441 424 441 394 471 425 441 423 442 423 442 424 441 424 442 424 441 423 442 423 442 424 442 423 442 424 441 423 442 424 442 428 440 1295 442 424 441 425 441 424 441 424 441 423 442 424 441 1294 443 424 441 424 441 424 442 423 442 423 442 423 442 425 441 424 441 424 441 424 441 424 442 424 441 449 416 423 442 424 442 427 442 1295 442 424 441 424 441 1295 442 427 442 1295 441 425 441 426 441
#
name: Heat_lo
type: raw
frequency: 38000
duty_cycle: 0.330000
data: 3461 1753 439 429 440 1298 439 427 439 426 439 426 439 426 439 427 439 426 439 426 439 426 439 427 439 426 439 430 438 1298 438 428 438 426 439 427 438 427 438 427 439 427 438 430 414 1321 439 1299 413 1323 414 451 414 455 414 1324 414 452 413 451 414 453 413 436 430 452 413 452 413 451 414 453 413 452 413 451 414 452 413 454 412 452 413 452 413 452 413 453 413 452 413 452 413 452 413 454 413 453 412 452 413 452 413 453 413 452 413 452 413 452 413 453 413 452 413 456 412 1323 412 1325 413 452 413 453 412 453 412 454 412 455 390 10044 3438 1779 412 457 412 1324 413 454 412 453 412 453 412 453 412 454 412 453 412 453 412 454 411 455 411 453 412 457 389 1347 390 477 389 476 389 476 389 476 389 402 465 475 390 479 390 1346 389 1348 389 1347 390 476 389 479 390 1348 390 476 389 476 389 476 389 477 389 475 390 476 389 476 389 477 389 476 389 476 389 476 389 478 388 480 389 1347 390 475 390 476 389 1347 390 476 389 479 389 1349 389 476 389 476 389 476 389 477 389 476 389 479 390 1348 389 477 389 476 389 476 389 476 389 476 390 476 389 476 389 476 389 476 389 1346 389 1347 389 1346 389 1347 390 1346 390 479 390 1347 390 476 389 1374 363 474 415 454 388 480 386 475 414 454 387 474 391 476 414 455 387 473 392 476 414 453 389 476 389 475 390 475 390 476 390 476 390 479 389 1346 389 1347 390 1348 389 476 389 476 389 477 389 476 389 476 389 475 390 477 389 440 425 479 389 1345 390 1347 390 1347 390 476 389 475 390 477 389 476 389 476 389 476 389 477 389 476 389 476 389 475 390 477 389 476 389 476 389 476 389 477 389 479 390 1347 390 476 389 477 389 476 389 476 389 476 389 476 389 1347 390 476 389 476 389 477 389 503 362 476 389 476 389 477 389 475 390 476 389 476 389 477 389 476 389 476 389 476 389 477 389 479 389 1347 390 479 390 1347 390 1348 389 476 389 476 389 477 389 477 390
#
name: Off
type: raw
frequency: 38000
duty_cycle: 0.330000
data: 3489 1725 493 375 493 1167 569 375 491 373 492 372 493 374 492 373 493 372 493 373 442 423 492 375 493 372 492 378 490 1245 443 423 493 374 491 375 490 374 442 424 492 374 491 379 440 1293 492 1245 443 1294 442 423 491 379 441 1296 491 375 441 423 442 423 442 425 441 423 442 425 440 424 441 425 441 424 441 421 444 424 441 425 441 423 442 423 442 423 442 453 413 424 442 451 414 424 441 426 440 424 441 424 441 424 441 425 441 424 441 424 441 424 441 426 440 425 440 427 442 1322 413 1296 442 424 441 423 442 424 441 424 442 427 441 9994 3463 1755 440 428 441 1296 441 426 440 425 440 426 439 425 440 426 440 423 442 425 440 425 440 372 494 425 440 428 440 1297 440 426 440 425 440 426 439 426 439 427 439 425 440 429 439 1297 439 1297 439 1297 440 426 439 429 440 1299 439 426 439 426 439 428 437 427 439 426 439 426 439 427 438 427 439 427 438 427 438 427 438 429 437 427 414 451 414 451 414 418 447 1323 414 452 413 455 414 1325 413 452 413 452 413 452 413 453 413 452 413 456 413 1324 413 453 413 452 413 453 412 452 413 454 412 453 412 453 412 453 412 452 413 1324 412 1323 412 1324 412 1324 412 1325 412 456 413 1324 412 404 461 1325 412 453 412 453 412 454 412 453 412 453 412 454 411 455 411 453 412 453 412 453 412 454 412 453 412 453 412 453 412 454 413 453 412 457 412 1323 413 1324 413 1324 412 453 412 453 412 454 413 453 412 453 412 453 412 454 412 452 413 456 412 1323 413 1324 413 1323 414 453 412 452 413 453 413 452 413 452 413 452 413 453 413 450 415 452 413 452 413 453 413 452 413 451 439 427 438 428 439 430 439 1298 439 426 439 428 438 426 439 428 437 426 439 427 438 1298 439 427 438 426 439 427 439 426 439 426 439 425 440 427 440 426 439 426 439 426 439 425 441 426 439 425 440 425 440 427 439 426 439 425 440 429 439 1297 440 1297 440 425 440 425 440 426 441 427 440
#
# Model: Maytag M6X06F2A
#
name: Off
type: parsed
protocol: NEC
address: 20 00 00 00
command: 02 00 00 00

View File

@@ -1,5 +1,5 @@
#include "thread.h"
#include "thread_list.h"
#include "thread_list_i.h"
#include "kernel.h"
#include "memmgr.h"
#include "memmgr_heap.h"
@@ -65,6 +65,9 @@ struct FuriThread {
// IMPORTANT: container MUST be the FIRST struct member
static_assert(offsetof(FuriThread, container) == 0);
// Our idle priority should be equal to the one from FreeRTOS
static_assert(FuriThreadPriorityIdle == tskIDLE_PRIORITY);
static size_t __furi_thread_stdout_write(FuriThread* thread, const char* data, size_t size);
static int32_t __furi_thread_stdout_flush(FuriThread* thread);
@@ -145,6 +148,8 @@ static void furi_thread_init_common(FuriThread* thread) {
furi_thread_set_appid(thread, "driver");
}
thread->priority = FuriThreadPriorityNormal;
FuriHalRtcHeapTrackMode mode = furi_hal_rtc_get_heap_track_mode();
if(mode == FuriHalRtcHeapTrackModeAll) {
thread->heap_trace_enabled = true;
@@ -269,7 +274,7 @@ void furi_thread_set_context(FuriThread* thread, void* context) {
void furi_thread_set_priority(FuriThread* thread, FuriThreadPriority priority) {
furi_check(thread);
furi_check(thread->state == FuriThreadStateStopped);
furi_check(priority >= FuriThreadPriorityIdle && priority <= FuriThreadPriorityIsr);
furi_check(priority <= FuriThreadPriorityIsr);
thread->priority = priority;
}
@@ -281,9 +286,7 @@ FuriThreadPriority furi_thread_get_priority(FuriThread* thread) {
void furi_thread_set_current_priority(FuriThreadPriority priority) {
furi_check(priority <= FuriThreadPriorityIsr);
UBaseType_t new_priority = priority ? priority : FuriThreadPriorityNormal;
vTaskPrioritySet(NULL, new_priority);
vTaskPrioritySet(NULL, priority);
}
FuriThreadPriority furi_thread_get_current_priority(void) {
@@ -345,7 +348,6 @@ void furi_thread_start(FuriThread* thread) {
furi_thread_set_state(thread, FuriThreadStateStarting);
uint32_t stack_depth = thread->stack_size / sizeof(StackType_t);
UBaseType_t priority = thread->priority ? thread->priority : FuriThreadPriorityNormal;
thread->is_active = true;
@@ -355,7 +357,7 @@ void furi_thread_start(FuriThread* thread) {
thread->name,
stack_depth,
thread,
priority,
thread->priority,
thread->stack_buffer,
&thread->container) == (TaskHandle_t)thread);
}

View File

@@ -30,11 +30,10 @@ typedef enum {
* @brief Enumeration of possible FuriThread priorities.
*/
typedef enum {
FuriThreadPriorityNone = 0, /**< Uninitialized, choose system default */
FuriThreadPriorityIdle = 1, /**< Idle priority */
FuriThreadPriorityIdle = 0, /**< Idle priority */
FuriThreadPriorityLowest = 14, /**< Lowest */
FuriThreadPriorityLow = 15, /**< Low */
FuriThreadPriorityNormal = 16, /**< Normal */
FuriThreadPriorityNormal = 16, /**< Normal, system default */
FuriThreadPriorityHigh = 17, /**< High */
FuriThreadPriorityHighest = 18, /**< Highest */
FuriThreadPriorityIsr =

View File

@@ -84,7 +84,7 @@ FuriThreadListItem* furi_thread_list_get_or_insert(FuriThreadList* instance, Fur
}
void furi_thread_list_process(FuriThreadList* instance, uint32_t runtime, uint32_t tick) {
furi_check(instance);
furi_assert(instance);
instance->runtime_previous = instance->runtime_current;
instance->runtime_current = runtime;

View File

@@ -68,14 +68,6 @@ FuriThreadListItem* furi_thread_list_get_at(FuriThreadList* instance, size_t pos
*/
FuriThreadListItem* furi_thread_list_get_or_insert(FuriThreadList* instance, FuriThread* thread);
/** Process items in the FuriThreadList instance
*
* @param instance The instance
* @param[in] runtime The runtime of the system since start
* @param[in] tick The tick when processing happened
*/
void furi_thread_list_process(FuriThreadList* instance, uint32_t runtime, uint32_t tick);
/** Get percent of time spent in ISR
*
* @param instance The instance

19
furi/core/thread_list_i.h Normal file
View File

@@ -0,0 +1,19 @@
#pragma once
#include "thread_list.h"
#ifdef __cplusplus
extern "C" {
#endif
/** Process items in the FuriThreadList instance
*
* @param instance The instance
* @param[in] runtime The runtime of the system since start
* @param[in] tick The tick when processing happened
*/
void furi_thread_list_process(FuriThreadList* instance, uint32_t runtime, uint32_t tick);
#ifdef __cplusplus
}
#endif

View File

@@ -1,3 +1,9 @@
/** Bit Buffer
*
* Various bits and bytes manipulation tools.
*
* @file bit_buffer.h
*/
#pragma once
#include <stddef.h>
@@ -10,25 +16,21 @@ extern "C" {
typedef struct BitBuffer BitBuffer;
// Construction, deletion, reset
/**
* Allocate a BitBuffer instance.
/** Allocate a BitBuffer instance.
*
* @param[in] capacity_bytes maximum buffer capacity, in bytes
*
* @return pointer to the allocated BitBuffer instance
*/
BitBuffer* bit_buffer_alloc(size_t capacity_bytes);
/**
* Delete a BitBuffer instance.
/** Delete a BitBuffer instance.
*
* @param[in,out] buf pointer to a BitBuffer instance
*/
void bit_buffer_free(BitBuffer* buf);
/**
* Clear all data from a BitBuffer instance.
/** Clear all data from a BitBuffer instance.
*
* @param[in,out] buf pointer to a BitBuffer instance
*/
@@ -36,22 +38,22 @@ void bit_buffer_reset(BitBuffer* buf);
// Copy and write
/**
* Copy another BitBuffer instance's contents to this one, replacing
* all of the original data.
* The destination capacity must be no less than the source data size.
/** Copy another BitBuffer instance's contents to this one, replacing all of the
* original data.
*
* @warning The destination capacity must be no less than the source data
* size.
*
* @param[in,out] buf pointer to a BitBuffer instance to copy into
* @param[in] other pointer to a BitBuffer instance to copy from
* @note
*/
void bit_buffer_copy(BitBuffer* buf, const BitBuffer* other);
/**
* Copy all BitBuffer instance's contents to this one, starting from start_index,
* replacing all of the original data.
* The destination capacity must be no less than the source data size
* counting from start_index.
/** Copy all BitBuffer instance's contents to this one, starting from
* start_index, replacing all of the original data.
*
* @warning The destination capacity must be no less than the source data
* size counting from start_index.
*
* @param[in,out] buf pointer to a BitBuffer instance to copy into
* @param[in] other pointer to a BitBuffer instance to copy from
@@ -59,11 +61,11 @@ void bit_buffer_copy(BitBuffer* buf, const BitBuffer* other);
*/
void bit_buffer_copy_right(BitBuffer* buf, const BitBuffer* other, size_t start_index);
/**
* Copy all BitBuffer instance's contents to this one, ending with end_index,
/** Copy all BitBuffer instance's contents to this one, ending with end_index,
* replacing all of the original data.
* The destination capacity must be no less than the source data size
* counting to end_index.
*
* @warning The destination capacity must be no less than the source data
* size counting to end_index.
*
* @param[in,out] buf pointer to a BitBuffer instance to copy into
* @param[in] other pointer to a BitBuffer instance to copy from
@@ -71,9 +73,11 @@ void bit_buffer_copy_right(BitBuffer* buf, const BitBuffer* other, size_t start_
*/
void bit_buffer_copy_left(BitBuffer* buf, const BitBuffer* other, size_t end_index);
/**
* Copy a byte array to a BitBuffer instance, replacing all of the original data.
* The destination capacity must be no less than the source data size.
/** Copy a byte array to a BitBuffer instance, replacing all of the original
* data.
*
* @warning The destination capacity must be no less than the source data
* size.
*
* @param[in,out] buf pointer to a BitBuffer instance to copy into
* @param[in] data pointer to the byte array to be copied
@@ -81,9 +85,11 @@ void bit_buffer_copy_left(BitBuffer* buf, const BitBuffer* other, size_t end_ind
*/
void bit_buffer_copy_bytes(BitBuffer* buf, const uint8_t* data, size_t size_bytes);
/**
* Copy a byte array to a BitBuffer instance, replacing all of the original data.
* The destination capacity must be no less than the source data size.
/** Copy a byte array to a BitBuffer instance, replacing all of the original
* data.
*
* @warning The destination capacity must be no less than the source data
* size.
*
* @param[in,out] buf pointer to a BitBuffer instance to copy into
* @param[in] data pointer to the byte array to be copied
@@ -91,20 +97,25 @@ void bit_buffer_copy_bytes(BitBuffer* buf, const uint8_t* data, size_t size_byte
*/
void bit_buffer_copy_bits(BitBuffer* buf, const uint8_t* data, size_t size_bits);
/**
* Copy a byte with parity array to a BitBuffer instance, replacing all of the original data.
* The destination capacity must be no less than the source data size.
/** Copy a byte with parity array to a BitBuffer instance, replacing all of the
* original data.
*
* @warning The destination capacity must be no less than the source data
* size.
*
* @param[in,out] buf pointer to a BitBuffer instance to copy into
* @param[in] data pointer to the byte array to be copied
* @param [in] size_bitss size of the data to be copied, in bits
* @param[in] size_bits size of the data to be copied, in bits
* @note Parity bits are placed starting with the most significant bit
* of each byte and moving up.
* @note Example: DDDDDDDD PDDDDDDD DPDDDDDD DDP...
*/
void bit_buffer_copy_bytes_with_parity(BitBuffer* buf, const uint8_t* data, size_t size_bits);
/**
* Write a BitBuffer instance's entire contents to an arbitrary memory location.
* The destination memory must be allocated. Additionally, the destination
* capacity must be no less than the source data size.
/** Write a BitBuffer instance's entire contents to an arbitrary memory location.
*
* @warning The destination memory must be allocated. Additionally, the
* destination capacity must be no less than the source data size.
*
* @param[in] buf pointer to a BitBuffer instance to write from
* @param[out] dest pointer to the destination memory location
@@ -112,16 +123,21 @@ void bit_buffer_copy_bytes_with_parity(BitBuffer* buf, const uint8_t* data, size
*/
void bit_buffer_write_bytes(const BitBuffer* buf, void* dest, size_t size_bytes);
/**
* Write a BitBuffer instance's entire contents to an arbitrary memory location.
/** Write a BitBuffer instance's entire contents to an arbitrary memory location.
*
* Additionally, place a parity bit after each byte.
* The destination memory must be allocated. Additionally, the destination
* capacity must be no less than the source data size plus parity.
*
* @warning The destination memory must be allocated. Additionally, the
* destination capacity must be no less than the source data size
* plus parity.
*
* @param[in] buf pointer to a BitBuffer instance to write from
* @param[out] dest pointer to the destination memory location
* @param[in] size_bytes maximum destination data size, in bytes
* @param [out] bits_written actual number of bits writen, in bits
* @param[out] bits_written actual number of bits written, in bits
* @note Parity bits are placed starting with the most significant bit of
* each byte and moving up.
* @note Example: DDDDDDDD PDDDDDDD DPDDDDDD DDP...
*/
void bit_buffer_write_bytes_with_parity(
const BitBuffer* buf,
@@ -129,10 +145,12 @@ void bit_buffer_write_bytes_with_parity(
size_t size_bytes,
size_t* bits_written);
/**
* Write a slice of BitBuffer instance's contents to an arbitrary memory location.
* The destination memory must be allocated. Additionally, the destination
* capacity must be no less than the requested slice size.
/** Write a slice of BitBuffer instance's contents to an arbitrary memory
* location.
*
* @warning The destination memory must be allocated. Additionally, the
* destination capacity must be no less than the requested slice
* size.
*
* @param[in] buf pointer to a BitBuffer instance to write from
* @param[out] dest pointer to the destination memory location
@@ -147,93 +165,107 @@ void bit_buffer_write_bytes_mid(
// Checks
/**
* Check whether a BitBuffer instance contains a partial byte (i.e. the bit count
* is not divisible by 8).
/** Check whether a BitBuffer instance contains a partial byte (i.e.\ the bit
* count is not divisible by 8).
*
* @param[in] buf pointer to a BitBuffer instance to be checked
*
* @return true if the instance contains a partial byte, false otherwise
*/
bool bit_buffer_has_partial_byte(const BitBuffer* buf);
/**
* Check whether a BitBuffer instance's contents start with the designated byte.
/** Check whether a BitBuffer instance's contents start with the designated byte.
*
* @param[in] buf pointer to a BitBuffer instance to be checked
* @param[in] byte byte value to be checked against
*
* @return true if data starts with designated byte, false otherwise
*/
bool bit_buffer_starts_with_byte(const BitBuffer* buf, uint8_t byte);
// Getters
/**
* Get a BitBuffer instance's capacity (i.e. the maximum possible amount of data), in bytes.
/** Get a BitBuffer instance's capacity (i.e.\ the maximum possible amount of
* data), in bytes.
*
* @param[in] buf pointer to a BitBuffer instance to be queried
*
* @return capacity, in bytes
*/
size_t bit_buffer_get_capacity_bytes(const BitBuffer* buf);
/**
* Get a BitBuffer instance's data size (i.e. the amount of stored data), in bits.
* Might be not divisible by 8 (see bit_buffer_is_partial_byte).
/** Get a BitBuffer instance's data size (i.e.\ the amount of stored data), in
* bits.
*
* @warning Might be not divisible by 8 (see bit_buffer_is_partial_byte).
*
* @param[in] buf pointer to a BitBuffer instance to be queried
*
* @return data size, in bits.
*/
size_t bit_buffer_get_size(const BitBuffer* buf);
/**
* Get a BitBuffer instance's data size (i.e. the amount of stored data), in bytes.
* If a partial byte is present, it is also counted.
* Get a BitBuffer instance's data size (i.e.\ the amount of stored data), in
* bytes.
*
* @warning If a partial byte is present, it is also counted.
*
* @param[in] buf pointer to a BitBuffer instance to be queried
*
* @return data size, in bytes.
*/
size_t bit_buffer_get_size_bytes(const BitBuffer* buf);
/**
* Get a byte value at a specified index in a BitBuffer instance.
* The index must be valid (i.e. less than the instance's data size in bytes).
/** Get a byte value at a specified index in a BitBuffer instance.
*
* @warning The index must be valid (i.e.\ less than the instance's data size
* in bytes).
*
* @param[in] buf pointer to a BitBuffer instance to be queried
* @param[in] index index of the byte in question
*
* @return byte value
*/
uint8_t bit_buffer_get_byte(const BitBuffer* buf, size_t index);
/**
* Get a byte value starting from the specified bit index in a BitBuffer instance.
* The resulting byte might correspond to a single byte (if the index is a multiple
* of 8), or two overlapping bytes combined.
* The index must be valid (i.e. less than the instance's data size in bits).
/** Get a byte value starting from the specified bit index in a BitBuffer
* instance.
*
* @warning The resulting byte might correspond to a single byte (if the
* index is a multiple of 8), or two overlapping bytes combined. The
* index must be valid (i.e.\ less than the instance's data size in
* bits).
*
* @param[in] buf pointer to a BitBuffer instance to be queried
* @param [in] index bit index of the byte in question
* @param[in] index_bits bit index of the byte in question
*
* @return byte value
*/
uint8_t bit_buffer_get_byte_from_bit(const BitBuffer* buf, size_t index_bits);
/**
* Get the pointer to a BitBuffer instance's underlying data.
/** Get the pointer to a BitBuffer instance's underlying data.
*
* @param[in] buf pointer to a BitBuffer instance to be queried
*
* @return pointer to the underlying data
*/
const uint8_t* bit_buffer_get_data(const BitBuffer* buf);
/**
* Get the pointer to a BitBuffer instance's underlying data.
/** Get the pointer to the parity data of a BitBuffer instance.
*
* @param[in] buf pointer to a BitBuffer instance to be queried
* @return pointer to the underlying data
*
* @return pointer to the parity data
*/
const uint8_t* bit_buffer_get_parity(const BitBuffer* buf);
// Setters
/**
* Set byte value at a specified index in a BitBuffer instance.
* The index must be valid (i.e. less than the instance's data size in bytes).
/** Set byte value at a specified index in a BitBuffer instance.
*
* @warning The index must be valid (i.e.\ less than the instance's data
* size in bytes).
*
* @param[in,out] buf pointer to a BitBuffer instance to be modified
* @param[in] index index of the byte in question
@@ -241,19 +273,20 @@ const uint8_t* bit_buffer_get_parity(const BitBuffer* buf);
*/
void bit_buffer_set_byte(BitBuffer* buf, size_t index, uint8_t byte);
/**
* Set byte and parity bit value at a specified index in a BitBuffer instance.
* The index must be valid (i.e. less than the instance's data size in bytes).
/** Set byte and parity bit value at a specified index in a BitBuffer instance.
*
* @param [in,out] buf pointer to a BitBuffer instance to be modified
* @warning The index must be valid (i.e.\ less than the instance's data
* size in bytes).
*
* @param[in,out] buff pointer to a BitBuffer instance to be modified
* @param[in] index index of the byte in question
* @param[in] byte byte value to be set at index
* @param[in] parity parity bit value to be set at index
*/
void bit_buffer_set_byte_with_parity(BitBuffer* buff, size_t index, uint8_t byte, bool parity);
/**
* Resize a BitBuffer instance to a new size, in bits.
/** Resize a BitBuffer instance to a new size, in bits.
*
* @warning May cause bugs. Use only if absolutely necessary.
*
* @param[in,out] buf pointer to a BitBuffer instance to be resized
@@ -261,8 +294,8 @@ void bit_buffer_set_byte_with_parity(BitBuffer* buff, size_t index, uint8_t byte
*/
void bit_buffer_set_size(BitBuffer* buf, size_t new_size);
/**
* Resize a BitBuffer instance to a new size, in bytes.
/** Resize a BitBuffer instance to a new size, in bytes.
*
* @warning May cause bugs. Use only if absolutely necessary.
*
* @param[in,out] buf pointer to a BitBuffer instance to be resized
@@ -272,19 +305,21 @@ void bit_buffer_set_size_bytes(BitBuffer* buf, size_t new_size_bytes);
// Modification
/**
* Append all BitBuffer's instance contents to this one. The destination capacity
* must be no less than its original data size plus source data size.
/** Append all BitBuffer's instance contents to this one.
*
* @warning The destination capacity must be no less than its original
* data size plus source data size.
*
* @param[in,out] buf pointer to a BitBuffer instance to be appended to
* @param[in] other pointer to a BitBuffer instance to be appended
*/
void bit_buffer_append(BitBuffer* buf, const BitBuffer* other);
/**
* Append a BitBuffer's instance contents to this one, starting from start_index.
* The destination capacity must be no less than the source data size
* counting from start_index.
/** Append a BitBuffer's instance contents to this one, starting from
* start_index.
*
* @warning The destination capacity must be no less than the source data
* size counting from start_index.
*
* @param[in,out] buf pointer to a BitBuffer instance to be appended to
* @param[in] other pointer to a BitBuffer instance to be appended
@@ -292,18 +327,20 @@ void bit_buffer_append(BitBuffer* buf, const BitBuffer* other);
*/
void bit_buffer_append_right(BitBuffer* buf, const BitBuffer* other, size_t start_index);
/**
* Append a byte to a BitBuffer instance.
* The destination capacity must be no less its original data size plus one.
/** Append a byte to a BitBuffer instance.
*
* @warning The destination capacity must be no less its original data
* size plus one.
*
* @param[in,out] buf pointer to a BitBuffer instance to be appended to
* @param[in] byte byte value to be appended
*/
void bit_buffer_append_byte(BitBuffer* buf, uint8_t byte);
/**
* Append a byte array to a BitBuffer instance.
* The destination capacity must be no less its original data size plus source data size.
/** Append a byte array to a BitBuffer instance.
*
* @warning The destination capacity must be no less its original data
* size plus source data size.
*
* @param[in,out] buf pointer to a BitBuffer instance to be appended to
* @param[in] data pointer to the byte array to be appended
@@ -311,9 +348,10 @@ void bit_buffer_append_byte(BitBuffer* buf, uint8_t byte);
*/
void bit_buffer_append_bytes(BitBuffer* buf, const uint8_t* data, size_t size_bytes);
/**
* Append a bit to a BitBuffer instance.
* The destination capacity must be sufficient to accomodate the additional bit.
/** Append a bit to a BitBuffer instance.
*
* @warning The destination capacity must be sufficient to accommodate the
* additional bit.
*
* @param[in,out] buf pointer to a BitBuffer instance to be appended to
* @param[in] bit bit value to be appended

View File

@@ -32,6 +32,16 @@ class FlipperFormatFile:
raise Exception("Unexpected line: not `key:value`")
return data[0].strip(), data[1].strip()
def readComment(self):
if self.cursor == len(self.lines):
raise EOFError()
line = self.lines[self.cursor].strip()
if line.startswith("#"):
self.cursor += 1
return line[1:].strip()
else:
return None
def readKey(self, key: str):
k, v = self.readKeyValue()
if k != key:
@@ -67,7 +77,7 @@ class FlipperFormatFile:
self.writeLine("")
def writeComment(self, text: str):
if text:
if text and len(text):
self.writeLine(f"# {text}")
else:
self.writeLine("#")
@@ -104,3 +114,4 @@ class FlipperFormatFile:
def save(self, filename: str):
with open(filename, "w", newline="\n") as file:
file.write("\n".join(self.lines))
file.write("\n")

View File

@@ -27,37 +27,51 @@ class Main(App):
return 1
data = []
unique = {}
unique_combo = {}
unique_payload = {}
while True:
try:
d = {}
d["comments"] = []
while (comment := f.readComment()) is not None:
d["comments"].append(comment)
d["name"] = f.readKey("name")
d["type"] = f.readKey("type")
key = None
key_combo = f'{d["name"]}'
key_payload = None
if d["type"] == "parsed":
d["protocol"] = f.readKey("protocol")
d["address"] = f.readKey("address")
d["command"] = f.readKey("command")
key = f'{d["protocol"]}{d["address"]}{d["command"]}'
key_payload = f'{d["protocol"]}{d["address"]}{d["command"]}'
key_combo += key_payload
elif d["type"] == "raw":
d["frequency"] = f.readKey("frequency")
d["duty_cycle"] = f.readKey("duty_cycle")
d["data"] = f.readKey("data")
key = f'{d["frequency"]}{d["duty_cycle"]}{d["data"]}'
key_payload = f'{d["frequency"]}{d["duty_cycle"]}{d["data"]}'
key_combo += key_payload
else:
raise Exception(f'Unknown type: {d["type"]}')
if not key in unique:
unique[key] = d
if not key_combo in unique_combo:
unique_combo[key_combo] = d
data.append(d)
# Check payload only
if not key_payload in unique_payload:
unique_payload[key_payload] = d
else:
self.logger.warn(f"Duplicate key: {key}")
self.logger.warning(f"Duplicate payload, check manually: {d}")
else:
self.logger.info(f"Duplicate data removed: {d}")
except EOFError:
break
# Form new file
f = FlipperFormatFile()
f.setHeader(filetype, version)
for i in data:
f.writeComment(None)
for comment in i["comments"]:
f.writeComment(comment)
f.writeKey("name", i["name"])
f.writeKey("type", i["type"])
if i["type"] == "parsed":

View File

@@ -121,7 +121,7 @@ class Main(App):
try:
shutil.rmtree(self.output_dir_path)
except Exception as ex:
self.logger.warn(f"Failed to clean output directory: {ex}")
self.logger.warning(f"Failed to clean output directory: {ex}")
if not exists(self.output_dir_path):
self.logger.debug(f"Creating output directory {self.output_dir_path}")

View File

@@ -152,7 +152,7 @@ class Main(App):
return 3
if not self.layout_check(updater_stage_size, dfu_size, radio_addr):
self.logger.warn("Memory layout looks suspicious")
self.logger.warning("Memory layout looks suspicious")
if self.args.disclaimer != "yes":
self.show_disclaimer()
return 2
@@ -205,7 +205,7 @@ class Main(App):
def layout_check(self, stage_size, fw_size, radio_addr):
if stage_size > self.UPDATER_SIZE_THRESHOLD:
self.logger.warn(
self.logger.warning(
f"Updater size {stage_size}b > {self.UPDATER_SIZE_THRESHOLD}b and is not loadable on older firmwares!"
)
@@ -217,13 +217,13 @@ class Main(App):
self.logger.debug(f"Expected reserved space size: {fw2stack_gap}")
fw2stack_gap_pages = fw2stack_gap / self.FLASH_PAGE_SIZE
if fw2stack_gap_pages < 0:
self.logger.warn(
self.logger.warning(
f"Firmware image overlaps C2 region and is not programmable!"
)
return False
elif fw2stack_gap_pages < self.MIN_GAP_PAGES:
self.logger.warn(
self.logger.warning(
f"Expected reserved flash size is too small (~{int(fw2stack_gap_pages)} page(s), need >={self.MIN_GAP_PAGES} page(s))"
)
return False

View File

@@ -1,5 +1,5 @@
entry,status,name,type,params
Version,+,74.0,,
Version,+,75.0,,
Header,+,applications/services/bt/bt_service/bt.h,,
Header,+,applications/services/bt/bt_service/bt_keys_storage.h,,
Header,+,applications/services/cli/cli.h,,
@@ -1652,7 +1652,6 @@ Function,+,furi_thread_list_free,void,FuriThreadList*
Function,+,furi_thread_list_get_at,FuriThreadListItem*,"FuriThreadList*, size_t"
Function,+,furi_thread_list_get_isr_time,float,FuriThreadList*
Function,+,furi_thread_list_get_or_insert,FuriThreadListItem*,"FuriThreadList*, FuriThread*"
Function,+,furi_thread_list_process,void,"FuriThreadList*, uint32_t, uint32_t"
Function,+,furi_thread_list_size,size_t,FuriThreadList*
Function,+,furi_thread_resume,void,FuriThreadId
Function,+,furi_thread_set_appid,void,"FuriThread*, const char*"
1 entry status name type params
2 Version + 74.0 75.0
3 Header + applications/services/bt/bt_service/bt.h
4 Header + applications/services/bt/bt_service/bt_keys_storage.h
5 Header + applications/services/cli/cli.h
1652 Function + furi_thread_list_get_at FuriThreadListItem* FuriThreadList*, size_t
1653 Function + furi_thread_list_get_isr_time float FuriThreadList*
1654 Function + furi_thread_list_get_or_insert FuriThreadListItem* FuriThreadList*, FuriThread*
Function + furi_thread_list_process void FuriThreadList*, uint32_t, uint32_t
1655 Function + furi_thread_list_size size_t FuriThreadList*
1656 Function + furi_thread_resume void FuriThreadId
1657 Function + furi_thread_set_appid void FuriThread*, const char*

View File

@@ -1,5 +1,5 @@
entry,status,name,type,params
Version,+,74.0,,
Version,+,75.0,,
Header,+,applications/drivers/subghz/cc1101_ext/cc1101_ext_interconnect.h,,
Header,+,applications/services/bt/bt_service/bt.h,,
Header,+,applications/services/bt/bt_service/bt_keys_storage.h,,
@@ -1908,7 +1908,6 @@ Function,+,furi_thread_list_free,void,FuriThreadList*
Function,+,furi_thread_list_get_at,FuriThreadListItem*,"FuriThreadList*, size_t"
Function,+,furi_thread_list_get_isr_time,float,FuriThreadList*
Function,+,furi_thread_list_get_or_insert,FuriThreadListItem*,"FuriThreadList*, FuriThread*"
Function,+,furi_thread_list_process,void,"FuriThreadList*, uint32_t, uint32_t"
Function,+,furi_thread_list_size,size_t,FuriThreadList*
Function,+,furi_thread_resume,void,FuriThreadId
Function,+,furi_thread_set_appid,void,"FuriThread*, const char*"
1 entry status name type params
2 Version + 74.0 75.0
3 Header + applications/drivers/subghz/cc1101_ext/cc1101_ext_interconnect.h
4 Header + applications/services/bt/bt_service/bt.h
5 Header + applications/services/bt/bt_service/bt_keys_storage.h
1908 Function + furi_thread_list_get_at FuriThreadListItem* FuriThreadList*, size_t
1909 Function + furi_thread_list_get_isr_time float FuriThreadList*
1910 Function + furi_thread_list_get_or_insert FuriThreadListItem* FuriThreadList*, FuriThread*
Function + furi_thread_list_process void FuriThreadList*, uint32_t, uint32_t
1911 Function + furi_thread_list_size size_t FuriThreadList*
1912 Function + furi_thread_resume void FuriThreadId
1913 Function + furi_thread_set_appid void FuriThread*, const char*