System SourceMeter® Instrument Reference Manual Section 5:
Introduction to TSP operation
2600BS-901-01 Rev. C / August 2016 5-7
File I/O
You can use the file I/O commands to open and close directories and files, write data, or to read a file
on an installed USB flash drive. File I/O commands are organized into two groups:
• Commands that reside in the fs and io table, for example: io.open(), io.close(),
io.input(), and io.output(). Use these commands to manage file system directories; open
and close file descriptors; and perform basic I/O operations on a pair of default files (one input
and one output).
• Commands that reside in the file descriptors (for example: fileVar:seek(),
fileVar:write(), and fileVar:read()) operate exclusively on the file with which they are
associated.
The root folder of the USB flash drive has the absolute path:
"/usb1/"
You can use either the slash (/) or backslash (\) as a directory separator. However, the backslash is
also used as an escape character, so if you use it as a directory separator, you will generally need to
use a double backslash (\\) when you are creating scripts or sending commands to the instrument.
For basic information about navigation and directory listing of files on a flash drive, see File system
navigation (on page 2-80).
File descriptor commands for file I/O use a colon (:) to separate the command parts rather than a
period (.), like the io commands.
File descriptors cannot be passed between nodes in a TSP-Link
®
system, so the io.open(),
fileVar::read(), and fileVar::write commands are not accessible to the TSP-Link system.
However, the default input and output files mentioned above allow for the execution of many file I/O
operations without any reference to a file descriptor.
fileVar:close() (on page 7-97)
fileVar:flush() (on page 7-97)
fileVar:read() (on page 7-98)
fileVar:seek() (on page 7-99)
fileVar:write() (on page 7-100)
fs.chdir() (on page 7-103)
fs.cwd() (on page 7-104)
fs.is_dir() (on page 7-104)
fs.is_file() (on page 7-105)
fs.mkdir() (on page 7-105)
fs.readdir() (on page 7-105)
fs.rmdir() (on page 7-106)
io.close() (on page 7-117)
io.flush() (on page 7-117)
io.input() (on page 7-118)
io.open() (on page 7-119)
io.output() (on page 7-119)
io.read() (on page 7-120)
io.type() (on page 7-121)
io.write() (on page 7-121)
os.remove() (on page 7-163)
os.rename() (on page 7-164)