Skip to content
tofupilotPublic

About

Upload hardware test data to TofuPilot from MATLAB.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

44 Commits

Folders and files

Repository files navigation

TofuPilot MATLAB Client

MATLAB client for the TofuPilot REST API. Struct-based, with retries and request lifecycle hooks.

Installation

Option 1: Add-On Explorer (recommended)

Search for TofuPilot in the MATLAB Add-On Explorer and click Install.

Option 2: GitHub

git clone https://github.com/tofupilot/matlab.git

Then add to your MATLAB path:

addpath('/path/to/matlab');
savepath;  % persist across sessions

Quick Start

sdk = tofupilot.TofuPilot('your-api-key');

% Create a test run
req.procedure_id = '550e8400-e29b-41d4-a716-446655440000';
req.serial_number = 'SN-001234';
req.part_number = 'PCB-V1.2';
req.outcome = 'PASS';
req.started_at = '2026-11-23T10:00:00Z';
req.ended_at = '2026-11-23T10:05:00Z';

run = sdk.Runs.create(req);
fprintf('Created run: %s\n', run.id);

Available Resources

Resource Methods Docs
Procedures create, list, get, delete, update docs/sdks/procedures
Runs create, list, delete, get, update, createAttachment, updateMetadata docs/sdks/runs
Attachments initialize, finalize docs/sdks/attachments
Units create, list, delete, get, update, addChild, removeChild, createAttachment, deleteAttachment docs/sdks/units
Parts create, list, get, update, delete docs/sdks/parts
Batches get, delete, update, list, create docs/sdks/batches
Stations create, list, getCurrent, get, update, remove docs/sdks/stations
Users list, getCurrent docs/sdks/users
Imports structured, tabular docs/sdks/imports
Logs list, get docs/sdks/logs
Phases list, get docs/sdks/phases
Measurements list, get docs/sdks/measurements
Deployments list, get docs/sdks/deployments
Identity whoami docs/sdks/identity
AuditLog list docs/sdks/audit_log
Versions get, delete, create docs/sdks/versions
Revisions get, update, delete, create docs/sdks/revisions
AttachmentHelpers upload, download docs/sdks/attachments

File Upload

The SDK provides helpers that handle the three-step upload flow (initialize → PUT → finalize) in a single call:

% Upload from disk
attachId = tofupilot.AttachmentHelpers.upload(sdk.Attachments, 'report.pdf');

% Link to a run
sdk.Runs.update(run.id, struct('attachments', {{attachId}}));

% Download a file
tofupilot.AttachmentHelpers.download(downloadUrl, 'local-report.pdf');

Phases & Measurements

now = char(datetime('now', 'TimeZone', 'UTC', 'Format', 'yyyy-MM-dd''T''HH:mm:ss''Z'''));

measurement = struct( ...
    'name', 'output_voltage', ...
    'outcome', 'PASS', ...
    'measured_value', 3.3, ...
    'unit', 'V');

phase = struct( ...
    'name', 'voltage_check', ...
    'outcome', 'PASS', ...
    'started_at', now, ...
    'ended_at', now, ...
    'measurements', {{measurement}});

req.procedure_id = 'your-procedure-id';
req.serial_number = 'SN-001';
req.part_number = 'PCB-V1';
req.outcome = 'PASS';
req.started_at = now;
req.ended_at = now;
req.phases = {{phase}};

run = sdk.Runs.create(req);

Retries

The client automatically retries on 429 (rate limit) and 5xx errors with exponential backoff (1s, 2s, 4s, ...). Default: 3 retries.

% Custom retry count
sdk = tofupilot.TofuPilot('your-api-key', 'MaxRetries', 5);

% Disable retries
sdk = tofupilot.TofuPilot('your-api-key', 'MaxRetries', 0);

Hooks

Inspect requests and responses with lifecycle hooks:

sdk = tofupilot.TofuPilot('your-api-key', ...
    'BeforeRequest', {@(ctx) fprintf('-> %s %s\n', ctx.method, ctx.path)}, ...
    'AfterSuccess', {@(ctx, resp) fprintf('OK\n')}, ...
    'AfterError', {@(ctx, err) fprintf('Error: %s\n', err.message)});

Self-Hosted

Point the client at your own TofuPilot instance:

sdk = tofupilot.TofuPilot('your-api-key', 'BaseUrl', 'https://your-instance.example.com/api');

Configuration

sdk = tofupilot.TofuPilot('your-api-key', ...
    'BaseUrl', 'https://your-server.com/api', ...
    'Timeout', 60, ...
    'MaxRetries', 5);

Requirements

  • MATLAB R2019b or later
  • No additional toolboxes required

License

This SDK is distributed under the MIT License. See LICENSE for details.

About

Upload hardware test data to TofuPilot from MATLAB.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages