Unable to read .bin data from Jetson

67 views (last 30 days)
Syed Muhammad
Syed Muhammad on 1 Sep 2025 at 7:46
Moved: dpb on 3 Sep 2025 at 14:46
I am try to run a matched Filter function on jetson, using the 'exe' library, but there is no data inside the .bin file that i have generated.
here is the matched filter fucntion
function matched_filter1 = matched_Filter_GPU(rx_signal_noisy, matched_filter) %#codegen
coder.gpu.kernelfun;
rx_signal_noisy = single(rx_signal_noisy);
matched_filter = single(matched_filter);
rx_signal_noisy = reshape(rx_signal_noisy, 1000, 100);
matched_filter1 = zeros(size(rx_signal_noisy));
matched_filter1 = conv2(rx_signal_noisy, matched_filter(:), 'same');
end
here is the wrapper function
function matched_Filter_wrapper(rx_signal_noisy, matched_filter) %#codegen
mf_output = matched_Filter_GPU(rx_signal_noisy, matched_filter);
fid = fopen('output_new.bin', 'wb');
tmp = single(real(mf_output(:)));
count = fwrite(fid, tmp, 'single')
fclose(fid);
end
here is the MATLAB code
clear
S = load('rx_signal_noisy.mat');
rx_signal_noisy = single(struct2array(S));
S = load('MF_coeff.mat');
MF_coeff = single(struct2array(S));
hwObj = jetson('169.254.172.219','hr','0000');
rx_signal_noisy_T = coder.typeof(rx_signal_noisy, [1 100000], [1 1]);
matched_filter_T = coder.typeof(MF_coeff, [1 100], [0 0]);
cfg = coder.gpuConfig('exe');
cfg.Hardware = coder.Hardware('NVIDIA Jetson');
cfg.GenerateReport = false;
cfg.VerificationMode = 'None';
cfg.CodeExecutionProfiling = false;
cfg.GenerateExampleMain = 'GenerateCodeAndCompile';
cfg.Hardware.BuildDir = '~/remoteBuildDir';
codegen('-config', cfg, 'matched_Filter_wrapper', '-args', {rx_signal_noisy_T, matched_filter_T})
putFile(hwObj, 'matched_Filter_wrapper.elf')
runApplication(hwObj, './matched_Filter_wrapper.elf');
getFile(hwObj, '~/remoteBuildDir/MATLAB_ws/R2024a/D/Drive_Data/Radar/Radar/output_new.bin')
fid = fopen('output_new.bin','rb');
n = prod(sz);
data = fread(fid, n, 'single'); fclose(fid);
the output of n = 1x2 double and the output of the data = 0x0 empty. kindly guide me throigh the process, it will be a great help. thankyou in advance
  5 Comments
dpb
dpb on 2 Sep 2025 at 18:11
Edited: dpb on 2 Sep 2025 at 18:13
codegen -config cfg matched_Filter_wrapper -args {rx_signal_noisy_T, matched_filter_T, NsampPRI_T, Npulses_T}
Looks to me like the argument list is going to be just text, not the actual data since you used command, not function form.
codegen('-config', cfg, 'matched_Filter_wrapper', '-args', {rx_signal_noisy_T, matched_filter_T, NsampPRI_T, Npulses_T})
I'm not positive about the use of the cell array versus individual arguments; but looks to me like your code is expecting individual arguments rather than a cell array.
Syed Muhammad
Syed Muhammad on 3 Sep 2025 at 4:31
Thankyou for the resposne again i have updated the functiona and also the codegen coammadn that you shared i have attached the output, kindly i have updated my question

Sign in to comment.

Answers (1)

dpb
dpb on 3 Sep 2025 at 14:42
Moved: dpb on 3 Sep 2025 at 14:46
Let's debug your code in MATLAB, first...
function matched_Filter_wrapper(rx_signal_noisy, matched_filter) %#codegen
mf_output = matched_Filter_GPU(rx_signal_noisy, matched_filter);
fid = fopen('output_new.bin', 'wb');
tmp = single(real(mf_output(:)));
count = fwrite(fid, tmp, 'single');
fclose(fid);
end
function matched_filter1 = matched_Filter_GPU(rx_signal_noisy, matched_filter)
rx_signal_noisy = single(rx_signal_noisy);
matched_filter = single(matched_filter);
rx_signal_noisy = reshape(rx_signal_noisy, 1000, 100);
matched_filter1 = zeros(size(rx_signal_noisy));
matched_filter1 = conv2(rx_signal_noisy, matched_filter(:), 'same');
end
s_n =rand(1000*100,1);
f=rand(100,2);
matched_Filter_wrapper({s_n,f})
Not enough input arguments.

Error in solution>matched_Filter_wrapper (line 2)
mf_output = matched_Filter_GPU(rx_signal_noisy, matched_filter);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
As noted, this doesn't work to pass arguments as a cell array. In MATLAB at the command line you get the error message that something went wrong; when try to run on the GPU, no such interface so you have to get it right or have some other way to handle errors.
The syntax
matched_Filter_wrapper(s_n,f)
does run.
NOTA BENE; the line
rx_signal_noisy = reshape(rx_signal_noisy, 1000, 100);
makes the code dependent upon the input signal always being identically 100000 elements so it will also fail for any other length signal.

Categories

Find more on Image Processing and Computer Vision in Help Center and File Exchange

Products


Release

R2024a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!