@@ -3,27 +3,38 @@ function ulog2csv(ulogfile, outputFileName)
33% outputFileName
44% usage£ºulog2csv('log001.ulg','log001')
55if exist(ulogfile ,' file' )
6- if ~exist(outputFileName ,' dir' )
7- mkdir(outputFileName );
8- end
9-
10- pathstr = pwd ;
6+ dirNmae= [userpath ,' \ulogTmp' ];
7+ if exist(dirNmae ,' dir' )
8+ rmdir(dirNmae ,' s' );
9+ end
10+ mkdir(dirNmae );
11+ mkdir([dirNmae ,' \' ,outputFileName ]);
12+
13+ copyfile(ulogfile ,dirNmae ,' f' );
14+
15+ pathstr = dirNmae ;
1116 pathstr= strrep(pathstr ,' :' ,' ' );
1217 pathstr= strrep(pathstr ,' \' ,' /' );
1318 pathstr(1 )=lower(pathstr(1 ));
1419 pathstr1= [' /mnt/' ,pathstr ];
15-
16- if exist([userpath ,' \Add-Ons\Toolboxes\PX4 PSP\code\+codertarget\+Pixhawk\+CMAKE_Utils\FirmwareVersion.mat' ],' file' )
17- load([userpath ,' \Add-Ons\Toolboxes\PX4 PSP\code\+codertarget\+Pixhawk\+CMAKE_Utils\FirmwareVersion.mat' ]);
20+ pathstr1= strrep(pathstr1 ,' ' ,' \ ' );
21+
22+ PSPFold= ' PX4PSP' ;
23+ if exist([userpath ,' \Add-Ons\Toolboxes\PX4 PSP' ],' dir' )
24+ PSPFold= ' PX4 PSP' ;
25+ end
26+
27+ if exist([userpath ,' \Add-Ons\Toolboxes\' ,PSPFold ,' \code\+codertarget\+Pixhawk\+CMAKE_Utils\FirmwareVersion.mat' ],' file' )
28+ load([userpath ,' \Add-Ons\Toolboxes\' ,PSPFold ,' \code\+codertarget\+Pixhawk\+CMAKE_Utils\FirmwareVersion.mat' ]);
1829 if exist(' buildToolchain' ,' var' )
1930 toolchainType= buildToolchain ;
2031
2132 if toolchainType == ' 1'
22- command = [' C:\Windows\system32 \b ash.exe -c ' ,' cd ~; ulog2csv ' ,' -o ' ,pathstr1 ,' /' ,outputFileName ,' / ' ,pathstr1 ,' /' ,ulogfile ,' ' ];
33+ command = [' wsl ' ,' cd ~; ulog2csv ' ,' -o ' ,pathstr1 ,' /' ,outputFileName ,' / ' ,pathstr1 ,' /' ,ulogfile ,' ' ];
2334 else
2435 defaultPX4Path = ' C:\PX4PSP' ;
25- if exist([userpath ,' \Add-Ons\Toolboxes\PX4 PSP \code\+codertarget\+Pixhawk\+CMAKE_Utils\CmakeInfo.mat' ],' file' )
26- load([userpath ,' \Add-Ons\Toolboxes\PX4 PSP \code\+codertarget\+Pixhawk\+CMAKE_Utils\CmakeInfo.mat' ]);
36+ if exist([userpath ,' \Add-Ons\Toolboxes\' , PSPFold , ' \code\+codertarget\+Pixhawk\+CMAKE_Utils\CmakeInfo.mat' ],' file' )
37+ load([userpath ,' \Add-Ons\Toolboxes\' , PSPFold , ' \code\+codertarget\+Pixhawk\+CMAKE_Utils\CmakeInfo.mat' ]);
2738 if ~isempty(Px4PSP_CmakeInfo .Px4_Base_Dir)
2839 defaultPX4Path= Px4PSP_CmakeInfo .Px4_Base_Dir;
2940 end
@@ -42,10 +53,14 @@ function ulog2csv(ulogfile, outputFileName)
4253end
4354 status = system(command );
4455 if status
45- error( ' Make sure this code executes in the same workspace as the data file!' );
56+ fprintf( 2 , ' Error: Make sure this code executes in the same workspace as the data file!\n ' );
4657 else
58+ copyfile([dirNmae ,' \' ,outputFileName ],[pwd ,' \' ,outputFileName ],' f' );
4759 disp(' *******The conversion is complete!*******' );
4860 end
61+ if exist(dirNmae ,' dir' )
62+ rmdir(dirNmae ,' s' );
63+ end
4964else
5065 error(' file does not exist!' );
5166end
0 commit comments