Окружение AVR-DOS

Материал из roboforum.ru Wiki
Версия от 05:10, 7 января 2009; MiBBiM (обсуждение | вклад) (Использование команд ввода-вывода в различных режимах)
Перейти к: навигация, поиск

Окружение AVR-DOS — конфигурация системы

AVR-DOS применительно к на данному микроконтроллеру.

Конфигурация файловой системы

Задается файлом config_avr-dos.bas.

Параметр Значение
cFileHandles Count of Filehandles: for each file opened at same

time, a filehandle buffer of 538 Bytes is needed

cSepFATHandle For higher speed in handling file operations the FAT

info can be stored in an own buffer, which needs

additional 517 Bytes.

Assign Constant cSepFATHandle with 1, if wanted,

otherwise with 0.

cFATDirSaveAtEnd Handling of saving changed FAT and Directory

Information of a open file for output.

Parameter 0 saves FAT and Directory information with

every saving of a data sector

Parameter 1 saves FAT and Directory Information only at

the CLOSE and FLUSH statement. This option increases the

writing speed of data and decreases the write frequency

of FAT and Directory Sectors

cTextQuotationMarks Surrounding String with Quotation Marks at the Command

WRITE

0 = No Surrounding of strings with quotation.marks

1 = Surrounding of strings with quotation.marks (f.E.

"Text")

cFATSecondUpdate Suppress updating of second FAT. Windows accepts a not

updated second FAT

PC-Command: chkdsk /f corrects the second FAT, it

overwrites the

second FAT with the first FAT

set this parameter to 0 for high speed continuing saving

data

0 = Second FAT is not updated

1 = Second FAT is updated if exist [default]

cVariableSeparator Character to separate ASCII Values in WRITE - statement

(and INPUT)

Normally a comma (,) is used, but it can be changed to

other values, f.E. to TAB (ASCII-Code 9) if EXCEL Files

with Tab separated values should be written or read.

This parameter works for WRITE and INPUT

Parameter value is the ASSCII-Code of the separator

44 = comma [default] 9 = TAB

Использование памяти файловой системой

General File System information (35 Bytes)

Параметр Тип Использование
gbDOSError Byte holds DOS Error of last file handling routine
gbFileSystem Byte File System Code from Master Boot Record
gbFileSystemStatus Byte Holds Information about FAT Type (16 or 32)
glFATFirstSector Long Number of first Sector of FAT Area on the Card
gbNumberOfFATs Byte Count of FAT copies
glSectorsPerFat Long Count of Sectors per FAT
glRootFirstSector Long Number of first Sector of Root Area on the Card
gwRootEntries Word Count of Root Entries
glDataFirstSector Long Number of first Sector of Data Area on the Card
gbSectorsPerCluster Byte Count of Sectors per Cluster
glMaxClusterNumber Long Highest usable Cluster number
glLastSearchedCluster Long Last cluster number found as free
glFS_Temp1 Long temorary Long variable for file system

Directory (559 Bytes)

Параметр Тип Использование
glDirFirstSectorNumber Long Number of first sector of current actual directory
gwFreeDirEntry Word Number of first free Dir-Entry
glFreeDirSectorNumber Long Number of Sector number with first free Directory Entry
gsDir0TempFileName String*11 Temporary Buffer for file name
gwDir0Entry Word Temporary Buffer for Directory Entry Number
glDir0SectorNumber Long Temporary Buffer for Directory Sector Number
gsTempFileName String*11 Hold file name for directory search
gwDirRootEntry Word Number of last handled directory entry
glDirSectorNumber Long Number of current loaded Sector
gbDirBufferStatus Byte Sector Buffer Status
gbDirBuffer Byte (512) Buffer for directory Sector

FAT (517 Bytes)

FAT Buffer is only allocated if the constant: cSepFATHandle = 1

Параметр Тип Использование
glFATSectorNumber Long Number of current loaded FAT sector
gbFATBufferStatus Byte Buffer status
gbFATBuffer Byte(512) buffer for FAT sector

File handling

Each file handle has a block of 538 Bytes in the variable abFileHandle which is a byte-array of size (538 * cFileHandles)

Параметр Тип Использование
FileNumber Byte File number for identification of the file in I/O

operations to the opened file

