manufacturer of I/O-rich SBCs, operator interfaces, handheld instruments, and development tools for embedded control low cost single board computers, embedded controllers, and operator interfaces for scientific instruments & industrial control development tools for embedded control order our low cost I/O-rich embedded control products embedded controller manufacturer profile single board computers & embedded controllers development tools & starter kits for your embedded design operator interfaces with touchscreens and graphical user interface plug-in expansion modules for digital & analog I/O C language & Forth language integrated development tools, IDE single board and embedded computer accessories embedded controller enclosures, bezels, environmental gaskets
Table of Contents

Introduction

Specifications

Hardware

Flash Card

Connecting To the Wildcard Bus

Selecting the Wildcard Address

Installing the CF Card

CF Card Software Package User Guide and Glossary

How To Install the CF Software

Using the Driver Code with C

Using the Driver Code with Forth

CF Card Software

Categorized List of Functions and Constants

ATA Failure Codes

ATA Primitives

CF Card Information

Directory

File Access and Position Modes

File I/O

File Processing

File System Error Handling

Initialization

Overview of Glossary Notation

Using the File System Functions

Commonly Used Terms

String Parameters and the Use of THIS_PAGE

Access Privileges

Root Directory Only and File Name Restrictions

File Position Indicator

Error Handling

Real-Time Clock on the Host Computer Enables Time/Date Marking of Files 12

Initialization

Automatic Initialization and File Processing

Upgrade note for former Memory Interface Board (MIB) Users

How To Create and Use an AUTOEXEC.QED File

Compile a Program into Flash Memory

Create a Set of Image Files

Transfer the Image File Contents into Memory

Restrictions on Software Upgrades

Recovering from Buggy AUTOSTART.QED Files

Compact Flash Card Software Package Main Glossary

Upgrade Notice for Prior Users of the Memory Interface Board

Sample FILEDEMO.C File (pdf)

Sample FILEDEMO.4th File (pdf)

CF Wildcard Hardware Schematic

The Compact-Flash Wildcard and
CF Card Software Package User Guide

<< Previous | Next>>

C: void File_Interpreter( void )
4th: File_Interpreter ( -- )
A replacement for QUIT, the standard QED-Forth interpreter. This function is typically not called directly; rather, it is invoked by Process_File. It is an infinite loop that typically takes its input from a specified file. It is capable of loading hex records (Intel or Motorola S records) into memory, calling File_To_Memory to perform a fast binary transfer of code, or executing or compiling any other valid Forth commands including commands to program flash, remove or set priority autostart vectors, or even recursively interpret other files. It is terminated by error-induced aborts, or when an end of file is encountered.
Implementation Details: This modified Forth interpreter assumes that the serial input primitives Key and AskKey have been revectored to point to File_Key and File_Ask_Key (see their glossary entries) so that input comes from a file, and that SERIAL_ACCESS has been properly initialized. These details are handled automatically by Process_File (which passes the xcfa of File_Interpreter to the Redirect function); see its glossary entry.

C: uchar File_Key( void )
4th: File_Key ( -- char )
Installed by Process_File as a revector of the Key serial input primitive function that is called by File_Interpreter. This function is typically not used directly by the programmer. Based on the key_fileid initialized by Process_File, this function calls File_Getc to get the next character from the file. If the end of file is encountered, this function returns an ASCII carriage return. No error reporting is performed via the return value; the calling program must use File_Error to trap errors such as end of file.

C: int File_Open( char* name_addr, uint name_page, int name_count, int access_mode )
4th: File_Open ( name_xaddr\name_count\access_mode -- file_id )
Opens in the root directory the file having the name and extension contained in the name_addr string, and assigns access privileges as specified by the access_mode. Returns a non-negative file_id if the open was successful. Returns -2 if the file system was not initialized (see Init_File_System); returns -1 if the open failed for any other reason. Valid access modes are R_MODE, RPLUS_MODE, W_MODE, WPLUS_MODE, A_MODE, and APLUS_MODE. The access modes behave just like the ANSI C standard access modes; see their glossary entries for details. Briefly, the modes that start with "R" (read) require that the file pre-exists. The modes that start with "W" (write) cause a like-named pre-existing file (if present) to be truncated to zero size. The modes that start with "A" (append) force any write to occur at the end of the file. The modes that include "PLUS" allow both reads and writes; otherwise, only the operation suggested by the leading letter of the mode is allowed ("R" = read, "W" or "A" = write). All files are treated as binary files (that is, text files are not stored in a different format than other files). The filename is passed to the function as a character string whose first byte is at the specified name_addr on the specified page. Forth programmers should pass a string that has been "unpacked" using the COUNT function. C programmers must pass name_count = -1 to inform the function that this is a null-terminated string. C programmers will typically pass the THIS_PAGE macro (defined in \include\mosaic\types.h) to specify the name_page parameter. The name string may have up to 8 characters followed by an optional period and up to 3 extension characters. No leading or trailing spaces are allowed in the name string. All names are automatically converted to upper case by this function. "Long file names" (that is, more than 8 characters in the name) are not supported. The following are examples of valid names:
    myname.4th
    MYNAME.C
    MYname
    SOMEBODY.TXT

