Skip to content

recording-writer

Collects received packets and periodically writes them to the filesystem.

Description

This script receives packets from all configured connections and stores them in the VBus Recording File Format to the filesystem in the configured intervals.

The files are stored under logs/recording/<year> and are named <year><month><day>.vbus. The UTC date is used for the formatting of the file's path. That means that data recorded at "2025-04-01 01:30:00 CEST (Central European Summertime)" will still be stored in a file under logs/recording/2025/20250331.vbus, because its still before midnight in UTC time.

Service

typescript
setInterval(interval: number): void;

setInterval

Change the interval in milliseconds that is used to store data to the filesystem. Defaults to 10000 (= 10 seconds). Cannot be changed after $.connect() was called.

Example

Config:

typescript
export default defineConfig({
  connections: [{
    kind: 'serialPort',
    path: '/dev/tty.usbmodem',
  }],
  scripts: [
    import('../scripts/recording-writer'),

    defineScript(async ($) => {
      const rwScript = await import('../scripts/recording-writer');
      const rwService = await rwScript.default.requireService();

      rwService.setInterval(1000); // = 1 second

      await $.connect();

      // NOTE: rwService.setInterval() is not allowed after $.connect()
    }),
  ],
});