FileMode Byte File open mode
FileDirEntry Word Number of directory entry
FileDirSectorNumber Long Number of Sector which holds the Directory entry of the file
FileFirstCluster Word First cluster
FileSize Long file size in bytes
FilePosition Long file pointer (next read/write) 0-based
FileSectorNumber Long number of current loaded sector
FileBufferStatus Byte buffer Status
FileBuffer Byte(512) buffer for the file sector
SectorTerminator Byte additional 00 Byte (string terminator) for direct reading ASCII files from the buffer

Error codes

Код Имя в компиляторе Объяснение
0 cpNoError No Error
1 cpEndOfFile Attempt behind End of File
17 cpNoMBR Sector 0 on Card is not a Master Boot Record
18 cpNoPBR No Partition Sector
19 cpFileSystemNotSupported Only FAT16 File system is supported
20 cpSectorSizeNotSupported Only sector size of 512 Bytes is supported
21 cpSectorsPerClusterNotSupported which are not power of 2 are not supported
22 cpCountOfClustersNotSupported Count of FAT (valid is 1 or 2) not supported (will be renamed with one of next release)
33 cpNoNextCluster Error in file cluster chain
34 cpNoFreeCluster No free cluster to allocate (Disk full)
35 cpClusterError Error in file cluster chain
49 cpNoFreeDirEntry Directory full
50 cpFileExist
51 cpFileDeleteNotAllowed Deleting of file not allowed (System, Hidden, Read-Only)
52 cpSubDirectoryNotEmpty Removing of sub-directory not possible, because it is not empty
53 cpSubDirectoryError General error at handling with sub-directory
54 cpNoASubDirectory Passed name is a file name and not a directory name
65 cpNoFreeFileNumber No free file number available, only theoretical error, if 255 file handles in use
66 cpFileNotFound File not found
67 cpFileNumberNotFound No file handle with such file number
68 cpFileOpenNoHandle All file handles occupied
69 cpFileOpenHandleInUse File handle number in use, can't create a new file handle with same file number
70 cpFileOpenShareConflict Tried to open a file in read and write modus in two file handles
71 cpFileInUse Can't delete file, which is in use
72 cpFileReadOnly Can't open a read only file for writing
73 cpFileNoWildCardAllowed No wildcard allowed in this function
74 CpFileNumberInvalid File number 0 is not allowed
97 cpFilePositionError
98 cpFileAccessError function not allowed in this file open mode
99 cpInvalidFilePosition new file position pointe is invalid (minus or 0)
100 cpFileSizeToGreat File size to great for function BLoad

Buffer Status: Bit definitions of Buffer Status Byte (Directory, FAT and File)

Bit DIR FAT File Compiler Alias Remark
0 (LSB) + dFATDirSaveAnyWay Status Bit which is set from CLOSE and FLUSh statement, to show AVR-DOS to save FAT and Directory Sectors
1 + dEOF End of File
2 + dEOFinSector End of File in this sector (= last sector loaded)
3 + + + dWritePending Something was written to sector, it must be saved to Card, before loading next sector
4 + dFATSector This is an FAT Sector, at writing to Card, Number of FAT copies must be checked and copy updated if necessary
5 + dFileEmpty File is empty, no sector (Cluster) is allocated in FAT to this file
6 + dFATDIRWritePending For this file FAT or directory was updated
7 + dFATDirSaveAtEnd Indicates, that FAT and Directory Information have only to be updated at FLUSH and CLOSE staements

Использование команд ввода-вывода в различных режимах

Команда Input Output Append Binary
Attr + + + +
Close + + + +
Put +
Get +
LOF + + + +
LOC + + + +
EOF + [1] [1] +
SEEK (Get Position) + +[1] +[1] +
SEEK (Set Position) +
Line Input + +
Print + + +
Input + +
Write + + +
  1. 1 2 3 4 Курсор всегда находится в позиции конца файла

Поддерживаемые выражения и функции: INITFILESYSTEM , OPEN , CLOSE, FLUSH , PRINT, LINE INPUT, LOC, LOF , EOF , FREEFILE , FILEATTR , SEEK , BSAVE , BLOAD , KILL , DISKFREE , DISKSIZE , GET , PUT ,FILEDATE , FILETIME , FILEDATETIME , DIR , FILELEN , WRITE , INPUT