Unable to read .bin data from Jetson
조회 수: 67 (최근 30일)
이전 댓글 표시
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
dpb
2025년 9월 2일 18:11
편집: dpb
2025년 9월 2일 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.
답변 (1개)
dpb
2025년 9월 3일 14:42
이동: dpb
2025년 9월 3일 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
참고 항목
카테고리
Help Center 및 File Exchange에서 Image Processing and Computer Vision에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!