Unable to read .bin data from Jetson
67 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
dpb
le 2 Sep 2025 à 18:11
Modifié(e) : dpb
le 2 Sep 2025 à 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.
Réponses (1)
dpb
le 3 Sep 2025 à 14:42
Déplacé(e) : dpb
le 3 Sep 2025 à 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})
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.
0 commentaires
Voir également
Catégories
En savoir plus sur Image Processing and Computer Vision dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!