-
Notifications
You must be signed in to change notification settings - Fork 0
/
openSoftrock.m
37 lines (32 loc) · 1.59 KB
/
openSoftrock.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
function [isOpen, warnings] = openSoftrock(SR_DLL_NAME)
% Load the PE0FKL SoftRock Si570 control library
if (libisloaded(SR_DLL_NAME))
unloadlibrary(SR_DLL_NAME);
end
disp('Loading PE0FKL Softrock Si570 control DLL...');
[notfound,warnings] = loadlibrary(SR_DLL_NAME);
if (~isempty(warnings))
disp(['Warnings while loading library. Please check warnings string for more info.']);
end
% libfunctionsview(SR_DLL_NAME) % View list of functions with data types
% Open the Softrock USB interface
vid = int32(hex2dec('16C0')); % Softrock USB VID
pid = int32(hex2dec('05DC')); % Softrock USB PID
iDevNum = int32(1); % Softrock device number
ptrArray = int8(zeros(128,1)); % fill with ASCII spaces
calllib(SR_DLL_NAME,'srOpen',vid, pid, ptrArray, ptrArray, ptrArray, iDevNum);
% Check if device opened
isOpen = calllib(SR_DLL_NAME,'srIsOpen');
if (isOpen)
% Get Softrock device info
srUsbInfo = calllib(SR_DLL_NAME,'srGetUsbInfo');
srManufacture = strrep(char(srUsbInfo.Value.Manufacturer), char(0), '');
srSerialNumber = strrep(char(srUsbInfo.Value.SerialNumber), char(0), '');
srProduct = strrep(char(srUsbInfo.Value.Product), char(0), '');
% Get version
ptrMajor = int32(0);
ptrMinor = int32(0);
[success, ptrMajor, ptrMinor] = calllib(SR_DLL_NAME,'srGetVersion', ptrMajor, ptrMinor);
disp(['Found Softrock interface ' srSerialNumber ', version ' num2str(ptrMajor) '.' num2str(ptrMinor)]);
end
end