Skip to content

Commit

Permalink
Merge pull request #59 from sync2brain/dev_removeFirmware
Browse files Browse the repository at this point in the history
Remove firmware as shipping dependency.
  • Loading branch information
pablorcum authored Apr 22, 2024
2 parents e371c8e + c458192 commit f254433
Show file tree
Hide file tree
Showing 14 changed files with 43 additions and 44 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ jobs:
branch: main
search_artifacts: true
name: bossdevice-firmware-${{ matrix.matlabVer }}
path: toolbox/dependencies/firmware
path: work
if_no_artifact_found: fail

- name: Prepend MATLAB to PATH on Windows (PowerShell)
Expand Down
9 changes: 2 additions & 7 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,9 @@ jobs:
repo: sync2brain/bossdevice-firmware
branch: main
search_artifacts: true
name: bossdevice-firmware-*
name_is_regexp: true
skip_unpack: true
name: bossdevice-firmware-${{ vars.MATLAB_VER }}
if_no_artifact_found: fail

- name: Unzip firmware artifacts into firmware folder
run: |
Get-ChildItem '.' -Filter bossdevice-firmware-*.zip | Expand-Archive -DestinationPath 'toolbox\dependencies\firmware'
path: work

# Download Speedgoat dependendencies
- name: Download Speedgoat dependencies artifacts
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
- [Simulink Real-Time®](https://www.mathworks.com/products/simulink-real-time.html)
- [Simulink Real-Time Target Support Package](https://www.mathworks.com/matlabcentral/fileexchange/76387-simulink-real-time-target-support-package) (no additional license required, installable from within MATLAB when you have Simulink Real-Time installed)
- [bossdevice](https://sync2brain.com/) hardware
- bossdevice firmware (MLDATX file included in the toolbox installer)
- [bossdevice firmware](https://sync2brain.com/downloads)

## Enable bossdevice communication over Control PC
1. Turn on the bossdevice and connect the `Control PC` Ethernet port on your bossdevice to an available Ethernet port on your computer.
Expand Down
Binary file modified docSource/bossdevice_api_gs_top.mlx
Binary file not shown.
Binary file modified docSource/bossdevice_api_setup.mlx
Binary file not shown.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

54 changes: 39 additions & 15 deletions toolbox/src/bossdevice.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
sgDepsPath
end

properties (SetAccess = immutable, Hidden)
toolboxPath
firmwareDepsPath
end

properties (SetAccess = protected)
firmwareFilepath
end
Expand Down Expand Up @@ -74,7 +79,7 @@ function initOscillationProps(obj)
end

% Get bossdevice API toolbox path
toolboxPath = fileparts(fileparts(which(mfilename)));
obj.toolboxPath = fileparts(fileparts(which(mfilename)));

% Initialize toolbox settings
s = settings;
Expand Down Expand Up @@ -102,7 +107,7 @@ function initOscillationProps(obj)
end

% Check and enable built-in Speedgoat dependencies
obj.sgDepsPath = fullfile(toolboxPath,'dependencies','sg');
obj.sgDepsPath = fullfile(obj.toolboxPath,'dependencies','sg');
isSGinstalled = bossapi.sg.isSpeedgoatBlocksetInstalled;

% Remove any possible instance of SG dependencies from the path
Expand Down Expand Up @@ -143,22 +148,16 @@ function initOscillationProps(obj)
end

% Search firmware binary and prompt user if not found in MATLAB path
firmwareDepsPath = fullfile(toolboxPath,'dependencies','firmware',matlabRelease.Release,[obj.appName,'.mldatx']);
obj.firmwareDepsPath = fullfile(obj.toolboxPath,'dependencies','firmware',matlabRelease.Release,[obj.appName,'.mldatx']);

% Figure out what firmware file to assign
if isfile(firmwareDepsPath)
obj.firmwareFilepath = firmwareDepsPath;
if isfile(obj.firmwareDepsPath)
obj.firmwareFilepath = obj.firmwareDepsPath;
elseif exist([obj.appName,'.mldatx'],"file")
obj.firmwareFilepath = obj.appName;
obj.firmwareFilepath = which([obj.appName,'.mldatx']);
elseif ~batchStartupOptionUsed
[filename, firmwareFilepath] = uigetfile([obj.appName,'.mldatx'],...
'Select the firmware binary to load on the bossdevice');
if isequal(filename,0)
disp('User selected Cancel. Please select firmware mldatx file to complete bossdevice dependencies.');
return;
else
obj.firmwareFilepath = fullfile(firmwareFilepath,filename);
end
obj.selectFirmware;
disp('Please run installFirmwareOnToolbox to permanently copy the firmware file into the toolbox and skip this step.');
else
error('bossapi:noMLDATX',[obj.appName,'.mldatx could not be found in the MATLAB path.']);
end
Expand All @@ -167,7 +166,32 @@ function initOscillationProps(obj)
if obj.isConnected
obj.initialize;
else
disp('Connect the bossdevice and initialize your bossdevice object to start. For example, if you are using "bd = bossdevice", run "bd.initialize".');
if ~batchStartupOptionUsed
disp('Connect the bossdevice and initialize your bossdevice object to start. For example, if you are using "bd = bossdevice", run "bd.initialize".');
end
end
end

function obj = selectFirmware(obj)
[filename, filepath] = uigetfile([obj.appName,'.mldatx'],...
'Select the firmware binary to load on the bossdevice');
if isequal(filename,0)
disp('User selected Cancel. Please select firmware mldatx file to complete bossdevice dependencies.');
return;
else
obj.firmwareFilepath = fullfile(filepath,filename);
end
end

function obj = installFirmwareOnToolbox(obj)
if isfile(obj.firmwareFilepath)
if ~isfolder(fileparts(obj.firmwareDepsPath))
mkdir(fileparts(obj.firmwareDepsPath));
end
copyfile(obj.firmwareFilepath,fileparts(obj.firmwareDepsPath),'f');
obj.firmwareFilepath = obj.firmwareDepsPath;
else
error('Firmware file is not located.');
end
end

Expand Down

0 comments on commit f254433

Please sign in to comment.