Knowledge Base

SX10508: More on Serial Programming

SX10508: Serial Logging
COM Ports

The easiest way to log with the SX10508 is via the serial port.  The default application treats the COM ports as follows:

  • COM0 (closest the 3 way screw terminal) is used for configuring the date/time and formatting the SD card.
  • COM1 is used for receiving log data, unless jumper J1 is removed, in which case the RS485 port is used.  All data sent to this port at 38400 baud will be written to an automatically opened file.
Commands

There are some special commands that may be sent to the COM1 (or RS485) logging port.  All commands are encapsulated in “{}”.  Any command that isn’t recognised will simply be written to the log file.

{datestamp [format]}Writes the SX10508’s date/time to the current file
{newfile [filename.ext]}Closes the current file and opens a new one
{flushdata}   Forces buffered data to be written to the SD Card
Datestamp

The [format] string uses the following special characters to construct the date that will be written to the SD Card.

aDay Of Week as 3 characters, eg “Mon”
eDay of month, eg “7” for 7th February
mMonth with leading 0, eg “02” for February, “12” for December.
nMonth without leading 0
YYear, eg “2016”
H24 Hour with leading 0, eg “01” for 1AM, “19” for 7pm
l12 Hour with leading 0, eg “10” for 10AM, “07” for 7pm
MMinutes with leading 0
SSeconds with leading 0
Pam/pm as lower case 
pAM/PM as upper case

For example:


iiPrintText COMTTL,"{datestamp Y/m/e H:M:S}"

Will write something like 2016/09/26 11:31:05.

New File

Files on the SD card are named something like “00000341.csv”.  When the card is inserted, the SX10508 will automatically sacn the filesystem and create a file whose number is larger than any other on the card.

{NewFile filename.ext}

This command is new from 17 March 2023 (firmware version 4.7, SPLatware version 2.1.5).  It instructs the logger to close the existing file and create a new file with the configured name in 8.3 format (fewer characters is also allowable).  If the file name matches one already on the SD card, it will overwrite the existing file.

See also More On Serial Programming