[FL-2220, FL-2221, FL-1883] RFID and iButton GUI update (#1107)
* RFID and iButton gui update * Grammar nazi: readed -> read * Grammar nazi pt.2: writed -> written Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
@@ -33,14 +33,14 @@ struct File {
|
||||
* @param file pointer to file object
|
||||
* @param buff pointer to buffer for reading
|
||||
* @param bytes_to_read how many bytes to read, must be smaller or equal to buffer size
|
||||
* @return how many bytes actually has been readed
|
||||
* @return how many bytes actually has been read
|
||||
*
|
||||
* @var FS_File_Api::write
|
||||
* @brief Write bytes from buffer to file
|
||||
* @param file pointer to file object
|
||||
* @param buff pointer to buffer for writing
|
||||
* @param bytes_to_read how many bytes to write, must be smaller or equal to buffer size
|
||||
* @return how many bytes actually has been writed
|
||||
* @return how many bytes actually has been written
|
||||
*
|
||||
* @var FS_File_Api::seek
|
||||
* @brief Move r/w pointer
|
||||
@@ -107,7 +107,7 @@ typedef struct {
|
||||
* @var FS_Dir_Api::read
|
||||
* @brief Read next object info in directory
|
||||
* @param file pointer to file object
|
||||
* @param fileinfo pointer to readed FileInfo, can be NULL
|
||||
* @param fileinfo pointer to read FileInfo, can be NULL
|
||||
* @param name pointer to name buffer, can be NULL
|
||||
* @param name_length name buffer length
|
||||
* @return success flag (if next object not exist also returns false and set error_id to FSE_NOT_EXIST)
|
||||
@@ -133,7 +133,7 @@ typedef struct {
|
||||
* @var FS_Common_Api::stat
|
||||
* @brief Open directory to get objects from
|
||||
* @param path path to file/directory
|
||||
* @param fileinfo pointer to readed FileInfo, can be NULL
|
||||
* @param fileinfo pointer to read FileInfo, can be NULL
|
||||
* @param name pointer to name buffer, can be NULL
|
||||
* @param name_length name buffer length
|
||||
* @return FS_Error error info
|
||||
|
@@ -76,7 +76,7 @@ bool storage_file_is_dir(File* file);
|
||||
* @param file pointer to file object.
|
||||
* @param buff pointer to a buffer, for reading
|
||||
* @param bytes_to_read how many bytes to read. Must be less than or equal to the size of the buffer.
|
||||
* @return uint16_t how many bytes were actually readed
|
||||
* @return uint16_t how many bytes were actually read
|
||||
*/
|
||||
uint16_t storage_file_read(File* file, void* buff, uint16_t bytes_to_read);
|
||||
|
||||
@@ -144,7 +144,7 @@ bool storage_dir_close(File* file);
|
||||
|
||||
/** Reads the next object in the directory
|
||||
* @param file pointer to file object.
|
||||
* @param fileinfo pointer to the readed FileInfo, may be NULL
|
||||
* @param fileinfo pointer to the read FileInfo, may be NULL
|
||||
* @param name pointer to name buffer, may be NULL
|
||||
* @param name_length name buffer length
|
||||
* @return success flag (if the next object does not exist, it also returns false and sets the file error id to FSE_NOT_EXIST)
|
||||
@@ -162,7 +162,7 @@ bool storage_dir_rewind(File* file);
|
||||
/** Retrieves information about a file/directory
|
||||
* @param app pointer to the api
|
||||
* @param path path to file/directory
|
||||
* @param fileinfo pointer to the readed FileInfo, may be NULL
|
||||
* @param fileinfo pointer to the read FileInfo, may be NULL
|
||||
* @return FS_Error operation result
|
||||
*/
|
||||
FS_Error storage_common_stat(Storage* storage, const char* path, FileInfo* fileinfo);
|
||||
|
@@ -112,10 +112,10 @@ static void storage_cli_list(Cli* cli, string_t path) {
|
||||
if(storage_dir_open(file, string_get_cstr(path))) {
|
||||
FileInfo fileinfo;
|
||||
char name[MAX_NAME_LENGTH];
|
||||
bool readed = false;
|
||||
bool read_done = false;
|
||||
|
||||
while(storage_dir_read(file, &fileinfo, name, MAX_NAME_LENGTH)) {
|
||||
readed = true;
|
||||
read_done = true;
|
||||
if(fileinfo.flags & FSF_DIRECTORY) {
|
||||
printf("\t[D] %s\r\n", name);
|
||||
} else {
|
||||
@@ -123,7 +123,7 @@ static void storage_cli_list(Cli* cli, string_t path) {
|
||||
}
|
||||
}
|
||||
|
||||
if(!readed) {
|
||||
if(!read_done) {
|
||||
printf("\tEmpty\r\n");
|
||||
}
|
||||
} else {
|
||||
@@ -141,18 +141,18 @@ static void storage_cli_read(Cli* cli, string_t path) {
|
||||
File* file = storage_file_alloc(api);
|
||||
|
||||
if(storage_file_open(file, string_get_cstr(path), FSAM_READ, FSOM_OPEN_EXISTING)) {
|
||||
const uint16_t read_size = 128;
|
||||
uint16_t readed_size = 0;
|
||||
const uint16_t size_to_read = 128;
|
||||
uint16_t read_size = 0;
|
||||
uint8_t* data = malloc(read_size);
|
||||
|
||||
printf("Size: %lu\r\n", (uint32_t)storage_file_size(file));
|
||||
|
||||
do {
|
||||
readed_size = storage_file_read(file, data, read_size);
|
||||
for(uint16_t i = 0; i < readed_size; i++) {
|
||||
read_size = storage_file_read(file, data, size_to_read);
|
||||
for(uint16_t i = 0; i < read_size; i++) {
|
||||
printf("%c", data[i]);
|
||||
}
|
||||
} while(readed_size > 0);
|
||||
} while(read_size > 0);
|
||||
printf("\r\n");
|
||||
|
||||
free(data);
|
||||
@@ -176,33 +176,33 @@ static void storage_cli_write(Cli* cli, string_t path) {
|
||||
if(storage_file_open(file, string_get_cstr(path), FSAM_WRITE, FSOM_OPEN_APPEND)) {
|
||||
printf("Just write your text data. New line by Ctrl+Enter, exit by Ctrl+C.\r\n");
|
||||
|
||||
uint32_t readed_index = 0;
|
||||
uint32_t read_index = 0;
|
||||
|
||||
while(true) {
|
||||
uint8_t symbol = cli_getc(cli);
|
||||
|
||||
if(symbol == CliSymbolAsciiETX) {
|
||||
uint16_t write_size = readed_index % buffer_size;
|
||||
uint16_t write_size = read_index % buffer_size;
|
||||
|
||||
if(write_size > 0) {
|
||||
uint16_t writed_size = storage_file_write(file, buffer, write_size);
|
||||
uint16_t written_size = storage_file_write(file, buffer, write_size);
|
||||
|
||||
if(writed_size != write_size) {
|
||||
if(written_size != write_size) {
|
||||
storage_cli_print_error(storage_file_get_error(file));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
buffer[readed_index % buffer_size] = symbol;
|
||||
printf("%c", buffer[readed_index % buffer_size]);
|
||||
buffer[read_index % buffer_size] = symbol;
|
||||
printf("%c", buffer[read_index % buffer_size]);
|
||||
fflush(stdout);
|
||||
readed_index++;
|
||||
read_index++;
|
||||
|
||||
if(((readed_index % buffer_size) == 0)) {
|
||||
uint16_t writed_size = storage_file_write(file, buffer, buffer_size);
|
||||
if(((read_index % buffer_size) == 0)) {
|
||||
uint16_t written_size = storage_file_write(file, buffer, buffer_size);
|
||||
|
||||
if(writed_size != buffer_size) {
|
||||
if(written_size != buffer_size) {
|
||||
storage_cli_print_error(storage_file_get_error(file));
|
||||
break;
|
||||
}
|
||||
@@ -239,11 +239,11 @@ static void storage_cli_read_chunks(Cli* cli, string_t path, string_t args) {
|
||||
printf("\r\nReady?\r\n");
|
||||
cli_getc(cli);
|
||||
|
||||
uint16_t readed_size = storage_file_read(file, data, buffer_size);
|
||||
for(uint16_t i = 0; i < readed_size; i++) {
|
||||
uint16_t read_size = storage_file_read(file, data, buffer_size);
|
||||
for(uint16_t i = 0; i < read_size; i++) {
|
||||
putchar(data[i]);
|
||||
}
|
||||
file_size -= readed_size;
|
||||
file_size -= read_size;
|
||||
}
|
||||
printf("\r\n");
|
||||
|
||||
@@ -277,9 +277,9 @@ static void storage_cli_write_chunk(Cli* cli, string_t path, string_t args) {
|
||||
buffer[i] = cli_getc(cli);
|
||||
}
|
||||
|
||||
uint16_t writed_size = storage_file_write(file, buffer, buffer_size);
|
||||
uint16_t written_size = storage_file_write(file, buffer, buffer_size);
|
||||
|
||||
if(writed_size != buffer_size) {
|
||||
if(written_size != buffer_size) {
|
||||
storage_cli_print_error(storage_file_get_error(file));
|
||||
}
|
||||
|
||||
@@ -400,17 +400,17 @@ static void storage_cli_md5(Cli* cli, string_t path) {
|
||||
File* file = storage_file_alloc(api);
|
||||
|
||||
if(storage_file_open(file, string_get_cstr(path), FSAM_READ, FSOM_OPEN_EXISTING)) {
|
||||
const uint16_t read_size = 512;
|
||||
const uint16_t size_to_read = 512;
|
||||
const uint8_t hash_size = 16;
|
||||
uint8_t* data = malloc(read_size);
|
||||
uint8_t* data = malloc(size_to_read);
|
||||
uint8_t* hash = malloc(sizeof(uint8_t) * hash_size);
|
||||
md5_context* md5_ctx = malloc(sizeof(md5_context));
|
||||
|
||||
md5_starts(md5_ctx);
|
||||
while(true) {
|
||||
uint16_t readed_size = storage_file_read(file, data, read_size);
|
||||
if(readed_size == 0) break;
|
||||
md5_update(md5_ctx, data, readed_size);
|
||||
uint16_t read_size = storage_file_read(file, data, size_to_read);
|
||||
if(read_size == 0) break;
|
||||
md5_update(md5_ctx, data, read_size);
|
||||
}
|
||||
md5_finish(md5_ctx, hash);
|
||||
free(md5_ctx);
|
||||
|
@@ -340,10 +340,10 @@ static uint16_t
|
||||
storage_ext_file_read(void* ctx, File* file, void* buff, uint16_t const bytes_to_read) {
|
||||
StorageData* storage = ctx;
|
||||
SDFile* file_data = storage_get_storage_file_data(file, storage);
|
||||
uint16_t bytes_readed = 0;
|
||||
file->internal_error_id = f_read(file_data, buff, bytes_to_read, &bytes_readed);
|
||||
uint16_t bytes_read = 0;
|
||||
file->internal_error_id = f_read(file_data, buff, bytes_to_read, &bytes_read);
|
||||
file->error_id = storage_ext_parse_error(file->internal_error_id);
|
||||
return bytes_readed;
|
||||
return bytes_read;
|
||||
}
|
||||
|
||||
static uint16_t
|
||||
|
@@ -349,7 +349,7 @@ static uint16_t
|
||||
lfs_t* lfs = lfs_get_from_storage(storage);
|
||||
LFSHandle* handle = storage_get_storage_file_data(file, storage);
|
||||
|
||||
uint16_t bytes_readed = 0;
|
||||
uint16_t bytes_read = 0;
|
||||
|
||||
if(lfs_handle_is_open(handle)) {
|
||||
file->internal_error_id =
|
||||
@@ -361,10 +361,10 @@ static uint16_t
|
||||
file->error_id = storage_int_parse_error(file->internal_error_id);
|
||||
|
||||
if(file->error_id == FSE_OK) {
|
||||
bytes_readed = file->internal_error_id;
|
||||
bytes_read = file->internal_error_id;
|
||||
file->internal_error_id = 0;
|
||||
}
|
||||
return bytes_readed;
|
||||
return bytes_read;
|
||||
}
|
||||
|
||||
static uint16_t
|
||||
|
Reference in New Issue
Block a user