Menu

FATFS_Binary_IO Log in to Edit

FATFS - Binary Record I/O

There is no direct support within fatfs but one is easily derived from using the text I/O facilities. The general procedure for writing a binary record is as follows:

  1. Write out the binary record's length (use Unsigned_8, Unsigned_16 or Unsigned_32 for length as appropriate).
  2. Write out the U8_Array.
    The procedure for reading the record is simply the reverse of that:
  3. Read binary record's length (using Unsigned_8, Unsigned_16 or Unsigned_32)
  4. Read the binary record's content into U8_Array

Applicable Read API

procedure Open_File(File : out TFCB_Type; Dir_Entry : Dir_Entry_Type; OK : out Boolean);
procedure Open_File(File : out TFCB_Type; Dir : in out DCB_Type; Name : String; OK : out Boolean);
procedure Rewind_File(File : in out TFCB_Type);
procedure Read(File : in out TFCB_Type; Buffer : out U8_Array; Count : out Unsigned_16; OK : out Boolean);
procedure Read(File : in out TFCB_Type; Data : out Unsigned_8; OK : out Boolean);
procedure Read(File : in out TFCB_Type; Data : out Unsigned_16; OK : out Boolean);
procedure Read(File : in out TFCB_Type; Data : out Unsigned_32; OK : out Boolean);
procedure Close_File(File : in out TFCB_Type);

Applicable Write API

procedure Open_File(File : out TWCB_Type; Dir : in out DCB_Type; Name : String; OK : out Boolean);
procedure Create_File(File : out TWCB_Type; Dir : in out DCB_Type; Name : String; OK : out Boolean);
procedure Write(File : in out TWCB_Type; Buffer : U8_Array; OK : out Boolean);
procedure Write(File : in out TWCB_Type; Data : Unsigned_8; OK : out Boolean);
procedure Write(File : in out TWCB_Type; Data : Unsigned_16; OK : out Boolean);
procedure Write(File : in out TWCB_Type; Data : Unsigned_32; OK : out Boolean);
procedure Sync_File(File : in out TWCB_Type; OK : out Boolean);
procedure Close_File(File : in out TWCB_Type; OK : out Boolean);

Related

Wiki: Fatfs

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.