Skip to content

Fat16

implements a minimal Arduino FAT16 Library

詳細情報

メンバー

writeError

is set to true if an error occurs during a . Set to false before calling and/or and check for true after calls to and/or .

bool Fat16::writeError

Fat16()

create with file closed

Fat16::Fat16(void)

curCluster()

fat_t Fat16::curCluster(void) const

戻り値

fat_t The current cluster number.

close()

uint8_t Fat16::close(void)

戻り値

uint8_t

curPosition()

uint32_t Fat16::curPosition(void) const

戻り値

uint32_t The current file position.

dirEntry()

Return a files directory entry

uint8_t Fat16::dirEntry(dir_t *dir)

引数

  • dir_t* dir Location for return of the files directory entry.

戻り値

uint8_t

fileSize()

uint32_t Fat16::fileSize(void) const

戻り値

uint32_t The file's size in bytes.

isOpen()

Checks the file's open/closed status for this instance of .

uint8_t Fat16::isOpen(void) const

戻り値

uint8_t The value true if a file is open otherwise false;

open()

uint8_t Fat16::open(const char *fileName, uint8_t oflag)

引数

  • constchar * fileName A valid 8.3 DOS name for a file in the root directory.
  • uint8_t oflag Values for are constructed by a bitwise-inclusive OR of flags from the following list

戻り値

uint8_t

open()

Open a file by file index.

uint8_t Fat16::open(uint16_t entry, uint8_t oflag)

引数

  • uint16_t entry
  • uint8_t oflag See .

戻り値

uint8_t

read()

int16_t Fat16::read(void)

戻り値

int16_t

read()

Read data from a file at starting at the current file position.

int16_t Fat16::read(void *buf, uint16_t nbyte)

引数

  • void * buf Pointer to the location that will receive the data.
  • uint16_t nbyte Maximum number of bytes to read.

戻り値

int16_t

remove()

uint8_t Fat16::remove(void)

戻り値

uint8_t

rewind()

Sets the file's current position to zero.

void Fat16::rewind(void)

seekCur()

Seek to current position plus bytes. See .

uint8_t Fat16::seekCur(uint32_t pos)

引数

  • uint32_t pos

戻り値

uint8_t

seekEnd()

Seek to end of file. See .

uint8_t Fat16::seekEnd(void)

戻り値

uint8_t

seekSet()

Sets the file's read/write position.

uint8_t Fat16::seekSet(uint32_t pos)

引数

  • uint32_t pos The new position in bytes from the beginning of the file.

戻り値

uint8_t

sync()

uint8_t Fat16::sync(void)

戻り値

uint8_t

timestamp()

T_WRITE - Set the file's last write/modification date and time.

uint8_t Fat16::timestamp(uint8_t flag, uint16_t year, uint8_t month, uint8_t day, uint8_t hour, uint8_t minute, uint8_t second)

引数

  • uint8_t flag
  • uint16_t year Valid range 1980 - 2107 inclusive.
  • uint8_t month Valid range 1 - 12 inclusive.
  • uint8_t day Valid range 1 - 31 inclusive.
  • uint8_t hour Valid range 0 - 23 inclusive.
  • uint8_t minute Valid range 0 - 59 inclusive.
  • uint8_t second Valid range 0 - 59 inclusive

戻り値

uint8_t

truncate()

Truncate a file to a specified length. The current file position will be maintained if it is less than or equal to otherwise it will be set to end of file.

uint8_t Fat16::truncate(uint32_t size)

引数

  • uint32_t size

戻り値

uint8_t

write()

Write data at the current position of an open file.

int16_t Fat16::write(const void *buf, uint16_t nbyte)

引数

  • constvoid * buf Pointer to the location of the data to be written.
  • uint16_t nbyte Number of bytes to write.

戻り値

int16_t

write()

Use to check for errors.

void Fat16::write(uint8_t b)

引数

  • uint8_t b

write()

Use to check for errors.

void Fat16::write(const char *str)

引数

  • constchar * str

write_P()

Use to check for errors.

void Fat16::write_P(PGM_P str)

引数

  • PGM_P str

writeln_P()

Use to check for errors.

void Fat16::writeln_P(PGM_P str)

引数

  • PGM_P str

clusterCount()

static fat_t Fat16::clusterCount(void)

戻り値

fat_t The count of clusters in the FAT16 volume.

clusterSize()

static uint8_t Fat16::clusterSize(void)

戻り値

uint8_t The number of 512 byte blocks in a cluster

dateTimeCallback()

See the function.

static void Fat16::dateTimeCallback(void(*dateTime)(uint16_t *date, uint16_t *time))

引数

  • timevoid()(uint16_t date, uint16_t *) dateTime The user's callback function. The callback function is of the form:

dateTimeCallbackCancel()

Cancel the date/time callback function.

static void Fat16::dateTimeCallbackCancel(void)

init()

Initialize a FAT16 volume.

uint8_t Fat16::init(SdCard *dev, uint8_t part)

引数

  • SdCard* dev The where the volume is located.
  • uint8_t part The partition to be used. Legal values for are 1-4 to use the corresponding partition on a device formatted with a MBR, Master Boot Record, or zero if the device is formatted as a super floppy with the FAT boot sector in block zero.

戻り値

uint8_t

init()

First try partition 1 then try super floppy format.

static uint8_t Fat16::init(SdCard *dev)

引数

  • SdCard* dev The where the volume is located.

戻り値

uint8_t

ls()

LS_SIZE - Print file size.

void Fat16::ls(uint8_t flags=0)

引数

  • uint8_t flags The inclusive OR of

printDirName()

Print the name field of a directory entry in 8.3 format to Serial.

void Fat16::printDirName(const dir_t &dir, uint8_t width)

引数

  • const& dir The directory structure containing the name.
  • uint8_t width Blank fill name if length is less than .

printFatDate()

Format is yyyy-mm-dd.

void Fat16::printFatDate(uint16_t fatDate)

引数

  • uint16_t fatDate The date field from a directory entry.

printFatTime()

Format is hh:mm:ss.

void Fat16::printFatTime(uint16_t fatTime)

引数

  • uint16_t fatTime The time field from a directory entry.

printTwoDigits()

Print a value as two digits to Serial.

void Fat16::printTwoDigits(uint8_t v)

引数

  • uint8_t v Value to be printed, 0 <= <= 99

readDir()

Unused entries and entries for long names are skipped.

uint8_t Fat16::readDir(dir_t *dir, uint16_t *index, uint8_t skip=(DIR_ATT_VOLUME_ID|DIR_ATT_DIRECTORY))

引数

  • dir_t* dir Location that will receive the entry.
  • uint16_t * index The search starts at and is updated with the root directory index of the found directory entry. If the entry is a file, it may be opened by calling .
  • uint8_t skip Skip entries that have these attributes. If is not specified, the default is to skip the volume label and directories.

戻り値

uint8_t

remove()

The directory entry and all data for the file are deleted.

uint8_t Fat16::remove(const char *fileName)

引数

  • constchar * fileName The name of the file to be removed.

戻り値

uint8_t

rootDirEntryCount()

static uint16_t Fat16::rootDirEntryCount(void)

戻り値

uint16_t The number of entries in the root directory.