The text of a manual · part 5 of 26
Videx BASIC for DuraTrax, LaserLite, LaserLite Pro, and LaserLite Mx Data Collectors, pages 41 to 50
Pages 41 to 50 of 252
The original document is the PDF (765 KB). This is its text as extracted, unedited; tables and drawings read best in the PDF, and each page heading opens it at that page.
For the Videx DuraTrax, Videx LaserLite, Videx LaserLite Mx and Videx LaserLite Pro
Page 41
or Argument command_str$
Description Complete command to send to the memory card processor. Must be the only parameter. Programmer is responsible for using the correct syntax within the command string. The system adds CRC error checking if the first character of the string is lowercase.
• Remarks This command constructs and sends a command to the memory card processor. Its ability to accept a variable number of parameters means that it can adapt to the variations in syntax of the command set. Also, since single letters are interpreted as the integer ASCII value of the letter, both mode and file-type letters can be specified exactly as they are in the actual memory card processor command. (See page 38 for information on file types, pages 39–40 for additional notes on the CARDCMD statement commands, and Appendix B for information on hash values.) The command syntax also allows the programmer to construct commands manually. A single string parameter (that is, with no command code parameter preceding) is presumed to contain the entire command already constructed. The string is sent as is, except when the first character is lowercase; then the CRC bytes are calculated and added to the end of the string. The command sends the number of parameters specified (up to the maximum of three), so you must be sure that the number of parameters matches the syntax for the command. The BASIC compiler insists that there is at least one parameter and that if there are three parameters beyond the command letter, that the last one is a string. After CARDCMD is used to send a command to the memory card processor, CARDSTATUS must be used to retrieve the response. Any data returned by previous commands, and not yet retrieved by a CARDSTATUS function call, will be lost. See also CARDSTATUS and HEX$. Chapter 4 Statement & Function Reference
33
Page 42
CARDCMD Global Errors If the LaserLite Mx operating system is unable to successfully execute the CARDCMD statement, it sets the global error flag. You may use the ERR() function to retrieve an error number. CARDCMD can issue the following errors: Error # -1 -2 -3 -4 - 11
Description Communications with the memory card timed out. There was no memory card module detected at startup. There was no memory card inserted in the module detected at startup. The card inserted in the memory card module does not have a recognized format. The memory card processor is asleep and cannot receive a command. Removing the memory card during operations can cause this.
• Example See the CARDSTATUS examples.
CARDCMD Statement Commands The following table gives a brief description of the commands that can be used by the CARDCMD statement. These commands provide communication to and from the LaserLite Mx’s memory card. The command set is described in detail on pages 39–57. Parameters within { } are required; parameters within [ ] are optional. The parameters must be sent in the given order. command_str$
Brief Description
Add a new record to the memory card’s open file. See page 39 for more information. List or send the memory card’s file C, {F/S/I}, [status bytes] management or status report. See pages 40–43 for more information. Delete a file from the memory card. D, {file type}, {filename} Delete an existing file. D, {file handle} D, {file handle}, {file type}, {filename} Rename an existing file. See page 44 for more information. A, [hash value], {record}
34
Chapter 4 Statement & Function Reference
Page 43
command_str$
Brief Description
F, [hash value], [key field]
Search for a record in the memory card’s open file with the given key field and send it to the host. Search for next record with same hash value or key field. See page 45 for more information. Delete a record from the memory card’s open file with the given key field. Delete next record with same hash value and key field. See page 46 for more information. Remove all deleted files from the memory card. See page 47 for more information. Move the pointer within the memory card’s open file. Show the current record. Delete the record at the move pointer. See pages 48–50 for more information. Format a new memory card or determine memory card ID. See page 51 for more information. Open a new or existing file on the memory card. Open an existing file. See pages 52–53 for more information. Calculate the CRC of a file and send it back to the host. See page 54 for more information. Perform a search within the memory card’s open file. See page 55 for more information. Read the memory card’s program version. See page 56 for more information. Repeat the last status byte or data. See page 57 for more information. Puts the data collector to sleep. See page 57 for more information.
F
H, [hash value], [key field] H
K, &1092
M, {# of records/bytes}, {F/R} M M, H N, [param1]
O, [modulus], {file type}, {filename} O, {file handle} Q, {file type}, {filename}
S, {field bytes}, {F/R}, {string}
V
Y Z
Chapter 4 Statement & Function Reference
35
Page 44
File Types The LaserLite Mx memory card system supports the following types of files: identification (D), boot (B), sequential (S), and indexed (I/H). Each file type serves a different purpose. The file types are described in the following table. See the LaserLite Mx Developer’s Reference Manual for complete information. Type D B
S I
H
36
Purpose A binary file that provides an ID for the memory card. Two types of boot files serve two different purposes. One (CRD) is for the memory card operating software that executes in its 32K XRAM; the other (CPU) is the main operating system (LMXxxx.OS) and application of the LaserLite Mx.
A binary file not intended for booting. This is the primary file type for data and cross-reference. Data is appended record-by-record. Each record is passed to the data management system to ‘hash’ and add to the record. This enables quick lookup. Another type of indexed file, but the decision of table entry is determined outside of the memory card data management system. This system may be useful for programs that must maintain a strict order of data, but require the ability to change or edit data.
Comments Only one (1) ID file may exist on the memory card at a time. These filenames are reserved by the LaserLite Mx system. CRD – The operating software for LaserLite Mx 32K XRAM. CPU – An operating system and application that may be booted from the memory card. Boot files must be appended with two bytes as bit complements to create a CRC of B001 hex over the entire file.
A hash table size must be indicated when indexed files are created. Please see the notes about hash tables in Appendix B.
Vxcom does not support transferring H files.
Chapter 4 Statement & Function Reference
Page 45
Notes on CARDCMD Statement Commands •= All communications between the host and the memory card must begin with a key character command and end with a carriage return. •= The key character of the commands may be lowercase or uppercase. When the key character is uppercase, the memory card module software is in debug mode; when the key character is lowercase, the software is in normal mode. The difference between debug mode and normal mode is that the communications between the host and memory card are CRC checked for normal mode, and not CRC checked for debug mode. •= For a lowercase key character command, the CRC is calculated from all of the bytes (including space and escape characters: & and ' or ") before the carriage return. The complements of the two CRC bytes are sent at the end of the command, before the carriage return, with the low byte first. The CRC of all the bytes sent across before the carriage return will always be &B001, if correct. The CRC of the returns from the memory card will only include the bytes before the carriage return. •= There are two different types of fields besides the key character for a command: parameters to control the behavior of the command and data to be passed between the host and the memory card. •= All of the fields for a command must be separated by a space and must be input in the order defined. •= The parameters may be binary values, single byte ASCII, and ASCII strings (such as filename and key field). •= A binary parameter may be up to four bytes long and can be input in both decimal and hexadecimal formats. •= The data may be hexadecimal values (for binary data) or ASCII strings (for records). •= All hexadecimal values used in the command line must begin with an ampersand (&) and end with an ampersand, space, or carriage return. •= All ASCII strings (with more than one character) must be enclosed in either single ('xxx') or double ("xxx") quotation marks; a single non-numeric ASCII byte does not need to be enclosed in quotation marks. Chapter 4 Statement & Function Reference
37
Page 46
•= The returns from the memory card can be status bytes (in decimal form), data (in hexadecimal or ASCII string format), or prompts responding to a single carriage input. The prompt for the firmware includes three bytes: a carriage return, a line feed, and a semicolon (:). The prompt for the memory card’s boot program (Data Management System (DMS)) is: a carriage return, line feed, and greater-than sign (>). All hexadecimal values returned by the memory card will begin with an ampersand (&). •= For indexed files, the DMS handles one record at a time. A tab character must separate the fields within the record. •= For sequential files, every byte in the data field of a command is written to the file. •= Doubling the “escape character” forces the character to be a data byte, for example, “&&” in a quoted string represents character &; “''” represents a ' character. If two continuous escape characters need to be used as Escape (as when sending two strings together) a space must be used to separate the strings. •= Do not include a carriage return or a backspace in a quoted string. A carriage return can only be used as the end of transmission mark and the backspace key will delete the previous byte. If nonprintable bytes need to be sent as part of a string, they should be sent as a hexadecimal value. •= Any binary data except the control characters (08 hex, 0D hex) and the escape characters (&, " or ') can be sent as ASCII strings.
38
Chapter 4 Statement & Function Reference
Page 47
CARDCMD Statement Commands The following sections provide complete information about each CARDCMD statement command.
A, [hash value] , {record} Adds data to the memory card’s open file (see the O command on pages 52–53 to open file). For an indexed (I) file, the card module first calculates the hash entry based on the key field of the record and then looks up the hash table for a pointer. If no pointer is found, it is the first record for the entry. The record is saved as the current end-of-file and the pointer at the hash table is set. If a pointer is found, a collision occurred for this entry. The DMS traverses the list and finds the last record with the same hash value. The new record is saved as the current end-of-file and the pointer is set at the last record. For type I files, the hash value is calculated internally. You can have more than one record with the same key field. The key field is delimited from other fields with a tab character (09 hex). For type H files, the hash value must also be passed with the command. For type S/D/B files, the A command appends {record} as data. Example: Add a record to the open file: CARDCMD A, "This is a record"
Successful return values: 00
(Record added)
Possible error codes that can be returned from this command: 01, 03, 04, 10, 32, 34, 39, 40, 41, 42, 53, 61, 63 (See pages 59– 60 for a description of the error codes.)
Chapter 4 Statement & Function Reference
39
Page 48
CARDCMD Statement Commands - continued
C, {F/S/I}, [status bytes] Lists the memory card’s file management or status information or sends a setup configuration to the memory card processor. F - List file management report. S - List status report. I - Send status report to the memory card processor. F - List File Management Report The file management report is sent out first, if asked, followed by individual file information. The filenames are enclosed in quotation marks. The file type is sent out as hexadecimal; all hexadecimal values in the report start with an ampersand (&). A space is used to separate hexadecimal from ASCII, or different parts of the listing (for example, a space between file 1 and file 2). The following tables show the order of the data format. A sample of the file management report is shown on the following page.
File Management Report Format: bytes 1–2 bytes 3–4 bytes 5–6 bytes 7 bytes 8–b1 bytes b2–b3 bytes b4–b5 ...
Total space of the card (Kbytes). Bad space (Kbytes). Available space (Kbytes). Number of files (including deleted files). 1st valid file information. 2nd valid file information. 3rd valid file information.
Individual File Information: byte 1 byte 2 byte 3 bytes 4–5 bytes 6–7 bytes 8–16 40
File serial number in the memory card. File status. File type. File table size. The file size (Kbytes). The filename (variable length from 1–18 bytes).
Chapter 4 Statement & Function Reference
Page 49
Example: Request file management report: CARDCMD C, F Example Return: &07980000076805 &01FF44FFFF0004 "card1" &02FF42FFFF0014 "CRD" &030049089B000C "data.txt" &03FF49089B000C "olddata.txt" &04FF49089B000C "data.txt" Note: The F command in a commands file issues the C, F command to the memory card. It creates the following report on the information above: Memory Card File and Memory Status Report Total Space: Bad Space: Available Space: Retrievable Space:
1944 Kbytes 0 Kbytes 1896 Kbytes 12 Kbytes
Number of deleted files: Number of valid files:
1 4
File Number 1 2 3 3 4
Table Size n/a n/a 2203 2203 2203
Deleted No No Yes No No
Type D B I I I
Kbytes 4 20 12 12 12
Name "card1" "CRD" "data.txt" "olddata.txt" "data.txt"
Chapter 4 Statement & Function Reference
41
Page 50
CARDCMD Statement Commands – continued The LaserLite Mx only allows one open file at a time. When you open a file, the Mx Data Management System (DMS) automatically closes a previously opened file and loses its reference to any given record. If your application requires you to open and close multiple files and you wish to re-open a file and return to the same record, then you must use the Cardcmd C, S and Cardcmd C, I statements. S – List Status Report At any given time the LaserLite Mx may have an open file and a pointer to data or to a record within that file. When power is removed from the memory card module during sleep, the data management system loses track of this information. The status report contains the information needed to restore the memory card system to a previous state. The operating system handles this automatically, but a developer may want to maintain a reference to a file and record among multiple files. This command provides that capability.
Status Report Format: byte 1 bytes 2–6 byte 7 bytes 8–b1
Last command before the C command. The move pointer: block # (2 bytes), page number (1 byte), column address (2 bytes). File type. Open filename (variable length).
Example: Request status report: Cardcmd C, S
Example Return: &4F001503006A04
Example Program: Cardcmd C, S
'Issue statement to get current 'file and record pointer Gosub process_cardcmd_error 'Process any errors Result% = Cardstatus(file1$)'Get status in file1$ Gosub process_card_error 'Process any return errors Cardcmd O, I, "file2.txt" 'Open the next file
42
Chapter 4 Statement & Function Reference