2021-12-03 02:50 AM
Dear All,
I'm currently working on a project that will use STM32H745ZI MCU and RTOS Azure ThreadX + FileX
While a in-house developed prototype board is not available, a NUCLEO-H745ZI-Q board is being used to get familiarised with SW and tools.
Development environment:
- IDE: STM32CubeIDE
- RTOS: Azure ThreadX and FileX
Note: ThreadX and FileX libraries are built separately(CMake based build) and linked with the application developed under the IDE.
FileX application description (IDE based):
1) Initialisation
1.1) Memory pool creation
1.2) FileX initialisation (call to "fx_system_initialize()")
1.3) Allocate a thread stack
1.4) Create and start a thread (single thread application)
2) Thread entry function environment
2.1) Creation and initialisation of a SRAM disk ("sram_disk")
2.2) Creation of a directory to be used as default ("/home")
2.3) Set the previously created directory as default
2.4) Run the test scenario
2.4.1) Create a new directory "test_dir1" under the default "home"
// mkdir test_dir1
// Get local path: [not set]
// Get default path: [/home]
2.4.2) Set the local path to the newly created directory
// cd test_dir1
// Get local path: [/home/test_dir1]
// Get default path: [/home]
2.4.3) Create a new directory "test_dir2" under "test_dir1"
// mkdir test_dir2
// Get local path: [/home/test_dir1]
// Get default path: [/home]
2.4.4) Set the local path to the newly created directory "test_dir2"
// cd test_dir2
// Get local path: [/home/test_dir1/test_dir2]
// Get default path: [/home]
2.4.5) Try to set the local path to "test_dir1" (using "fx_directory_local_path_restore()" )
// cd ..
// Get local path:
// Expected: /home/test_dir1/
// Obtained: /home/test_dir1/test_dir2
// Get default path: [/home]
2.5 Loop forever
I was expecting that "fx_directory_local_path_restore()" would restore the previous local path to "/home/test_dir1" but that is not the case.
Could someone please explain what is the correct use of "fx_directory_local_path_restore()" ?
Many thanks for your time,
Carlos
Test scenario code follows:
// ----------------------------------------------------------------------------------------------------------
static char testFileName1[] = "test_file1";
static char testFileName2[] = "test_file2";
static char testDir1[] = "test_dir1";
static char testDir2[] = "test_dir2";
static char upDir[] = "..";
static char curDir[] = ".";
void local_path_test_scenario(FX_LOCAL_PATH* fxPreviousLocalPath)
{
UINT status;
CHAR default_path_name_buffer[256];
CHAR local_path_name_buffer[256];
// mkdir testDir1
status = fx_directory_create(&sram_disk, testDir1);
if (FX_SUCCESS != status) assert(0);
// Get local path: [not set]
status = fx_directory_local_path_get_copy(&sram_disk, local_path_name_buffer, 256);
if (FX_SUCCESS != status) assert(0);
// Get default path: [/home]
status = fx_directory_default_get_copy(&sram_disk, default_path_name_buffer, 256);
if (FX_SUCCESS != status) assert(0);
// cd testDir1
status = fx_directory_local_path_set(&sram_disk, fxPreviousLocalPath, testDir1);
if (FX_SUCCESS != status) assert(0);
// Get local path: [/home/test_dir1]
status = fx_directory_local_path_get_copy(&sram_disk,local_path_name_buffer, 256);
if (FX_SUCCESS != status) assert(0);
// Get default path: [/home]
status = fx_directory_default_get_copy(&sram_disk, default_path_name_buffer, 256);
if (FX_SUCCESS != status) assert(0);
// mkdir test_dir2
status = fx_directory_create(&sram_disk, testDir2);
if (FX_SUCCESS != status) assert(0);
// Get local path: [/home/test_dir1]
status = fx_directory_local_path_get_copy(&sram_disk, local_path_name_buffer, 256);
if (FX_SUCCESS != status) assert(0);
// Get default path: [/home]
status = fx_directory_default_get_copy(&sram_disk, default_path_name_buffer, 256);
if (FX_SUCCESS != status) assert(0);
// cd test_dir2
status = fx_directory_local_path_set(&sram_disk, fxPreviousLocalPath, testDir2);
if (FX_SUCCESS != status) assert(0);
// Get local path: [/home/test_dir1/test_dir2]
status = fx_directory_local_path_get_copy(&sram_disk, local_path_name_buffer, 256);
if (FX_SUCCESS != status) assert(0);
// Get default path: [/home]
status = fx_directory_default_get_copy(&sram_disk, default_path_name_buffer, 256);
if (FX_SUCCESS != status) assert(0);
// cd ..
status = fx_directory_local_path_restore(&sram_disk, fxPreviousLocalPath);
if (FX_SUCCESS != status) assert(0);
// Get local path:
// Expected: /home/test_dir1/
// Obtained: /home/test_dir1/test_dir2
status = fx_directory_local_path_get_copy(&sram_disk, local_path_name_buffer, 256);
if (FX_SUCCESS != status) assert(0);
// Get default path: [/home]
status = fx_directory_default_get_copy(&sram_disk, default_path_name_buffer, 256);
if (FX_SUCCESS != status) assert(0);
}
// ----------------------------------------------------------------------------------------------------------
2021-12-14 01:15 PM
Hi,
IIRC, the sequence you descibed is working correctly.
status = fx_directory_local_path_set(&sram_disk, fxPreviousLocalPath, testDir2);
the Local path here is set to "testDir2"
then later the fx_directory_local_path_restore is called, so it is returning the last path set that is "testDir2"
status = fx_directory_local_path_restore(&sram_disk, fxPreviousLocalPath);
if (FX_SUCCESS != status) assert(0);
// Get local path:
// Expected: /home/test_dir1/
// Obtained: /home/test_dir1/test_dir2
Am I missing something?
regards
Haithem.