Accessing Backup Files on the CloudBox

The CloudBox offers multiple methods for users to access and manage backup files, ensuring data integrity during race events. Backup files are essential for storing passings data, especially in cases where network connections might be lost or when post-event analysis is required. You can retrieve backup data through methods like USB Pen Drive, browser download link, or by using the Rewind feature. Additionally, each backup file is saved in .txt format and named using a timestamp to help identify when the backup was created.

This article will cover the different ways to access backup files and provide a code example for analyzing the .txt backup files.

Backup File Format

All backup files on the CloudBox are saved in .txt format, with the file name consisting of a timestamp that reflects the creation time. The format of the file name is:

YYYYMMDD-HHMMSS.txt

For example, a backup file created on September 18, 2024, at 09:36:34 would be named:

20240918-093634.txt

Backup File Content

Each file contains JSON-formatted entries, similar to the data transmitted during a TCP socket connection. These entries represent individual passings, with information such as the RFID tag read, timestamp, antenna used, RSSI value, and more.

Example JSON entry from a backup file:

{
  "epc": "3D2E372D39293A313C313734",
  "timestamp": "2024-09-18;09:36:34.098",
  "seenCount": 1,
  "antenna": 1,
  "rssi": -58,
  "passingNumber": 1,
  "tagStr": "MC00169",
  "latitude": null,
  "longitude": null,
  "chksum": "6a0f5"
}

Each passing is stored sequentially, with all relevant timing data captured.

1. Accessing Backups via USB Pen Drive

One of the easiest ways to retrieve your CloudBox backups is by connecting a USB Pen Drive to the device. The CloudBox automatically detects the USB drive and transfers backup files to it. The system will notify you of the connection status and whether the download was successful or encountered an error.

How It Works:

  • When a USB drive is connected to the CloudBox, the system detects the device and begins the backup download process.

  • The user is notified of the drive detection, download progress, and any errors that may occur.

  • During this process, the CloudBox will emit a light sequence—flashing every 500ms for 2 seconds—to indicate that the USB drive has been detected.

Important Considerations:

  • USB Drive Format: The USB drive must be formatted in MS-DOS (FAT32). Drives with other formats may not be detected by the CloudBox.

  • Drive Name: The drive's name should use standard characters (e.g., PEN_BACKUPS) to ensure compatibility.

  • Notifications: If you're connected to the CloudBox interface, you will receive notifications indicating whether the connection and download were successful or if any errors occurred.

Another convenient way to access backups is by using a direct download link in a web browser. You can download all backup files in a zipped format by accessing the following link:

http://{clbx_ip_address}:2999/download

For example, if the CloudBox's IP address is 192.168.1.11, the link to download backups would be:

http://192.168.1.11:2999/download

How It Works:

  • Open a browser and navigate to the download link using the CloudBox's Ethernet IP address.

  • You can download all backup files stored on the CloudBox in a zipped format, making it easy to transfer and archive the data.

Important Considerations:

  • The CloudBox must be connected to the same network as your computer (either via Ethernet, WiFi on the same subnet, or WiFi Access Point).

  • Make sure to keep the backup storage clean by periodically downloading and deleting old files to avoid storage issues.

3. Rewind Feature for Retrieving Passings

The Rewind feature allows you to retrieve specific passings data between a given time range. This feature is especially useful for analyzing race data after the event, as it provides a stream of past passings to connected TCP clients.

How It Works:

  • The Rewind feature returns a stream of passings data to connected TCP clients.

  • You can specify a startTimestamp and endTimestamp to limit the data to a specific time range. If both are set to null, the CloudBox will return all passings available in the backup files.

Command Format:

  • Rewind Command:

    REWIND;startTimestamp;endTimestamp

    Example format for timestamps:

    REWIND;2024-09-18 09:30:00;2024-09-18 10:30:00
  • startTimestamp and endTimestamp must be in the format YYYY-MM-DD HH:mm:ss. If no timestamp is provided, the system will return all available data from the backup.

Important Considerations:

  • The Rewind feature can be used during an active timing session (START_MODE). This allows you to access past data while still recording new passings in real time.

  • Keep in mind that if no specific time range is provided, retrieving a large amount of data could take time, especially if the backup storage is not regularly cleaned.

Notifications and LED Indications

The CloudBox provides various feedback mechanisms when interacting with backups:

  • USB Detection: The CloudBox will flash its LED every 500 ms for 2 seconds when a USB drive is detected, indicating that the backup download process is starting.

  • User Notifications: If you are connected to the CloudBox via the web interface, you will receive notifications when:

    • The USB drive is connected.

    • The backup download completes successfully.

    • Any errors occur during the download process.

These notifications ensure that users are aware of the backup status and can respond if needed.

Analyzing Backup Files

Here’s an example of how you can read and analyze the backup files using Python, C#, and Node.js.

Python Example:

import json

# Path to the backup file
backup_file = "20240918-093634.txt"

# Open the backup file and parse each line as a JSON object
with open(backup_file, "r") as file:
    for line in file:
        passing_data = json.loads(line)
        print(f"Tag: {passing_data['epc']}, Timestamp: {passing_data['timestamp']}, Antenna: {passing_data['antenna']}")

C# Example:

using System;
using System.IO;
using Newtonsoft.Json.Linq;

class BackupAnalysis
{
    static void Main()
    {
        string backupFilePath = "20240918-093634.txt";
        
        foreach (string line in File.ReadLines(backupFilePath))
        {
            JObject passingData = JObject.Parse(line);
            Console.WriteLine($"Tag: {passingData["epc"]}, Timestamp: {passingData["timestamp"]}, Antenna: {passingData["antenna"]}");
        }
    }
}

Node.js Example:

const fs = require('fs');

// Path to the backup file
const backupFile = '20240918-093634.txt';

// Read and parse each line of the backup file
fs.readFile(backupFile, 'utf8', (err, data) => {
    if (err) throw err;
    
    data.split('\n').forEach(line => {
        if (line) {
            const passingData = JSON.parse(line);
            console.log(`Tag: ${passingData.epc}, Timestamp: ${passingData.timestamp}, Antenna: ${passingData.antenna}`);
        }
    });
});

These examples show how you can parse the JSON entries in the backup files and extract key information like epc (RFID tag), timestamp, and antenna.

Summary

The CloudBox provides multiple ways to access and manage backup files, including using a USB Pen Drive, downloading via a browser link, or using the Rewind feature for targeted passings retrieval. Each backup file is saved in a .txt format with a timestamped name, and the entries inside the file are stored in JSON format, representing each passing. Regularly downloading and analyzing these backups ensures that race data is securely stored and easily accessible for post-event analysis.

Last updated