SD Command
Applies to: DLOG-DMM modes. Can be used in any mode; data is saved to the SD card only in DLOG and DMM modes.
The SD command manages the SD memory card. When the SD card is inserted in
the appropriate slot it must be mounted before the CT-BOX can use it;
likewise, the SD card must be unmounted before it is removed from the
CT-BOX device.
Command Format:
R/W |
Command |
Response |
Description |
|---|---|---|---|
W |
|
|
Mount the SD card |
W |
|
|
Unmount the SD card |
R |
|
|
Read the SD card status |
W |
|
|
Reset the SD card |
R |
|
list of files + |
List all files on the SD card |
W |
|
|
Remove the selected file |
R |
|
|
Show the file size, in bytes |
R |
|
file contents + |
Read the contents of the file |
Parameter(s):
Name |
Type |
Description |
|---|---|---|
|
string |
Name of the file on the SD card |
SD Card Reset
If needed, the SD memory card can be remotely reset using the SD:RST
command. The remote reset action is equivalent to removing the SD card from
its slot and inserting it again.
Important
After a remote SD card reset the user must issue an SD:MOUNT command, so
that the CT-BOX prepares the card for use.
File Naming
When data saving is enabled (see SAVE), the CT-BOX creates a new text file at every ACQ:ON, whose name is built from the CT-BOX name, the mode of operation and the date and time:
<name>_<mode>_<year><month><day>_<hour><minutes><seconds>.txt
<name>is the first 8 characters of the user-defined CT-BOX name (see CTBOX:NAME); a shorter name is used as it is;<mode>isDLOGorDMM, according to the mode of operation;the date and time are taken from the Real-Time Clock (see DATE and TIME).
Example: with the CT-BOX name set to DIPOLE, a DLOG acquisition saved on
25.09.26 at 14:35:07 is stored in the file:
DIPOLE_DLOG_260925_143507.txt
SD Data Management
Four commands are available for the management of the SD data contents:
SD:LSlists all the files that are on the SD card. The reply is in the form<filename1>\r\n<filename2>\r\n...; after the last filename is printed, the CT-BOX sends anACKto inform the user that the list of files has reached the end.SD:RM:<filename>removes the selected file from the SD card. After the file is removed, the CT-BOX sends anACKto inform the user that the operation succeeded.SD:SIZE:<filename>returns the size of the selected file, expressed in bytes.SD:READ:<filename>reads the content of the selected file and prints the data on the active communication stream. After the data is printed, the CT-BOX sends anACKto inform the user that the operation succeeded.
Errors
When an SD command fails, the CT-BOX replies with one of the following
error codes (see List of the Error Codes). Some failures also set
a bit of the Error Register, which stays high
until ERR:CLR.
Command |
Reply |
Cause |
Error Register bit |
|---|---|---|---|
|
|
The SD card is already mounted |
– |
|
|
The SD card cannot be mounted (missing, not formatted, …) |
|
|
|
The SD card is not mounted |
– |
|
|
The SD card cannot be unmounted |
|
|
|
The SD card is not mounted |
– |
|
|
The files cannot be listed |
– |
|
|
The SD card is not mounted |
– |
|
|
The file cannot be removed (e.g. it does not exist) |
– |
|
|
The SD card is not mounted |
– |
|
|
The file cannot be opened (e.g. it does not exist) |
|
|
|
The SD card is not mounted |
– |
|
|
The file cannot be opened (e.g. it does not exist) |
|
|
|
The file cannot be read |
|
SD:MOUNT and SD:UNMOUNT are not repeatable: issuing them when the card
is already in the requested state is answered with a NAK. Read the state
with SD:? first if it is not known.
NAK:22 is sent when a read fails part-way through the file: the data read
until then has already been printed, and NAK:22 takes the place of the
final ACK.
The SD commands are accepted in every mode, but data is saved to the SD
card only in DLOG and DMM modes (see SAVE). While the CT-BOX is
acquiring data, every SD command except SD:? replies with NAK:6; in DLOG
mode with the printout active, the command instead stops the printout and
replies with NAK:4.
Example(s):
Mount the SD card and read back its status:
SD:MOUNT
ACK
SD:?
MOUNT