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

The Hitec programmer's record on the card: HITEC.TXT in the folder BENCH/HITEC/CONF, the values before a write (hitec_card.h). More...

#include <stdatomic.h>
#include <stdbool.h>
#include <stdio.h>
#include <unistd.h>
#include "esp_log.h"
#include "card_tree.h"
#include "hitec_card.h"
#include "hitec_panel.h"
#include "panel.h"
#include "storage.h"

Macros

#define HITEC_FILE_NAME   HITEC_CARD_RECORD ".TXT"
 The record's name, HITEC.TXT.
#define HITEC_FILE_NEW   HITEC_CARD_RECORD ".NEW"
 The record's name while it is written, HITEC.NEW.

Functions

static void paths (void)
 The paths of the record and of its new text.
void hitec_record_write (void)
 Write the text the render loop handed over (panel.h).
static bool record_read (const char *path, size_t *len)
 path into s_hitec_file.
void hitec_record_load (void)
 Read the record from the card at the start (panel.h).

Variables

static const char * TAG = "hitec"
 The log tag.
char s_hitec_file [HITEC_CARD_TEXT_MAX]
 The record's text (panel.h).
size_t s_hitec_file_len
 The bytes of s_hitec_file to write (panel.h).
unsigned s_hitec_file_mount
 The mount the text is written to (panel.h).
atomic_uint s_hitec_file_sent
 Texts handed over (panel.h).
atomic_uint s_hitec_file_done
 Texts written or given up on (panel.h).
atomic_bool s_hitec_file_ok
 Whether the card took the last text whole (panel.h).
static char s_path [96]
 The record's path, the logger's and the start's.
static char s_path_new [96]
 The path of its new text.

Detailed Description

The Hitec programmer's record on the card: HITEC.TXT in the folder BENCH/HITEC/CONF, the values before a write (hitec_card.h).

Hitec is a name or trademark of its owner; it is used here only to say which servos this module works with.

The render loop fills s_hitec_file and counts s_hitec_file_sent up; the logger task writes it (hitec_record_write()), says in s_hitec_file_ok whether the card took it whole, and counts s_hitec_file_done up. One text at a time: the render loop fills the buffer only while the two counts are equal.

The text goes to HITEC.NEW and takes the name HITEC.TXT once the card holds it whole, so that a write the card or the supply ends leaves one of the two whole: HITEC.TXT as it was, or HITEC.NEW complete. FAT has no rename over a file, so HITEC.TXT is removed between the two; hitec_record_load() takes a whole HITEC.NEW before HITEC.TXT.

The record is read once, at the start, before the tasks run. A card put in later is not read for a record.

SPDX-License-Identifier: MIT

Function Documentation

◆ hitec_record_load()

void hitec_record_load ( void )

Read the record from the card at the start (panel.h).

Read the record from the card into the Hitec programmer, once, at the start before the tasks run.

Read the record from the card at the start (panel.h).

◆ hitec_record_write()

void hitec_record_write ( void )

Write the text the render loop handed over (panel.h).

Write the text the render loop handed over, on the logger task: HITEC.NEW, then its name HITEC.TXT. Nothing when none waits.

Write the text the render loop handed over (panel.h).

◆ record_read()

bool record_read ( const char * path,
size_t * len )
static

path into s_hitec_file.

Parameters
pathThe file.
lenReceives its length; 0 for a file that does not read.
Returns
false for no file.

Variable Documentation

◆ s_hitec_file

char s_hitec_file[HITEC_CARD_TEXT_MAX]

The record's text (panel.h).

The record's text, as hitec_card_text() writes it.

The record's text (panel.h).

◆ s_hitec_file_done

atomic_uint s_hitec_file_done

Texts written or given up on (panel.h).

Texts the logger has written or given up on.

Texts written or given up on (panel.h).

◆ s_hitec_file_len

size_t s_hitec_file_len

The bytes of s_hitec_file to write (panel.h).

The bytes of s_hitec_file to write; 0 removes the record.

The bytes of s_hitec_file to write (panel.h).

◆ s_hitec_file_mount

unsigned s_hitec_file_mount

The mount the text is written to (panel.h).

The mount the text is written to (storage_mount_count()).

The mount the text is written to (panel.h).

◆ s_hitec_file_ok

atomic_bool s_hitec_file_ok

Whether the card took the last text whole (panel.h).

Whether the card took the last text whole.

Whether the card took the last text whole (panel.h).

◆ s_hitec_file_sent

atomic_uint s_hitec_file_sent

Texts handed over (panel.h).

Texts the render loop handed over; one ahead of s_hitec_file_done while one waits.

Texts handed over (panel.h).