The following are invalid for the reason shown in parentheses:

    MYNAME. (no extension is present after the .)
    .. (directories are not supported)
    TOOMANYCHARS.txt (too many characters in name)
    MYNAME.MANY(too many characters in extension)
NOTE: It is the user's responsibility to pass a correctly formed name string to the function. Not all malformed strings will produce an explicit error condition.
The function will return an error (that is, file_id = -1) under the following conditions:
    truncate failed in W_MODE or WPLUS_MODE;
    file did not pre-exist in R_MODE or RPLUS_MODE;
    too many files are open (i.e., no file_id's are available);
    disk is full;
    root directory is full (see ERR_ROOT_DIR_FULL for details).
See the glossary entries that start with "ERR_" for a complete list of error codes.
This function sets the file position pointer to zero, but note that File_Write may automatically relocate the file position to the end of the file if the access mode is A_MODE or APLUS_MODE. If a pre-existing file is opened and its directory entry specifies read-only access, the file's access mode is set to R_MODE regardless of the access_mode parameter that is passed to this function.
CAUTION: If this function or other functions that accept name strings as parameters are typed interactively at the QED-Forth monitor using the Forth syntax, the dictionary pointer must point to modifiable RAM, not flash memory. This is because Forth emplaces strings typed interactively at the current dictionary pointer, and attempts to emplace data in flash without using the specially coded flash operations will cause a software crash. To avoid this problem, you can usually type the command
    1 USE.PAGE
before an interactive session; this puts the dictionary pointer on page 1 RAM on a QED-Flash board that has 128K RAM and is operating in the STANDARD.MAP mode. If only 32K of RAM is present in the center socket, you could type
    HEX BO00 0 DP X!
to locate the dictionary pointer in the processor's on-chip RAM.
EXAMPLE OF INTERACTIVE USE: Typical interactive use from the terminal is as follows (note that there is 1 blank space after the leading quote in the MYFILE.TXT string):
    INTEGER: myfileID
    " MYFILE.TXT" COUNT WPLUS_MODE FILE_OPEN TO myfileID

Then, to put text into the file, see the glossary entry for File_Capture. To close the file, execute:
    myfileID FILE_CLOSE

C: int File_Putc( char c, int file_id )
4th: File_Putc ( char\file_id -- [char] or [err_eof] )
Writes the specified character to the specified open file in the root directory at the current file position, and increments the file position pointer by 1. Returns ERR_EOF if a write error occurred. If ERR_EOF is returned, further information about the error may be obtained by executing File_Error; see its glossary entry. See also File_Write and File_Getc.

C: int File_Puts( char* source_addr, uint source_page, uint maxchars, int file_id )
4th: File_Puts ( source_xaddr\maxchars\file_id -- numchars_written )
Writes a string to a text file and returns the number of characters written as a 16-bit number. Writes the contents from the source buffer starting at source_addr on the specified page to the specified file starting at the current file position. C programmers will typically specify a source_addr in common RAM with source_page = 0. Terminates when maxchars bytes have been written, or when a null character in the source buffer is encountered, whichever occurs first. There is no special treatment of any characters other than the null. Note that, unlike fputs() in C, this File_Puts function returns numchars_written instead of returning a pointer to the source string. Use File_Error or File_EOF to test for errors after this function executes. See also File_Gets.
Benchmark: This function typically executes in under 21 milliseconds per character.

C: int File_Put_CRLF( int file_id )
4th: File_Put_CRLF ( file_id--error)
A handy utility for emplacing a carriage return (ASCII 0x0D) followed by a linefeed (ASCII 0x0A) sequence into the specified file at the current file position. Increments the file position by 2, and returns a nonzero error flag if a write error occurred.

<< Previous | Next>>


Home|Site Map|Products|Manuals|Resources|Order|About Us
Copyright (c) 2009 Mosaic Industries, Inc.
Your source for single board computers, embedded controllers, and operator interfaces for instruments and automation