How to SD Card File 1byte Read?

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
User8320
Level 1
Level 1
Hi. Everyone.

I tested the SD Card can read the file.

Source is shown below.

int file_Read(const char *pcFileName, long FilePoint)
{
FILE *ptr;
status_t status;
status_t status1;
status_t status2;
const char buffer[1024] = {0,};
uint32_t block_size;
uint32_t num_blocks;

ptr = fopen(pcFileName, "r+");

status1 = fseek(ptr, FilePoint, SEEK_CUR);

if (ptr == NULL)
return -1;

block_size = 40;
num_blocks = sizeof(char);
status2 = fread(&buffer, num_blocks, block_size, ptr);

status = fclose(ptr);

}

Point f_seek function is used to increase gradually from 0 to 4 when read only values ​​that fall into the drainage.

if FilePoint = 0 -> Data Read Ok.
FilePoint = 1 -> Data Read Fail.
FilePoint = 2 -> Data Read Fail.
FilePoint = 3 -> Data Read Fail.
FilePoint = 4 -> Data Read Ok.
FilePoint = 5 -> Data Read Fail.
FilePoint = 6 -> Data Read Fail.
FilePoint = 7 -> Data Read Fail.

Do not know why this happens.

And I want to read only 1byte.
0 Likes
0 Replies