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

Материал из roboforum.ru Wiki
Перейти к: навигация, поиск

Окружение 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

Коды ошибок

Код Имя в компиляторе Объяснение
0 cpNoError Нет ошибки
1 cpEndOfFile Попытка чтения файла за пределами его конца
17 cpNoMBR Сектор 0 на диске не является Master Boot Record
18 cpNoPBR Нет Partition Sector
19 cpFileSystemNotSupported Неподдерживаемая файловая система, поддерживается только FAT16«(в описании другое)»
20 cpSectorSizeNotSupported Неподдерживаемый размер сектора, поддерживаются сектора 512 Байт.
21 cpSectorsPerClusterNotSupported Подддерживаются только 1, 2, 4, 8, 16, 32, 64 секторов в кластере. Это нормальные значения для отформатированного раздела. Экзотические размеры кластера, не делящиеся нацело на 2, не поддерживаются
22 cpCountOfClustersNotSupported Данное количество разделов не поддерживается (поддерживается только 1 или 2 раздела)

«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 Нет свободный клатеров«(cluster)», диск заполнен
35 cpClusterError Ошибка чтения кластера файла «Error in file cluster chain»
49 cpNoFreeDirEntry Директория заполнена «Directory full»
50 cpFileExist
51 cpFileDeleteNotAllowed Удаление файла запрещено его атрибутами(файл скрытый, системный, или только для чтения)
52 cpSubDirectoryNotEmpty Невозможно удалить каталог, он не пуст.
53 cpSubDirectoryError General error at handling with sub-directory
54 cpNoASubDirectory Имя не соотвествует каталогу, это файл.
65 cpNoFreeFileNumber Нет свободных идентификаторов файлового потока (возможно открыть не более 255 файлов одновременно)
66 cpFileNotFound Файл не найден
67 cpFileNumberNotFound Такой идентификатор файлового потока не существует
68 cpFileOpenNoHandle Все идентификаторы файлового потока неверны «All file handles occupied»
69 cpFileOpenHandleInUse Такой идентификатор файлового потока уже используется, невозможно создать новый поток с таким идентификатором
70 cpFileOpenShareConflict Невозможно получить доступ к файлу(напр, одновременне открытие для записи и чтения)
71 cpFileInUse Невозможно удалить файл, использующийся в данный момент
72 cpFileReadOnly Невозможно произвести запись, файл только для чтения.
73 cpFileNoWildCardAllowed Специальные символы(WildCards) не разрешены при использовании данной функции
74 CpFileNumberInvalid Файловый идентификатор не поддерживается (напр, 0)
97 cpFilePositionError Позиция файлового курсора неверна («сам придумал»)
98 cpFileAccessError Функция не может выполнятся в текущем режиме открытия файла«(подробнее)»
99 cpInvalidFilePosition Новая позиция файлового курсора неверна (отрицательное значение или 0)
100 cpFileSizeToGreat Размер файла слишком большой для использования функции 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