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

SD:MOUNT

ACK / NAK:x

Mount the SD card

W

SD:UNMOUNT

ACK / NAK:x

Unmount the SD card

R

SD:?

MOUNT / UNMOUNT

Read the SD card status

W

SD:RST

ACK / NAK:x

Reset the SD card

R

SD:LS

list of files + ACK / NAK:x

List all files on the SD card

W

SD:RM:<filename>

ACK / NAK:x

Remove the selected file

R

SD:SIZE:<filename>

<size> / NAK:x

Show the file size, in bytes

R

SD:READ:<filename>

file contents + ACK / NAK:x

Read the contents of the file

Parameter(s):

Name

Type

Description

<filename>

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> is DLOG or DMM, 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:LS lists 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 an ACK to 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 an ACK to 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 an ACK to 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

SD:MOUNT

NAK:18

The SD card is already mounted

–

SD:MOUNT

NAK:18

The SD card cannot be mounted (missing, not formatted, …)

#1 SD mount error

SD:UNMOUNT

NAK:19

The SD card is not mounted

–

SD:UNMOUNT

NAK:19

The SD card cannot be unmounted

#1 SD mount error

SD:LS

NAK:16

The SD card is not mounted

–

SD:LS

NAK:17

The files cannot be listed

–

SD:RM:<filename>

NAK:16

The SD card is not mounted

–

SD:RM:<filename>

NAK:20

The file cannot be removed (e.g. it does not exist)

–

SD:SIZE:<filename>

NAK:16

The SD card is not mounted

–

SD:SIZE:<filename>

NAK:21

The file cannot be opened (e.g. it does not exist)

#2 SD open error

SD:READ:<filename>

NAK:16

The SD card is not mounted

–

SD:READ:<filename>

NAK:21

The file cannot be opened (e.g. it does not exist)

#2 SD open error

SD:READ:<filename>

NAK:22

The file cannot be read

#7 SD read error

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