1. Home
  2. Docs
  3. Code Overview
  4. Data Logs

Data Logs

Some modules such as mircoSD memory card module H1BR60 feature permanent logging functionality to a FAT-formatted micro-SD card. You can create up to 10 simultaneous logs with up to 30 different variables across all logs. Logs are a tabulated text files that consist of a header section, a bunch of columns-each representing a single logged variable, and a bunch of rows-each representing the variables’ value at a given moment. Logs have two types: RATE and EVENT. The former type logs variable state periodically at a fixed rate, while the latter logs only a state change. Below is an example of RATE log

Datalog created by BOS V0.1.5 on H1BR6
Log type: Rate @ 10.00 Hz
Count    Float    UINT 32
1    120.400002    1123077325
2    120.400002    1123077325
3    120.400002    1123077325
4    120.400002    1123077325
5    120.400002    1123077325
6    120.400002    1123077325

And this is an example of an EVENT log:

Datalog created by BOS V0.1.5 on H1BR6
Log type: Events
Count,Switch 3 (E-stop)
11,RELEASED_FOR_2_SEC
21,CLICKED
31,CLICKED
41,PRESSED_FOR_1_SEC
59,RELEASED_FOR_2_SEC
65,CLICKED

Use this API to create a new log:

Module_Status CreateLog(const char* logName, logType_t type, float rate, delimiterFormat_t delimiterFormat, indexColumnFormat_t indexColumnFormat,const char* indexColumnLabel)

Where:

  • logName: Log file name (without extension).
  • type: Log type (RATE or EVENT)
  • rate: Logging rate in Hz (max 1000 Hz).
  • delimiterFormat: (FMT_TABFMT_COMMA)
  • indexColumnFormat: Index column (first column) format (FMT_SAMPLEFMT_TIME)
  • indexColumnLabel: Index column label text.

This API returns:

  • H1BR6_OK: Log created successfully.
  • H1BR6_ERR_LogNameExists: Log already exists on card.
  • H1BR6_ERR_WrongParams: Wrong log parameters.
  • H1BR6_ERR_SD: SD card failure.
  • H1BR6_ERR_MaxLogs: Maximum number of logs reached.

Once a log has been created, you can add new variables to the log using this API:

Module_Status LogVar(const char* logName, logVarType_t type, uint32_t source, const char* ColumnLabel)

Where:

  • logName: Log file name (without extension).
  • type: Log variable type (PORT_DIGITAL: log any array port as a digital input (TXD or RXD pin), PORT_DATA: log any array port as a serial data port, PORT_BUTTON: log any button/switch connected to array ports, MEMORY_DATA_UINT8, MEMORY_DATA_INT8, MEMORY_DATA_UINT16, MEMORY_DATA_INT16, MEMORY_DATA_UINT32, MEMORY_DATA_INT32, MEMORY_DATA_FLOAT: log any Flash/RAM memory location with a given data type).
  • source: log variable source (P1 .. Px if type is PORT_DATAB1 .. Bx if type is PORT_BUTTONP1TXD .. PxTXD or P1RXD .. PxRXD if type is PORT_DIGITAL; 32-bit memory address if type is MEMORY_DATA).
  • ColumnLabel: Logged variable column label text.

This API returns:

  • H1BR6_OK: Log created successfully.
  • H1BR6_ERR_LogDoesNotExist: Log was not found.
  • H1BR6_ERR_MemoryFull: Cannot allocate enough MCU memory for this variable (EVENT type logs only).
  • H1BR6_ERR_MaxLogVars: Maximum number of logged variables reached.

Adding a variable to a log does not start the logging process automatically. You can use the StartLog(), StopLog(), PauseLog() and ResumeLog() APIs to control the logging process for each log independently. You can also delete a log from the uSD card using DeleteLog() API.

Note: If the module booted without a uSD card (or with a malfunctioning one), the logging functionality will be aborted, and the indicator LED will blink indefinitely. Just replace the card and the module should resume normal operation.

How can we help?

0