rcbench
Servo and ESC test bench: panel, IOmcu and shared C
Loading...
Searching...
No Matches
panel_card.c File Reference

The card's files outside the run log: the ESC profiles read at start-up, the log viewer's list, open and delete, and the servo programmer's record and file requests, which the logger task serves (panel_log.c). More...

#include <stdatomic.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "esp_heap_caps.h"
#include "esp_log.h"
#include "card_tree.h"
#include "esc_profile.h"
#include "kst_card.h"
#include "kst_files.h"
#include "kst_panel.h"
#include "kst_prog.h"
#include "log_name.h"
#include "log_select.h"
#include "log_take.h"
#include "log_viewer_screen.h"
#include "panel.h"
#include "storage.h"

Data Structures

struct  esc_card_t
struct  card_pick_t
 One directory entry on its way into the viewer's list. More...

Macros

#define ESC_CARD_DIR   CARD_ESC_CONF
#define ESC_CARD_MAX   (2u * ESC_PROFILE_MAX_OVERRIDES)
#define CARD_SUFFIXES   ".csv .txt"
#define CARD_PATH_MAX
#define KST_FILE_NAME   "KST.TXT"
#define KST_FILE_NEW   "KST.NEW"

Functions

static void esc_card_take (const storage_entry_t *entry, void *ctx)
static void esc_profiles_read (void)
void esc_profiles_load (void)
static size_t card_read (void *ctx, char *buf, size_t max)
 One read of the open log for the viewer, counted as the render task's progress (render_progress()).
static void card_tick (void)
 The walks' tick (storage_walk()): one directory entry read on the render task, counted as its progress, for the reason card_read() gives.
static bool card_busy (const char *name)
static void card_folder (const char *dir, void *ctx)
static unsigned card_written (log_viewer_tab_t *tab, void *ctx)
static void card_take (const storage_entry_t *entry, void *ctx)
 Offer one directory entry of the walk to the page.
static int card_list (log_viewer_file_t *out, int max_entries, log_viewer_page_t *page, void *ctx)
 The viewer's list(): the page page names of the folder the viewer points at.
static bool card_open (const char *name, log_source_t *src, void *ctx)
static void card_close (void *ctx)
static const char * card_volume (void *ctx)
static card_state_t card_state (void *ctx)
static unsigned card_mounts (void *ctx)
static bool card_remove (const char *name, void *ctx)
void kst_record_write (void)
static bool kst_record_read (const char *path, size_t *len)
static bool kst_record_use (bool late, size_t len)
static void kst_record_load_held (bool late)
void kst_record_load (bool late)
void kst_card_serve (void)

Variables

static const char * TAG = "rcbench"
static FILE * s_card_file
static size_t(*) s_card_read (void *ctx, char *buf, size_t max)
 The read of the source card_open() set up, which card_read() wraps.
atomic_uint s_log_open_run
atomic_uint s_test_open_run
atomic_uint s_test_open_txt
static char s_card_dir [CARD_DIR_MAX]
static unsigned s_card_mount
const log_viewer_io_t k_card_io
char s_kst_file [KST_PROG_FILE_MAX]
static char s_kst_path [64]
static char s_kst_path_new [64]
size_t s_kst_file_len
unsigned s_kst_file_mount
atomic_uint s_kst_file_sent
atomic_uint s_kst_file_done
atomic_bool s_kst_file_ok
kst_prog_card_req_t s_kst_card_req
unsigned s_kst_card_mount
kst_prog_card_done_t s_kst_card_done
atomic_uint s_kst_card_sent
atomic_uint s_kst_card_answered

Detailed Description

The card's files outside the run log: the ESC profiles read at start-up, the log viewer's list, open and delete, and the servo programmer's record and file requests, which the logger task serves (panel_log.c).

SPDX-License-Identifier: MIT

Macro Definition Documentation

◆ CARD_PATH_MAX

#define CARD_PATH_MAX
Value:
(sizeof(STORAGE_MOUNT_POINT) + CARD_DIR_MAX \
+ STORAGE_NAME_MAX)
#define CARD_DIR_MAX
Room for a folder path and its terminator: two folders of 8 characters and the "/" between them are 1...
Definition card_tree.h:113

◆ CARD_SUFFIXES

#define CARD_SUFFIXES   ".csv .txt"

the walk's suffixes

Function Documentation

◆ card_list()

int card_list ( log_viewer_file_t * out,
int max_entries,
log_viewer_page_t * page,
void * ctx )
static

The viewer's list(): the page page names of the folder the viewer points at.

One walk of ".csv .txt" (log_select_lists()). A walk that found another card mounted is walked again, once.

Parameters
outtakes the page's entries, in the order the list draws
max_entriesroom in out
pagewhich page; its ahead and held are written
ctxunused
Returns
the files the folder holds that the list shows, 0 for a folder not made yet, -1 with no volume or a card that does not read

◆ card_read()

size_t card_read ( void * ctx,
char * buf,
size_t max )
static

One read of the open log for the viewer, counted as the render task's progress (render_progress()).

The viewer reads a log whole inside one pass of the render loop, up to LOG_DEFAULT_MAX_ROWS (60,000) rows in two passes over the file, and that pass can last longer than the watchdog's FRAME_WATCH_MS (1000ms): a live supply output held by a programming port stays on while LOGS is open. Counted per read, the watchdog sees one read's length at a time, which a card that stops answering still exceeds.

Parameters
ctxThe FILE * of the open log.
bufWhere the bytes go.
maxRoom in buf, bytes.
Returns
The bytes read; 0 at the end or on a failure.

◆ card_take()

void card_take ( const storage_entry_t * entry,
void * ctx )
static

Offer one directory entry of the walk to the page.

A folder, a name the list does not hold (log_select_lists()) and a file the logger has open are left out; the rest is counted and offered.

Parameters
entrythe entry, borrowed for the call
ctxthe walk's card_pick_t

Variable Documentation

◆ k_card_io

const log_viewer_io_t k_card_io
Initial value:
= {
.list = card_list,
.open = card_open,
.close = card_close,
.volume = card_volume,
.remove = card_remove,
.folder = card_folder,
.written = card_written,
.card = card_state,
.mounts = card_mounts,
.ctx = NULL,
}
static int card_list(log_viewer_file_t *out, int max_entries, log_viewer_page_t *page, void *ctx)
The viewer's list(): the page page names of the folder the viewer points at.
Definition panel_card.c:375