The following are possible status values for CF Card/USB Storage Status.
Listed Files
When the File List Output function "_CF_dir ( )" or "_USB_dir ( )" is executed, the number of file lists that are actually written in the LS Area is stored in "Listed Files [s:CF_FILELIST_NUM]/[s:USB_FILELIST_NUM]".
Usage example
_CF_dir ("\DATA\*.*", [w:[#INTERNAL]LS0100], 10, 0)
[w:LS0200] = [s:CF_FILELIST_NUM]
When obtaining a file list of the 10 files and the specified folder contains only five files, "5" is stored in [s:CF_FILELIST_NUM].
When no files are written, the total number of files contained in the specified folder is written in [s:CF_FILELIST_NUM].
Number of Read Bytes
When the File Read function "_CF_read ( )" or "_USB_read ( )" is executed, the number of bytes actually read out is stored in "Readout Bytes [s:CF_READ_NUM] / [s:USB_READ_NUM].
Usage example
_CF_read ("\DATA", "DATA0001.BIN", [w:[#INTERNAL]LS0100], 16, 16)
[w:[#INTERNAL]LS0200] = [s:CF_READ_NUM]
When an attempt is made to read 16 bytes but only 12 bytes are read successfully, "12" is stored in [s:CF_READ_NUM].
CF Card/USB Storage Error Status
Stores the error status generated when the CF Card or USB Storage is accessed.
Bit Position |
Error Name |
Description |
---|---|---|
15 |
Reserved |
Reserved |
14 |
||
13 |
||
12 |
||
11 |
||
10 |
||
9 |
||
8 |
||
7 |
||
6 |
File rename error |
|
5 |
File delete error |
|
4 |
File write error |
|
3 |
File read error |
|
2 |
File list error |
|
1 |
CF Card/USB storage error |
|
0 |
No CF Card/USB Storage |
|
Even when a CF Card/USB storage Error occurs, processing will continue. Be sure to write the script so that it checks for errors when you use the file operation functions of a CF Card/USB storage.
Example:
_CF_dir ("\DATA\*.*", [w:[#INTERNAL]LS0100], 2, 1) // Output file list
if ([s:CF_ERR_STAT02] <> 0) // Check error status.
{
set ([b:[#INTERNAL]LS005000]) // Set error display bit address.
}
endif
CF Card/USB storage Error Detail Status Storage Area
Each Bit will be set when an error occurs. You can check what factors lead to the error by setting Detail Status. In each function, Detail Status is stored in LS9132 to LS9137 for Extend System Area (LS9138 to LS9143 for USB storage). These areas are read-only.
Error list for each function
Editor Function Name |
|
Error Status |
Cause |
---|---|---|---|
_CF_dir ( ) |
LS9132 |
0010h |
Invalid D-Script data (Error in retrieving folder name specified with fixed string) |
0012h |
File name (path name) error | ||
0018h |
LS Area writing range error | ||
0020h |
No CF Card | ||
0021h |
Invalid CF Card | ||
0100h |
Directory open error |
Editor Function Name |
|
Error Status |
Cause |
---|---|---|---|
_CF_read ( ) |
LS9133 |
0010h |
Invalid D-Script data (Error in retrieving folder name/file name specified with fixed string) |
0011h |
LS Area reading range error | ||
0012h |
File name (path name) error | ||
0018h |
LS Area writing range error | ||
0020h |
No CF Card | ||
0021h |
Invalid CF Card | ||
0101h |
File seek error (Offset error) | ||
0102h |
Number of readout bytes error | ||
0110h |
File creation (open) error |
Editor Function Name |
|
Error Status |
Cause |
---|---|---|---|
_CF_write ( ) |
LS9134 |
0010h |
Invalid D-Script data (Error in retrieving folder name/file name specified with fixed string) |
0011h |
LS Area reading range error | ||
0012h |
File name (path name) error | ||
0020h |
No CF Card | ||
0021h |
Invalid CF Card | ||
0101h |
File seek error (Offset error) | ||
0104h |
Folder creation error | ||
0108h |
Write mode error | ||
0110h |
File creation (open) error | ||
0111h |
File write error (For example, insufficient space on CF Card) |
Editor Function Name |
|
Error Status |
Cause |
---|---|---|---|
_CF_delete ( ) |
LS9135 |
0010h |
Invalid D-Script data (Error in retrieving folder name/file name specified with fixed string) |
0011h |
LS Area reading range error | ||
0012h |
File name (path name) error | ||
0020h |
No CF Card | ||
0021h |
Invalid CF Card | ||
0112h |
File delete error (For example, specified file does not exist. Specified file is read-only.) |
Editor Function Name |
|
Error Status |
Cause |
---|---|---|---|
_CF_rename ( ) |
LS9136 |
0010h |
Invalid D-Script data (Error in retrieving folder name/file name specified with fixed string) |
0011h |
LS Area reading range error | ||
0012h |
File name (path name) error | ||
0020h |
No CF Card | ||
0021h |
Invalid CF Card | ||
0114h |
File rename error (For example, specified file does not exist. File name already exists.) |
Editor Function Name |
|
Error Status |
Cause |
---|---|---|---|
_CF_read_csv ( ) |
LS9137 |
0001h |
Parameter error |
0002h |
CF Card error (No CF Card, Open file error, File read error) | ||
0003h |
Write Error |
Editor Function Name |
|
Error Status |
Cause |
---|---|---|---|
_USB_dir ( ) |
LS9138 |
0010h |
Invalid D-Script data (Error in retrieving folder name specified with fixed string) |
0012h |
File name (path name) error | ||
0018h |
LS Area writing range error | ||
0020h |
No USB storage | ||
0021h |
Invalid USB storage | ||
0100h |
Directory open error |
Editor Function Name |
|
Error Status |
Cause |
---|---|---|---|
_USB_read ( ) |
LS9139 |
0010h |
Invalid D-Script data (Error in retrieving folder name/file name specified with fixed string) |
0011h |
LS Area reading range error | ||
0012h |
File name (path name) error | ||
0018h |
LS Area writing range error | ||
0020h |
No USB storage | ||
0021h |
Invalid USB storage | ||
0101h |
File seek error (Offset error) | ||
0102h |
Number of readout bytes error | ||
0110h |
File creation (open) error |
Editor Function Name |
|
Error Status |
Cause |
---|---|---|---|
_USB_write ( ) |
LS9140 |
0010h |
Invalid D-Script data (Error in retrieving folder name/file name specified with fixed string) |
0011h |
LS Area reading range error | ||
0012h |
File name (path name) error | ||
0020h |
No USB storage | ||
0021h |
Invalid USB storage | ||
0101h |
File seek error (Offset error) | ||
0104h |
Folder creation error | ||
0108h |
Write mode error | ||
0110h |
File creation (open) error | ||
0111h |
File write error (For example: insufficient space on USB storage) |
Editor Function Name |
|
Error Status |
Cause |
---|---|---|---|
_USB_delete ( ) |
LS9141 |
0010h |
Invalid D-Script data (Error in retrieving folder name/file name specified with fixed string) |
0011h |
LS Area reading range error | ||
0012h |
File name (path name) error | ||
0020h |
No USB storage | ||
0021h |
Invalid USB storage | ||
0112h |
File delete error (For example, specified file does not exist. Specified file is read-only.) |
Editor Function Name |
|
Error Status |
Cause |
---|---|---|---|
_USB_rename ( ) |
LS9142 |
0010h |
Invalid D-Script data (Error in retrieving folder name/file name specified with fixed string) |
0011h |
LS Area reading range error | ||
0012h |
File name (path name) error | ||
0020h |
No USB storage | ||
0021h |
Invalid USB storage | ||
0114h |
File rename error (For example, specified file does not exist. File name already exists.) |
Editor Function Name |
|
Error Status |
Cause |
---|---|---|---|
_USB_read_csv ( ) |
LS9143 |
0001h |
Parameter error |
0002h |
USB storage error (No USB storage, File open error, File read error) | ||
0003h |
Write Error |
When data is read/written from/to device addresses at the execution of the File Read/File Write function, the storage order of the written (readout) data can be specified.
Setting the data storage mode in LS9130 can change the storage order. The mode can be selected from four options: 0, 1, 2 or 3.
Use the following to reference LS9130.
_CF_write() CF file operation: Write to file
_CF_read() CF file operation: Read file
_CF_read_csv() CF file operation: Read CSV file
_USB_write() USB file operation: Write to file
_USB_read() USB file operation: Read file
_USB_read_csv() USB file operation: Read CSV file
IO_WRITE([p:PRN],...) Print operation: Send
When writing or reading to device addresses, instead of using the LS9130 storage mode, you can use the following functions to interact with the [Text Data Mode] property in the [System Settings] window's [Device/PLC] page.
_CF_dir() CF file operation: Output file list
_USB_dir() USB file operation: Output file list
Mode 0
For example, when the File Read function is used to write a string "ABCDEFG" in a device address
[w:[#INTERNAL]LS9130] = 0
_CF_read ("\DATA", "DATA0001.BIN", [w:[#INTERNAL]LS0100], 0, 7)
When the device address length is 16 bits
When the device address length is 32 bits
Mode 1
For example, when the File Read function is used to write a string "ABCDEFG" in a device address
[w:[#INTERNAL]LS9130] = 1
_CF_read ("\DATA", "DATA0001.BIN", [w:[#INTERNAL]LS0100], 0, 7)
When the device address length is 16 bits
When the device address length is 32 bits
Mode 2
For example, when the File Read function is used to write a string "ABCDEFG" in a device address
[w:[#INTERNAL]LS9130] = 2
_CF_read ("\DATA", "DATA0001.BIN", [w:[#INTERNAL]LS0100], 0, 7)
When the device address length is 16 bits
When the device address length is 32 bits
Mode 3
For example, when the File Read function is used to write a string "ABCDEFG" in a device address
[w:[#INTERNAL]LS9130] = 3
_CF_read ("\DATA", "DATA0001.BIN", [w:[#INTERNAL]LS0100], 0, 7)
When the device address length is 16 bits
When the device address length is 32 bits
The data storage mode is not the same as the string data mode in the [System Settings] window's [Device/PLC] page. The comparison of the data storage mode and the string data mode is shown below.
Data in Device Addresses |
LH/HL Storage |
Double-word Byte LH/HL storage order |
D-Script data storage mode |
Text Data Mode |
---|---|---|---|---|
Store from Start Data |
HL Order |
HL Order |
0 |
1 |
LH Order |
1 |
2 | ||
HL Order |
LH Order |
2 |
5 | |
LH Order |
3 |
4 | ||
Store from Last Data |
HL Order |
HL Order |
— |
3 |
LH Order |
— |
7 | ||
HL Order |
LH Order |
— |
8 | |
LH Order |
— |
6 |
There is a limit to the frequency that data can be rewritten to the CF Card. Therefore, be sure to backup all CF Card data regularly to another storage media. Assuming that 500 KB of DOS format data is overwritten, the limit is 100,000 times.
If an error occurs during CF Card/USB storage processing, the error is written to the CF Card Error/USB storage error status [s:CF_ERR_STAT]/[s:USB_ERR_STAT]. For more details, see CF Card/USB Storage Error Status.
The following symbols and characters cannot be used in folder names or file names. Use of these symbols and characters in a folder name or file name will generate an error.
: , = + / " [ ] | < > ? [space]
To specify a root folder, specify " " (empty string) as the folder name.